This commit is contained in:
blueloveTH 2023-07-09 03:11:25 +08:00
parent e6c5ace927
commit 1b978b5d01
5 changed files with 20 additions and 7 deletions

View File

@ -16,11 +16,6 @@ int main(int argc, char** argv){
#elif __APPLE__ #elif __APPLE__
void* p = dlopen("libpocketpy.dylib", RTLD_NOW | RTLD_GLOBAL); void* p = dlopen("libpocketpy.dylib", RTLD_NOW | RTLD_GLOBAL);
#endif #endif
if(p == nullptr){
std::cerr << "unable to load dynamic library" << std::endl;
return 1;
}
pkpy::VM* vm = pkpy_new_vm(); pkpy::VM* vm = pkpy_new_vm();
pkpy::_bind(vm, vm->builtins, "input() -> str", &f_input); pkpy::_bind(vm, vm->builtins, "input() -> str", &f_input);

View File

@ -0,0 +1,19 @@
cmake_minimum_required(VERSION 3.17)
project(test)
set(CMAKE_CXX_STANDARD 17)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
include_directories(
${CMAKE_CURRENT_LIST_DIR}/../../include
)
add_library(
${PROJECT_NAME}
SHARED
test.cpp
)

View File

View File

@ -1 +0,0 @@
clang++ -std=c++17 -fno-rtti -O2 -stdlib=libc++ -Wfatal-errors -o libtest.so test.cpp -I../../include -fPIC -shared

View File

@ -1,6 +1,6 @@
import os import os
print(os.getcwd()) print(os.getcwd())
test = __import__('libtest.so') test = __import__('build/libtest.so')
test.hello() test.hello()