From 7a469801ecb55fcde0199d4e41b1cec3a17dcb05 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 8 Mar 2026 13:42:13 +0100 Subject: [CHORE] Patch command-line nebuild for multiple targets. Signed-off-by: Amlal El Mahrouss --- src/CommandLine/CLI.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/CommandLine') diff --git a/src/CommandLine/CLI.cpp b/src/CommandLine/CLI.cpp index 22c889b..5645728 100644 --- a/src/CommandLine/CLI.cpp +++ b/src/CommandLine/CLI.cpp @@ -10,16 +10,20 @@ #include #include #include +#include +#include -constexpr auto kNeBuildFileJson = "Jbuild"; -constexpr auto kNeBuildFileToml = "Tbuild"; +constexpr auto kNeBuildFileJson = "Jbuild.json"; +constexpr auto kNeBuildFileToml = "Tbuild.toml"; int main(int argc, char** argv) { if (argc < 1) return EXIT_FAILURE; NeBuild::BuildConfig config; - for (size_t index = 1; index < argc; ++index) { + std::vector jobs; + + for (size_t index{1}; index < argc; ++index) { std::string index_path = argv[index]; if (index_path == "-v" || index_path == "-version") { @@ -34,8 +38,10 @@ int main(int argc, char** argv) { } auto index_cpy = index; + std::mutex mutex; - std::thread job_build_thread([&index_path, &index, &index_cpy, &argc, &argv, &config]() -> void { + jobs.push_back(std::thread{[&mutex, &index, &index_cpy, &argc, &argv, &config](std::string index_path) -> void { + std::unique_lock lk{mutex}; std::unique_ptr builder; constexpr auto kJsonExtension = ".json"; @@ -76,11 +82,12 @@ int main(int argc, char** argv) { if (builder && !builder->BuildTarget(config)) { config.has_failed(true); } - }); - - job_build_thread.join(); + }, index_path}); } + for (auto& job : jobs) + job.join(); + // check for whether config is valid. if so return failure, or success. return !config ? EXIT_FAILURE : EXIT_SUCCESS; } -- cgit v1.2.3