summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-12-02 06:29:25 -0500
committerAmlal El Mahrouss <amlal@nekernel.org>2025-12-02 06:29:25 -0500
commite523488c70e33ec3bb83e785ec6dd20261b26974 (patch)
tree6077325aba8f47817b0455254fdda2ffe57e5104 /src
parentf9d7e440829fb5899198517396bbc7e580ecb801 (diff)
chore: new NeBuild API and breaking SDK changes.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src')
-rw-r--r--src/cli/main.cc22
-rw-r--r--src/lib/JSONManifestBuilder.cc8
-rw-r--r--src/lib/TOMLManifestBuilder.cc7
3 files changed, 21 insertions, 16 deletions
diff --git a/src/cli/main.cc b/src/cli/main.cc
index 02889ff..e3a17a0 100644
--- a/src/cli/main.cc
+++ b/src/cli/main.cc
@@ -6,9 +6,9 @@
#include <NeBuildKit/JSONManifestBuilder.h>
#include <NeBuildKit/TOMLManifestBuilder.h>
+#include <thread>
-static bool kFailed = false;
-static bool kDryRun = false;
+static NeBuild::BuildConfig kConfig;
int main(int argc, char** argv) {
if (argc <= 1) return EXIT_FAILURE;
@@ -23,7 +23,7 @@ int main(int argc, char** argv) {
return EXIT_SUCCESS;
} else if (index_path == "-dry-run" || index_path == "-n") {
- kDryRun = true;
+ kConfig.dry_run_ = true;
continue;
} else if (index_path == "-h" || index_path == "-help") {
NeBuild::Logger::info() << "usage: nebuild <options> <file>.\n";
@@ -43,7 +43,7 @@ int main(int argc, char** argv) {
builder = new NeBuild::JSONManifestBuilder();
if (!builder) {
- kFailed = true;
+ kConfig.has_failed_ = true;
return;
}
} else {
@@ -51,16 +51,16 @@ int main(int argc, char** argv) {
builder = new NeBuild::TOMLManifestBuilder();
if (index_path.ends_with(kTomlExtension)) {
- goto toml_build;
+ goto nebuild_build_target;
} else {
NeBuild::Logger::info()
<< "error: file '" << index_path << "' is not a manifest file!" << std::endl;
- kFailed = true;
+ kConfig.has_failed_ = true;
return;
}
}
- toml_build:
+ nebuild_build_target:
std::string next_path;
if (argv[index_cpy + 1]) next_path = argv[index_cpy + 1];
@@ -72,8 +72,10 @@ int main(int argc, char** argv) {
NeBuild::Logger::info() << "building manifest: " << index_path << std::endl;
- if (builder && !builder->BuildTarget(index_path, kDryRun)) {
- kFailed = true;
+ kConfig.path_ = index_path;
+
+ if (builder && !builder->BuildTarget(kConfig)) {
+ kConfig.has_failed_ = true;
}
toml_build_done:
@@ -84,5 +86,5 @@ int main(int argc, char** argv) {
job_build_thread.join();
}
- return kFailed ? EXIT_FAILURE : EXIT_SUCCESS;
+ return !kConfig ? EXIT_FAILURE : EXIT_SUCCESS;
}
diff --git a/src/lib/JSONManifestBuilder.cc b/src/lib/JSONManifestBuilder.cc
index 9de6608..c6ff4d8 100644
--- a/src/lib/JSONManifestBuilder.cc
+++ b/src/lib/JSONManifestBuilder.cc
@@ -4,6 +4,8 @@
// ============================================================= //
#include <NeBuildKit/JSONManifestBuilder.h>
+#include <json/json.h>
+#include <fstream>
using namespace NeBuild;
using namespace nlohmann;
@@ -18,14 +20,14 @@ namespace FS = std::filesystem;
/// @retval true building has succeeded.
/// @retval false fail to build, see error message.
/// =========================================================== ///
-bool JSONManifestBuilder::BuildTarget(const std::string& argv_val, const bool dry_run) {
+bool JSONManifestBuilder::BuildTarget(BuildConfig& config) {
std::string path;
- if (argv_val.empty()) {
+ if (config.path_.empty()) {
NeBuild::Logger::info() << "nebuild: error: file path is empty" << std::endl;
return false;
} else {
- path = argv_val;
+ path = config.path_;
if (!FS::exists(path)) {
NeBuild::Logger::info() << "nebuild: error: file '" << path << "' does not exist"
diff --git a/src/lib/TOMLManifestBuilder.cc b/src/lib/TOMLManifestBuilder.cc
index fc10c88..a58b280 100644
--- a/src/lib/TOMLManifestBuilder.cc
+++ b/src/lib/TOMLManifestBuilder.cc
@@ -4,6 +4,7 @@
// ============================================================= //
#include <NeBuildKit/TOMLManifestBuilder.h>
+#include <toml++/toml.hpp>
#include <filesystem>
using namespace NeBuild;
@@ -17,14 +18,14 @@ namespace FS = std::filesystem;
/// @retval true building has succeeded.
/// @retval false fail to build, see error message.
/// =========================================================== ///
-bool TOMLManifestBuilder::BuildTarget(const std::string& argv_val, const bool dry_run) {
+bool TOMLManifestBuilder::BuildTarget(BuildConfig& config) {
std::string path;
- if (argv_val.empty()) {
+ if (config.path_.empty()) {
NeBuild::Logger::info() << "nebuild: error: file path is empty" << std::endl;
return false;
} else {
- path = argv_val;
+ path = config.path_;
if (!FS::exists(path)) {
NeBuild::Logger::info() << "nebuild: error: file '" << path << "' does not exist"