This commit is contained in:
blueloveTH 2023-07-09 01:11:43 +08:00
parent 383a6d3194
commit 0e736b2f71
3 changed files with 16 additions and 9 deletions

View File

@ -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")

View File

@ -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

View File

@ -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) \