Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@
with:
channel: stable
flutter-version-file: pubspec.yaml
- name: Patch Flutter macOS AOT FFI retention
run: dart tool/patch_flutter_macos_aot.dart
- run: flutter pub get
- name: Inject DanDan API Credentials
run: |
Expand Down Expand Up @@ -204,4 +206,4 @@
uses: actions/upload-artifact@v4
with:
name: ios_outputs
path: oneAnime_ios_*.ipa
path: oneAnime_ios_*.ipa
4 changes: 3 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@
with:
channel: stable
flutter-version-file: pubspec.yaml
- name: Patch Flutter macOS AOT FFI retention
run: dart tool/patch_flutter_macos_aot.dart
- run: flutter pub get
- name: Inject DanDan API Credentials
run: |
Expand Down Expand Up @@ -351,4 +353,4 @@
oneAnime_macos_*.dmg
oneAnime_ios_*.ipa
oneAnime_linux_*.tar.gz
oneAnime_linux_*.AppImage
oneAnime_linux_*.AppImage
56 changes: 56 additions & 0 deletions tool/patch_flutter_macos_aot.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import 'dart:io';

// Work around https://github.com/flutter/flutter/issues/188060.
const _ffiStructs = <String>[
'_WindowCreationRequest',
'_Size',
'_Offset',
'_Rect',
'_Constraints',
];

void main() {
final flutterRoot = Platform.environment['FLUTTER_ROOT'];
if (flutterRoot == null || flutterRoot.isEmpty) {
stderr.writeln('FLUTTER_ROOT is not set.');
exitCode = 1;
return;
}

final sourceFile = File(
'$flutterRoot/packages/flutter/lib/src/widgets/_window_macos.dart',
);
if (!sourceFile.existsSync()) {
stderr.writeln('Flutter macOS windowing source was not found.');
exitCode = 1;
return;
}

var source = sourceFile.readAsStringSync();
var changed = false;

for (final struct in _ffiStructs) {
final declaration = 'final class $struct extends Struct {';
final retainedDeclaration = "@pragma('vm:entry-point')\n$declaration";

if (source.contains(retainedDeclaration)) {
continue;
}

if (declaration.allMatches(source).length != 1) {
stderr.writeln('Expected one declaration for $struct.');
exitCode = 1;
return;
}

source = source.replaceFirst(declaration, retainedDeclaration);
changed = true;
}

if (changed) {
sourceFile.writeAsStringSync(source);
stdout.writeln('Patched Flutter macOS AOT FFI retention.');
} else {
stdout.writeln('Flutter macOS AOT FFI retention is already patched.');
}
}
Loading