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/src/JSONManifestBuilder.cc | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'dev/src') 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