ci(linux): fix Pointer<bool> and store_dart_post_cobject override types
build-linux / build-linux-x64 (push) Failing after 4m11s
build-windows / build-windows-x64 (push) Has been cancelled

This commit is contained in:
2026-05-05 19:57:45 +02:00
parent 6fceac39d5
commit 159daf7964
+25 -12
View File
@@ -172,25 +172,38 @@ jobs:
fi
echo "Stripped stray 'typedef bool = ...' line from generated_bridge.dart"
# Second flutter_rust_bridge_codegen 1.80.1 bug: inside
# `ffi.NativeFunction<...>` template arguments, inner FFI types
# `Int` and `Pointer` are emitted without the `ffi.` prefix that the
# parent file's `import 'dart:ffi' as ffi;` requires. Patch both the
# main bridge file (where the source class field declarations live)
# and the freezed part file (which copies those field types verbatim).
# Second bug: inside `ffi.NativeFunction<...>` template arguments,
# inner FFI types `Int` and `Pointer` are emitted without the `ffi.`
# prefix that the parent file's `import 'dart:ffi' as ffi;` requires.
for f in flutter/lib/generated_bridge.dart flutter/lib/generated_bridge.freezed.dart; do
[ -f "$f" ] || continue
sed -i -E '
s/([^A-Za-z0-9_.])Pointer</\1ffi.Pointer</g
s/([^A-Za-z0-9_.])Int([> ,)])/\1ffi.Int\2/g
' "$f"
# Sanity check
if grep -nE '[<,( ]Int[ >,)]|[<,( ]Pointer<' "$f" >/dev/null; then
echo "WARNING: $f still has unprefixed FFI types after patch:" >&2
grep -nE '[<,( ]Int[ >,)]|[<,( ]Pointer<' "$f" | head >&2
fi
done
echo "Prefixed unqualified Int/Pointer in NativeFunction template args"
# Third bug: codegen emits `ffi.Pointer<bool>` (lowercase Dart bool,
# which isn't a NativeType) instead of `ffi.Pointer<ffi.Bool>` (the
# FFI Bool marker type that satisfies Pointer's bound). Same for any
# `ffi.Pointer<bool*>` variants if they appear (defensive). This also
# has to NOT touch `bool` outside Pointer<>.
sed -i 's/ffi\.Pointer<bool>/ffi.Pointer<ffi.Bool>/g' flutter/lib/generated_bridge.dart
# Fourth bug: the wire class's override of store_dart_post_cobject has
# parameter type `int` (web/stub form) but the active native parent
# in flutter_rust_bridge expects
# Pointer<NativeFunction<Bool Function(Int64, Pointer<Void>)>>
# The internal _lookup is `Void Function(Int)` so we pass ptr.address.
# Confine the substitution to the lines between `void
# store_dart_post_cobject(` and the closing `);` to avoid touching
# other functions.
sed -i '/void store_dart_post_cobject(/,/);/ {
s| int ptr,| ffi.Pointer<ffi.NativeFunction<ffi.Bool Function(ffi.Int64, ffi.Pointer<ffi.Void>)>> ptr,|
s| ptr,| ptr.address,|
}' flutter/lib/generated_bridge.dart
echo "Applied flutter_rust_bridge 1.80.1 Linux-output workarounds (4 patches)"
- name: Diagnose generated bridge files
shell: bash