2023-03-23 10:04:44 +08:00
# This yaml shares the build bridge steps with ci and nightly.
name : Build flutter-rust-bridge
2023-11-23 21:11:45 +02:00
# 2023-11-23 18:00:00+00:00
2023-03-23 10:04:44 +08:00
on :
workflow_call :
2023-05-12 15:16:25 +08:00
env :
2024-08-25 20:46:21 +08:00
FLUTTER_VERSION : "3.19.6"
2023-11-01 17:04:32 +08:00
FLUTTER_RUST_BRIDGE_VERSION : "1.80.1"
2024-04-16 20:18:17 +08:00
RUST_VERSION : "1.75" # https://github.com/rustdesk/rustdesk/discussions/7503
2023-11-03 21:41:48 +02:00
2023-03-23 10:04:44 +08:00
jobs :
generate_bridge :
runs-on : ${{ matrix.job.os }}
strategy :
fail-fast : false
matrix :
job :
- {
target : x86_64-unknown-linux-gnu,
2023-04-03 20:22:17 +08:00
os : ubuntu-20.04,
2023-03-23 10:04:44 +08:00
extra-build-args : "" ,
}
steps :
- name : Checkout source code
2023-12-13 13:22:38 +00:00
uses : actions/checkout@v4
2023-03-23 10:04:44 +08:00
- name : Install prerequisites
run : |
2023-11-03 21:41:48 +02:00
sudo apt-get install ca-certificates -y
sudo apt-get update -y
sudo apt-get install -y \
clang \
cmake \
curl \
gcc \
git \
g++ \
libclang-10-dev \
libgtk-3-dev \
llvm-10-dev \
nasm \
ninja-build \
pkg-config \
2023-11-15 16:03:40 +02:00
wget
2023-03-23 10:04:44 +08:00
- name : Install Rust toolchain
2023-11-23 21:11:45 +02:00
uses : dtolnay/rust-toolchain@v1
2023-03-23 10:04:44 +08:00
with :
2024-04-16 20:18:17 +08:00
toolchain : ${{ env.RUST_VERSION }}
2023-11-23 21:11:45 +02:00
targets : ${{ matrix.job.target }}
2024-04-16 20:18:17 +08:00
components : "rustfmt"
2023-03-23 10:04:44 +08:00
- uses : Swatinem/rust-cache@v2
with :
prefix-key : bridge-${{ matrix.job.os }}
- name : Cache Bridge
id : cache-bridge
uses : actions/cache@v3
with :
path : /tmp/flutter_rust_bridge
key : vcpkg-${{ matrix.job.arch }}
- name : Install flutter
uses : subosito/flutter-action@v2
with :
channel : "stable"
2023-05-12 15:16:25 +08:00
flutter-version : ${{ env.FLUTTER_VERSION }}
2023-03-23 10:04:44 +08:00
cache : true
- name : Install flutter rust bridge deps
shell : bash
run : |
2023-06-06 07:39:44 +08:00
cargo install flutter_rust_bridge_codegen --version ${{ env.FLUTTER_RUST_BRIDGE_VERSION }} --features "uuid"
2023-03-23 10:04:44 +08:00
pushd flutter && flutter pub get && popd
- name : Run flutter rust bridge
run : |
~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart
- name : Upload Artifact
uses : actions/upload-artifact@master
with :
name : bridge-artifact
path : |
./src/bridge_generated.rs
./src/bridge_generated.io.rs
2023-11-03 21:41:48 +02:00
./flutter/lib/generated_bridge.dart
2023-04-19 18:52:49 +03:00
./flutter/lib/generated_bridge.freezed.dart