summaryrefslogtreecommitdiffhomepage
path: root/dev
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-09-28 17:05:08 +0200
committerGitHub <noreply@github.com>2025-09-28 17:05:08 +0200
commita8e72e63ee1921d6a85b801d2cdeff3f4872d468 (patch)
tree6faac4e4180cb8bdaa67a8c62c2b9b4a9995f15d /dev
parentd21a3b2e16b4e5f974dd000e11c868e2021292f0 (diff)
parentff9afeee748fba7bd023f7decafa8fb99298b146 (diff)
Merge pull request #4 from nekernel-org/dev
v0.0.6: NeBuild
Diffstat (limited to 'dev')
-rw-r--r--dev/src/JSONManifestBuilder.cc37
1 files changed, 22 insertions, 15 deletions
diff --git a/dev/src/JSONManifestBuilder.cc b/dev/src/JSONManifestBuilder.cc
index 33d7f62..0b010fe 100644
--- a/dev/src/JSONManifestBuilder.cc
+++ b/dev/src/JSONManifestBuilder.cc
@@ -5,6 +5,10 @@
#include <BuildKit/JSONManifestBuilder.h>
+#if defined(NEBUILD_POSIX)
+#include <dlfcn.h>
+#endif
+
using JSON = nlohmann::json;
namespace FS = std::filesystem;
@@ -99,12 +103,24 @@ bool JSONManifestBuilder::BuildTarget(const std::string& argv_val, const bool dr
try {
if (json_obj["run_after_build"].get<bool>()) {
- if (target.ends_with(".so")) {
- NeBuild::Logger::info()
- << "error: can't open dynamic library, it mayn't have an entrypoint" << std::endl;
+ 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();
- return true;
- } else if (target.ends_with(".dylib") || target.ends_with(".dll")) {
+ dlclose(dll);
+
+ return true;
+ }
+#endif
+
+ return false;
+ } else {
std::ifstream file = std::ifstream(target);
std::stringstream ss;
@@ -119,17 +135,8 @@ bool JSONManifestBuilder::BuildTarget(const std::string& argv_val, const bool dr
NeBuild::Logger::info()
<< "error: can't open FEP dynamic library, it mayn't contain an entrypoint"
<< std::endl;
- else if (ss.str()[0] == 'M' && ss.str()[1] == 'Z')
- NeBuild::Logger::info()
- << "error: can't open MZ dynamic library, it mayn't contain an entrypoint"
- << std::endl;
- else if (ss.str()[0] == 0x7F && ss.str()[1] == 'E') {
- NeBuild::Logger::info()
- << "error: can't open ELF dynamic library, it mayn't contain an entrypoint"
- << std::endl;
- }
- return true;
+ return false;
}
#if defined(NEBUILD_WINDOWS)