diff options
Diffstat (limited to 'src/tools.cc')
-rw-r--r-- | src/tools.cc | 500 |
1 files changed, 471 insertions, 29 deletions
diff --git a/src/tools.cc b/src/tools.cc index 394a91c..4dc6b3b 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -6,6 +6,7 @@ #include <filesystem> #include <iostream> #include <sstream> +#include <algorithm> #include <cassert> #include <cstdio> @@ -20,6 +21,8 @@ std::ostream& operator<<(std::ostream& stream, const ctor::c_opt& opt) case ctor::c_opt::output: stream << "ctor::c_opt::output"; break; case ctor::c_opt::debug: stream << "ctor::c_opt::debug"; break; case ctor::c_opt::warn_all: stream << "ctor::c_opt::warn_all"; break; + case ctor::c_opt::warn_conversion: stream << "ctor::c_opt::warn_conversion"; break; + case ctor::c_opt::warn_extra: stream << "ctor::c_opt::warn_extra"; break; case ctor::c_opt::warnings_as_errors: stream << "ctor::c_opt::warnings_as_errors"; break; case ctor::c_opt::generate_dep_tree: stream << "ctor::c_opt::generate_dep_tree"; break; case ctor::c_opt::no_link: stream << "ctor::c_opt::no_link"; break; @@ -28,6 +31,7 @@ std::ostream& operator<<(std::ostream& stream, const ctor::c_opt& opt) case ctor::c_opt::optimization: stream << "ctor::c_opt::optimization"; break; case ctor::c_opt::position_independent_code: stream << "ctor::c_opt::position_independent_code"; break; case ctor::c_opt::position_independent_executable: stream << "ctor::c_opt::position_independent_executable"; break; + case ctor::c_opt::define: stream << "ctor::c_opt::define"; break; case ctor::c_opt::custom: stream << "ctor::c_opt::custom"; break; } @@ -42,6 +46,8 @@ std::ostream& operator<<(std::ostream& stream, const ctor::cxx_opt& opt) case ctor::cxx_opt::output: stream << "ctor::cxx_opt::output"; break; case ctor::cxx_opt::debug: stream << "ctor::cxx_opt::debug"; break; case ctor::cxx_opt::warn_all: stream << "ctor::cxx_opt::warn_all"; break; + case ctor::cxx_opt::warn_conversion: stream << "ctor::cxx_opt::warn_conversion"; break; + case ctor::cxx_opt::warn_extra: stream << "ctor::cxx_opt::warn_extra"; break; case ctor::cxx_opt::warnings_as_errors: stream << "ctor::cxx_opt::warnings_as_errors"; break; case ctor::cxx_opt::generate_dep_tree: stream << "ctor::cxx_opt::generate_dep_tree"; break; case ctor::cxx_opt::no_link: stream << "ctor::cxx_opt::no_link"; break; @@ -50,6 +56,7 @@ std::ostream& operator<<(std::ostream& stream, const ctor::cxx_opt& opt) case ctor::cxx_opt::optimization: stream << "ctor::cxx_opt::optimization"; break; case ctor::cxx_opt::position_independent_code: stream << "ctor::cxx_opt::position_independent_code"; break; case ctor::cxx_opt::position_independent_executable: stream << "ctor::cxx_opt::position_independent_executable"; break; + case ctor::cxx_opt::define: stream << "ctor::cxx_opt::define"; break; case ctor::cxx_opt::custom: stream << "ctor::cxx_opt::custom"; break; } @@ -109,18 +116,27 @@ ctor::toolchain getToolChain(const std::string& compiler) std::filesystem::path cc(compiler); auto cc_cmd = cc.stem().string(); + std::cout << "getToolChain: [" << cc_cmd << "] => "; + // Note: "g++" is a substring of "clang++" so "clang++" must be tested first. if(cc_cmd.find("clang++") != std::string::npos || cc_cmd.find("clang") != std::string::npos) { + std::cout << "clang" << std::endl; return ctor::toolchain::clang; } else if(cc_cmd.find("g++") != std::string::npos || cc_cmd.find("gcc") != std::string::npos || cc_cmd.find("mingw") != std::string::npos) { + std::cout << "gcc" << std::endl; return ctor::toolchain::gcc; } + else if(to_lower(cc_cmd).find("cl") != std::string::npos) + { + std::cout << "msvc" << std::endl; + return ctor::toolchain::msvc; + } std::cerr << "Unsupported output system.\n"; return ctor::toolchain::gcc; @@ -146,12 +162,258 @@ ctor::toolchain getToolChain(ctor::output_system system) return getToolChain(cfg.get(ctor::cfg::build_cxx, "g++")); } } +namespace msvc { +std::string get_arch([[maybe_unused]] ctor::output_system system) +{ + std::string arch; + // TODO + return arch; +} + +ctor::arch get_arch([[maybe_unused]] const std::string& str) +{ + return ctor::arch::windows; +} + +ctor::c_flag c_option(const std::string& flag) +{ + if(flag.starts_with("/I")) + { + std::string path = flag.substr(2); + path.erase(0, path.find_first_not_of(' ')); + return { ctor::c_opt::include_path, path }; + } + + return { ctor::c_opt::custom, flag }; +} + +ctor::cxx_flag cxx_option(const std::string& flag) +{ + if(flag.starts_with("/I")) + { + std::string path = flag.substr(2); + path.erase(0, path.find_first_not_of(' ')); + return { ctor::cxx_opt::include_path, path }; + } + + return { ctor::cxx_opt::custom, flag }; +} + +ctor::ld_flag ld_option(const std::string& flag) +{ + if(flag.starts_with("/L")) + { + std::string path = flag.substr(2); + path.erase(0, path.find_first_not_of(' ')); + return { ctor::ld_opt::library_path, path }; + } + + return { ctor::ld_opt::custom, flag }; +} + +ctor::ar_flag ar_option(const std::string& flag) +{ + return { ctor::ar_opt::custom, flag }; +} + +std::vector<std::string> cxx_option(ctor::cxx_opt opt, const std::string& arg, + const std::string& arg2) +{ + switch(opt) + { + case ctor::cxx_opt::output: + return {"/Fo\"" + arg + "\""}; + case ctor::cxx_opt::debug: + return {"/DEBUG"}; + case ctor::cxx_opt::warn_all: + return {"/W4"}; + case ctor::cxx_opt::warn_conversion: + return {"/W4"}; // TODO: This is incorrect + case ctor::cxx_opt::warn_extra: + return {"/W4"}; // TODO: This is incorrect + case ctor::cxx_opt::warnings_as_errors: + return {"/WX"}; + case ctor::cxx_opt::generate_dep_tree: + return {"/sourceDependencies", arg}; + case ctor::cxx_opt::no_link: + return {"/c"}; + case ctor::cxx_opt::include_path: + return {"/I" + arg}; + case ctor::cxx_opt::cpp_std: + return {"/std:" + arg}; + case ctor::cxx_opt::optimization: + { + int o{0}; + try + { + o = std::stoi(arg); + o = std::clamp(o, 0, 2); + } + catch(...) + { + // bad number? + } + return {"/O" + std::to_string(o)}; + } + case ctor::cxx_opt::position_independent_code: + return {}; // TODO? + case ctor::cxx_opt::position_independent_executable: + return {}; // TODO? + case ctor::cxx_opt::define: + if(!arg2.empty()) + { + return {"/D" + arg + "=" + esc(arg2)}; + } + else + { + return {"/D" + arg}; + } + case ctor::cxx_opt::custom: + return {arg}; + } + + std::cerr << "Unsupported compiler option.\n"; + return {}; +} + +std::vector<std::string> c_option(ctor::c_opt opt, const std::string& arg, + const std::string& arg2) +{ + switch(opt) + { + case ctor::c_opt::output: + return {"/Fo\"" + arg + "\""}; + case ctor::c_opt::debug: + return {"/DEBUG"}; + case ctor::c_opt::warn_all: + return {"/W4"}; + case ctor::c_opt::warn_conversion: + return {"/W4"}; // TODO: This is incorrect + case ctor::c_opt::warn_extra: + return {"/W4"}; // TODO: This is incorrect + case ctor::c_opt::warnings_as_errors: + return {"/WX"}; + case ctor::c_opt::generate_dep_tree: + return {"/sourceDependencies", arg}; + case ctor::c_opt::no_link: + return {"/c"}; + case ctor::c_opt::include_path: + return {"/I" + arg}; + case ctor::c_opt::c_std: + return {"/std:" + arg}; + case ctor::c_opt::optimization: + { + int o{0}; + try + { + o = std::stoi(arg); + o = std::clamp(o, 0, 2); + } + catch(...) + { + // bad number? + } + return {"/O" + std::to_string(o)}; + } + case ctor::c_opt::position_independent_code: + return {}; // TODO? + case ctor::c_opt::position_independent_executable: + return {}; // TODO? + case ctor::c_opt::define: + if(!arg2.empty()) + { + return {"/D" + arg + "=" + esc(arg2)}; + } + else + { + return {"/D" + arg}; + } + case ctor::c_opt::custom: + return {arg}; + } + + std::cerr << "Unsupported compiler option.\n"; + return {}; +} + +std::vector<std::string> ld_option(ctor::ld_opt opt, const std::string& arg, + [[maybe_unused]]const std::string& arg2) +{ + switch(opt) + { + case ctor::ld_opt::output: + return {"/out:" + arg + ""}; + case ctor::ld_opt::strip: + return {}; // TODO? + case ctor::ld_opt::warn_all: + return {"/Wall"}; + case ctor::ld_opt::warnings_as_errors: + return {"/WX"}; + case ctor::ld_opt::library_path: + return {"/LIBPATH:\""+arg+"\""}; + case ctor::ld_opt::link: + return {arg}; // TODO? + case ctor::ld_opt::cpp_std: + return {"/std:" + arg}; + case ctor::ld_opt::build_shared: + return {}; // TODO? + case ctor::ld_opt::threads: + return {}; // TODO? + case ctor::ld_opt::position_independent_code: + return {}; // TODO? + case ctor::ld_opt::position_independent_executable: + return {}; // TODO? + case ctor::ld_opt::custom: + return {arg}; + } + + std::cerr << "Unsupported compiler option.\n"; + return {}; +} + +std::vector<std::string> ar_option(ctor::ar_opt opt, const std::string& arg, + [[maybe_unused]]const std::string& arg2) +{ + switch(opt) + { + case ctor::ar_opt::replace: + return {}; + case ctor::ar_opt::add_index: + return {}; + case ctor::ar_opt::create: + return {}; + case ctor::ar_opt::output: + return {"/out:" + arg}; + case ctor::ar_opt::custom: + return {arg}; + } + + std::cerr << "Unsupported compiler option.\n"; + return {}; +} + +std::vector<std::string> asm_option(ctor::asm_opt opt, const std::string& arg, + [[maybe_unused]]const std::string& arg2) +{ + switch(opt) + { + case ctor::asm_opt::custom: + return {arg}; + } + + std::cerr << "Unsupported compiler option.\n"; + return {}; +} +} // msvc:: + namespace gcc { -std::string get_arch(ctor::output_system system) +std::string get_arch([[maybe_unused]] ctor::output_system system) { + std::string arch; + // TODO popen on windows +#if !defined(_WIN32) std::string cmd; - const auto& c = ctor::get_configuration(); switch(system) { @@ -172,7 +434,6 @@ std::string get_arch(ctor::output_system system) return {};//ctor::arch::unknown; } - std::string arch; while(!feof(pipe)) { constexpr auto buffer_size{1024}; @@ -198,6 +459,7 @@ std::string get_arch(ctor::output_system system) // Remove 'Target: ' prefix constexpr auto prefix_length{8}; arch = arch.substr(prefix_length); +#endif // _WIN32 return arch; } @@ -245,6 +507,56 @@ ctor::c_flag c_option(const std::string& flag) return { ctor::c_opt::include_path, path }; } + if(flag.starts_with("-std=")) + { + std::string std = flag.substr(5); + return { ctor::c_opt::c_std, std }; + } + + if(flag.starts_with("-O")) + { + std::string opt = flag.substr(2, 1); + return { ctor::c_opt::optimization, opt }; + } + + if(flag.starts_with("-Wall")) + { + return { ctor::c_opt::warn_all }; + } + + if(flag.starts_with("-Wconversion")) + { + return { ctor::c_opt::warn_conversion}; + } + + if(flag.starts_with("-Wextra")) + { + return { ctor::c_opt::warn_extra}; + } + + if(flag.starts_with("-Werror")) + { + return { ctor::c_opt::warnings_as_errors }; + } + + if(flag.starts_with("-g")) + { + return { ctor::c_opt::debug }; + } + + if(flag.starts_with("-D")) + { + std::string def = flag.substr(2); + auto pos = def.find('='); + if(pos != def.npos) + { + return { ctor::c_opt::define, def.substr(0, pos), def.substr(pos + 1) }; + } + else + { + return { ctor::c_opt::define, def }; + } + } return { ctor::c_opt::custom, flag }; } @@ -257,6 +569,57 @@ ctor::cxx_flag cxx_option(const std::string& flag) return { ctor::cxx_opt::include_path, path }; } + if(flag.starts_with("-std=")) + { + std::string std = flag.substr(5); + return { ctor::cxx_opt::cpp_std, std }; + } + + if(flag.starts_with("-O")) + { + std::string opt = flag.substr(2, 1); + return { ctor::cxx_opt::optimization, opt }; + } + + if(flag.starts_with("-Wall")) + { + return { ctor::cxx_opt::warn_all }; + } + + if(flag.starts_with("-Werror")) + { + return { ctor::cxx_opt::warnings_as_errors }; + } + + if(flag.starts_with("-Wconversion")) + { + return { ctor::cxx_opt::warn_conversion}; + } + + if(flag.starts_with("-Wextra")) + { + return { ctor::cxx_opt::warn_extra}; + } + + if(flag.starts_with("-g")) + { + return { ctor::cxx_opt::debug }; + } + + if(flag.starts_with("-D")) + { + std::string def = flag.substr(2); + auto pos = def.find('='); + if(pos != def.npos) + { + return { ctor::cxx_opt::define, def.substr(0, pos), def.substr(pos + 1) }; + } + else + { + return { ctor::cxx_opt::define, def }; + } + } + return { ctor::cxx_opt::custom, flag }; } @@ -269,6 +632,11 @@ ctor::ld_flag ld_option(const std::string& flag) return { ctor::ld_opt::library_path, path }; } + if(flag.starts_with("-pthread")) + { + return { ctor::ld_opt::threads }; + } + return { ctor::ld_opt::custom, flag }; } @@ -277,7 +645,8 @@ ctor::ar_flag ar_option(const std::string& flag) return { ctor::ar_opt::custom, flag }; } -std::vector<std::string> cxx_option(ctor::cxx_opt opt, const std::string& arg) +std::vector<std::string> cxx_option(ctor::cxx_opt opt, const std::string& arg, + const std::string& arg2) { switch(opt) { @@ -287,6 +656,10 @@ std::vector<std::string> cxx_option(ctor::cxx_opt opt, const std::string& arg) return {"-g"}; case ctor::cxx_opt::warn_all: return {"-Wall"}; + case ctor::cxx_opt::warn_conversion: + return {"-Wconversion"}; + case ctor::cxx_opt::warn_extra: + return {"-Wextra"}; case ctor::cxx_opt::warnings_as_errors: return {"-Werror"}; case ctor::cxx_opt::generate_dep_tree: @@ -303,6 +676,12 @@ std::vector<std::string> cxx_option(ctor::cxx_opt opt, const std::string& arg) return {"-fPIC"}; case ctor::cxx_opt::position_independent_executable: return {"-fPIE"}; + case ctor::cxx_opt::define: + if(!arg2.empty()) + { + return {"-D" + arg + "=" + arg2}; + } + return {"-D" + arg}; case ctor::cxx_opt::custom: return {arg}; } @@ -311,7 +690,8 @@ std::vector<std::string> cxx_option(ctor::cxx_opt opt, const std::string& arg) return {}; } -std::vector<std::string> c_option(ctor::c_opt opt, const std::string& arg) +std::vector<std::string> c_option(ctor::c_opt opt, const std::string& arg, + const std::string& arg2) { switch(opt) { @@ -321,6 +701,10 @@ std::vector<std::string> c_option(ctor::c_opt opt, const std::string& arg) return {"-g"}; case ctor::c_opt::warn_all: return {"-Wall"}; + case ctor::c_opt::warn_conversion: + return {"-Wconversion"}; + case ctor::c_opt::warn_extra: + return {"-Wextra"}; case ctor::c_opt::warnings_as_errors: return {"-Werror"}; case ctor::c_opt::generate_dep_tree: @@ -337,6 +721,12 @@ std::vector<std::string> c_option(ctor::c_opt opt, const std::string& arg) return {"-fPIC"}; case ctor::c_opt::position_independent_executable: return {"-fPIE"}; + case ctor::c_opt::define: + if(!arg2.empty()) + { + return {"-D" + arg + "=" + arg2}; + } + return {"-D" + arg}; case ctor::c_opt::custom: return {arg}; } @@ -345,7 +735,8 @@ std::vector<std::string> c_option(ctor::c_opt opt, const std::string& arg) return {}; } -std::vector<std::string> ld_option(ctor::ld_opt opt, const std::string& arg) +std::vector<std::string> ld_option(ctor::ld_opt opt, const std::string& arg, + [[maybe_unused]]const std::string& arg2) { switch(opt) { @@ -379,7 +770,8 @@ std::vector<std::string> ld_option(ctor::ld_opt opt, const std::string& arg) return {}; } -std::vector<std::string> ar_option(ctor::ar_opt opt, const std::string& arg) +std::vector<std::string> ar_option(ctor::ar_opt opt, const std::string& arg, + [[maybe_unused]]const std::string& arg2) { switch(opt) { @@ -399,7 +791,8 @@ std::vector<std::string> ar_option(ctor::ar_opt opt, const std::string& arg) return {}; } -std::vector<std::string> asm_option(ctor::asm_opt opt, const std::string& arg) +std::vector<std::string> asm_option(ctor::asm_opt opt, const std::string& arg, + [[maybe_unused]]const std::string& arg2) { switch(opt) { @@ -420,6 +813,8 @@ std::string get_arch(ctor::output_system system) case ctor::toolchain::clang: case ctor::toolchain::gcc: return gcc::get_arch(system); + case ctor::toolchain::msvc: + return msvc::get_arch(system); case ctor::toolchain::any: case ctor::toolchain::none: break; @@ -435,6 +830,8 @@ ctor::arch get_arch(ctor::output_system system, const std::string& str) case ctor::toolchain::clang: case ctor::toolchain::gcc: return gcc::get_arch(str); + case ctor::toolchain::msvc: + return msvc::get_arch(str); case ctor::toolchain::any: case ctor::toolchain::none: break; @@ -444,13 +841,16 @@ ctor::arch get_arch(ctor::output_system system, const std::string& str) std::vector<std::string> c_option(ctor::toolchain toolchain, ctor::c_opt opt, - const std::string& arg) + const std::string& arg, + const std::string& arg2) { switch(toolchain) { case ctor::toolchain::gcc: case ctor::toolchain::clang: - return gcc::c_option(opt, arg); + return gcc::c_option(opt, arg, arg2); + case ctor::toolchain::msvc: + return msvc::c_option(opt, arg, arg2); case ctor::toolchain::any: { std::ostringstream ss; @@ -459,6 +859,10 @@ std::vector<std::string> c_option(ctor::toolchain toolchain, { ss << ", \"" << arg << "\""; } + if(!arg2.empty()) + { + ss << ", \"" << arg2 << "\""; + } ss << "}"; return { ss.str() }; } @@ -472,13 +876,16 @@ std::vector<std::string> c_option(ctor::toolchain toolchain, std::vector<std::string> cxx_option(ctor::toolchain toolchain, ctor::cxx_opt opt, - const std::string& arg) + const std::string& arg, + const std::string& arg2) { switch(toolchain) { case ctor::toolchain::gcc: case ctor::toolchain::clang: - return gcc::cxx_option(opt, arg); + return gcc::cxx_option(opt, arg, arg2); + case ctor::toolchain::msvc: + return msvc::cxx_option(opt, arg, arg2); case ctor::toolchain::any: { std::ostringstream ss; @@ -487,6 +894,10 @@ std::vector<std::string> cxx_option(ctor::toolchain toolchain, { ss << ", \"" << arg << "\""; } + if(!arg2.empty()) + { + ss << ", \"" << arg2 << "\""; + } ss << "}"; return { ss.str() }; } @@ -500,13 +911,16 @@ std::vector<std::string> cxx_option(ctor::toolchain toolchain, std::vector<std::string> ld_option(ctor::toolchain toolchain, ctor::ld_opt opt, - const std::string& arg) + const std::string& arg, + const std::string& arg2) { switch(toolchain) { case ctor::toolchain::gcc: case ctor::toolchain::clang: - return gcc::ld_option(opt, arg); + return gcc::ld_option(opt, arg, arg2); + case ctor::toolchain::msvc: + return msvc::ld_option(opt, arg, arg2); case ctor::toolchain::any: { std::ostringstream ss; @@ -515,6 +929,10 @@ std::vector<std::string> ld_option(ctor::toolchain toolchain, { ss << ", \"" << arg << "\""; } + if(!arg2.empty()) + { + ss << ", \"" << arg2 << "\""; + } ss << "}"; return { ss.str() }; } @@ -528,13 +946,16 @@ std::vector<std::string> ld_option(ctor::toolchain toolchain, std::vector<std::string> ar_option(ctor::toolchain toolchain, ctor::ar_opt opt, - const std::string& arg) + const std::string& arg, + const std::string& arg2) { switch(toolchain) { case ctor::toolchain::gcc: case ctor::toolchain::clang: - return gcc::ar_option(opt, arg); + return gcc::ar_option(opt, arg, arg2); + case ctor::toolchain::msvc: + return msvc::ar_option(opt, arg, arg2); case ctor::toolchain::any: { std::ostringstream ss; @@ -543,6 +964,10 @@ std::vector<std::string> ar_option(ctor::toolchain toolchain, { ss << ", \"" << arg << "\""; } + if(!arg2.empty()) + { + ss << ", \"" << arg2 << "\""; + } ss << "}"; return { ss.str() }; } @@ -556,13 +981,16 @@ std::vector<std::string> ar_option(ctor::toolchain toolchain, std::vector<std::string> asm_option(ctor::toolchain toolchain, ctor::asm_opt opt, - const std::string& arg) + const std::string& arg, + const std::string& arg2) { switch(toolchain) { case ctor::toolchain::gcc: case ctor::toolchain::clang: - return gcc::asm_option(opt, arg); + return gcc::asm_option(opt, arg, arg2); + case ctor::toolchain::msvc: + return msvc::asm_option(opt, arg, arg2); case ctor::toolchain::any: { std::ostringstream ss; @@ -571,6 +999,10 @@ std::vector<std::string> asm_option(ctor::toolchain toolchain, { ss << ", \"" << arg << "\""; } + if(!arg2.empty()) + { + ss << ", \"" << arg2 << "\""; + } ss << "}"; return { ss.str() }; } @@ -590,6 +1022,8 @@ ctor::c_flag c_option(const std::string& flag, ctor::toolchain toolchain) case ctor::toolchain::gcc: case ctor::toolchain::clang: return gcc::c_option(flag); + case ctor::toolchain::msvc: + return msvc::c_option(flag); case ctor::toolchain::any: case ctor::toolchain::none: break; @@ -605,6 +1039,8 @@ ctor::cxx_flag cxx_option(const std::string& flag, ctor::toolchain toolchain) case ctor::toolchain::gcc: case ctor::toolchain::clang: return gcc::cxx_option(flag); + case ctor::toolchain::msvc: + return msvc::cxx_option(flag); case ctor::toolchain::any: case ctor::toolchain::none: break; @@ -620,6 +1056,8 @@ ctor::ld_flag ld_option(const std::string& flag, ctor::toolchain toolchain) case ctor::toolchain::gcc: case ctor::toolchain::clang: return gcc::ld_option(flag); + case ctor::toolchain::msvc: + return msvc::ld_option(flag); case ctor::toolchain::any: case ctor::toolchain::none: break; @@ -635,6 +1073,8 @@ ctor::ar_flag ar_option(const std::string& flag, ctor::toolchain toolchain) case ctor::toolchain::gcc: case ctor::toolchain::clang: return gcc::ar_option(flag); + case ctor::toolchain::msvc: + return msvc::ar_option(flag); case ctor::toolchain::any: case ctor::toolchain::none: break; @@ -649,6 +1089,7 @@ ctor::asm_flag asm_option(const std::string& flag, ctor::toolchain toolchain) { case ctor::toolchain::gcc: case ctor::toolchain::clang: + case ctor::toolchain::msvc: case ctor::toolchain::any: case ctor::toolchain::none: break; @@ -665,7 +1106,7 @@ std::vector<std::string> to_strings(ctor::toolchain toolchain, if(flag.toolchain == ctor::toolchain::any || flag.toolchain == toolchain) { - return c_option(toolchain, flag.opt, flag.arg); + return c_option(toolchain, flag.opt, flag.arg, flag.arg2); } return {}; @@ -677,7 +1118,7 @@ std::vector<std::string> to_strings(ctor::toolchain toolchain, if(flag.toolchain == ctor::toolchain::any || flag.toolchain == toolchain) { - return cxx_option(toolchain, flag.opt, flag.arg); + return cxx_option(toolchain, flag.opt, flag.arg, flag.arg2); } return {}; @@ -689,7 +1130,7 @@ std::vector<std::string> to_strings(ctor::toolchain toolchain, if(flag.toolchain == ctor::toolchain::any || flag.toolchain == toolchain) { - return ld_option(toolchain, flag.opt, flag.arg); + return ld_option(toolchain, flag.opt, flag.arg, flag.arg2); } return {}; @@ -701,7 +1142,7 @@ std::vector<std::string> to_strings(ctor::toolchain toolchain, if(flag.toolchain == ctor::toolchain::any || flag.toolchain == toolchain) { - return ar_option(toolchain, flag.opt, flag.arg); + return ar_option(toolchain, flag.opt, flag.arg, flag.arg2); } return {}; @@ -713,7 +1154,7 @@ std::vector<std::string> to_strings(ctor::toolchain toolchain, if(flag.toolchain == ctor::toolchain::any || flag.toolchain == toolchain) { - return asm_option(toolchain, flag.opt, flag.arg); + return asm_option(toolchain, flag.opt, flag.arg, flag.arg2); } return {}; @@ -732,10 +1173,11 @@ ctor::toolchain guess_toolchain(const std::string& opt) return ctor::toolchain::gcc; } - //if(opt[0] == '/') - //{ - // return ctor::toolchain::msvc; - //} + if(opt[0] == '/') + { + return ctor::toolchain::msvc; + } + return ctor::toolchain::any; } } @@ -806,8 +1248,8 @@ ctor::target_type target_type_from_extension(ctor::toolchain toolchain, } } - if(toolchain == ctor::toolchain::any// || - //toolchain == ctor::toolchain::msvc || + if(toolchain == ctor::toolchain::any || + toolchain == ctor::toolchain::msvc// || //toolchain == ctor::toolchain::mingw || ) { |