aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Conf.cpp51
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)