|
|
|
|
|
|
|
|
if (arg == "<FLAGS>") { |
|
|
if (arg == "<FLAGS>") { |
|
|
extend(command, flags); |
|
|
extend(command, flags); |
|
|
} else { |
|
|
} else { |
|
|
arg = replace(arg, "<FILE>", spec.source_path.string()); |
|
|
|
|
|
|
|
|
arg = replace(arg, "<IN>", spec.source_path.string()); |
|
|
arg = replace(arg, "<OUT>", spec.out_path.string()); |
|
|
arg = replace(arg, "<OUT>", spec.out_path.string()); |
|
|
command.push_back(arg); |
|
|
command.push_back(arg); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
vector<string> toolchain::create_archive_command(const archive_spec& spec) const noexcept { |
|
|
vector<string> toolchain::create_archive_command(const archive_spec& spec) const noexcept { |
|
|
vector<string> cmd; |
|
|
vector<string> cmd; |
|
|
for (auto& arg : _archive_template) { |
|
|
for (auto& arg : _archive_template) { |
|
|
if (arg == "<OBJECTS>") { |
|
|
|
|
|
|
|
|
if (arg == "<IN>") { |
|
|
std::transform(spec.input_files.begin(), |
|
|
std::transform(spec.input_files.begin(), |
|
|
spec.input_files.end(), |
|
|
spec.input_files.end(), |
|
|
std::back_inserter(cmd), |
|
|
std::back_inserter(cmd), |
|
|
[](auto&& p) { return p.string(); }); |
|
|
[](auto&& p) { return p.string(); }); |
|
|
} else { |
|
|
} else { |
|
|
cmd.push_back(replace(arg, "<ARCHIVE>", spec.out_path.string())); |
|
|
|
|
|
|
|
|
cmd.push_back(replace(arg, "<OUT>", spec.out_path.string())); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return cmd; |
|
|
return cmd; |
|
|
|
|
|
|
|
|
vector<string> toolchain::create_link_executable_command(const link_exe_spec& spec) const noexcept { |
|
|
vector<string> toolchain::create_link_executable_command(const link_exe_spec& spec) const noexcept { |
|
|
vector<string> cmd; |
|
|
vector<string> cmd; |
|
|
for (auto& arg : _link_exe_template) { |
|
|
for (auto& arg : _link_exe_template) { |
|
|
if (arg == "<INPUTS>") { |
|
|
|
|
|
|
|
|
if (arg == "<IN>") { |
|
|
std::transform(spec.inputs.begin(), |
|
|
std::transform(spec.inputs.begin(), |
|
|
spec.inputs.end(), |
|
|
spec.inputs.end(), |
|
|
std::back_inserter(cmd), |
|
|
std::back_inserter(cmd), |
|
|
|
|
|
|
|
|
ret._archive_suffix = ".a"; |
|
|
ret._archive_suffix = ".a"; |
|
|
ret._object_suffix = ".o"; |
|
|
ret._object_suffix = ".o"; |
|
|
ret._warning_flags = {"-Wall", "-Wextra"}; |
|
|
ret._warning_flags = {"-Wall", "-Wextra"}; |
|
|
ret._archive_template = {"ar", "rcs", "<ARCHIVE>", "<OBJECTS>"}; |
|
|
|
|
|
|
|
|
ret._archive_template = {"ar", "rcs", "<OUT>", "<IN>"}; |
|
|
|
|
|
|
|
|
std::vector<std::string> common_flags = { |
|
|
std::vector<std::string> common_flags = { |
|
|
"<FLAGS>", |
|
|
"<FLAGS>", |
|
|
|
|
|
|
|
|
"-c", |
|
|
"-c", |
|
|
"-o", |
|
|
"-o", |
|
|
"<OUT>", |
|
|
"<OUT>", |
|
|
"<FILE>", |
|
|
|
|
|
|
|
|
"<IN>", |
|
|
}; |
|
|
}; |
|
|
std::vector<std::string> c_flags; |
|
|
std::vector<std::string> c_flags; |
|
|
std::vector<std::string> cxx_flags = {"-std=c++17"}; |
|
|
std::vector<std::string> cxx_flags = {"-std=c++17"}; |
|
|
|
|
|
|
|
|
if (starts_with(s, "gcc")) { |
|
|
if (starts_with(s, "gcc")) { |
|
|
c_compiler_base = "gcc"; |
|
|
c_compiler_base = "gcc"; |
|
|
cxx_compiler_base = "g++"; |
|
|
cxx_compiler_base = "g++"; |
|
|
common_flags.push_back("-Og"); |
|
|
|
|
|
|
|
|
common_flags.push_back("-O0"); |
|
|
} else if (starts_with(s, "clang")) { |
|
|
} else if (starts_with(s, "clang")) { |
|
|
c_compiler_base = "clang"; |
|
|
c_compiler_base = "clang"; |
|
|
cxx_compiler_base = "clang++"; |
|
|
cxx_compiler_base = "clang++"; |
|
|
|
|
|
|
|
|
} else if (s == "msvc") { |
|
|
} else if (s == "msvc") { |
|
|
ret._inc_template = {"/I<PATH>"}; |
|
|
ret._inc_template = {"/I<PATH>"}; |
|
|
ret._def_template = {"/D<DEF>"}; |
|
|
ret._def_template = {"/D<DEF>"}; |
|
|
ret._c_compile = {"cl.exe", "/nologo", "<FLAGS>", "/c", "<FILE>", "/Fo<OUT>"}; |
|
|
|
|
|
|
|
|
ret._c_compile = {"cl.exe", "/nologo", "<FLAGS>", "/c", "<IN>", "/Fo<OUT>"}; |
|
|
ret._cxx_compile = {"cl.exe", |
|
|
ret._cxx_compile = {"cl.exe", |
|
|
"/nologo", |
|
|
"/nologo", |
|
|
"<FLAGS>", |
|
|
"<FLAGS>", |
|
|
"/std:c++latest", |
|
|
"/std:c++latest", |
|
|
"/EHsc", |
|
|
"/EHsc", |
|
|
"/c", |
|
|
"/c", |
|
|
"<FILE>", |
|
|
|
|
|
|
|
|
"<IN>", |
|
|
"/Fo<OUT>"}; |
|
|
"/Fo<OUT>"}; |
|
|
std::vector<std::string_view> common_flags = {"/Z7", "/O2", "/MT", "/DEBUG"}; |
|
|
std::vector<std::string_view> common_flags = {"/Z7", "/O2", "/MT", "/DEBUG"}; |
|
|
extend(ret._c_compile, common_flags); |
|
|
extend(ret._c_compile, common_flags); |
|
|
|
|
|
|
|
|
ret._archive_suffix = ".lib"; |
|
|
ret._archive_suffix = ".lib"; |
|
|
ret._object_suffix = ".obj"; |
|
|
ret._object_suffix = ".obj"; |
|
|
ret._exe_suffix = ".exe"; |
|
|
ret._exe_suffix = ".exe"; |
|
|
ret._archive_template = {"lib", "/nologo", "/OUT:<ARCHIVE>", "<OBJECTS>"}; |
|
|
|
|
|
|
|
|
ret._archive_template = {"lib", "/nologo", "/OUT:<OUT>", "<IN>"}; |
|
|
ret._link_exe_template |
|
|
ret._link_exe_template |
|
|
= {"cl.exe", "/nologo", "/std:c++latest", "/EHsc", "<INPUTS>", "/Fe<OUT>"}; |
|
|
|
|
|
|
|
|
= {"cl.exe", "/nologo", "/std:c++latest", "/EHsc", "<IN>", "/Fe<OUT>"}; |
|
|
ret._warning_flags = {"/W4"}; |
|
|
ret._warning_flags = {"/W4"}; |
|
|
} else { |
|
|
} else { |
|
|
return std::nullopt; |
|
|
return std::nullopt; |