-
Notifications
You must be signed in to change notification settings - Fork 300
/
consts.dart
118 lines (101 loc) · 3.3 KB
/
consts.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import 'dart:io';
import 'package:flutter_rust_bridge_internal/src/utils/makefile_dart_infra.dart';
const kRustPackagesAllowWeb = [
'frb_rust',
'frb_example/dart_minimal/rust',
'frb_example/pure_dart/rust',
'frb_example/pure_dart_pde/rust',
'frb_example/dart_build_rs/rust',
'frb_example/deliberate_bad/rust',
'frb_example/integrate_third_party/rust',
'frb_example/flutter_via_create/rust',
'frb_example/flutter_via_integrate/rust',
'frb_example/flutter_package/rust',
'frb_example/gallery/rust',
];
const kRustPackagesDisallowWeb = [
'frb_codegen',
'frb_macros',
];
const kRustPackages = [
...kRustPackagesAllowWeb,
...kRustPackagesDisallowWeb,
];
const kDartExampleIntegratePackages = [
'frb_example/flutter_via_create',
'frb_example/flutter_via_integrate',
];
const kDartExamplePackages = [
'frb_example/dart_minimal',
'frb_example/pure_dart',
'frb_example/pure_dart_pde',
'frb_example/dart_build_rs',
'frb_example/deliberate_bad',
'frb_example/integrate_third_party',
'frb_example/flutter_package',
...kDartExampleIntegratePackages,
'frb_example/gallery',
];
const kDartNonExamplePackages = [
'frb_dart',
'frb_utils',
'tools/frb_internal',
];
const kDartPackages = [
...kDartNonExamplePackages,
...kDartExamplePackages,
];
enum DartMode { dart, flutter }
const kDartModeOfPackage = {
'frb_dart': DartMode.dart,
'frb_utils': DartMode.dart,
'tools/frb_internal': DartMode.dart,
'frb_example/dart_minimal': DartMode.dart,
'frb_example/pure_dart': DartMode.dart,
'frb_example/pure_dart_pde': DartMode.dart,
'frb_example/dart_build_rs': DartMode.dart,
'frb_example/deliberate_bad': DartMode.dart,
'frb_example/integrate_third_party': DartMode.flutter,
'frb_example/flutter_via_create': DartMode.flutter,
'frb_example/flutter_via_integrate': DartMode.flutter,
'frb_example/flutter_package': DartMode.flutter,
'frb_example/flutter_package/example': DartMode.flutter,
'frb_example/gallery': DartMode.flutter,
};
const kBuildWebPackageReplacer = {
'frb_example/flutter_package/example': 'frb_example/flutter_package',
};
final exec = SimpleExecutor(
env: {
'CARGO_TERM_COLOR': 'always',
},
// Use project root directory
pwd: Directory.current.parent.parent.uri.toFilePath(),
);
/// Normally, `dart pub get` will be run automatically when executing `dart test` and so on.
/// But there seems to be a bug currently.
/// Temporary workaround before https://github.com/dart-lang/sdk/issues/54160 is fixed.
Future<void> runPubGetIfNotRunYet(String package) async {
final mode = kDartModeOfPackage[package]!;
await _runPubGetIfNotRunYetRaw(package, mode);
for (final extraPackage in [
'$package/rust_builder/cargokit/build_tool',
'$package/cargokit/build_tool',
]) {
await _runPubGetIfNotRunYetRaw(extraPackage, mode);
}
}
Future<void> _runPubGetIfNotRunYetRaw(String package, DartMode mode) async {
final dirPackage = '${exec.pwd}/$package';
if ((await Directory(dirPackage).exists()) &&
(!await Directory('$dirPackage/.dart_tool').exists())) {
await runPubGet(package, mode);
}
}
Future<void> runPubGet(String package, DartMode mode) async {
final cmd = switch (mode) {
DartMode.dart => 'dart --enable-experiment=native-assets',
DartMode.flutter => 'flutter',
};
await exec('$cmd pub get', relativePwd: package);
}