aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authordec05eba <dec05eba@dec05ebas-iMac.local>2018-09-29 22:03:50 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:39:33 +0200
commite7ebd55c31148089eb54ffbd708216c1c7cb09ff (patch)
tree2a55e1bfe6ce3e2f8ca6c21d8046565abcafd4d9 /backend
parent19370a2213efe960e959832145a165d6e2ad6a65 (diff)
Add support for macos
Diffstat (limited to 'backend')
-rw-r--r--backend/ninja/Ninja.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp
index ac683a0..3d71574 100644
--- a/backend/ninja/Ninja.cpp
+++ b/backend/ninja/Ninja.cpp
@@ -635,6 +635,16 @@ namespace backend
Result<bool> Ninja::build(const SibsConfig &config, const _tinydir_char_t *savePath, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallback, GlobalIncludeDirCallbackFunc globalIncludeDirCallback)
{
+ bool isCCompilerClang = false;
+ Result<ExecResult> cCompilerVersion = exec("cc --version");
+ if(cCompilerVersion && cCompilerVersion.unwrap().exitCode == 0 && cCompilerVersion.unwrap().execStdout.find("clang") != string::npos)
+ isCCompilerClang = true;
+
+ bool isCppCompilerClang = false;
+ Result<ExecResult> cppCompilerVersion = exec("c++ --version");
+ if(cppCompilerVersion && cppCompilerVersion.unwrap().exitCode == 0 && cppCompilerVersion.unwrap().execStdout.find("clang") != string::npos)
+ isCppCompilerClang = true;
+
Result<bool> createBuildDirResult = createDirectoryRecursive(savePath);
if (!createBuildDirResult)
return createBuildDirResult;
@@ -1073,6 +1083,15 @@ namespace backend
string projectGeneratedBinaryFlags;
if (!sourceFiles.empty() && !zigTest)
{
+ string noUndefinedFlag;
+ if(!onlyZigFiles)
+ {
+ if(usesCppFiles)
+ noUndefinedFlag = isCppCompilerClang ? "-Wl,-undefined,error" : "-Wl,--no-undefined,--as-needed";
+ else
+ noUndefinedFlag = isCCompilerClang ? "-Wl,-undefined,error" : "-Wl,--no-undefined,--as-needed";
+ }
+
string projectGeneratedBinary = "\"";
projectGeneratedBinary += savePathUtf8;
projectGeneratedBinary += "/";
@@ -1119,7 +1138,7 @@ namespace backend
ninja::NinjaArg::createRaw("-o"),
ninja::NinjaArg::createRaw("$out"),
ninja::NinjaArg::createRaw("$in"),
- ninja::NinjaArg::createRaw("-Wl,--no-undefined,--as-needed")
+ ninja::NinjaArg::createRaw(noUndefinedFlag)
});
if(config.getSanitize())
@@ -1307,7 +1326,7 @@ namespace backend
ninja::NinjaArg::createRaw("-shared"),
ninja::NinjaArg::createRaw("-o"),
ninja::NinjaArg::createRaw("$out"),
- ninja::NinjaArg::createRaw("-Wl,--no-undefined,--as-needed")
+ ninja::NinjaArg::createRaw(noUndefinedFlag)
});
if(config.getSanitize())
@@ -1529,7 +1548,7 @@ namespace backend
Result<bool> Ninja::compile(const _tinydir_char_t *buildFilePath)
{
-#if OS_FAMILY == OS_FAMILY_POSIX
+#if OS_TYPE == OS_TYPE_LINUX
FileString command = TINYDIR_STRING("script -eqc 'ninja -C \"");
command += buildFilePath;
command += TINYDIR_STRING("\"' /dev/null");