Skip to content

Commit

Permalink
dupate
Browse files Browse the repository at this point in the history
  • Loading branch information
committed Feb 6, 2023
1 parent d8dfbc8 commit c40cf14
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cross-compile-application.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Compile Cross platform
on: [push]
on: [workflow_dispatch]

jobs:
build:
Expand Down
77 changes: 8 additions & 69 deletions .github/workflows/cross-compile-library.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
55 changes: 41 additions & 14 deletions native_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})

target_link_libraries(whisper PRIVATE whisper_lib ggml ${CMAKE_THREAD_LIBS_INIT})
2 changes: 1 addition & 1 deletion native_lib/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
```
```

0 comments on commit c40cf14

Please sign in to comment.