From 0e736b2f71ce5f2600a90daec5da103747960009 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 9 Jul 2023 01:11:43 +0800 Subject: [PATCH] ... --- amalgamate.py | 2 +- include/pocketpy/common.h | 7 ++++--- src/pocketpy.cpp | 16 +++++++++++----- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/amalgamate.py b/amalgamate.py index 31cd9aa9..f93d16e3 100644 --- a/amalgamate.py +++ b/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") diff --git a/include/pocketpy/common.h b/include/pocketpy/common.h index 5d2c6418..4d83561b 100644 --- a/include/pocketpy/common.h +++ b/include/pocketpy/common.h @@ -162,12 +162,13 @@ inline PyObject* const PY_OP_YIELD = (PyObject*)0b110011; #endif #include -#elif __unix__ - -#include #elif __EMSCRIPTEN__ #include +#elif __unix__ + +#include + #endif \ No newline at end of file diff --git a/src/pocketpy.cpp b/src/pocketpy.cpp index 30c0b7d1..5a46b0af 100644 --- a/src/pocketpy.cpp +++ b/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) \