aboutsummaryrefslogtreecommitdiff
path: root/backend/ninja/Ninja.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backend/ninja/Ninja.cpp')
-rw-r--r--backend/ninja/Ninja.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp
index 1990926..50cd577 100644
--- a/backend/ninja/Ninja.cpp
+++ b/backend/ninja/Ninja.cpp
@@ -238,7 +238,7 @@ namespace backend
// TODO: First check if pkg-config is installed. If it's not, only check dependencies that exists in the dependencies sub directory.
// If pkg-config is installed and dependency is not installed, check in dependencies sub directory.
- Result<bool> Ninja::getLinkerFlags(const SibsConfig &config, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallback, GlobalIncludeDirCallbackFunc globalIncludeDirCallback) const
+ Result<bool> Ninja::getLinkerFlags(const SibsConfig &config, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallback, GlobalIncludeDirCallbackFunc globalIncludeDirCallback, CflagsCallbackFunc cflagsCallbackFunc) const
{
const vector<Dependency> &dependencies = config.getDependencies();
if(dependencies.empty()) return Result<bool>::Ok(true);
@@ -268,10 +268,10 @@ namespace backend
}
}
- Result<string> pkgConfigLinkerFlagsResult = PkgConfig::getDynamicLibsLinkerFlags(pkgConfigDependencies);
- if (pkgConfigLinkerFlagsResult.isErr())
+ Result<PkgConfigFlags> pkgConfigFlagsResult = PkgConfig::getDynamicLibsFlags(pkgConfigDependencies);
+ if (!pkgConfigFlagsResult)
{
- printf("%s, using global lib...\n", pkgConfigLinkerFlagsResult.getErrMsg().c_str());
+ printf("%s, using global lib...\n", pkgConfigFlagsResult.getErrMsg().c_str());
globalLibDependencies.reserve(globalLibDependencies.size() + pkgConfigDependencies.size());
for (const Dependency &pkgConfigDependency : pkgConfigDependencies)
{
@@ -281,8 +281,11 @@ namespace backend
}
else
{
- if (!pkgConfigLinkerFlagsResult.unwrap().empty())
- dynamicLinkerFlagCallback(pkgConfigLinkerFlagsResult.unwrap());
+ const PkgConfigFlags &pkgConfigFlag = pkgConfigFlagsResult.unwrap();
+ if (!pkgConfigFlag.linkerFlags.empty())
+ dynamicLinkerFlagCallback(pkgConfigFlag.linkerFlags);
+ if(!pkgConfigFlag.cflags.empty())
+ cflagsCallbackFunc(pkgConfigFlag.cflags);
}
#else
for (const Dependency &dependency : dependencies)
@@ -381,8 +384,15 @@ namespace backend
allLinkerFlags += " ";
allLinkerFlags += linkerFlag;
};
+
+ string cflags;
+ auto cflagsCallbackFunc = [&cflags](const string &dependencyCflags)
+ {
+ cflags += " ";
+ cflags += dependencyCflags;
+ };
- Result<bool> linkerFlags = getLinkerFlags(config, staticLinkerFlagCallbackFunc, dynamicLinkerFlagCallback, globalIncludeDirCallback);
+ Result<bool> linkerFlags = getLinkerFlags(config, staticLinkerFlagCallbackFunc, dynamicLinkerFlagCallback, globalIncludeDirCallback, cflagsCallbackFunc);
if (linkerFlags.isErr())
return Result<bool>::Err(linkerFlags.getErrMsg());
@@ -587,14 +597,15 @@ namespace backend
case Compiler::GCC:
{
// -Werror
- result += " '-I" + config.getPackageName() + "@exe' '-I..' -Wall -Wextra -Werror=return-type -fexceptions -fdiagnostics-show-option '-fdiagnostics-color=always' '-pipe' '-D_FILE_OFFSET_BITS=64' '-Winvalid-pch' '-Wnon-virtual-dtor' " + optimizationFlags + " '-g'";
+ result += " '-I" + config.getPackageName() + "@exe' " + cflags + " '-I..' -Wall -Wextra -Werror=return-type -fexceptions -fdiagnostics-show-option '-fdiagnostics-color=always' '-pipe' '-D_FILE_OFFSET_BITS=64' '-Winvalid-pch' '-Wnon-virtual-dtor' " + optimizationFlags + " '-g'";
break;
}
case Compiler::MSVC:
{
result += " ";
result += optimizationFlags;
- result += " /EHsc";
+ result += " /EHsc ";
+ result += cflags;
switch (config.getOptimizationLevel())
{
case OPT_LEV_DEBUG: