Quellcode durchsuchen

Support distinguishing "external" headers

default_compile_flags
vector-of-bool vor 5 Jahren
Ursprung
Commit
5c1b193a19
5 geänderte Dateien mit 47 neuen und 16 gelöschten Zeilen
  1. +1
    -1
      src/dds/build/plan/compile_file.cpp
  2. +17
    -0
      src/dds/toolchain/from_dds.cpp
  3. +1
    -0
      src/dds/toolchain/prep.hpp
  4. +24
    -14
      src/dds/toolchain/toolchain.cpp
  5. +4
    -1
      src/dds/toolchain/toolchain.hpp

+ 1
- 1
src/dds/build/plan/compile_file.cpp Datei anzeigen

@@ -17,7 +17,7 @@ compile_command_info compile_file_plan::generate_compile_command(build_env_ref e
spec.enable_warnings = _rules.enable_warnings();
extend(spec.include_dirs, _rules.include_dirs());
for (const auto& use : _rules.uses()) {
extend(spec.include_dirs, env.ureqs.include_paths(use));
extend(spec.external_include_dirs, env.ureqs.include_paths(use));
}
extend(spec.definitions, _rules.defs());
return env.toolchain.create_compile_command(spec);

+ 17
- 0
src/dds/toolchain/from_dds.cpp Datei anzeigen

@@ -95,6 +95,7 @@ toolchain dds::parse_toolchain_dds(const lm::pair_list& pairs, strv context) {
optional<bool> do_debug;
optional<bool> do_optimize;
opt_str_seq include_template;
opt_str_seq external_include_template;
opt_str_seq define_template;
opt_str_seq warning_flags;
opt_str_seq flags;
@@ -118,6 +119,7 @@ toolchain dds::parse_toolchain_dds(const lm::pair_list& pairs, strv context) {
lm::read_opt("C++-Version", cxx_version),
// Flag templates
read_argv{"Include-Template", include_template},
read_argv{"External-Include-Template", include_template},
read_argv{"Define-Template", define_template},
// Flags
read_argv_acc{"Warning-Flags", warning_flags},
@@ -440,6 +442,21 @@ toolchain dds::parse_toolchain_dds(const lm::pair_list& pairs, strv context) {
std::terminate();
});

tc.external_include_template = read_opt(external_include_template, [&]() -> string_seq {
if (!compiler_id) {
// Just reuse the include template for regular files
return tc.include_template;
}
if (is_gnu_like) {
return {"-isystem", "<PATH>"};
} else if (is_msvc) {
// MSVC has external-header support inbound, but it is not fully ready yet
return {"/I", "<PATH>"};
}
assert(false && "External-Include-Template deduction failed");
std::terminate();
});

tc.define_template = read_opt(define_template, [&]() -> string_seq {
if (!compiler_id) {
fail(context, "Cannot deduce 'Define-Template' without 'Compiler-ID'");

+ 1
- 0
src/dds/toolchain/prep.hpp Datei anzeigen

@@ -14,6 +14,7 @@ struct toolchain_prep {
string_seq c_compile;
string_seq cxx_compile;
string_seq include_template;
string_seq external_include_template;
string_seq define_template;
string_seq link_archive;
string_seq link_exe;

+ 24
- 14
src/dds/toolchain/toolchain.cpp Datei anzeigen

@@ -20,20 +20,21 @@ using opt_string = optional<string>;

toolchain toolchain::realize(const toolchain_prep& prep) {
toolchain ret;
ret._c_compile = prep.c_compile;
ret._cxx_compile = prep.cxx_compile;
ret._inc_template = prep.include_template;
ret._def_template = prep.define_template;
ret._link_archive = prep.link_archive;
ret._link_exe = prep.link_exe;
ret._warning_flags = prep.warning_flags;
ret._archive_prefix = prep.archive_prefix;
ret._archive_suffix = prep.archive_suffix;
ret._object_prefix = prep.object_prefix;
ret._object_suffix = prep.object_suffix;
ret._exe_prefix = prep.exe_prefix;
ret._exe_suffix = prep.exe_suffix;
ret._deps_mode = prep.deps_mode;
ret._c_compile = prep.c_compile;
ret._cxx_compile = prep.cxx_compile;
ret._inc_template = prep.include_template;
ret._extern_inc_template = prep.external_include_template;
ret._def_template = prep.define_template;
ret._link_archive = prep.link_archive;
ret._link_exe = prep.link_exe;
ret._warning_flags = prep.warning_flags;
ret._archive_prefix = prep.archive_prefix;
ret._archive_suffix = prep.archive_suffix;
ret._object_prefix = prep.object_prefix;
ret._object_suffix = prep.object_suffix;
ret._exe_prefix = prep.exe_prefix;
ret._exe_suffix = prep.exe_suffix;
ret._deps_mode = prep.deps_mode;
return ret;
}

@@ -41,6 +42,10 @@ vector<string> toolchain::include_args(const fs::path& p) const noexcept {
return replace(_inc_template, "<PATH>", p.string());
}

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

vector<string> toolchain::definition_args(std::string_view s) const noexcept {
return replace(_def_template, "<DEF>", s);
}
@@ -67,6 +72,11 @@ toolchain::create_compile_command(const compile_file_spec& spec) const noexcept
extend(flags, inc_args);
}

for (auto&& ext_inc_dir : spec.external_include_dirs) {
auto inc_args = external_include_args(ext_inc_dir);
extend(flags, inc_args);
}

for (auto&& def : spec.definitions) {
auto def_args = definition_args(def);
extend(flags, def_args);

+ 4
- 1
src/dds/toolchain/toolchain.hpp Datei anzeigen

@@ -21,7 +21,8 @@ struct compile_file_spec {
fs::path out_path;
std::vector<std::string> definitions = {};
std::vector<fs::path> include_dirs = {};
language lang = language::automatic;
std::vector<fs::path> external_include_dirs = {};
language lang = language::automatic;
bool enable_warnings = false;
};

@@ -48,6 +49,7 @@ class toolchain {
string_seq _c_compile;
string_seq _cxx_compile;
string_seq _inc_template;
string_seq _extern_inc_template;
string_seq _def_template;
string_seq _link_archive;
string_seq _link_exe;
@@ -74,6 +76,7 @@ public:

std::vector<std::string> definition_args(std::string_view s) const noexcept;
std::vector<std::string> include_args(const fs::path& p) const noexcept;
std::vector<std::string> external_include_args(const fs::path& p) const noexcept;
compile_command_info create_compile_command(const compile_file_spec&) const noexcept;
std::vector<std::string> create_archive_command(const archive_spec&) const noexcept;
std::vector<std::string> create_link_executable_command(const link_exe_spec&) const noexcept;

Laden…
Abbrechen
Speichern