diff options
Diffstat (limited to 'backend')
-rw-r--r-- | backend/ninja/Ninja.cpp | 25 |
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"); |