From a1da8d105364fd23f4d34f0a342aea3e0d76e0b1 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Wed, 15 Apr 2020 00:32:45 +0200 Subject: [PATCH] Allow for easy switching between fake and real env. --- src/run_context.hpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/run_context.hpp b/src/run_context.hpp index a093a6f..0bc3ec1 100644 --- a/src/run_context.hpp +++ b/src/run_context.hpp @@ -17,7 +17,13 @@ #pragma once -#include "env_fake.hpp" +#define USE_FAKE_ENV + +#if defined(USE_FAKE_ENV) +# include "env_fake.hpp" +#else +# include "env_real.hpp" +#endif #include #include #if !defined(NDEBUG) @@ -31,12 +37,17 @@ namespace duck { class RunContext { public: typedef std::filesystem::path path_type; +#if defined(USE_FAKE_ENV) + typedef EnvFake env_type; +#else + typedef EnvReal env_type; +#endif RunContext(); ~RunContext() noexcept = default; - EnvFake& env() noexcept { return m_env; } - const EnvFake& env() const noexcept { return m_env; } + env_type& env() noexcept { return m_env; } + const env_type& env() const noexcept { return m_env; } void add_to_env (std::string_view colours); @@ -47,7 +58,7 @@ namespace duck { const path_type& gcc_env_d() const; private: - EnvFake m_env; + env_type m_env; path_type m_root; path_type m_eprefix; path_type m_eroot; @@ -58,4 +69,8 @@ namespace duck { #if !defined(NDEBUG) std::ostream& operator<< (std::ostream&, const RunContext& sp); #endif + +#if defined(USE_FAKE_ENV) +# undef USE_FAKE_ENV +#endif } //namespace duck