Environment

env.h

class Project

Public Functions

Project() = delete
Project(const Project&) = delete
Project(Project&&) = delete

Public Static Functions

static void Init(const fs::path &project_root_dir, const fs::path &project_build_dir)
static void Deinit()
static bool IsInit()
static const fs::path &GetRootDir()
static const fs::path &GetBuildDir()

logging.h

void buildcc::env::log_trace(std::string_view tag, std::string_view message)
void buildcc::env::log_debug(std::string_view tag, std::string_view message)
void buildcc::env::log_info(std::string_view tag, std::string_view message)
void buildcc::env::log_warning(std::string_view tag, std::string_view message)
void buildcc::env::log_critical(std::string_view tag, std::string_view message)

assert_fatal.h

Warning

doxygenfunction: Unable to resolve function “assert_fatal” with arguments ([[maybe_unused]] const char*) in doxygen xml output for project “buildcc_documentation” from directory: /home/runner/work/build_in_cpp/build_in_cpp/build/xml. Potential matches:

- template<bool expr> void assert_fatal(const char *message)
- template<bool expr> void assert_fatal(const std::string &message)
- void assert_fatal(bool expression, const char *message)
- void assert_fatal(bool expression, const std::string &message)
template<bool expr>
inline void buildcc::env::assert_fatal(const std::string &message)

Compile time expr asserts fatally when false.

inline void buildcc::env::assert_fatal(bool expression, const char *message)

Runtime expr asserts fatally when false.

inline void buildcc::env::assert_fatal(bool expression, const std::string &message)

Runtime expr asserts fatally when false.

ASSERT_FATAL(expr, message)

Runtime expr asserts fatally when false.

command.h

class Command

Public Functions

explicit Command() = default
void AddDefaultArgument(const std::string &key, const std::string &value)

Add key-value pairs that are used by fmt as identifiers Example: {“key”, “value”} -> fmt::format(“{key}”) -> “value”.

NOTE: These default arguments persist throughout the lifetime of the Command object

void AddDefaultArguments(const std::unordered_map<std::string, std::string> &arguments)

Add multiple key-value pairs that are used by fmt as identifiers Example: {“key”, “value”} -> fmt::format(“{key}”) -> “value”.

NOTE: These default arguments persist throughout the lifetime of the Command object

std::string Construct(const std::string &pattern, const std::unordered_map<const char*, std::string> &arguments = {}) const

Construct a specialized string using input pattern and supplied arguments.

NOTE: These arguments are only valid for the Construct function call

const std::string &GetDefaultValueByKey(const std::string &key) const

Get the Default Value By Key object NOTE: Only works when key/value pairs are added to DefaultArgument(s) Assert Fatal if default value is not found.

Public Static Functions

static bool Execute(const std::string &command, const optional<fs::path> &working_directory = {}, std::vector<std::string> *stdout_data = nullptr, std::vector<std::string> *stderr_data = nullptr)

Execute a particular command over a subprocess and optionally redirect stdout and stderr to user supplied dynamic string lists.

Parameters:
  • commandCommand is run on the shell

  • working_directory – Current working directory

  • stdout_data – Redirect stdout to user OR default print to console

  • stderr_data – Redirect stderr to user OR default print to console

Returns:

true when exit code = 0

Returns:

false when exit code != 0

host_compiler.h

inline constexpr bool buildcc::env::is_gcc()
inline constexpr bool buildcc::env::is_mingw()
inline constexpr bool buildcc::env::is_clang()
inline constexpr bool buildcc::env::is_msvc()

host_os.h

inline constexpr bool buildcc::env::is_linux()
inline constexpr bool buildcc::env::is_win()
inline constexpr bool buildcc::env::is_mac()
inline constexpr bool buildcc::env::is_unix()
enum class buildcc::OsId

Values:

enumerator Linux
enumerator Win
enumerator Mac
enumerator Unix
enumerator Undefined
inline constexpr OsId buildcc::get_host_os()

host_os_util.h

inline constexpr char const *buildcc::env::get_os_envvar_delim()

Get the OS environment variable delimiter ; for windows : for linux, unix and mac.

Returns:

constexpr char const* for supported operating systems

Returns:

nullptr otherwise with a critical message to raise an issue

inline constexpr const char *buildcc::env::get_os_executable_extension()

Get the OS executable extension “.exe” for windows “” for linux, unix and mac.

Returns:

constexpr const char* for supported operating systems

Returns:

nullptr otherwise with a critical message to raise an issue

task_state.h

enum class buildcc::env::TaskState

Values:

enumerator SUCCESS
enumerator FAILURE
TaskState buildcc::env::get_task_state()

util.h

inline bool buildcc::env::save_file(const char *name, const std::string &buf, bool binary)
inline bool buildcc::env::load_file(const char *name, bool binary, std::string *buf)

Condition under which code throws and should terminate 1: fs::file_size -> filesystem_error, bad_alloc error 2: resize -> length_error, bad_alloc error 3: ifs.read -> badbit 4: