aboutsummaryrefslogtreecommitdiff
path: root/src/GlobalLib.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2017-12-28 16:57:06 +0100
committerdec05eba <dec05eba@protonmail.com>2017-12-28 16:57:11 +0100
commit1f583ebb6e3973c992d59886659bf53ff87f41de (patch)
treecfefa98bf921d443f577785d744a5fe6d12f2e86 /src/GlobalLib.cpp
parentda405ce0c1c9c675aee1710917d9d89b7eb34922 (diff)
Add optimization level option to building
Diffstat (limited to 'src/GlobalLib.cpp')
-rw-r--r--src/GlobalLib.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/GlobalLib.cpp b/src/GlobalLib.cpp
index 30a044f..d994a27 100644
--- a/src/GlobalLib.cpp
+++ b/src/GlobalLib.cpp
@@ -60,7 +60,7 @@ namespace sibs
return _tinydir_strncmp(path, subPathOf.c_str(), subPathOf.size()) == 0;
}
- Result<string> GlobalLib::getLibsLinkerFlags(const string &globalLibRootDir, const string &name, const string &version, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallbackFunc)
+ Result<string> GlobalLib::getLibsLinkerFlags(const SibsConfig &parentConfig, const string &globalLibRootDir, const string &name, const string &version, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallbackFunc)
{
Result<bool> packageExistsResult = validatePackageExists(globalLibRootDir, name);
if(packageExistsResult.isErr())
@@ -110,7 +110,7 @@ namespace sibs
}
}
- SibsConfig sibsConfig(packageDir);
+ SibsConfig sibsConfig(packageDir, parentConfig.getOptimizationLevel());
Result<bool> result = Config::readFromFile(projectConfFilePath.c_str(), sibsConfig);
if(result.isErr())
return Result<string>::Err(result.getErrMsg());
@@ -175,8 +175,18 @@ namespace sibs
}
else
{
- string debugBuildPath = packageDir + "/sibs-build/debug";
- string libPath = debugBuildPath;
+ string buildPath = packageDir + "/sibs-build/";
+ switch(sibsConfig.getOptimizationLevel())
+ {
+ case OPT_LEV_DEBUG:
+ buildPath += "debug";
+ break;
+ case OPT_LEV_RELEASE:
+ buildPath += "release";
+ break;
+ }
+
+ string libPath = buildPath;
libPath += "/lib";
libPath += name;
if(libraryType == backend::Ninja::LibraryType::STATIC)
@@ -199,11 +209,11 @@ namespace sibs
// TODO: Use different directories depending on the project type, but .o build files should be in the same directory
// no matter what project type, since they are used for executables, static/dynamic libraries
- Result<bool> createBuildDirResult = createDirectoryRecursive(debugBuildPath.c_str());
+ Result<bool> createBuildDirResult = createDirectoryRecursive(buildPath.c_str());
if(createBuildDirResult.isErr())
return Result<string>::Err(createBuildDirResult);
- Result<bool> buildFileResult = ninja.build(sibsConfig, debugBuildPath.c_str(), staticLinkerFlagCallbackFunc, dynamicLinkerFlagCallbackFunc);
+ Result<bool> buildFileResult = ninja.build(sibsConfig, buildPath.c_str(), staticLinkerFlagCallbackFunc, dynamicLinkerFlagCallbackFunc);
if (buildFileResult.isErr())
return Result<string>::Err(buildFileResult.getErrMsg());