From 1f6ee990275f412d4cc84483051fd549710da634 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 1 Jan 2018 09:40:08 +0100 Subject: Add config parsing for cmake cmake has not integrated yet, but it will parse... Add test script to easily run tests --- include/Conf.hpp | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 78 insertions(+), 1 deletion(-) (limited to 'include/Conf.hpp') diff --git a/include/Conf.hpp b/include/Conf.hpp index 75076fa..d3d80f9 100644 --- a/include/Conf.hpp +++ b/include/Conf.hpp @@ -146,7 +146,28 @@ namespace sibs class SibsConfig : public ConfigCallback { public: - SibsConfig(Compiler _compiler, const FileString &_projectPath, OptimizationLevel _optimizationLevel = OPT_LEV_DEBUG) : compiler(_compiler), projectPath(_projectPath), packageType((PackageType)-1), optimizationLevel(_optimizationLevel), finishedProcessing(false) {} + SibsConfig(Compiler _compiler, const FileString &_projectPath, OptimizationLevel _optimizationLevel = OPT_LEV_DEBUG) : + compiler(_compiler), + projectPath(_projectPath), + packageType((PackageType)-1), + optimizationLevel(_optimizationLevel), + finishedProcessing(false), + useCmake(false) + { + cmakeDirGlobal = projectPath; + cmakeDirStatic = cmakeDirGlobal; + cmakeDirDynamic = cmakeDirGlobal; + switch(optimizationLevel) + { + case OPT_LEV_DEBUG: + cmakeArgsGlobal = "\"-DCMAKE_BUILD_TYPE=Debug\""; + break; + case OPT_LEV_RELEASE: + cmakeArgsGlobal = "\"-DCMAKE_BUILD_TYPE=Release\""; + break; + } + } + virtual ~SibsConfig(){} Compiler getCompiler() const @@ -216,6 +237,54 @@ namespace sibs return ignoreDirs; } + const FileString& getCmakeDir() const + { + return cmakeDirGlobal; + } + + const FileString& getCmakeDirStatic() const + { + return cmakeDirStatic; + } + + const FileString& getCmakeDirDynamic() const + { + return cmakeDirDynamic; + } + + // Get cmake args for all builds. This is args under [cmake] only + const std::string& getCmakeArgs() const + { + return cmakeArgsGlobal; + } + + // Get cmake args for static build. This is a combination of args under [cmake] and under [cmake.static] + std::string getCmakeArgsStatic() const + { + std::string result; + result.reserve(cmakeArgsGlobal.size() + 1 + cmakeArgsStatic.size()); + result += cmakeArgsGlobal; + result += " "; + result += cmakeArgsStatic; + return result; + } + + // Get cmake args for dynamic build. This is a combination of args under [cmake] and under [cmake.dynamic] + std::string getCmakeArgsDynamic() const + { + std::string result; + result.reserve(cmakeArgsGlobal.size() + 1 + cmakeArgsDynamic.size()); + result += cmakeArgsGlobal; + result += " "; + result += cmakeArgsDynamic; + return result; + } + + bool shouldUseCmake() const + { + return useCmake; + } + void setPackageType(PackageType packageType) { this->packageType = packageType; @@ -230,6 +299,7 @@ namespace sibs virtual void finished() override; void failInvalidFieldUnderObject(const StringView &fieldName) const; private: + void parseCmake(const StringView &fieldName, const ConfigValue &fieldValue, std::string &cmakeDir, std::string &cmakeArgs); void validatePackageName() const; protected: StringView currentObject; @@ -247,6 +317,13 @@ namespace sibs OptimizationLevel optimizationLevel; std::vector debugStaticLibs; std::vector releaseStaticLibs; + FileString cmakeDirGlobal; + FileString cmakeDirStatic; + FileString cmakeDirDynamic; + std::string cmakeArgsGlobal; + std::string cmakeArgsStatic; + std::string cmakeArgsDynamic; + bool useCmake; bool finishedProcessing; }; -- cgit v1.2.3