ci(linux): sed-patch ffi.Int/ffi.Pointer prefix in generated_bridge.freezed.dart
This commit is contained in:
@@ -120,15 +120,31 @@ jobs:
|
|||||||
--c-output ./flutter/macos/Runner/bridge_generated.h
|
--c-output ./flutter/macos/Runner/bridge_generated.h
|
||||||
cp ./flutter/macos/Runner/bridge_generated.h ./flutter/ios/Runner/bridge_generated.h
|
cp ./flutter/macos/Runner/bridge_generated.h ./flutter/ios/Runner/bridge_generated.h
|
||||||
|
|
||||||
# Explicitly regenerate .freezed.dart files. fr_bridge_codegen 1.80.1
|
# Explicitly regenerate .freezed.dart files.
|
||||||
# is supposed to invoke build_runner internally, but on Debian 13's
|
|
||||||
# toolchain that auto-step has been observed to leave a stale or
|
|
||||||
# half-generated lib/generated_bridge.freezed.dart behind, which then
|
|
||||||
# fails compilation later in `flutter build linux` with errors like
|
|
||||||
# `Type 'Int' not found` (unprefixed FFI types). --delete-conflicting-outputs
|
|
||||||
# ensures the file is fully rebuilt.
|
|
||||||
(cd flutter && dart run build_runner build --delete-conflicting-outputs)
|
(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
|
||||||
|
|
||||||
- name: vcpkg install dependencies (x64-linux)
|
- name: vcpkg install dependencies (x64-linux)
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
|
|||||||
Reference in New Issue
Block a user