diff options
Diffstat (limited to 'backend/BackendUtils.cpp')
-rw-r--r-- | backend/BackendUtils.cpp | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/backend/BackendUtils.cpp b/backend/BackendUtils.cpp index 158cd12..befd7ed 100644 --- a/backend/BackendUtils.cpp +++ b/backend/BackendUtils.cpp @@ -6,9 +6,9 @@ using namespace std; using namespace sibs; -static const char *cCompilerPath = nullptr; -static const char *cppCompilerPath = nullptr; -static const char *linkerPath = nullptr; +static std::vector<FileString> cCompilerPath; +static std::vector<FileString> cppCompilerPath; +static std::vector<FileString> linkerPath; namespace backend { @@ -108,7 +108,6 @@ namespace backend #endif projectConfPath += TINYDIR_STRING("project.conf"); - auto projectConfFileType = getFileType(projectConfPath.c_str()); if(!sibsConfig.isTest() && getFileType(projectConfPath.c_str()) == FileType::REGULAR) { backend::Ninja *subProject = new backend::Ninja(); @@ -131,82 +130,82 @@ namespace backend }); } - string BackendUtils::getCompilerCExecutable(Compiler compiler) + std::vector<sibs::FileString> BackendUtils::getCompilerCExecutable(Compiler compiler) { - if(cCompilerPath) + if(!cCompilerPath.empty()) return cCompilerPath; char *cc = std::getenv("CC"); if(cc) { - cCompilerPath = cc; + cCompilerPath = { toFileString(cc) }; return cCompilerPath; } switch(compiler) { case Compiler::GCC: - cCompilerPath = "ccache cc"; + cCompilerPath = { TINYDIR_STRING("ccache"), TINYDIR_STRING("cc") }; break; case Compiler::MINGW_W64: - cCompilerPath = "x86_64-w64-mingw32-cc"; + cCompilerPath = { TINYDIR_STRING("x86_64-w64-mingw32-cc") }; break; case Compiler::MSVC: - cCompilerPath = "cl.exe"; + cCompilerPath = { TINYDIR_STRING("cl.exe") }; break; } return cCompilerPath; } - string BackendUtils::getCompilerCppExecutable(Compiler compiler) + std::vector<sibs::FileString> BackendUtils::getCompilerCppExecutable(Compiler compiler) { - if(cppCompilerPath) + if(!cppCompilerPath.empty()) return cppCompilerPath; char *cxx = std::getenv("CXX"); if(cxx) { - cppCompilerPath = cxx; + cppCompilerPath = { toFileString(cxx) }; return cppCompilerPath; } switch(compiler) { case Compiler::GCC: - cppCompilerPath = "ccache c++"; + cppCompilerPath = { TINYDIR_STRING("ccache"), TINYDIR_STRING("c++") }; break; case Compiler::MINGW_W64: - cppCompilerPath = "x86_64-w64-mingw32-c++"; + cppCompilerPath = { TINYDIR_STRING("x86_64-w64-mingw32-c++") }; break; case Compiler::MSVC: - cppCompilerPath = "cl.exe"; + cppCompilerPath = { TINYDIR_STRING("cl.exe") }; break; } return cppCompilerPath; } - string BackendUtils::getCompilerLinker(Compiler compiler) + std::vector<sibs::FileString> BackendUtils::getCompilerLinker(Compiler compiler) { - if(linkerPath) + if(!linkerPath.empty()) return linkerPath; char *ar = std::getenv("AR"); if(ar) { - linkerPath = ar; + linkerPath = { toFileString(ar) }; return linkerPath; } switch(compiler) { case Compiler::GCC: - linkerPath = "ar"; + linkerPath = { TINYDIR_STRING("ar") }; break; case Compiler::MINGW_W64: - linkerPath = "x86_64-w64-mingw32-ar"; + linkerPath = { TINYDIR_STRING("x86_64-w64-mingw32-ar") }; break; case Compiler::MSVC: - linkerPath = "lib.exe"; + linkerPath = { TINYDIR_STRING("lib.exe") }; break; } return linkerPath; @@ -215,7 +214,9 @@ namespace backend RuntimeCompilerType BackendUtils::getCCompilerType(Compiler compiler) { RuntimeCompilerType cCompilerType = RuntimeCompilerType::NONE; - Result<ExecResult> cCompilerVersion = exec(toFileString(getCompilerCExecutable(compiler)) + TINYDIR_STRING(" --version")); + std::vector<FileString> args = getCompilerCExecutable(compiler); + args.push_back(TINYDIR_STRING("--version")); + Result<ExecResult> cCompilerVersion = exec(args); if(cCompilerVersion && cCompilerVersion.unwrap().exitCode == 0) { if(cCompilerVersion.unwrap().execStdout.find("Emscripten") != string::npos) @@ -231,7 +232,9 @@ namespace backend RuntimeCompilerType BackendUtils::getCppCompilerType(Compiler compiler) { RuntimeCompilerType cppCompilerType = RuntimeCompilerType::NONE; - Result<ExecResult> cppCompilerVersion = exec(toFileString(getCompilerCppExecutable(compiler)) + TINYDIR_STRING(" --version")); + std::vector<FileString> args = getCompilerCppExecutable(compiler); + args.push_back(TINYDIR_STRING("--version")); + Result<ExecResult> cppCompilerVersion = exec(args); if(cppCompilerVersion && cppCompilerVersion.unwrap().exitCode == 0) { if(cppCompilerVersion.unwrap().execStdout.find("Emscripten") != string::npos) |