Kaynağa Gözat

Centralize path handling logic around generated header roots

default_compile_flags
vector-of-bool 4 yıl önce
ebeveyn
işleme
87f60a1e39
3 değiştirilmiş dosya ile 26 ekleme ve 7 silme
  1. +3
    -3
      src/dds/build/builder.cpp
  2. +19
    -2
      src/dds/build/plan/library.cpp
  3. +4
    -2
      src/dds/build/plan/library.hpp

+ 3
- 3
src/dds/build/builder.cpp Dosyayı Görüntüle

@@ -153,9 +153,9 @@ prepare_ureqs(const build_plan& plan, const toolchain& toolchain, path_ref out_r
if (const auto& arc = lib.archive_plan()) {
lib_reqs.linkable_path = out_root / arc->calc_archive_file_path(toolchain);
}
if (lib.has_generated_headers()) {
lib_reqs.include_paths.push_back(out_root / "__dds/gen"
/ lib.output_subdirectory());
auto gen_incdir_opt = lib.generated_include_dir();
if (gen_incdir_opt) {
lib_reqs.include_paths.push_back(out_root / *gen_incdir_opt);
}
}
}

+ 19
- 2
src/dds/build/plan/library.cpp Dosyayı Görüntüle

@@ -7,9 +7,24 @@
#include <range/v3/view/transform.hpp>

#include <cassert>
#include <string>

using namespace dds;

namespace {

const std::string gen_dir_qual = "__dds/gen";

fs::path rebase_gen_incdir(path_ref subdir) { return gen_dir_qual / subdir; }
} // namespace

std::optional<fs::path> library_plan::generated_include_dir() const noexcept {
if (_templates.empty()) {
return std::nullopt;
}
return rebase_gen_incdir(output_subdirectory());
}

library_plan library_plan::create(const library_root& lib,
const library_build_params& params,
std::optional<std::string_view> qual_name_) {
@@ -48,8 +63,10 @@ library_plan library_plan::create(const library_root& lib,
compile_rules.enable_warnings() = params.enable_warnings;
compile_rules.uses() = lib.manifest().uses;

const auto codegen_subdir = rebase_gen_incdir(params.out_subdir);

if (!template_sources.empty()) {
compile_rules.include_dirs().push_back("__dds/gen" / params.out_subdir);
compile_rules.include_dirs().push_back(codegen_subdir);
}

// Convert the library sources into their respective file compilation plans.
@@ -113,7 +130,7 @@ library_plan library_plan::create(const library_root& lib,

std::vector<render_template_plan> render_templates;
for (const auto& sf : template_sources) {
render_templates.emplace_back(sf, "__dds/gen" / params.out_subdir);
render_templates.emplace_back(sf, codegen_subdir);
}

// Done!

+ 4
- 2
src/dds/build/plan/library.hpp Dosyayı Görüntüle

@@ -128,9 +128,11 @@ public:
*/
auto& links() const noexcept { return _lib.manifest().links; }
/**
* Return `true` if this object has generated header files
* The path to the directory that should be added for the #include search
* path for this library, relative to the build root. Returns `nullopt` if
* this library has no generated headers.
*/
bool has_generated_headers() const noexcept { return !templates().empty(); }
std::optional<fs::path> generated_include_dir() const noexcept;

/**
* Named constructor: Create a new `library_plan` automatically from some build-time parameters.

Yükleniyor…
İptal
Kaydet