summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal <amlal@nekernel.org>2025-08-10 14:44:11 +0200
committerAmlal <amlal@nekernel.org>2025-08-10 14:44:49 +0200
commit4c462511485168cfc831a1447267fd76145d5183 (patch)
tree4133a79658d9df7db05556cc80d95a34342a84bb
parentbc9a0f44a1db9b0cefd891d0d6dcb758dd00b209 (diff)
feat! breaking changes in nebuild's API, examples have been updated too.
Signed-off-by: Amlal <amlal@nekernel.org>
-rw-r--r--CREDITS3
-rw-r--r--dev/BuildKit/IManifestBuilder.h2
-rw-r--r--dev/BuildKit/Imports.h8
-rw-r--r--dev/BuildKit/JSONManifestBuilder.h2
-rw-r--r--dev/cli/Tool.cc2
-rw-r--r--dev/src/JSONManifestBuilder.cc27
-rw-r--r--examples/example_02_libnebuild/libnebuild.cc2
-rw-r--r--vendor/rang/rang.h (renamed from vendor/rang.h)0
8 files changed, 21 insertions, 25 deletions
diff --git a/CREDITS b/CREDITS
index 9b99798..fc97a0a 100644
--- a/CREDITS
+++ b/CREDITS
@@ -1,2 +1,3 @@
rang: https://github.com/agauniyal/rang
-json: https://github.com/nlohmann/json \ No newline at end of file
+json: https://github.com/nlohmann/json
+toml++: https://marzer.github.io/tomlplusplus/ \ No newline at end of file
diff --git a/dev/BuildKit/IManifestBuilder.h b/dev/BuildKit/IManifestBuilder.h
index bb1881d..1dd8bce 100644
--- a/dev/BuildKit/IManifestBuilder.h
+++ b/dev/BuildKit/IManifestBuilder.h
@@ -25,7 +25,7 @@ class IManifestBuilder {
/// @param arg_val filename path.
/// @retval true succeeded.
/// @retval false failed.
- virtual bool BuildTarget(int arg_sz, const char* arg_val, const bool dry_run = false) = 0;
+ virtual bool BuildTarget(const std::string& arg, const bool dry_run = false) = 0;
virtual const char* BuildSystem() = 0;
};
} // namespace NeBuild \ No newline at end of file
diff --git a/dev/BuildKit/Imports.h b/dev/BuildKit/Imports.h
index b365dca..9260c1e 100644
--- a/dev/BuildKit/Imports.h
+++ b/dev/BuildKit/Imports.h
@@ -13,11 +13,7 @@
#include <sstream>
#include <string>
#include <thread>
-
-extern "C" {
-#include <assert.h>
-}
-
-#include <rang.h>
+#include <cassert>
+#include <rang/rang.h>
#endif // NEBUILD_INCLUDES_H
diff --git a/dev/BuildKit/JSONManifestBuilder.h b/dev/BuildKit/JSONManifestBuilder.h
index dd81e8c..b853ccf 100644
--- a/dev/BuildKit/JSONManifestBuilder.h
+++ b/dev/BuildKit/JSONManifestBuilder.h
@@ -27,7 +27,7 @@ class JSONManifestBuilder final NEBUILD_MANIFEST_BUILDER {
/// @param arg_val filename path.
/// @retval true build succeeded.
/// @retval false failed to build.
- bool BuildTarget(int arg_sz, const char* arg_val, const bool dry_run = false) override;
+ bool BuildTarget(const std::string& arg_val, const bool dry_run = false) override;
const char* BuildSystem() override;
};
} // namespace NeBuild \ No newline at end of file
diff --git a/dev/cli/Tool.cc b/dev/cli/Tool.cc
index 4c226fc..315f197 100644
--- a/dev/cli/Tool.cc
+++ b/dev/cli/Tool.cc
@@ -60,7 +60,7 @@ int main(int argc, char** argv) {
NeBuild::Logger::info() << "building manifest: " << index_path << std::endl;
- if (builder && !builder->BuildTarget(index_path.size(), index_path.c_str(), kDryRun)) {
+ if (builder && !builder->BuildTarget(index_path, kDryRun)) {
kFailed = true;
}
diff --git a/dev/src/JSONManifestBuilder.cc b/dev/src/JSONManifestBuilder.cc
index 183cac9..3b03bf8 100644
--- a/dev/src/JSONManifestBuilder.cc
+++ b/dev/src/JSONManifestBuilder.cc
@@ -5,7 +5,6 @@
#include <BuildKit/JSONManifestBuilder.h>
-using String = std::string;
using JSON = nlohmann::json;
namespace FS = std::filesystem;
@@ -17,14 +16,14 @@ using namespace NeBuild;
/// @param arg_val filename path (must be a valid JSON file).
/// @retval true building has succeeded.
/// @retval false fail to build, see error message.
-bool JSONManifestBuilder::BuildTarget(int arg_sz, const char* arg_val, const bool dry_run) {
- String path;
+bool JSONManifestBuilder::BuildTarget(const std::string& argv_val, const bool dry_run) {
+ std::string path;
- if (!arg_val || arg_sz < 0) {
+ if (argv_val.empty()) {
NeBuild::Logger::info() << "nebuild: error: file path is empty" << std::endl;
return false;
} else {
- path += arg_val;
+ path = argv_val;
if (!FS::exists(path)) {
NeBuild::Logger::info() << "nebuild: error: file '" << path << "' does not exist" << std::endl;
@@ -42,39 +41,39 @@ bool JSONManifestBuilder::BuildTarget(int arg_sz, const char* arg_val, const boo
JSON json_obj = JSON::parse(json);
- String compiler = json_obj["compiler_path"].get<String>();
+ std::string compiler = json_obj["compiler_path"].get<std::string>();
JSON header_search_path = json_obj["headers_path"];
JSON sources_files = json_obj["sources_path"];
- String command = compiler + " ";
+ std::string command = compiler + " ";
for (auto& sources : sources_files) {
- command += sources.get<String>() + " ";
+ command += sources.get<std::string>() + " ";
}
for (auto& headers : header_search_path) {
- command += "-I" + headers.get<String>() + " ";
+ command += "-I" + headers.get<std::string>() + " ";
}
JSON macros_list = json_obj["cpp_macros"];
for (auto& macro : macros_list) {
- command += "-D" + macro.get<String>() + " ";
+ command += "-D" + macro.get<std::string>() + " ";
}
JSON compiler_flags = json_obj["compiler_flags"];
for (auto& flag : compiler_flags) {
- command += flag.get<String>() + " ";
+ command += flag.get<std::string>() + " ";
}
if (json_obj["compiler_std"].is_string())
- command += "-std=" + json_obj["compiler_std"].get<String>() + " ";
+ command += "-std=" + json_obj["compiler_std"].get<std::string>() + " ";
- command += "-o " + json_obj["output_name"].get<String>();
+ command += "-o " + json_obj["output_name"].get<std::string>();
- auto target = json_obj["output_name"].get<String>();
+ auto target = json_obj["output_name"].get<std::string>();
NeBuild::Logger::info() << "output path: " << target << "\n";
NeBuild::Logger::info() << "command: " << command << "\n";
diff --git a/examples/example_02_libnebuild/libnebuild.cc b/examples/example_02_libnebuild/libnebuild.cc
index 282e684..74cbe18 100644
--- a/examples/example_02_libnebuild/libnebuild.cc
+++ b/examples/example_02_libnebuild/libnebuild.cc
@@ -11,5 +11,5 @@ int main(int argc, char** argv) {
auto builder = new NeBuild::JSONManifestBuilder();
if (!builder) return EXIT_FAILURE;
- return builder->BuildTarget(strlen(kPath), kPath);
+ return builder->BuildTarget(kPath);
}
diff --git a/vendor/rang.h b/vendor/rang/rang.h
index 204ab1d..204ab1d 100644
--- a/vendor/rang.h
+++ b/vendor/rang/rang.h