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 /src | |
parent | 2f2555bb21dc0f53cf28155082a2bb0ac12c8959 (diff) |
Add for directories in config. Needed by some cmake projects
Diffstat (limited to 'src')
-rw-r--r-- | src/Conf.cpp | 51 |
1 files changed, 47 insertions, 4 deletions
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) |