@@ -7,46 +7,48 @@ import 'dart:io';
7
7
import 'package:crypto/crypto.dart' show sha256;
8
8
import 'package:intl4x/src/hook_helpers/build_libs.g.dart' show buildLib;
9
9
import 'package:intl4x/src/hook_helpers/build_options.dart'
10
- show BuildModeEnum, getBuildOptions;
10
+ show BuildModeEnum, BuildOptions, getBuildOptions;
11
11
import 'package:intl4x/src/hook_helpers/hashes.dart' show fileHashes;
12
12
import 'package:intl4x/src/hook_helpers/shared.dart' show assetId, package;
13
13
import 'package:intl4x/src/hook_helpers/version.dart' show version;
14
14
import 'package:native_assets_cli/code_assets.dart' ;
15
15
16
16
void main (List <String > args) async {
17
17
await build (args, (input, output) async {
18
- final buildOptions = await getBuildOptions (
19
- input.outputDirectory. toFilePath (),
20
- );
21
- if (buildOptions == null ) {
18
+ BuildOptions buildOptions;
19
+ try {
20
+ buildOptions = await getBuildOptions (input.userDefines );
21
+ } catch (e ) {
22
22
throw ArgumentError ('''
23
+ Error: $e
24
+
25
+
26
+ Set the build mode with either `fetch`, `local`, or `checkout` by writing into your pubspec:
23
27
24
- Unknown build mode for icu4x. Set the build mode with either `fetch`, `local`, or `checkout` by writing into your pubspec:
25
28
* fetch: Fetch the precompiled binary from a CDN.
26
29
```
27
- ...
28
- hook:
29
- intl4x:
30
- buildMode: fetch
31
- ...
30
+ hooks:
31
+ user_defines:
32
+ intl4x:
33
+ buildMode: fetch
32
34
```
35
+
33
36
* local: Use a locally existing binary at the environment variable `LOCAL_ICU4X_BINARY`.
34
37
```
35
- ...
36
- hook:
37
- intl4x:
38
- buildMode: local
39
- localDylibPath: path/to/dylib.so
40
- ...
38
+ hooks:
39
+ user_defines:
40
+ intl4x:
41
+ buildMode: local
42
+ localDylibPath: path/to/dylib.so
41
43
```
44
+
42
45
* checkout: Build a fresh library from a local git checkout of the icu4x repository.
43
46
```
44
- ...
45
- hook:
46
- intl4x:
47
- buildMode: checkout
48
- checkoutPath: path/to/checkout
49
- ...
47
+ hooks:
48
+ user_defines:
49
+ intl4x:
50
+ buildMode: checkout
51
+ checkoutPath: path/to/checkout
50
52
```
51
53
52
54
''' );
@@ -70,17 +72,13 @@ hook:
70
72
final builtLibrary = await buildMode.build ();
71
73
// For debugging purposes
72
74
// ignore: deprecated_member_use
73
- output.addMetadatum ( 'ICU4X_BUILD_MODE' , buildOptions.buildMode.name);
75
+ output.metadata. addAll ({ 'ICU4X_BUILD_MODE' : buildOptions.buildMode.name} );
74
76
75
- final targetOS = input.config.code.targetOS;
76
- final targetArchitecture = input.config.code.targetArchitecture;
77
77
output.assets.code.add (
78
78
CodeAsset (
79
79
package: package,
80
80
name: assetId,
81
81
linkMode: DynamicLoadingBundled (),
82
- architecture: targetArchitecture,
83
- os: targetOS,
84
82
file: builtLibrary,
85
83
),
86
84
routing:
@@ -156,12 +154,12 @@ final class FetchMode extends BuildMode {
156
154
}
157
155
158
156
final class LocalMode extends BuildMode {
159
- final String ? localPath;
157
+ final Uri ? localPath;
160
158
LocalMode (super .input, this .localPath, super .treeshake);
161
159
162
160
String get _localLibraryPath {
163
161
if (localPath != null ) {
164
- return localPath! ;
162
+ return localPath! . toFilePath (windows : Platform .isWindows) ;
165
163
}
166
164
throw ArgumentError (
167
165
'`LOCAL_ICU4X_BINARY` is empty. '
@@ -190,7 +188,7 @@ final class LocalMode extends BuildMode {
190
188
}
191
189
192
190
final class CheckoutMode extends BuildMode {
193
- final String ? checkoutPath;
191
+ final Uri ? checkoutPath;
194
192
195
193
CheckoutMode (super .input, this .checkoutPath, super .treeshake);
196
194
@@ -209,23 +207,23 @@ final class CheckoutMode extends BuildMode {
209
207
input.config.buildStatic (treeshake),
210
208
input.config.code.targetOS == OS .iOS &&
211
209
input.config.code.iOS.targetSdk == IOSSdk .iPhoneSimulator,
212
- Directory (checkoutPath! ),
210
+ Directory . fromUri (checkoutPath! ),
213
211
[
214
212
'icu_collator' ,
215
213
'icu_datetime' ,
216
214
'icu_list' ,
217
215
'icu_decimal' ,
218
216
'icu_plurals' ,
219
217
'experimental_components' ,
218
+ 'default_components' ,
219
+ 'compiled_data' ,
220
220
],
221
221
);
222
222
return builtLib.uri;
223
223
}
224
224
225
225
@override
226
- List <Uri > get dependencies => [
227
- Uri .directory (checkoutPath! ).resolve ('Cargo.lock' ),
228
- ];
226
+ List <Uri > get dependencies => [checkoutPath! .resolve ('Cargo.lock' )];
229
227
}
230
228
231
229
extension on BuildConfig {
0 commit comments