-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tool: rewrite pigeon gen as dart program
- Loading branch information
1 parent
429e272
commit d534770
Showing
2 changed files
with
51 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
); | ||
} |