From 9f9507d75ccdff561a390c441d45c000382c42fc Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 4 Nov 2018 08:15:07 +0100 Subject: Use dll files for mingw, use mingw cmake --- backend/ninja/Ninja.cpp | 107 ++++-------------------------------------------- 1 file changed, 7 insertions(+), 100 deletions(-) (limited to 'backend/ninja') diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp index 526fccb..d5bfc67 100644 --- a/backend/ninja/Ninja.cpp +++ b/backend/ninja/Ninja.cpp @@ -722,109 +722,14 @@ namespace backend return result; } - static string getCompilerCExecutable(Compiler compiler) - { - char *cc = std::getenv("CC"); - if(cc) - return cc; - - string result; - switch(compiler) - { - case Compiler::GCC: - result = "ccache cc"; - break; - case Compiler::MINGW_W64: - result = "x86_64-w64-mingw32-cc"; - break; - case Compiler::MSVC: - result = "cl.exe"; - break; - } - return result; - } - - static string getCompilerCppExecutable(Compiler compiler) - { - char *cxx = std::getenv("CXX"); - if(cxx) - return cxx; - - string result; - switch(compiler) - { - case Compiler::GCC: - result = "ccache c++"; - break; - case Compiler::MINGW_W64: - result = "x86_64-w64-mingw32-c++"; - break; - case Compiler::MSVC: - result = "cl.exe"; - break; - } - return result; - } - - static string getCompilerLinker(Compiler compiler) - { - char *ar = std::getenv("AR"); - if(ar) - return ar; - - string result; - switch(compiler) - { - case Compiler::GCC: - result = "ar"; - break; - case Compiler::MINGW_W64: - result = "x86_64-w64-mingw32-ar"; - break; - case Compiler::MSVC: - result = "lib.exe"; - break; - } - return result; - } - - enum class RuntimeCompilerType - { - NONE, - OTHER, - CLANG, - EMSCRIPTEN - }; - Result Ninja::build(const SibsConfig &config, const _tinydir_char_t *savePath, LinkerFlagCallbackFunc staticLinkerFlagCallbackFunc, LinkerFlagCallbackFunc dynamicLinkerFlagCallback, GlobalIncludeDirCallbackFunc globalIncludeDirCallback) { - string cCompilerName = getCompilerCExecutable(config.getCompiler()); - string cppCompilerName = getCompilerCppExecutable(config.getCompiler()); - string compilerLinker = getCompilerLinker(config.getCompiler()); - - RuntimeCompilerType cCompilerType = RuntimeCompilerType::NONE; - Result cCompilerVersion = exec(toFileString(cCompilerName) + TINYDIR_STRING(" --version")); - if(cCompilerVersion && cCompilerVersion.unwrap().exitCode == 0) - { - if(cCompilerVersion.unwrap().execStdout.find("Emscripten") != string::npos) - cCompilerType = RuntimeCompilerType::EMSCRIPTEN; - else if(cCompilerVersion.unwrap().execStdout.find("clang") != string::npos) - cCompilerType = RuntimeCompilerType::CLANG; - else - cCompilerType = RuntimeCompilerType::OTHER; - } + string cCompilerName = BackendUtils::getCompilerCExecutable(config.getCompiler()); + string cppCompilerName = BackendUtils::getCompilerCppExecutable(config.getCompiler()); + string compilerLinker = BackendUtils::getCompilerLinker(config.getCompiler()); - RuntimeCompilerType cppCompilerType = RuntimeCompilerType::NONE; - Result cppCompilerVersion = exec(toFileString(cppCompilerName) + TINYDIR_STRING(" --version")); - if(cppCompilerVersion && cppCompilerVersion.unwrap().exitCode == 0) - { - if(cppCompilerVersion.unwrap().execStdout.find("Emscripten") != string::npos) - cppCompilerType = RuntimeCompilerType::EMSCRIPTEN; - else if(cppCompilerVersion.unwrap().execStdout.find("clang") != string::npos) - cppCompilerType = RuntimeCompilerType::CLANG; - else - cppCompilerType = RuntimeCompilerType::OTHER; - } + RuntimeCompilerType cCompilerType = BackendUtils::getCCompilerType(config.getCompiler()); + RuntimeCompilerType cppCompilerType = BackendUtils::getCppCompilerType(config.getCompiler()); if(cCompilerType != RuntimeCompilerType::NONE && cppCompilerType != RuntimeCompilerType::NONE && cCompilerType != cppCompilerType) return Result::Err("The c and c++ compiler has to be of the same type"); @@ -1608,6 +1513,8 @@ namespace backend const char *fileExtension = CONFIG_DYNAMIC_LIB_FILE_EXTENSION; if(compilerType == RuntimeCompilerType::EMSCRIPTEN) fileExtension = "wasm"; + else if(config.getCompiler() == Compiler::MINGW_W64) + fileExtension = "dll"; generatedFile = "lib" + config.getPackageName() + "." + fileExtension; break; } -- cgit v1.2.3