diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-17 10:06:26 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-17 10:06:26 +0100 |
| commit | 76cf9156127bf7f082294a0c7e79f86059fe69ab (patch) | |
| tree | 5070f4695b591780f60b728cc14e624c5a31b5d8 /dev/src/JSONManifestBuilder.cc | |
| parent | a8e72e63ee1921d6a85b801d2cdeff3f4872d468 (diff) | |
| parent | c782117221f0b8f0bb018df673f935c1791fee32 (diff) | |
Merge pull request #5 from nekernel-org/dev
release: NeBuild v0.0.7
Diffstat (limited to 'dev/src/JSONManifestBuilder.cc')
| -rw-r--r-- | dev/src/JSONManifestBuilder.cc | 84 |
1 files changed, 14 insertions, 70 deletions
diff --git a/dev/src/JSONManifestBuilder.cc b/dev/src/JSONManifestBuilder.cc index 0b010fe..daf47af 100644 --- a/dev/src/JSONManifestBuilder.cc +++ b/dev/src/JSONManifestBuilder.cc @@ -5,12 +5,7 @@ #include <BuildKit/JSONManifestBuilder.h> -#if defined(NEBUILD_POSIX) -#include <dlfcn.h> -#endif - -using JSON = nlohmann::json; - +using JSON = nlohmann::json; namespace FS = std::filesystem; using namespace NeBuild; @@ -49,19 +44,26 @@ bool JSONManifestBuilder::BuildTarget(const std::string& argv_val, const bool dr 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"]; - std::string command = compiler + " "; - for (auto& sources : sources_files) { - command += sources.get<std::string>() + " "; - } + JSON header_search_path = json_obj["compiler_headers_path"]; for (auto& headers : header_search_path) { command += "-I" + headers.get<std::string>() + " "; } + JSON headers_path = json_obj["headers_path"]; + + for (auto& headers : headers_path) { + command += "-I" + headers.get<std::string>() + " "; + } + + JSON sources_files = json_obj["sources_path"]; + + for (auto& sources : sources_files) { + command += sources.get<std::string>() + " "; + } + JSON macros_list = json_obj["cpp_macros"]; for (auto& macro : macros_list) { @@ -84,15 +86,6 @@ bool JSONManifestBuilder::BuildTarget(const std::string& argv_val, const bool dr NeBuild::Logger::info() << "output path: " << target << "\n"; NeBuild::Logger::info() << "command: " << command << "\n"; - try { - if (json_obj["dry_run"].get<bool>()) return true; - } catch (...) { - } - - if (dry_run) { - return true; - } - auto ret_exec = std::system(command.c_str()); if (ret_exec > 0) { @@ -100,57 +93,8 @@ bool JSONManifestBuilder::BuildTarget(const std::string& argv_val, const bool dr << std::endl; return false; } - - try { - if (json_obj["run_after_build"].get<bool>()) { - if (target.ends_with(".so") || target.ends_with(".dylib")) { -#if defined(NEBUILD_POSIX) - auto dll = dlopen(target.c_str(), RTLD_LAZY); - - if (dll) { - int (*entrypoint)(void) = nullptr; - entrypoint = (decltype(entrypoint))dlsym(dll, "shared_runner"); - - if (entrypoint) entrypoint(); - - dlclose(dll); - - return true; - } -#endif - - return false; - } else { - std::ifstream file = std::ifstream(target); - std::stringstream ss; - - ss << file.rdbuf(); - - if (ss.str()[0] == 'O' && ss.str()[1] == 'p' && ss.str()[2] == 'e' && ss.str()[3] == 'n') - NeBuild::Logger::info() - << "error: can't open PEF dynamic library, it mayn't contain an entrypoint" - << std::endl; - else if (ss.str()[0] == 'n' && ss.str()[1] == 'e' && ss.str()[2] == 'p' && - ss.str()[3] == 'O') - NeBuild::Logger::info() - << "error: can't open FEP dynamic library, it mayn't contain an entrypoint" - << std::endl; - - return false; - } - -#if defined(NEBUILD_WINDOWS) - std::system((".\\" + target).c_str()); -#else - std::system(("./" + target).c_str()); -#endif - } - } catch (...) { - return true; - } } catch (std::runtime_error& err) { NeBuild::Logger::info() << "error: " << err.what() << std::endl; - return false; } |
