Toolchain Utils

Commonly used Utils (Classes / Structs) for Toolchain

file_ext.h

enum class buildcc::FileExt

Values:

enumerator Asm

Valid Assembly source extension.

enumerator C

Valid C source extension.

enumerator Cpp

Valid Cpp source extension.

enumerator Header

Valid Header extension.

enumerator Invalid

Not a valid C/C++ family extension.

toolchain_config.h

struct ToolchainConfig

Public Functions

ToolchainConfig() = default
FileExt GetFileExt(const fs::path &filepath) const

Get the valid file extension from a path.

See ToolchainConfig::valid_c_ext, ToolchainConfig::valid_cpp_ext, ToolchainConfig::valid_asm_ext, ToolchainConfig::valid_header_ext

Parameters:

filepath – Absolute / Relative path of the file

Returns:

FileExt File path detected as per Toolchain::valid_* variables

bool IsValidSource(const fs::path &filepath) const

Checks for C/C++ source file validity.

See ToolchainConfig::valid_c_ext, ToolchainConfig::valid_cpp_ext, ToolchainConfig::valid_asm_ext

Parameters:

filepath – Absolute / Relative path of file

Returns:

true If file extension belongs to the above valid_* list

Returns:

false If file extension does not belong to the above valid_* list

bool IsValidHeader(const fs::path &filepath) const

Checks for Header file validity.

See ToolchainConfig::valid_header_ext

Parameters:

filepath – Absolute / Relative path of file

Returns:

true If file extension belongs to above valid_* list

Returns:

false If file extension does not belong to above valid_* list

void ExpectsValidSource(const fs::path &filepath) const

Expects Source file validity.

env::assert_fatal if not a valid source

Parameters:

filepath – Absolute / Relative path of file

void ExpectsValidHeader(const fs::path &filepath) const

Expects header file validity.

env::assert_fatal if not a valid header

Parameters:

filepath – Absolute / Relative path of file

Public Members

std::string obj_ext = {".o"}
std::string pch_header_ext = {".h"}
std::string pch_compile_ext = {".gch"}
std::string prefix_include_dir = {"-I"}
std::string prefix_lib_dir = {"-L"}
std::unordered_set<std::string> valid_c_ext = {".c"}
std::unordered_set<std::string> valid_cpp_ext = {".cpp", ".cxx", ".cc"}
std::unordered_set<std::string> valid_asm_ext = {".s", ".S", ".asm"}
std::unordered_set<std::string> valid_header_ext = {".h", ".hpp"}

toolchain_id.h

enum class buildcc::ToolchainId

Values:

enumerator Gcc

GCC Toolchain.

enumerator Msvc

MSVC Toolchain.

enumerator Clang

Clang Toolchain.

enumerator MinGW

MinGW Toolchain (Similar to GCC, but for Windows)

enumerator Custom

Custom Toolchain not defined in this list.

enumerator Undefined

Default value when unknown.

toolchain_executables.h

struct ToolchainExecutables

Public Functions

explicit ToolchainExecutables() = default
inline explicit ToolchainExecutables(std::string_view as, std::string_view c, std::string_view cpp, std::string_view ar, std::string_view link)

Public Members

std::string assembler
std::string c_compiler
std::string cpp_compiler
std::string archiver
std::string linker