From 89d0750365a35cf3619220b603560f245ded8d2d Mon Sep 17 00:00:00 2001 From: ekibun Date: Fri, 22 Jan 2021 15:18:11 +0800 Subject: [PATCH] linux test --- .github/workflows/test.yml | 23 +++++++++++++++++++++++ example/linux/flutter/CMakeLists.txt | 1 + lib/ffi.dart | 2 +- test/CMakeLists.txt | 4 ++++ 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..8ede019 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,23 @@ +name: Test + +on: + push: + branches: + - master + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + steps: + - uses: actions/checkout@v2 + - name: Flutter action + uses: subosito/flutter-action@v1.1.1 + with: + channel: "stable" + flutter-version: "1.12.x" + - run: flutter pub get + - run: flutter test test/flutter_qjs_test.dart \ No newline at end of file diff --git a/example/linux/flutter/CMakeLists.txt b/example/linux/flutter/CMakeLists.txt index 4f48a7c..9f236b5 100644 --- a/example/linux/flutter/CMakeLists.txt +++ b/example/linux/flutter/CMakeLists.txt @@ -81,6 +81,7 @@ add_custom_command( ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" linux-x64 ${CMAKE_BUILD_TYPE} + VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" diff --git a/lib/ffi.dart b/lib/ffi.dart index 97f14d2..c0fe8bd 100644 --- a/lib/ffi.dart +++ b/lib/ffi.dart @@ -54,7 +54,7 @@ final DynamicLibrary qjsLib = Platform.environment['FLUTTER_TEST'] == 'true' ? DynamicLibrary.open("test/build/Debug/ffiquickjs.dll") : Platform.isMacOS ? DynamicLibrary.open("test/build/libffiquickjs.dylib") - : DynamicLibrary.process()) + : DynamicLibrary.open("test/build/libffiquickjs.so")) : (Platform.isWindows ? DynamicLibrary.open("flutter_qjs_plugin.dll") : Platform.isAndroid diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3eead7c..c22485e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,6 +3,10 @@ project(ffiquickjs LANGUAGES CXX) include("${CMAKE_CURRENT_SOURCE_DIR}/../cxx/quickjs.cmake") +IF (CMAKE_SYSTEM_NAME MATCHES "Linux") + target_compile_options(quickjs PRIVATE "-fPIC") +ENDIF () + add_library(ffiquickjs SHARED ${CXX_LIB_DIR}/ffi.cpp) target_compile_features(ffiquickjs PUBLIC cxx_std_17) target_link_libraries(ffiquickjs PRIVATE quickjs) \ No newline at end of file