blueloveTH пре 2 година
родитељ
комит
0e736b2f71
3 измењених фајлова са 16 додато и 9 уклоњено
  1. 1 1
      amalgamate.py
  2. 4 3
      include/pocketpy/common.h
  3. 11 5
      src/pocketpy.cpp

+ 1 - 1
amalgamate.py

@@ -81,7 +81,7 @@ with open("amalgamated/main.cpp", "wt", encoding='utf-8') as f:
 	f.write(text)
 
 if sys.platform in ['linux', 'darwin']:
-	ok = os.system("clang++ -o pocketpy amalgamated/main.cpp --std=c++17 -stdlib=libc++")
+	ok = os.system("clang++ -o pocketpy amalgamated/main.cpp --std=c++17 -stdlib=libc++ -ldl")
 	if ok == 0:
 		print("Test build success!")
 		os.remove("pocketpy")

+ 4 - 3
include/pocketpy/common.h

@@ -162,12 +162,13 @@ inline PyObject* const PY_OP_YIELD = (PyObject*)0b110011;
 #endif
 
 #include <Windows.h>
-#elif __unix__
-
-#include <dlfcn.h>
 
 #elif __EMSCRIPTEN__
 
 #include <emscripten.h>
 
+#elif __unix__
+
+#include <dlfcn.h>
+
 #endif

+ 11 - 5
src/pocketpy.cpp

@@ -11,11 +11,18 @@ static dylib_entry_t load_dylib(const char* path){
     std::error_code ec;
     auto p = std::filesystem::absolute(path, ec);
     if(ec) return nullptr;
-    HMODULE handle = LoadLibraryA(p.c_str());
+    HMODULE handle = LoadLibraryA((LPCSTR)p.c_str());
     if(!handle) return nullptr;
     return (dylib_entry_t)GetProcAddress(handle, "platform_module__init__");
 }
-#else
+#elif __EMSCRIPTEN__
+
+static dylib_entry_t load_dylib(const char* path){
+    return nullptr;
+}
+
+#elif __unix__
+
 static dylib_entry_t load_dylib(const char* path){
     std::error_code ec;
     auto p = std::filesystem::absolute(path, ec);
@@ -24,15 +31,14 @@ static dylib_entry_t load_dylib(const char* path){
     if(!handle) return nullptr;
     return (dylib_entry_t)dlsym(handle, "platform_module__init__");
 }
-#endif
-
 #else
 static dylib_entry_t load_dylib(const char* path){
-    PK_UNUSED(path);
     return nullptr;
 }
 #endif
 
+#endif
+
 
 void init_builtins(VM* _vm) {
 #define BIND_NUM_ARITH_OPT(name, op)                                                                    \