blueloveTH 2 jaren geleden
bovenliggende
commit
3201d83377
4 gewijzigde bestanden met toevoegingen van 28 en 27 verwijderingen
  1. 1 25
      .github/workflows/main.yml
  2. 5 0
      include/pocketpy/export.h
  3. 11 2
      tests/dylib/CMakeLists.txt
  4. 11 0
      tests/dylib/test.cpp

+ 1 - 25
.github/workflows/main.yml

@@ -61,11 +61,6 @@ jobs:
         path: output
     - name: Benchmark
       run: python3 scripts/run_tests.py benchmark
-    - name: GCC Build Test
-      run: |
-        SRC=$(find src/ -name "*.cpp")
-        g++ -o main --std=c++17 src/main.cpp $SRC
-        python3 scripts/run_tests.py
     - name: C Binding Test
       run: bash run_c_binding_test.sh
   build_macos:
@@ -111,23 +106,4 @@ jobs:
           rm -rf tmp
       - uses: actions/upload-artifact@v3
         with:
-          path: plugins/flutter/example/build/app/outputs/flutter-apk/output
-  # build_web:
-  #   runs-on: ubuntu-latest
-  #   steps:
-  #   - uses: actions/checkout@v3
-  #   - name: Setup emsdk
-  #     uses: mymindstorm/setup-emsdk@v12
-  #     with:
-  #       version: 3.1.25
-  #       actions-cache-folder: 'emsdk-cache'
-  #   - name: Verify emsdk
-  #     run: emcc -v
-  #   - name: Compile
-  #     run: |
-  #       mkdir -p output/web/lib
-  #       python3 build.py web
-  #       cp web/lib/* output/web/lib
-  #   - uses: actions/upload-artifact@v3
-  #     with:
-  #       path: output
+          path: plugins/flutter/example/build/app/outputs/flutter-apk/output

+ 5 - 0
include/pocketpy/export.h

@@ -12,3 +12,8 @@
 #define PK_INLINE_EXPORT PK_EXPORT inline
 
 #endif
+
+#ifdef PK_SHARED_MODULE
+#undef PK_EXPORT
+#define PK_EXPORT
+#endif

+ 11 - 2
tests/dylib/CMakeLists.txt

@@ -4,8 +4,17 @@ project(test)
 
 set(CMAKE_CXX_STANDARD 17)
 
-if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
+if(MSVC)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR- /EHsc /utf-8 /O2")
+else()
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fexceptions -O2")
+    if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
+    endif()
+endif()
+
+if (MSVC)
+    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /FORCE:UNRESOLVED")
 endif()
 
 include_directories(

+ 11 - 0
tests/dylib/test.cpp

@@ -1,3 +1,4 @@
+#define PK_SHARED_MODULE
 #include "pocketpy.h"
 
 using namespace pkpy;
@@ -15,4 +16,14 @@ extern "C" {
         return mod;
     }
 
+#if _WIN32
+BOOL WINAPI DllMain(
+    HINSTANCE hinstDLL,  // handle to DLL module
+    DWORD fdwReason,     // reason for calling function
+    LPVOID lpvReserved )  // reserved
+{
+    return TRUE;  // Successful DLL_PROCESS_ATTACH.
+}
+#endif
+
 }