Browse Source

Change spelling of toolchain template args

default_compile_flags
vector-of-bool 4 years ago
parent
commit
692f720111
2 changed files with 24 additions and 24 deletions
  1. +14
    -14
      src/dds/toolchain/from_json.cpp
  2. +10
    -10
      src/dds/toolchain/toolchain.cpp

+ 14
- 14
src/dds/toolchain/from_json.cpp View File

if (lang == language::cxx) { if (lang == language::cxx) {
extend(ret, {"/EHsc"}); extend(ret, {"/EHsc"});
} }
extend(ret, {"/nologo", "/permissive-", "<FLAGS>", "/c", "<IN>", "/Fo<OUT>"});
extend(ret, {"/nologo", "/permissive-", "[flags]", "/c", "[in]", "/Fo[out]"});
} else if (is_gnu_like) { } else if (is_gnu_like) {
if (do_optimize.has_value() && *do_optimize) { if (do_optimize.has_value() && *do_optimize) {
extend(ret, {"-O2"}); extend(ret, {"-O2"});
if (do_debug.has_value() && *do_debug) { if (do_debug.has_value() && *do_debug) {
extend(ret, {"-g"}); extend(ret, {"-g"});
} }
extend(ret, {"-fPIC", "-pthread", "<FLAGS>", "-c", "<IN>", "-o<OUT>"});
extend(ret, {"-fPIC", "-pthread", "[flags]", "-c", "[in]", "-o[out]"});
} }
if (common_flags) { if (common_flags) {
extend(ret, *common_flags); extend(ret, *common_flags);
fail(context, "Cannot deduce 'include_template' without 'compiler_id'"); fail(context, "Cannot deduce 'include_template' without 'compiler_id'");
} }
if (is_gnu_like) { if (is_gnu_like) {
return {"-I", "<PATH>"};
return {"-I", "[path]"};
} else if (is_msvc) { } else if (is_msvc) {
return {"/I", "<PATH>"};
return {"/I", "[path]"};
} }
assert(false && "'include_template' deduction failed"); assert(false && "'include_template' deduction failed");
std::terminate(); std::terminate();
return tc.include_template; return tc.include_template;
} }
if (is_gnu_like) { if (is_gnu_like) {
return {"-isystem", "<PATH>"};
return {"-isystem", "[path]"};
} else if (is_msvc) { } else if (is_msvc) {
// MSVC has external-header support inbound, but it is not fully ready yet // MSVC has external-header support inbound, but it is not fully ready yet
return {"/I", "<PATH>"};
return {"/I", "[path]"};
} }
assert(false && "external_include_template deduction failed"); assert(false && "external_include_template deduction failed");
std::terminate(); std::terminate();
fail(context, "Cannot deduce 'define_template' without 'compiler_id'"); fail(context, "Cannot deduce 'define_template' without 'compiler_id'");
} }
if (is_gnu_like) { if (is_gnu_like) {
return {"-D", "<DEF>"};
return {"-D", "[def]"};
} else if (is_msvc) { } else if (is_msvc) {
return {"/D", "<DEF>"};
return {"/D", "[def]"};
} }
assert(false && "define_template deduction failed"); assert(false && "define_template deduction failed");
std::terminate(); std::terminate();
fail(context, "Unable to deduce archive creation rules without a 'compiler_id'"); fail(context, "Unable to deduce archive creation rules without a 'compiler_id'");
} }
if (is_msvc) { if (is_msvc) {
return {"lib", "/nologo", "/OUT:<OUT>", "<IN>"};
return {"lib", "/nologo", "/OUT:[out]", "[in]"};
} else if (is_gnu_like) { } else if (is_gnu_like) {
return {"ar", "rcs", "<OUT>", "<IN>"};
return {"ar", "rcs", "[out]", "[in]"};
} }
assert(false && "No archive command"); assert(false && "No archive command");
std::terminate(); std::terminate();
ret = {get_compiler_executable_path(language::cxx), ret = {get_compiler_executable_path(language::cxx),
"/nologo", "/nologo",
"/EHsc", "/EHsc",
"<IN>",
"/Fe<OUT>"};
"[in]",
"/Fe[out]"};
} else if (is_gnu_like) { } else if (is_gnu_like) {
ret = {get_compiler_executable_path(language::cxx), ret = {get_compiler_executable_path(language::cxx),
"-fPIC", "-fPIC",
"<IN>",
"[in]",
"-pthread", "-pthread",
"-o<OUT>"};
"-o[out]"};
} else { } else {
assert(false && "No link-exe command"); assert(false && "No link-exe command");
std::terminate(); std::terminate();

+ 10
- 10
src/dds/toolchain/toolchain.cpp View File

} }


vector<string> toolchain::include_args(const fs::path& p) const noexcept { vector<string> toolchain::include_args(const fs::path& p) const noexcept {
return replace(_inc_template, "<PATH>", p.string());
return replace(_inc_template, "[path]", p.string());
} }


vector<string> toolchain::external_include_args(const fs::path& p) const noexcept { vector<string> toolchain::external_include_args(const fs::path& p) const noexcept {
return replace(_extern_inc_template, "<PATH>", p.string());
return replace(_extern_inc_template, "[path]", p.string());
} }


vector<string> toolchain::definition_args(std::string_view s) const noexcept { vector<string> toolchain::definition_args(std::string_view s) const noexcept {
return replace(_def_template, "<DEF>", s);
return replace(_def_template, "[def]", s);
} }


compile_command_info toolchain::create_compile_command(const compile_file_spec& spec, compile_command_info toolchain::create_compile_command(const compile_file_spec& spec,
vector<string> command; vector<string> command;
auto& cmd_template = lang == language::c ? _c_compile : _cxx_compile; auto& cmd_template = lang == language::c ? _c_compile : _cxx_compile;
for (auto arg : cmd_template) { for (auto arg : cmd_template) {
if (arg == "<FLAGS>") {
if (arg == "[flags]") {
extend(command, flags); extend(command, flags);
} else { } else {
arg = replace(arg, "<IN>", spec.source_path.string());
arg = replace(arg, "<OUT>", spec.out_path.string());
arg = replace(arg, "[in]", spec.source_path.string());
arg = replace(arg, "[out]", spec.out_path.string());
command.push_back(arg); command.push_back(arg);
} }
} }
toolchain_knobs) const noexcept { toolchain_knobs) const noexcept {
vector<string> cmd; vector<string> cmd;
for (auto& arg : _link_archive) { for (auto& arg : _link_archive) {
if (arg == "<IN>") {
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, "<OUT>", spec.out_path.string()));
cmd.push_back(replace(arg, "[out]", spec.out_path.string()));
} }
} }
return cmd; return cmd;
toolchain_knobs) const noexcept { toolchain_knobs) const noexcept {
vector<string> cmd; vector<string> cmd;
for (auto& arg : _link_exe) { for (auto& arg : _link_exe) {
if (arg == "<IN>") {
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),
[](auto&& p) { return p.string(); }); [](auto&& p) { return p.string(); });
} else { } else {
cmd.push_back(replace(arg, "<OUT>", spec.output.string()));
cmd.push_back(replace(arg, "[out]", spec.output.string()));
} }
} }
return cmd; return cmd;

Loading…
Cancel
Save