From faba2972543b2a647dcb44f03a3643fe988d770f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 9 Jun 2019 12:32:05 +0200 Subject: Add for directories in config. Needed by some cmake projects --- src/Conf.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) (limited to 'src') 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 Config::readFromFile(const _tinydir_char_t *filepath, SibsConfig &config) { Result fileContentResult = getFileContent(filepath); @@ -515,6 +526,36 @@ namespace sibs return Result::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) -- cgit v1.2.3