From 67f502af0e8194d4dfd9010c297e51b40a85e7fc Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 16 Nov 2025 10:25:44 +0100 Subject: feat: wip TOML support for NeBuild TOML files. fix: JSON: fix broken JSON implementation. Signed-off-by: Amlal El Mahrouss --- dev/cli/App.cc | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ dev/cli/Tool.cc | 76 ---------------------------------------------------- 2 files changed, 83 insertions(+), 76 deletions(-) create mode 100644 dev/cli/App.cc delete mode 100644 dev/cli/Tool.cc (limited to 'dev/cli') diff --git a/dev/cli/App.cc b/dev/cli/App.cc new file mode 100644 index 0000000..ca81d4e --- /dev/null +++ b/dev/cli/App.cc @@ -0,0 +1,83 @@ + +// ============================================================= // +// nebuild +// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. +// ============================================================= // + +#include +#include + +static bool kFailed = false; +static bool kDryRun = false; + +int main(int argc, char** argv) { + if (argc <= 1) return EXIT_FAILURE; + + for (size_t index = 1; index < argc; ++index) { + std::string index_path = argv[index]; + + if (index_path == "-v" || index_path == "--version") { + NeBuild::Logger::info() << "NeKernel Build Tool.\n"; + NeBuild::Logger::info() + << "Bugs, or issues? Check out: https://github.com/nekernel-org/nebuild/issues\n"; + + return EXIT_SUCCESS; + } else if (index_path == "--dry-run") { + kDryRun = true; + continue; + } else if (index_path == "-h" || index_path == "--help") { + NeBuild::Logger::info() << "usage: nebuild \n"; + + return EXIT_SUCCESS; + } + + if (index_path.starts_with("-")) { + NeBuild::Logger::info() << "error: unknown option '" << index_path << "'\n"; + + return EXIT_FAILURE; + } + + std::thread job_build_thread( + [](std::string index_path) -> void { + NeBuild::IManifestBuilder* builder = nullptr; + + const auto kJsonExtension = ".json"; + + if (index_path.ends_with(kJsonExtension)) { + builder = new NeBuild::JSONManifestBuilder(); + + if (!builder) { + kFailed = true; + return; + } + } else { + const auto kTomlExtension = ".toml"; + builder = new NeBuild::TOMLManifestBuilder(); + + if (index_path.ends_with(kTomlExtension)) { + goto end; + } else { + NeBuild::Logger::info() + << "error: file '" << index_path << "' is not a JSON file!" << std::endl; + kFailed = true; + return; + } + } + + end: + NeBuild::Logger::info() << "building manifest: " << index_path << std::endl; + + if (builder && !builder->BuildTarget(index_path, kDryRun)) { + kFailed = true; + } + + delete builder; + builder = nullptr; + }, + index_path); + + job_build_thread.join(); + } + + return kFailed ? EXIT_FAILURE : EXIT_SUCCESS; +} diff --git a/dev/cli/Tool.cc b/dev/cli/Tool.cc deleted file mode 100644 index 1d49c9f..0000000 --- a/dev/cli/Tool.cc +++ /dev/null @@ -1,76 +0,0 @@ - -// ============================================================= // -// nebuild -// Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. -// ============================================================= // - -#include - -static bool kFailed = false; -static bool kDryRun = false; - -int main(int argc, char** argv) { - if (argc <= 1) return EXIT_FAILURE; - - for (size_t index = 1; index < argc; ++index) { - std::string index_path = argv[index]; - - if (index_path == "-v" || index_path == "--version") { - NeBuild::Logger::info() << "Brought to you by Amlal El Mahrouss for NeKernel.org.\n"; - NeBuild::Logger::info() << "© 2024-2025 Amlal El Mahrouss, all rights reserved.\n"; - - NeBuild::Logger::info() - << "Bugs, issues? Check out: https://github.com/nekernel-org/nebuild/issues\n"; - - return EXIT_SUCCESS; - } else if (index_path == "--dry-run") { - kDryRun = true; - continue; - } else if (index_path == "-h" || index_path == "--help") { - NeBuild::Logger::info() << "Usage: nebuild \n"; - - return EXIT_SUCCESS; - } - - if (index_path.starts_with("-")) { - NeBuild::Logger::info() << "error: unknown option '" << index_path << "'\n"; - - return EXIT_FAILURE; - } - - std::thread job_build_thread( - [](std::string index_path) -> void { - NeBuild::IManifestBuilder* builder = nullptr; - - const auto kJsonExtension = ".json"; - - if (index_path.ends_with(kJsonExtension)) { - builder = new NeBuild::JSONManifestBuilder(); - - if (!builder) { - kFailed = true; - return; - } - } else { - NeBuild::Logger::info() - << "error: file '" << index_path << "' is not a JSON file!" << std::endl; - kFailed = true; - return; - } - - NeBuild::Logger::info() << "building manifest: " << index_path << std::endl; - - if (builder && !builder->BuildTarget(index_path, kDryRun)) { - kFailed = true; - } - - delete builder; - builder = nullptr; - }, - index_path); - - job_build_thread.join(); - } - - return kFailed ? EXIT_FAILURE : EXIT_SUCCESS; -} -- cgit v1.2.3