Allow for easy switching between fake and real env.
This commit is contained in:
parent
a6bf45fab9
commit
a1da8d1053
1 changed files with 19 additions and 4 deletions
|
@ -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 <filesystem>
|
||||
#include <string>
|
||||
#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
|
||||
|
|
Loading…
Reference in a new issue