From 3201d833771edea8c460a32e02419a418a7e09dd Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 9 Jul 2023 03:27:47 +0800 Subject: [PATCH] ... --- .github/workflows/main.yml | 26 +------------------------- include/pocketpy/export.h | 5 +++++ tests/dylib/CMakeLists.txt | 13 +++++++++++-- tests/dylib/test.cpp | 11 +++++++++++ 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9935fdd3..c6b1f6a5 100644 --- a/.github/workflows/main.yml +++ b/.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 \ No newline at end of file + path: plugins/flutter/example/build/app/outputs/flutter-apk/output \ No newline at end of file diff --git a/include/pocketpy/export.h b/include/pocketpy/export.h index f23a769e..56cbe6c4 100644 --- a/include/pocketpy/export.h +++ b/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 diff --git a/tests/dylib/CMakeLists.txt b/tests/dylib/CMakeLists.txt index d470b418..8e1474f0 100644 --- a/tests/dylib/CMakeLists.txt +++ b/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( diff --git a/tests/dylib/test.cpp b/tests/dylib/test.cpp index 983b4b6e..29d2ce4c 100644 --- a/tests/dylib/test.cpp +++ b/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 + } \ No newline at end of file