From e7ebd55c31148089eb54ffbd708216c1c7cb09ff Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 29 Sep 2018 22:03:50 +0200 Subject: Add support for macos --- backend/ninja/Ninja.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'backend/ninja') 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 Ninja::build(const SibsConfig &config, const _tinydir_char_t *savePath, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallback, GlobalIncludeDirCallbackFunc globalIncludeDirCallback) { + bool isCCompilerClang = false; + Result cCompilerVersion = exec("cc --version"); + if(cCompilerVersion && cCompilerVersion.unwrap().exitCode == 0 && cCompilerVersion.unwrap().execStdout.find("clang") != string::npos) + isCCompilerClang = true; + + bool isCppCompilerClang = false; + Result cppCompilerVersion = exec("c++ --version"); + if(cppCompilerVersion && cppCompilerVersion.unwrap().exitCode == 0 && cppCompilerVersion.unwrap().execStdout.find("clang") != string::npos) + isCppCompilerClang = true; + Result 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 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"); -- cgit v1.2.3