瀏覽代碼

Merge branch 'develop' into feature/pkg-id-type

default_compile_flags
vector-of-bool 5 年之前
父節點
當前提交
60427b068e
共有 4 個檔案被更改,包括 25 行新增12 行删除
  1. +2
    -5
      src/dds/build.cpp
  2. +23
    -4
      src/dds/build/plan/compile_exec.cpp
  3. +0
    -2
      src/dds/package_manifest.cpp
  4. +0
    -1
      src/dds/package_manifest.hpp

+ 2
- 5
src/dds/build.cpp 查看文件



if (test_driver == test_lib::catch_) { if (test_driver == test_lib::catch_) {
// Don't generate a test library helper // Don't generate a test library helper
return;
} }


std::string fname; std::string fname;
if (test_driver == test_lib::catch_main) { if (test_driver == test_lib::catch_main) {
fname = "catch-main.cpp"; fname = "catch-main.cpp";
definition = "CATCH_CONFIG_MAIN"; definition = "CATCH_CONFIG_MAIN";
} else if (test_driver == test_lib::catch_runner) {
fname = "catch-runner.cpp";
definition = "CATCH_CONFIG_RUNNER";
} else { } else {
assert(false && "Impossible: Invalid `test_driver` for catch library"); assert(false && "Impossible: Invalid `test_driver` for catch library");
std::terminate(); std::terminate();
const package_manifest& man, const package_manifest& man,
build_env_ref env) { build_env_ref env) {
auto& test_driver = *man.test_driver; auto& test_driver = *man.test_driver;
if (test_driver == test_lib::catch_ || test_driver == test_lib::catch_main
|| test_driver == test_lib::catch_runner) {
if (test_driver == test_lib::catch_ || test_driver == test_lib::catch_main) {
prepare_catch2_driver(lib_params, test_driver, params, env); prepare_catch2_driver(lib_params, test_driver, params, env);
} else { } else {
assert(false && "Unreachable"); assert(false && "Unreachable");

+ 23
- 4
src/dds/build/plan/compile_exec.cpp 查看文件

#include <spdlog/spdlog.h> #include <spdlog/spdlog.h>


#include <algorithm> #include <algorithm>
#include <atomic>
#include <cassert> #include <cassert>
#include <thread> #include <thread>


compile_command_info cmd_info; compile_command_info cmd_info;
}; };


std::optional<deps_info> do_compile(const compile_file_full& cf, build_env_ref env) {
struct compile_counter {
std::atomic_size_t n;
const std::size_t max;
const std::size_t max_digits;
};

std::optional<deps_info>
do_compile(const compile_file_full& cf, build_env_ref env, compile_counter& counter) {
fs::create_directories(cf.object_file_path.parent_path()); fs::create_directories(cf.object_file_path.parent_path());
auto source_path = cf.plan.source_path(); auto source_path = cf.plan.source_path();
auto msg = fmt::format("[{}] Compile: {:40}",
auto msg = fmt::format("[{}] Compile: {}",
cf.plan.qualifier(), cf.plan.qualifier(),
fs::relative(source_path, cf.plan.source().basis_path).string()); fs::relative(source_path, cf.plan.source().basis_path).string());
spdlog::info(msg); spdlog::info(msg);
auto&& [dur_ms, proc_res] auto&& [dur_ms, proc_res]
= timed<std::chrono::milliseconds>([&] { return run_proc(cf.cmd_info.command); }); = timed<std::chrono::milliseconds>([&] { return run_proc(cf.cmd_info.command); });
spdlog::info("{} - {:>7n}ms", msg, dur_ms.count());

auto nth = counter.n.fetch_add(1);
spdlog::info("{:60} - {:>7n}ms [{:{}}/{}]",
msg,
dur_ms.count(),
nth,
counter.max_digits,
counter.max);


const bool compiled_okay = proc_res.okay(); const bool compiled_okay = proc_res.okay();
const auto compile_retc = proc_res.retc; const auto compile_retc = proc_res.retc;
| views::transform([&](auto&& plan) { return realize_plan(plan, env); }) // | views::transform([&](auto&& plan) { return realize_plan(plan, env); }) //
| views::filter([&](auto&& real) { return should_compile(real, env); }); | views::filter([&](auto&& real) { return should_compile(real, env); });


const auto total = compiles.size();
const auto max_digits = fmt::format("{}", total).size();
compile_counter counter{{0}, total, max_digits};

std::vector<deps_info> all_new_deps; std::vector<deps_info> all_new_deps;
std::mutex mut; std::mutex mut;
auto okay = parallel_run(each_realized, njobs, [&](const compile_file_full& full) { auto okay = parallel_run(each_realized, njobs, [&](const compile_file_full& full) {
auto new_dep = do_compile(full, env);
auto new_dep = do_compile(full, env, counter);
if (new_dep) { if (new_dep) {
std::unique_lock lk{mut}; std::unique_lock lk{mut};
all_new_deps.push_back(std::move(*new_dep)); all_new_deps.push_back(std::move(*new_dep));

+ 0
- 2
src/dds/package_manifest.cpp 查看文件

auto& test_driver_str = *opt_test_driver; auto& test_driver_str = *opt_test_driver;
if (test_driver_str == "Catch-Main") { if (test_driver_str == "Catch-Main") {
ret.test_driver = test_lib::catch_main; ret.test_driver = test_lib::catch_main;
} else if (test_driver_str == "Catch-Runner") {
ret.test_driver = test_lib::catch_runner;
} else if (test_driver_str == "Catch") { } else if (test_driver_str == "Catch") {
ret.test_driver = test_lib::catch_; ret.test_driver = test_lib::catch_;
} else { } else {

+ 0
- 1
src/dds/package_manifest.hpp 查看文件

enum class test_lib { enum class test_lib {
catch_, catch_,
catch_main, catch_main,
catch_runner,
}; };


struct package_manifest { struct package_manifest {

Loading…
取消
儲存