mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
...
This commit is contained in:
parent
34fdd423df
commit
578d6a25cd
@ -42,6 +42,6 @@ else()
|
||||
target_link_libraries(${PROJECT_EXE_NAME} ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten")
|
||||
target_link_libraries(${PROJECT_NAME} ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
|
@ -25,11 +25,11 @@
|
||||
#if TARGET_IPHONE_SIMULATOR
|
||||
// iOS, tvOS, or watchOS Simulator
|
||||
#define PK_SYS_PLATFORM "ios"
|
||||
#define PK_SUPPORT_DYLIB 0
|
||||
#define PK_SUPPORT_DYLIB 4
|
||||
#elif TARGET_OS_IPHONE
|
||||
// iOS, tvOS, or watchOS device
|
||||
#define PK_SYS_PLATFORM "ios"
|
||||
#define PK_SUPPORT_DYLIB 0
|
||||
#define PK_SUPPORT_DYLIB 4
|
||||
#elif TARGET_OS_MAC
|
||||
#define PK_SYS_PLATFORM "darwin"
|
||||
#include <dlfcn.h>
|
||||
@ -39,7 +39,8 @@
|
||||
#endif
|
||||
#define PK_EXPORT __attribute__((visibility("default")))
|
||||
#elif __ANDROID__
|
||||
#define PK_SUPPORT_DYLIB 0
|
||||
#include <dlfcn.h>
|
||||
#define PK_SUPPORT_DYLIB 3
|
||||
#define PK_EXPORT __attribute__((visibility("default")))
|
||||
#define PK_SYS_PLATFORM "android"
|
||||
#elif __linux__
|
||||
|
@ -7,6 +7,7 @@ using dylib_entry_t = const char* (*)(void*, const char*);
|
||||
#if PK_ENABLE_OS
|
||||
|
||||
#if PK_SUPPORT_DYLIB == 1
|
||||
// win32
|
||||
static dylib_entry_t load_dylib(const char* path){
|
||||
std::error_code ec;
|
||||
auto p = std::filesystem::absolute(path, ec);
|
||||
@ -32,7 +33,7 @@ static dylib_entry_t load_dylib(const char* path){
|
||||
return (dylib_entry_t)GetProcAddress(handle, "platform_module__init__");
|
||||
}
|
||||
#elif PK_SUPPORT_DYLIB == 2
|
||||
|
||||
// linux/darwin
|
||||
static dylib_entry_t load_dylib(const char* path){
|
||||
std::error_code ec;
|
||||
auto p = std::filesystem::absolute(path, ec);
|
||||
@ -41,6 +42,15 @@ static dylib_entry_t load_dylib(const char* path){
|
||||
if(!handle) return nullptr;
|
||||
return (dylib_entry_t)dlsym(handle, "platform_module__init__");
|
||||
}
|
||||
|
||||
#elif PK_SUPPORT_DYLIB == 3
|
||||
// android
|
||||
static dylib_entry_t load_dylib(const char* path){
|
||||
void* handle = dlopen(path, RTLD_LAZY);
|
||||
if(!handle) return nullptr;
|
||||
return (dylib_entry_t)dlsym(handle, "platform_module__init__");
|
||||
}
|
||||
|
||||
#else
|
||||
static dylib_entry_t load_dylib(const char* path){
|
||||
return nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user