From c53e622b648635539e4870fd0c9159c5d8c3be4a Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 20 Jun 2021 20:21:58 +0200 Subject: Introduction of configuration generation for controlling tool-chain. --- libcppbuild.h | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) (limited to 'libcppbuild.h') diff --git a/libcppbuild.h b/libcppbuild.h index 2aba987..81e7a9e 100644 --- a/libcppbuild.h +++ b/libcppbuild.h @@ -3,25 +3,45 @@ #include #include -//#include +#include enum class TargetType { - Auto, // Default - deduce from target name + Auto, // Default - deduce from target name and sources extensions + Executable, StaticLibrary, DynamicLibrary, + Object, +}; + +enum class Language +{ + Auto, // Default - deduce language from source extensions + + C, + Cpp, + Asm, +}; + +enum class OutputSystem +{ + Target, // Output for the target system + BuildHost, // Internal tool during cross-compilation }; struct BuildConfiguration { TargetType type{TargetType::Auto}; + Language language{Language::Auto}; + OutputSystem system{OutputSystem::Target}; std::string target; - std::vector sources; - std::vector depends; - std::vector cxxflags; - std::vector cflags; - std::vector ldflags; + std::vector sources; // source list + std::vector depends; // internal dependencies + std::vector cxxflags; // flags for c++ compiler + std::vector cflags; // flags for c compiler + std::vector ldflags; // flags for linker + std::vector asmflags; // flags for asm translator }; using BuildConfigurations = std::vector; @@ -33,3 +53,8 @@ int reg(const char* location, BuildConfigurations (*cb)()); #define CONCAT_INNER(a, b) a ## b #define UNIQUE_NAME(base) CONCAT(base, __LINE__) #define REG(cb) namespace { int UNIQUE_NAME(unique) = reg(__FILE__, cb); } + +const std::map& configuration(); +bool hasConfiguration(const std::string& key); +const std::string& getConfiguration(const std::string& key, + const std::string& defaultValue = {}); -- cgit v1.2.3