瀏覽代碼

Cleanup for `build_plan`

default_compile_flags
vector-of-bool 5 年之前
父節點
當前提交
6733934ddd
共有 3 個文件被更改,包括 62 次插入6 次删除
  1. +3
    -1
      src/dds/build/plan/full.cpp
  2. +30
    -3
      src/dds/build/plan/full.hpp
  3. +29
    -2
      src/dds/build/plan/package.hpp

+ 3
- 1
src/dds/build/plan/full.cpp 查看文件

@@ -17,6 +17,7 @@ using namespace dds;

namespace {

/// XXX: Duplicated in compile_exec.cpp !!
template <typename Range, typename Fn>
bool parallel_run(Range&& rng, int n_jobs, Fn&& fn) {
// We don't bother with a nice thread pool, as the overhead of most build
@@ -91,10 +92,10 @@ void build_plan::archive_all(const build_env& env, int njobs) const {
}

void build_plan::link_all(const build_env& env, int njobs) const {
// Generate a pairing between executables and the libraries that own them
std::vector<std::pair<std::reference_wrapper<const library_plan>,
std::reference_wrapper<const link_executable_plan>>>
executables;

for (auto&& lib : iter_libraries(*this)) {
for (auto&& exe : lib.executables()) {
executables.emplace_back(lib, exe);
@@ -112,6 +113,7 @@ void build_plan::link_all(const build_env& env, int njobs) const {

std::vector<test_failure> build_plan::run_all_tests(build_env_ref env, int njobs) const {
using namespace ranges::views;
// Collect executables that are tests
auto test_executables = //
iter_libraries(*this) //
| transform(&library_plan::executables) //

+ 30
- 3
src/dds/build/plan/full.hpp 查看文件

@@ -5,18 +5,45 @@

namespace dds {

/**
* Encompases an entire build plan.
*
* A build plan consists of some number of packages, defined as `package_plan`
* objects.
*/
class build_plan {
/// The packages that are part of this plan.
std::vector<package_plan> _packages;

public:
/**
* Append a new package plan. Returns a reference to the package plan so that it can be further
* tweaked. Note that the reference is not stable.
*/
package_plan& add_package(package_plan p) noexcept {
return _packages.emplace_back(std::move(p));
}

/**
* All of the packages in this plan
*/
auto& packages() const noexcept { return _packages; }
void compile_all(const build_env& env, int njobs) const;
void archive_all(const build_env& env, int njobs) const;
void link_all(const build_env& env, int njobs) const;
/**
* Compile all files in the plan.
*/
void compile_all(const build_env& env, int njobs) const;
/**
* Generate all static library archive in the plan
*/
void archive_all(const build_env& env, int njobs) const;
/**
* Link all runtime binaries (executables) in the plan
*/
void link_all(const build_env& env, int njobs) const;

/**
* Execute all tests defined in the plan. Returns information for every failed test.
*/
std::vector<test_failure> run_all_tests(build_env_ref env, int njobs) const;
};


+ 29
- 2
src/dds/build/plan/package.hpp 查看文件

@@ -7,20 +7,47 @@

namespace dds {

/**
* A package is a top-level component with a name, namespace, and some number of associated
* libraries. A package plan will roughly correspond to either a source distribution or a project
* directory
*/
class package_plan {
std::string _name;
std::string _namespace;
/// Package name
std::string _name;
/// The package namespace. Used to specify interdependencies
std::string _namespace;
/// The libraries in this package
std::vector<library_plan> _libraries;

public:
/**
* Create a new package plan.
* @param name The name of the package
* @param namespace_ The namespace of the package. Used when specifying linker dependencies.
*/
package_plan(std::string_view name, std::string_view namespace_)
: _name(name)
, _namespace(namespace_) {}

/**
* Add a library plan to this package plan
* @param lp The `library_plan` to add to the package. Once added, the
* library plan cannot be changed directly.
*/
void add_library(library_plan lp) { _libraries.emplace_back(std::move(lp)); }

/**
* Get the package name
*/
auto& name() const noexcept { return _name; }
/**
* The package namespace
*/
auto& namespace_() const noexcept { return _namespace; }
/**
* The libraries in the package
*/
auto& libraries() const noexcept { return _libraries; }
};


Loading…
取消
儲存