blueloveTH 2 年 前
コミット
1b978b5d01
5 ファイル変更20 行追加7 行削除
  1. 0 5
      src2/main.cpp
  2. 19 0
      tests/dylib/CMakeLists.txt
  3. 0 0
      tests/dylib/build.bat
  4. 0 1
      tests/dylib/build.sh
  5. 1 1
      tests/dylib/main.py

+ 0 - 5
src2/main.cpp

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

+ 19 - 0
tests/dylib/CMakeLists.txt

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

+ 0 - 0
tests/dylib/build.bat


+ 0 - 1
tests/dylib/build.sh

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

+ 1 - 1
tests/dylib/main.py

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