Skip to content

Commit b9cdcab

Browse files
committed
added windows build
1 parent 1674f67 commit b9cdcab

File tree

3 files changed

+126
-0
lines changed

3 files changed

+126
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Windows Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
FLUTTER_VERSION: '3.38.0'
11+
12+
jobs:
13+
build-windows:
14+
runs-on: windows-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Setup Rust
19+
uses: dtolnay/rust-toolchain@stable
20+
21+
- name: Setup Flutter
22+
uses: subosito/flutter-action@v2
23+
with:
24+
flutter-version: ${{ env.FLUTTER_VERSION }}
25+
channel: stable
26+
27+
- name: Cache Cargo
28+
uses: Swatinem/rust-cache@v2
29+
with:
30+
shared-key: rust-windows-release
31+
32+
- name: Install flutter_rust_bridge_codegen
33+
run: cargo install flutter_rust_bridge_codegen
34+
35+
- name: Get Flutter dependencies
36+
working-directory: packages/fula_client
37+
run: flutter pub get
38+
39+
- name: Generate Rust bindings
40+
run: flutter_rust_bridge_codegen generate
41+
42+
- name: Build Windows DLL
43+
run: cargo build -p fula-flutter --release
44+
45+
- name: Upload Windows DLL artifact
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: windows-x86_64
49+
path: target/release/fula_flutter.dll
50+
retention-days: 1
51+
52+
attach-to-release:
53+
needs: build-windows
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Determine release tag
57+
id: tag
58+
run: |
59+
if [ "${{ github.event_name }}" = "release" ]; then
60+
echo "tag=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
61+
else
62+
TAG=$(gh api repos/${{ github.repository }}/releases/latest --jq .tag_name)
63+
echo "tag=$TAG" >> $GITHUB_OUTPUT
64+
fi
65+
env:
66+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
68+
- name: Download Windows DLL artifact
69+
uses: actions/download-artifact@v4
70+
with:
71+
name: windows-x86_64
72+
path: windows-libs/
73+
74+
- name: Package Windows libs
75+
run: cd windows-libs && zip -r ../windows-libs.zip .
76+
77+
- name: Upload to GitHub Release
78+
uses: softprops/action-gh-release@v1
79+
with:
80+
tag_name: ${{ steps.tag.outputs.tag }}
81+
files: windows-libs.zip
82+
env:
83+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

packages/fula_client/pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ platforms:
3232
android:
3333
ios:
3434
web:
35+
windows:
3536

3637
flutter:
3738
plugin:
@@ -40,6 +41,8 @@ flutter:
4041
ffiPlugin: true
4142
ios:
4243
ffiPlugin: true
44+
windows:
45+
ffiPlugin: true
4346
web:
4447
pluginClass: FulaClientWeb
4548
fileName: fula_client_web.dart
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(fula_flutter VERSION 0.1.0 LANGUAGES C)
3+
4+
# Pre-built DLL path (downloaded from GitHub Releases or built locally)
5+
set(FULA_DLL "${CMAKE_CURRENT_SOURCE_DIR}/fula_flutter.dll")
6+
7+
if(EXISTS "${FULA_DLL}")
8+
# Install the pre-built DLL to the Flutter app's build output
9+
install(FILES "${FULA_DLL}" DESTINATION "${CMAKE_INSTALL_PREFIX}")
10+
else()
11+
# Option: build from source if DLL not found and BUILD_FROM_SOURCE is set
12+
option(BUILD_FROM_SOURCE "Build fula_flutter from Rust source" OFF)
13+
14+
if(BUILD_FROM_SOURCE)
15+
# Find the workspace root (3 levels up from windows/)
16+
get_filename_component(WORKSPACE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../.." ABSOLUTE)
17+
18+
add_custom_command(
19+
OUTPUT "${WORKSPACE_ROOT}/target/release/fula_flutter.dll"
20+
COMMAND cargo build -p fula-flutter --release
21+
WORKING_DIRECTORY "${WORKSPACE_ROOT}"
22+
COMMENT "Building fula_flutter from Rust source..."
23+
)
24+
25+
add_custom_target(build_fula_flutter ALL
26+
DEPENDS "${WORKSPACE_ROOT}/target/release/fula_flutter.dll"
27+
)
28+
29+
install(
30+
FILES "${WORKSPACE_ROOT}/target/release/fula_flutter.dll"
31+
DESTINATION "${CMAKE_INSTALL_PREFIX}"
32+
)
33+
else()
34+
message(FATAL_ERROR
35+
"fula_flutter.dll not found at ${FULA_DLL}. "
36+
"Download it from GitHub Releases and place it in the windows/ directory, "
37+
"or set -DBUILD_FROM_SOURCE=ON to build from Rust source."
38+
)
39+
endif()
40+
endif()

0 commit comments

Comments
 (0)