From c40cf1459b6c848e4ffb6df88dc1f4c6001972f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BF=B4?= <￴> Date: Mon, 6 Feb 2023 17:04:53 +0700 Subject: [PATCH] dupate --- .../workflows/cross-compile-application.yaml | 2 +- .github/workflows/cross-compile-library.yaml | 77 ++----------------- native_lib/CMakeLists.txt | 55 +++++++++---- native_lib/readme.md | 2 +- 4 files changed, 51 insertions(+), 85 deletions(-) diff --git a/.github/workflows/cross-compile-application.yaml b/.github/workflows/cross-compile-application.yaml index e7fe066..c0b28e0 100644 --- a/.github/workflows/cross-compile-application.yaml +++ b/.github/workflows/cross-compile-application.yaml @@ -1,5 +1,5 @@ name: Compile Cross platform -on: [push] +on: [workflow_dispatch] jobs: build: diff --git a/.github/workflows/cross-compile-library.yaml b/.github/workflows/cross-compile-library.yaml index be0cec1..dd54efd 100644 --- a/.github/workflows/cross-compile-library.yaml +++ b/.github/workflows/cross-compile-library.yaml @@ -50,78 +50,17 @@ jobs: shell: bash - name: Mkdir result run: mkdir result - - name: Set Flutter enable devices - continue-on-error: true - run: | - flutter config --enable-web - flutter config --enable-linux-desktop - flutter config --enable-macos-desktop - flutter config --enable-windows-desktop - flutter config --enable-android - flutter config --enable-ios - - name: Activate Flutter Distribute - continue-on-error: true - run: dart pub global activate flutter_distributor - - # Compile specta app - - name: Compile Application For Desktop - continue-on-error: true - run: | - cd package/whisper_flutter/example - flutter pub get - if [ "$RUNNER_OS" == "Linux" ]; then - flutter_distributor package --platform linux --targets deb - mv dist/*/*.deb ../../../result/ - fi - if [ "$RUNNER_OS" == "Windows" ]; then - flutter build windows --release - fi - if [ "$RUNNER_OS" == "macOS" ]; then - flutter_distributor package --platform macos --targets dmg - mv dist/*/*.dmg ../../../result/ - fi + - name: Compile shell: bash - - name: Compile Application For Android - continue-on-error: true - run: | - cd package/whisper_flutter/example - if [ "$RUNNER_OS" == "macOS" ]; then - flutter build apk --release --split-per-abi - mv build/app/outputs/apk/release/*.apk ../../../result/ - fi - shell: bash - - name: Compile Application For iOS - continue-on-error: true - run: | - cd package/whisper_flutter/example - if [ "$RUNNER_OS" == "macOS" ]; then - flutter build ios --no-codesign - cd build/ios/iphoneos - mkdir Payload - cd Payload - ln -s ../Runner.app - cd .. - zip -r app_ios.ipa Payload - mv app_ios.ipa ../../.../../../result/ - fi - shell: bash - - name: Compile Application For Web - continue-on-error: true run: | - cd package/whisper_flutter/example - if [ "$RUNNER_OS" == "macOS" ]; then - flutter build web - cd build/web - zip -r web-app.zip . - mv web-app.zip ../.../../../result/ + cd native_lib + if [ "$RUNNER_OS" == "Linux" ]; then + mkdir build + cd build + cmake -DCMAKE_BUILD_TYPE=Release .. + cmake --build . + mv ./libwhisper.so ../../result/ fi - shell: bash - - name: Publish artifact - uses: actions/upload-artifact@v3 - continue-on-error: true - with: - name: Artifact - path: result/* - name: Publish Release uses: marvinpinto/action-automatic-releases@latest with: diff --git a/native_lib/CMakeLists.txt b/native_lib/CMakeLists.txt index 609a64a..6457660 100644 --- a/native_lib/CMakeLists.txt +++ b/native_lib/CMakeLists.txt @@ -1,25 +1,52 @@ +# # The Flutter tooling requires that developers have CMake 3.10 or later +# # installed. You should not increase this version, as doing so will cause +# # the plugin to fail to compile for some customers of the plugin. +# cmake_minimum_required(VERSION 3.10) + +# project(whisper_library VERSION 0.0.1 LANGUAGES C CXX) + +# message("Started Compile Whisper") + +# set(CMAKE_CXX_STANDARD 20) +# set(CMAKE_CXX_STANDARD_REQUIRED ON) +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++2a -fPIC") + +# add_library(ggml whisper.cpp/ggml.c) +# add_library(whisper_lib whisper.cpp/whisper.cpp) +# add_library(whisper SHARED main.cpp) + +# # set_target_properties(whisper PROPERTIES +# # PUBLIC_HEADER whisper.cpp/whisper.h +# # OUTPUT_NAME "whisper" +# # ) + +# target_compile_definitions(whisper PUBLIC DART_SHARED_LIB) +# target_link_libraries(whisper PRIVATE ggml ${CMAKE_THREAD_LIBS_INIT}) + # The Flutter tooling requires that developers have CMake 3.10 or later # installed. You should not increase this version, as doing so will cause # the plugin to fail to compile for some customers of the plugin. cmake_minimum_required(VERSION 3.10) project(whisper_library VERSION 0.0.1 LANGUAGES C CXX) - -message("Started Compile Whisper") - set(CMAKE_CXX_STANDARD 20) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++2a -fPIC") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") -add_library(ggml whisper.cpp/ggml.c) -add_library(whisper_lib whisper.cpp/whisper.cpp) add_library(whisper SHARED main.cpp) - -# set_target_properties(whisper_flutter PROPERTIES -# PUBLIC_HEADER whisper.cpp/whisper.h -# OUTPUT_NAME "whisper" -# ) +add_library(whisper_lib whisper.cpp/whisper.cpp) +add_library(ggml whisper.cpp/ggml.c) + +set_target_properties(whisper PROPERTIES + PUBLIC_HEADER whisper.cpp/whisper.h + OUTPUT_NAME "whisper" +) + +if (WIN32) +set_target_properties(whisper PROPERTIES + WINDOWS_EXPORT_ALL_SYMBOLS ON +) +endif (WIN32) target_compile_definitions(whisper PUBLIC DART_SHARED_LIB) -target_link_libraries(whisper PRIVATE ggml ${CMAKE_THREAD_LIBS_INIT}) - \ No newline at end of file +target_link_libraries(whisper PRIVATE whisper_lib ggml ${CMAKE_THREAD_LIBS_INIT}) diff --git a/native_lib/readme.md b/native_lib/readme.md index 7764d2b..2fb0992 100644 --- a/native_lib/readme.md +++ b/native_lib/readme.md @@ -9,4 +9,4 @@ cmake --build . cmake .. -DCMAKE_TOOLCHAIN_FILE=${ANDROID_SDK}/ndk/24.0.8215888/build/cmake/android.toolchain.cmake -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI=arm64-v8a cmake --build . -``` \ No newline at end of file +```