diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-10-26 17:10:50 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-06 07:39:33 +0200 |
commit | b4b2ef62d02d1edc5218bd157599fe7a9fd697b1 (patch) | |
tree | 612861a255f80a302628d0dc17b8ae980c1140c2 | |
parent | 58fc50700dc0c1cac608979c68fc7e5aaf8874bb (diff) |
Allow using CC and CXX to overwrite compiler
-rw-r--r-- | backend/ninja/Ninja.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp index 624d1dc..9a445c2 100644 --- a/backend/ninja/Ninja.cpp +++ b/backend/ninja/Ninja.cpp @@ -724,11 +724,15 @@ namespace backend static string getCompilerCExecutable(Compiler compiler) { + char *cc = std::getenv("CC"); + if(cc) + return cc; + string result; switch(compiler) { case Compiler::GCC: - result = "cc"; + result = "ccache cc"; break; case Compiler::MINGW_W64: result = "x86_64-w64-mingw32-cc"; @@ -742,11 +746,15 @@ namespace backend static string getCompilerCppExecutable(Compiler compiler) { + char *cxx = std::getenv("CXX"); + if(cxx) + return cxx; + string result; switch(compiler) { case Compiler::GCC: - result = "c++"; + result = "ccache c++"; break; case Compiler::MINGW_W64: result = "x86_64-w64-mingw32-c++"; @@ -986,8 +994,7 @@ namespace backend case LibraryType::EXECUTABLE: { baseCompileCArgs.insert(baseCompileCArgs.end(), { - ninja::NinjaArg("ccache"), - ninja::NinjaArg(cCompilerName), + ninja::NinjaArg::createRaw(cCompilerName), ninja::NinjaArg("-c"), ninja::NinjaArg::createRaw("-fPIE -fPIC"), ninja::NinjaArg("$in"), @@ -1000,8 +1007,7 @@ namespace backend case LibraryType::DYNAMIC: { baseCompileCArgs.insert(baseCompileCArgs.end(), { - ninja::NinjaArg("ccache"), - ninja::NinjaArg(cCompilerName), + ninja::NinjaArg::createRaw(cCompilerName), ninja::NinjaArg("-c"), ninja::NinjaArg("-fPIC"), ninja::NinjaArg("$in"), @@ -1358,7 +1364,6 @@ namespace backend { string rpath = extractDynamicLibDirsFromLinkerFlags(dynamicLinkerFlags); buildExeArgs.insert(buildExeArgs.end(), { - ninja::NinjaArg::createRaw("ccache"), ninja::NinjaArg::createRaw(usesCppFiles ? cppCompilerName : cCompilerName), ninja::NinjaArg::createRaw("-o"), ninja::NinjaArg::createRaw("$out"), @@ -1580,7 +1585,6 @@ namespace backend case Compiler::GCC: { buildDynamicArgs.insert(buildDynamicArgs.end(), { - ninja::NinjaArg::createRaw("ccache"), ninja::NinjaArg::createRaw(usesCppFiles ? cppCompilerName : cCompilerName), ninja::NinjaArg::createRaw("$in"), ninja::NinjaArg::createRaw("-shared"), |