aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rw-r--r--backend/ninja/Ninja.cpp57
1 files changed, 23 insertions, 34 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp
index 08ef41d..0408ca4 100644
--- a/backend/ninja/Ninja.cpp
+++ b/backend/ninja/Ninja.cpp
@@ -698,11 +698,21 @@ namespace backend
return result;
}
+ static FileString array_to_file_string(const std::vector<FileString> &vec) {
+ FileString result;
+ for(const FileString &str : vec) {
+ if(!result.empty())
+ result += TINYDIR_STRING(" ");
+ result += str;
+ }
+ return result;
+ }
+
Result<bool> Ninja::build(const SibsConfig &config, const _tinydir_char_t *savePath, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallback, GlobalIncludeDirCallbackFunc globalIncludeDirCallback)
{
- std::vector<FileString> cCompilerName = BackendUtils::getCompilerCExecutable(config.getCompiler());
- std::vector<FileString> cppCompilerName = BackendUtils::getCompilerCppExecutable(config.getCompiler());
- std::vector<FileString> compilerLinker = BackendUtils::getCompilerLinker(config.getCompiler());
+ FileString cCompilerName = array_to_file_string(BackendUtils::getCompilerCExecutable(config.getCompiler()));
+ FileString cppCompilerName = array_to_file_string(BackendUtils::getCompilerCppExecutable(config.getCompiler()));
+ FileString compilerLinker = array_to_file_string(BackendUtils::getCompilerLinker(config.getCompiler()));
RuntimeCompilerType cCompilerType = BackendUtils::getCCompilerType(config.getCompiler());
RuntimeCompilerType cppCompilerType = BackendUtils::getCppCompilerType(config.getCompiler());
@@ -1000,13 +1010,8 @@ namespace backend
ninja::NinjaArg("-Wnon-virtual-dtor")
});
- for(auto it = cCompilerName.rbegin(), end = cCompilerName.rend(); it != end; ++it) {
- compileCCommand.insert(compileCCommand.begin(), ninja::NinjaArg(*it));
- }
-
- for(auto it = cppCompilerName.rbegin(), end = cppCompilerName.rend(); it != end; ++it) {
- compileCppCommand.insert(compileCppCommand.begin(), ninja::NinjaArg(*it));
- }
+ compileCCommand.insert(compileCCommand.begin(), ninja::NinjaArg(cCompilerName));
+ compileCppCommand.insert(compileCppCommand.begin(), ninja::NinjaArg(cppCompilerName));
break;
}
case Compiler::MSVC:
@@ -1326,13 +1331,9 @@ namespace backend
case Compiler::GCC:
{
if(usesCppFiles) {
- for(const FileString &arg : cppCompilerName) {
- buildExeArgs.push_back(ninja::NinjaArg(arg));
- }
+ buildExeArgs.push_back(ninja::NinjaArg(cppCompilerName));
} else {
- for(const FileString &arg : cCompilerName) {
- buildExeArgs.push_back(ninja::NinjaArg(arg));
- }
+ buildExeArgs.push_back(ninja::NinjaArg(cCompilerName));
}
string rpath = extractDynamicLibDirsFromLinkerFlags(dynamicLinkerFlags);
buildExeArgs.insert(buildExeArgs.end(), {
@@ -1383,9 +1384,7 @@ namespace backend
}
case Compiler::MSVC:
{
- for(const FileString &arg : cppCompilerName) {
- buildExeArgs.push_back(ninja::NinjaArg(arg));
- }
+ buildExeArgs.push_back(ninja::NinjaArg(cppCompilerName));
// TODO: Do not link all of these. Find a way to only link the ones that are needed
buildExeArgs.insert(buildExeArgs.end(), {
ninja::NinjaArg::createRaw("$in"),
@@ -1483,9 +1482,7 @@ namespace backend
case Compiler::MINGW_W64:
case Compiler::GCC:
{
- for(const FileString &arg : compilerLinker) {
- buildStaticArgs.push_back(ninja::NinjaArg(arg));
- }
+ buildStaticArgs.push_back(ninja::NinjaArg(compilerLinker));
buildStaticArgs.insert(buildStaticArgs.end(), {
ninja::NinjaArg::createRaw("rcs"),
ninja::NinjaArg::createRaw("$out"),
@@ -1495,9 +1492,7 @@ namespace backend
}
case Compiler::MSVC:
{
- for(const FileString &arg : compilerLinker) {
- buildStaticArgs.push_back(ninja::NinjaArg(arg));
- }
+ buildStaticArgs.push_back(ninja::NinjaArg(compilerLinker));
buildStaticArgs.insert(buildStaticArgs.end(), {
ninja::NinjaArg::createRaw("/OUT:$out"),
ninja::NinjaArg::createRaw("$in")
@@ -1576,13 +1571,9 @@ namespace backend
case Compiler::GCC:
{
if(usesCppFiles) {
- for(const FileString &arg : cppCompilerName) {
- buildDynamicArgs.push_back(ninja::NinjaArg(arg));
- }
+ buildDynamicArgs.push_back(ninja::NinjaArg(cppCompilerName));
} else {
- for(const FileString &arg : cCompilerName) {
- buildDynamicArgs.push_back(ninja::NinjaArg(arg));
- }
+ buildDynamicArgs.push_back(ninja::NinjaArg(cCompilerName));
}
buildDynamicArgs.insert(buildDynamicArgs.end(), {
ninja::NinjaArg::createRaw("$in"),
@@ -1625,9 +1616,7 @@ namespace backend
}
case Compiler::MSVC:
{
- for(const FileString &arg : compilerLinker) {
- buildDynamicArgs.push_back(ninja::NinjaArg(arg));
- }
+ buildDynamicArgs.push_back(ninja::NinjaArg(compilerLinker));
buildDynamicArgs.insert(buildDynamicArgs.end(), {
ninja::NinjaArg::createRaw("/OUT:$out"),
ninja::NinjaArg::createRaw("$in"),