Skip to content

Commit

Permalink
tool: rewrite pigeon gen as dart program
Browse files Browse the repository at this point in the history
  • Loading branch information
arnemolland committed Jun 6, 2023
1 parent 429e272 commit d534770
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 23 deletions.
23 changes: 0 additions & 23 deletions pigeon.sh

This file was deleted.

51 changes: 51 additions & 0 deletions tool/gen_pigeon.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// ignore_for_file: avoid_print

import 'dart:io';

Future<void> runPigeon(String input, String dartOut, String swiftOut) async {
var result = await Process.run('dart', [
'run',
'pigeon',
'--input',
input,
'--dart_out',
dartOut,
'--swift_out',
swiftOut
]);

if (result.exitCode != 0) {
print('Error running pigeon:\n${result.stderr}');
exit(result.exitCode);
}
}

void main() async {
// UserDefaults for iOS
await runPigeon(
'api/user_defaults.dart',
'lib/api/user_defaults.dart',
'ios/Classes/UserDefaultsAPI.swift',
);

// UserDefaults for macOS
await runPigeon(
'api/user_defaults.dart',
'lib/api/user_defaults.dart',
'macos/Classes/UserDefaultsAPI.swift',
);

// WidgetKit for iOS
await runPigeon(
'api/widget_kit.dart',
'lib/api/widget_kit.dart',
'ios/Classes/WidgetKitAPI.swift',
);

// WidgetKit for macOS
await runPigeon(
'api/widget_kit.dart',
'lib/api/widget_kit.dart',
'macos/Classes/WidgetKitAPI.swift',
);
}

0 comments on commit d534770

Please sign in to comment.