-
Notifications
You must be signed in to change notification settings - Fork 16
/
codegen.dart
37 lines (31 loc) · 1.22 KB
/
codegen.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import 'dart:io';
import 'codegen_context.dart' show context;
import 'templates/platformconstants.dart.dart' as dart_template;
import 'templates/platformconstants.h.dart' as objc_header_template;
import 'templates/platformconstants.java.dart' as java_template;
import 'templates/platformconstants.m.dart' as objc_impl_template;
typedef Template = String Function(Map<String, dynamic> context);
const String projectRoot = '../';
Map<Template, String> toGenerate = {
// input template method vs output file path
dart_template.$: '${projectRoot}lib/src/generated/platform_constants.dart',
java_template.$:
'${projectRoot}android/src/main/java/io/ably/flutter/plugin/generated/PlatformConstants.java',
objc_header_template.$:
'${projectRoot}ios/Classes/codec/AblyPlatformConstants.h',
objc_impl_template.$:
'${projectRoot}ios/Classes/codec/AblyPlatformConstants.m',
};
void main() {
for (final entry in toGenerate.entries) {
final source = entry.key(context).replaceAll(RegExp(r'\t'), ' ');
File(entry.value).writeAsStringSync('''
//
// Generated code. Do not modify.
// source file can be found at bin/templates'
//
$source''');
// ignore: avoid_print
print('File written: ${entry.value} ✔');
}
}