ci(linux): use Flutter 3.22.3 for bridge gen (mirrors upstream); 3.24.5 for build
build-linux / build-linux-x64 (push) Failing after 21s
build-windows / build-windows-x64 (push) Successful in 1h9m38s

This commit is contained in:
2026-05-05 18:58:26 +02:00
parent 1bde1f27b4
commit feb48fb9cb
2 changed files with 53 additions and 39 deletions
+26 -27
View File
@@ -106,13 +106,31 @@ jobs:
[[ -x "$tools/bin/flutter_rust_bridge_codegen" ]] || { echo "missing fr_bridge_codegen"; exit 1; }
echo "$tools/bin" >> "$GITHUB_PATH"
- name: Generate Rust <-> Dart bridge
- name: Generate Rust <-> Dart bridge (with Flutter 3.22.3)
shell: bash
run: |
set -e
export PATH="/opt/cargo-tools/bin:$PATH"
# flutter_rust_bridge_codegen 1.80.1 + freezed produces broken Dart
# output (wrong FFI types, unprefixed Int/Pointer in part files) when
# run under Flutter 3.24.5 on Linux. Upstream's bridge.yml works around
# this by running the bridge generation under Flutter 3.22.3 -- the
# produced .dart/.freezed.dart files are then compatible with the
# 3.24.5 build that follows.
#
# provision.sh installs Flutter 3.22.3 at /opt/flutter-bridge alongside
# /opt/flutter (3.24.5). Use the bridge SDK ONLY for pub get + codegen,
# then unset PATH overrides so subsequent steps use the build SDK.
export PATH="/opt/cargo-tools/bin:/opt/flutter-bridge/bin:$PATH"
flutter --version
command -v flutter_rust_bridge_codegen
(cd flutter && flutter pub get)
# extended_text 14.0.0 requires Flutter 3.24+. Downgrade to 13.0.0 for
# the bridge-gen pub get under 3.22.3. Mirrors upstream bridge.yml.
(cd flutter && \
sed -i -e 's/extended_text: 14.0.0/extended_text: 13.0.0/g' pubspec.yaml && \
flutter pub get && \
git checkout -- pubspec.yaml)
flutter_rust_bridge_codegen \
--llvm-path "$LLVM_HOME" \
--rust-input ./src/flutter_ffi.rs \
@@ -120,30 +138,11 @@ jobs:
--c-output ./flutter/macos/Runner/bridge_generated.h
cp ./flutter/macos/Runner/bridge_generated.h ./flutter/ios/Runner/bridge_generated.h
# Explicitly regenerate .freezed.dart files.
(cd flutter && dart run build_runner build --delete-conflicting-outputs)
# Workaround for a flutter_rust_bridge 1.80.1 + freezed interaction:
# the generated `lib/generated_bridge.freezed.dart` references FFI
# types like `Int` and `Pointer` *without* the `ffi.` prefix that the
# parent file's `import 'dart:ffi' as ffi;` requires. Result is
# "Type 'Int' not found" / "Type 'Pointer' not found" at build time.
# Add the prefix where it's missing -- only when the identifier is
# NOT already prefixed (no preceding `.`) and is NOT part of a longer
# token (no preceding alnum/underscore).
freezed=./flutter/lib/generated_bridge.freezed.dart
if [ -f "$freezed" ]; then
echo "Patching FFI type prefixes in $(basename "$freezed")"
sed -i -E '
s/([^A-Za-z0-9_.])Pointer</\1ffi.Pointer</g
s/([^A-Za-z0-9_.])Int([> ,)])/\1ffi.Int\2/g
' "$freezed"
# Sanity: there should be no remaining unprefixed Int/Pointer in FFI position.
if grep -nE '[<,( ]Int[ >,)]|[<,( ]Pointer<' "$freezed" >/dev/null; then
echo "WARNING: still found unprefixed FFI types after patch:"
grep -nE '[<,( ]Int[ >,)]|[<,( ]Pointer<' "$freezed" | head
fi
fi
# Re-resolve packages with the build SDK (3.24.5) so pubspec.lock has
# the correct entries for the final build. The generated_bridge files
# produced under 3.22.3 above stay on disk -- they're plain Dart and
# remain compatible with 3.24.5's compiler.
(cd flutter && /opt/flutter/bin/flutter pub get)
- name: vcpkg install dependencies (x64-linux)
shell: bash