diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-06-09 12:32:05 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-06 07:39:33 +0200 |
commit | faba2972543b2a647dcb44f03a3643fe988d770f (patch) | |
tree | 134d5909a086c0b15d1659e0cacfbcd9ad3bbde4 | |
parent | 2f2555bb21dc0f53cf28155082a2bb0ac12c8959 (diff) |
Add for directories in config. Needed by some cmake projects
-rw-r--r-- | include/Conf.hpp | 6 | ||||
-rw-r--r-- | src/Conf.cpp | 51 |
2 files changed, 50 insertions, 7 deletions
diff --git a/include/Conf.hpp b/include/Conf.hpp index eae79d4..03b2e46 100644 --- a/include/Conf.hpp +++ b/include/Conf.hpp @@ -418,6 +418,9 @@ namespace sibs std::string versionStr; PackageVersion version; Platform platform; + std::vector<std::string> includeDirs; + std::vector<std::string> exposeIncludeDirs; + std::vector<std::string> ignoreDirs; protected: virtual void processObject(StringView name) override; virtual void processField(StringView name, const ConfigValue &value) override; @@ -444,10 +447,7 @@ namespace sibs PackageType packageType; std::vector<PackageListDependency*> packageListDependencies; std::vector<GitDependency*> gitDependencies; - std::vector<std::string> includeDirs; - std::vector<std::string> exposeIncludeDirs; std::vector<Platform> platforms; - std::vector<std::string> ignoreDirs; std::unordered_map<std::string, std::string> defines; OptimizationLevel optimizationLevel; std::vector<std::string> debugStaticLibs; diff --git a/src/Conf.cpp b/src/Conf.cpp index aade4f7..1962517 100644 --- a/src/Conf.cpp +++ b/src/Conf.cpp @@ -450,6 +450,17 @@ namespace sibs bool objectDefined; }; + static void replaceAll(std::string &input, const std::string &oldStr, const std::string &newStr) { + size_t index = 0; + while(true) { + index = input.find(oldStr, index); + if(index == std::string::npos) + break; + input.replace(index, oldStr.size(), newStr); + index += newStr.size(); + } + } + Result<bool> Config::readFromFile(const _tinydir_char_t *filepath, SibsConfig &config) { Result<StringView> fileContentResult = getFileContent(filepath); @@ -515,6 +526,36 @@ namespace sibs return Result<bool>::Err("Packaging is only supported for projects that are of type executable"); } + std::string outDir = std::string("sibs-build/") + asString(config.platform) + "/"; + if(config.packaging) + { + outDir += "package"; + } + else + { + switch(config.getOptimizationLevel()) + { + case OPT_LEV_DEBUG: + outDir += "debug"; + break; + case OPT_LEV_RELEASE: + outDir += "release"; + break; + } + } + + for(std::string &includeDir : config.includeDirs) { + replaceAll(includeDir, "$out", outDir); + } + + for(std::string &exposeIncludeDir : config.exposeIncludeDirs) { + replaceAll(exposeIncludeDir, "$out", outDir); + } + + for(std::string &ignoreDir : config.ignoreDirs) { + replaceAll(ignoreDir, "$out", outDir); + } + return parseResult; } @@ -527,23 +568,25 @@ namespace sibs exit(6); } - buildPath = projectPath + TINYDIR_STRING("/sibs-build/") + toFileString(asString(sibsConfig.platform)) + TINYDIR_STRING("/"); + std::string outDir = std::string("sibs-build/") + asString(sibsConfig.platform) + "/"; if(sibsConfig.packaging) { - buildPath += TINYDIR_STRING("package"); + outDir += "package"; } else { switch(sibsConfig.getOptimizationLevel()) { case OPT_LEV_DEBUG: - buildPath += TINYDIR_STRING("debug"); + outDir += "debug"; break; case OPT_LEV_RELEASE: - buildPath += TINYDIR_STRING("release"); + outDir += "release"; break; } } + + buildPath = projectPath + TINYDIR_STRING("/") + toFileString(outDir); } const char* asString(OptimizationLevel optLevel) |