From 4c462511485168cfc831a1447267fd76145d5183 Mon Sep 17 00:00:00 2001 From: Amlal Date: Sun, 10 Aug 2025 14:44:11 +0200 Subject: feat! breaking changes in nebuild's API, examples have been updated too. Signed-off-by: Amlal --- dev/BuildKit/IManifestBuilder.h | 2 +- dev/BuildKit/Imports.h | 8 ++------ dev/BuildKit/JSONManifestBuilder.h | 2 +- dev/cli/Tool.cc | 2 +- dev/src/JSONManifestBuilder.cc | 27 +++++++++++++-------------- 5 files changed, 18 insertions(+), 23 deletions(-) (limited to 'dev') 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 #include #include - -extern "C" { -#include -} - -#include +#include +#include #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 -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(); + std::string compiler = json_obj["compiler_path"].get(); 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() + " "; + command += sources.get() + " "; } for (auto& headers : header_search_path) { - command += "-I" + headers.get() + " "; + command += "-I" + headers.get() + " "; } JSON macros_list = json_obj["cpp_macros"]; for (auto& macro : macros_list) { - command += "-D" + macro.get() + " "; + command += "-D" + macro.get() + " "; } JSON compiler_flags = json_obj["compiler_flags"]; for (auto& flag : compiler_flags) { - command += flag.get() + " "; + command += flag.get() + " "; } if (json_obj["compiler_std"].is_string()) - command += "-std=" + json_obj["compiler_std"].get() + " "; + command += "-std=" + json_obj["compiler_std"].get() + " "; - command += "-o " + json_obj["output_name"].get(); + command += "-o " + json_obj["output_name"].get(); - auto target = json_obj["output_name"].get(); + auto target = json_obj["output_name"].get(); NeBuild::Logger::info() << "output path: " << target << "\n"; NeBuild::Logger::info() << "command: " << command << "\n"; -- cgit v1.2.3