From c7bafa1138dc8b3f6b0998302ab51017a5243774 Mon Sep 17 00:00:00 2001 From: Ezekiel Warren Date: Mon, 9 Dec 2024 22:14:32 -0800 Subject: [PATCH] feat: concurrent builds --- src/main.cpp2 | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/main.cpp2 b/src/main.cpp2 index 36fd61c..437f562 100644 --- a/src/main.cpp2 +++ b/src/main.cpp2 @@ -575,6 +575,7 @@ cl_build_binary_cmd: (info: cpp2b_source_binary_info, bin_outpath: fs::path) -> cmd_str += " \"(transpiled_src.string())$\""; cmd_str += " -I\"(cppfront_include_dir.string())$\""; cmd_str += " /Fe\"(bin_outpath.string())$\""; + cmd_str += " /Fd\"(fs::relative(bin_outpath).parent_path().string())$\\\""; return cmd_str; } @@ -932,7 +933,11 @@ do_build: (targets: std::vector) -> (stuff: full_build_info, exit_c bin_targets.reserve(targets.size()); } - bin_loop: for stuff.bins do(bin) { + + bin_futures: std::vector, std::future>> = (); + bin_futures.reserve(stuff.bins.size()); + + bin_loop: for stuff.bins do(inout bin) { bin_target_name := fs::path(bin.name()).generic_string(); if !targets.empty() { @@ -955,13 +960,22 @@ do_build: (targets: std::vector) -> (stuff: full_build_info, exit_c } } - build_result := build_binary(bin); + bin_futures.emplace_back( + std::ref(bin), + std::async(std::launch::async, build_binary, bin) + ); + } + + for bin_futures do(inout p) { + build_result := p.second.get(); + bin := p.first.get(); + stuff.bin_results.emplace_back(build_result); if build_result.exit_code != 0 { log_error("failed to build binary - exit code {}", build_result.exit_code); print_log_file(build_result.log_path); - continue bin_loop; + continue; } log_success("binary built {} ({}ms)", fs::relative(build_result.outpath).generic_string(), build_result.duration.count());