diff options
| -rw-r--r-- | include/NeBuildKit/Detail/Config.h | 10 | ||||
| -rw-r--r-- | install_windows.cmake | 4 | ||||
| -rw-r--r-- | src/CommandLine/CLI.cpp | 21 |
3 files changed, 22 insertions, 13 deletions
diff --git a/include/NeBuildKit/Detail/Config.h b/include/NeBuildKit/Detail/Config.h index e292fbe..4e7088d 100644 --- a/include/NeBuildKit/Detail/Config.h +++ b/include/NeBuildKit/Detail/Config.h @@ -1,6 +1,6 @@ // ============================================================= // // NeBuild -// Copyright (C) 2024-2025, Amlal El Mahrouss and NeKernel Authors, licensed under BSD-3 license. +// Copyright (C) 2024-2026, Amlal El Mahrouss and NeKernel Authors, licensed under BSD-3 license. // ============================================================= // #pragma once @@ -42,13 +42,13 @@ struct BuildConfig final { explicit operator bool() { return has_failed_; } bool dry_run() { return dry_run_; } - void dry_run(const bool dr) { dry_run_ = dr; } + void dry_run(const bool& dr) { dry_run_ = dr; } bool has_failed() { return has_failed_; } - void has_failed(const bool dr) { has_failed_ = dr; } + void has_failed(const bool& dr) { has_failed_ = dr; } const std::string& path() { return path_; } - void path(const std::string& pat) { path_ = pat; } + void path(const std::string& path) { path_ = path; } BuildConfig() = default; ~BuildConfig() = default; @@ -57,6 +57,7 @@ struct BuildConfig final { /// \brief Logger namespace. namespace NeBuild::Logger { + /// @brief replacement for std::cout for NeBuild logging. /// @todo change this to spdlog? inline std::ostream& info() noexcept { @@ -64,4 +65,5 @@ inline std::ostream& info() noexcept { out << rang::fg::red << "nebuild: " << rang::style::reset; return out; } + } // namespace NeBuild::Logger diff --git a/install_windows.cmake b/install_windows.cmake index 792b4a9..73bce94 100644 --- a/install_windows.cmake +++ b/install_windows.cmake @@ -7,12 +7,12 @@ cmake_minimum_required(VERSION 3.30) # Append .exe when it's a Windows build (The Windows loader requires it) -if(BUILD_WINDOWS) +if(DEFINED BUILD_WINDOWS) set_target_properties(nebuild PROPERTIES OUTPUT_NAME "nebuild.exe") add_custom_target(build-nebuild-windows COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target nebuild - COMMENT "=> NeBuild built successfully for Windows (configure with -DBUILD_WINDOWS=ON)." + COMMENT "=> NeBuild successfully built for Windows (configure with -DBUILD_WINDOWS=ON)." ) endif() 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 <NeBuildKit/TOMLManifestBuilder.h> #include <memory> #include <thread> +#include <mutex> +#include <vector> -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<std::thread> 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<decltype(mutex)> lk{mutex}; std::unique_ptr<NeBuild::IManifestBuilder> 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; } |
