Fix dependencies in intl4x (#849)
* Fix dependencies in intl4x
* Adapt version in pubspec
* Swtich to real version
diff --git a/pkgs/intl4x/CHANGELOG.md b/pkgs/intl4x/CHANGELOG.md
index 9c64489..3d44616 100644
--- a/pkgs/intl4x/CHANGELOG.md
+++ b/pkgs/intl4x/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.9.1
+
+- Small fixes in imports
+
## 0.9.0
- Update for `icu4x` and `build.dart` changes.
diff --git a/pkgs/intl4x/hook/build.dart b/pkgs/intl4x/hook/build.dart
index d7d9568..82d0fba 100644
--- a/pkgs/intl4x/hook/build.dart
+++ b/pkgs/intl4x/hook/build.dart
@@ -17,7 +17,7 @@
final buildMode = switch (Platform.environment['ICU4X_BUILD_MODE']) {
'local' => LocalMode(),
'checkout' => CheckoutMode(config),
- 'fetch' || null => FetchMode(),
+ 'fetch' || null => FetchMode(config),
String() => throw ArgumentError('''
@@ -36,7 +36,7 @@
name: assetId,
linkMode: DynamicLoadingBundled(),
architecture: config.targetArchitecture,
- os: OS.current,
+ os: config.targetOS,
file: builtLibrary,
));
@@ -70,20 +70,27 @@
}
final class FetchMode implements BuildMode {
+ final BuildConfig config;
+
+ FetchMode(this.config);
+
@override
Future<Uri> build() async {
// TODO: Get a nicer CDN than a generated link to a privately owned repo.
- final request = await HttpClient().getUrl(Uri.parse(
- 'https://nightly.link/mosuem/i18n/workflows/intl4x_artifacts/main/lib-$platformName-latest.zip'));
+ final uri = Uri.parse(
+ 'https://nightly.link/mosuem/i18n/workflows/intl4x_artifacts/main/lib-$platformName-latest.zip');
+ final request = await HttpClient().getUrl(uri);
final response = await request.close();
-
+ if (response.statusCode != 200) {
+ throw ArgumentError('The request to $uri failed');
+ }
final zippedDynamicLibrary =
File(path.join(Directory.systemTemp.path, 'tmp.zip'));
zippedDynamicLibrary.createSync();
await response.pipe(zippedDynamicLibrary.openWrite());
- final directory = await Directory.systemTemp.createTemp();
- final dynamicLibrary = File.fromUri(directory.uri.resolve('icu4xlib'));
+ final dynamicLibrary =
+ File.fromUri(config.outputDirectory.resolve('icu4xlib'));
await dynamicLibrary.create();
unzipFirstFile(input: zippedDynamicLibrary, output: dynamicLibrary);
return dynamicLibrary.uri;
@@ -136,92 +143,101 @@
}
Future<Uri> buildLib(BuildConfig config, String workingDirectory) async {
- final rustTarget = _asRustTarget(
- config.targetOS,
- config.targetArchitecture,
- config.targetOS == OS.iOS && config.targetIOSSdk == IOSSdk.iPhoneSimulator,
- );
- final isNoStd = _isNoStdTarget((config.targetOS, config.targetArchitecture));
+ final dylibFileName =
+ config.targetOS.dylibFileName(crateName.replaceAll('-', '_'));
+ final dylibFileUri = config.outputDirectory.resolve(dylibFileName);
+ if (!config.dryRun) {
+ final rustTarget = _asRustTarget(
+ config.targetOS,
+ config.dryRun ? null : config.targetArchitecture!,
+ config.targetOS == OS.iOS &&
+ config.targetIOSSdk == IOSSdk.iPhoneSimulator,
+ );
+ final isNoStd =
+ _isNoStdTarget((config.targetOS, config.targetArchitecture));
- if (!isNoStd) {
- final rustArguments = ['target', 'add', rustTarget];
- final rustup = await Process.run(
- 'rustup',
- rustArguments,
+ if (!isNoStd) {
+ final rustArguments = ['target', 'add', rustTarget];
+ final rustup = await Process.run(
+ 'rustup',
+ rustArguments,
+ workingDirectory: workingDirectory,
+ );
+
+ if (rustup.exitCode != 0) {
+ throw ProcessException(
+ 'rustup',
+ rustArguments,
+ rustup.stderr.toString(),
+ rustup.exitCode,
+ );
+ }
+ }
+ final tempDir = await Directory.systemTemp.createTemp();
+
+ final stdFeatures = [
+ 'default_components',
+ 'compiled_data',
+ 'buffer_provider',
+ 'logging',
+ 'simple_logger',
+ 'experimental_components',
+ ];
+ final noStdFeatures = [
+ 'default_components',
+ 'compiled_data',
+ 'buffer_provider',
+ 'libc-alloc',
+ 'panic-handler',
+ 'experimental_components',
+ ];
+ final linkModeType = config.linkModePreference == LinkModePreference.static
+ ? 'staticlib'
+ : 'cdylib';
+ final arguments = [
+ if (isNoStd) '+nightly',
+ 'rustc',
+ '-p=$crateName',
+ '--crate-type=$linkModeType',
+ '--release',
+ '--config=profile.release.panic="abort"',
+ '--config=profile.release.codegen-units=1',
+ '--no-default-features',
+ if (!isNoStd) '--features=${stdFeatures.join(',')}',
+ if (isNoStd) '--features=${noStdFeatures.join(',')}',
+ if (isNoStd) '-Zbuild-std=core,alloc',
+ if (isNoStd) '-Zbuild-std-features=panic_immediate_abort',
+ '--target=$rustTarget',
+ '--target-dir=${tempDir.path}'
+ ];
+ final cargo = await Process.run(
+ 'cargo',
+ arguments,
workingDirectory: workingDirectory,
);
- if (rustup.exitCode != 0) {
+ if (cargo.exitCode != 0) {
throw ProcessException(
- 'rustup',
- rustArguments,
- rustup.stderr.toString(),
- rustup.exitCode,
+ 'cargo',
+ arguments,
+ cargo.stderr.toString(),
+ cargo.exitCode,
);
}
- }
- final stdFeatures = [
- 'default_components',
- 'compiled_data',
- 'buffer_provider',
- 'logging',
- 'simple_logger',
- 'experimental_components',
- ];
- final noStdFeatures = [
- 'default_components',
- 'compiled_data',
- 'buffer_provider',
- 'libc-alloc',
- 'panic-handler',
- 'experimental_components',
- ];
- final tempDir = Directory.systemTemp.createTempSync();
- final linkModeType = config.linkModePreference == LinkModePreference.static
- ? 'staticlib'
- : 'cdylib';
- final arguments = [
- if (isNoStd) '+nightly',
- 'rustc',
- '-p=$crateName',
- '--crate-type=$linkModeType',
- '--release',
- '--config=profile.release.panic="abort"',
- '--config=profile.release.codegen-units=1',
- '--no-default-features',
- if (!isNoStd) '--features=${stdFeatures.join(',')}',
- if (isNoStd) '--features=${noStdFeatures.join(',')}',
- if (isNoStd) '-Zbuild-std=core,alloc',
- if (isNoStd) '-Zbuild-std-features=panic_immediate_abort',
- '--target=$rustTarget',
- '--target-dir=${tempDir.path}'
- ];
- final cargo = await Process.run(
- 'cargo',
- arguments,
- workingDirectory: workingDirectory,
- );
-
- if (cargo.exitCode != 0) {
- throw ProcessException(
- 'cargo',
- arguments,
- cargo.stderr.toString(),
- cargo.exitCode,
+ final builtPath = path.join(
+ tempDir.path,
+ rustTarget,
+ 'release',
+ dylibFileName,
);
+ final file = File(builtPath);
+ if (!(await file.exists())) {
+ throw FileSystemException('Building the dylib failed', builtPath);
+ }
+ await file.copy(dylibFileUri.path);
}
-
- final dylibFilePath = path.join(
- tempDir.path,
- rustTarget,
- 'release',
- config.targetOS.dylibFileName(crateName.replaceAll('-', '_')),
- );
- if (!File(dylibFilePath).existsSync()) {
- throw FileSystemException('Building the dylib failed', dylibFilePath);
- }
- return Uri.file(dylibFilePath);
+ return dylibFileUri;
}
String _asRustTarget(OS os, Architecture? architecture, bool isSimulator) {
@@ -249,7 +265,8 @@
(OS.windows, Architecture.arm64) => 'aarch64-pc-windows-msvc',
(OS.windows, Architecture.ia32) => 'i686-pc-windows-msvc',
(OS.windows, Architecture.x64) => 'x86_64-pc-windows-msvc',
- (_, _) => throw UnimplementedError('Target not available for rust'),
+ (_, _) => throw UnimplementedError(
+ 'Target ${(os, architecture)} not available for rust'),
};
}
diff --git a/pkgs/intl4x/pubspec.yaml b/pkgs/intl4x/pubspec.yaml
index 09af2d6..8564727 100644
--- a/pkgs/intl4x/pubspec.yaml
+++ b/pkgs/intl4x/pubspec.yaml
@@ -1,7 +1,7 @@
name: intl4x
description: >-
A lightweight modular library for internationalization (i18n) functionality.
-version: 0.9.0
+version: 0.9.1
repository: https://github.com/dart-lang/i18n/tree/main/pkgs/intl4x
platforms:
web:
@@ -17,16 +17,16 @@
sdk: ">=3.3.0 <4.0.0"
dependencies:
+ archive: ^3.4.10
ffi: ^2.1.0
js: ^0.7.1
meta: ^1.12.0
native_assets_cli: ^0.6.0
+ path: ^1.9.0
dev_dependencies:
- archive: ^3.4.10
args: ^2.4.2
collection: ^1.18.0
dart_flutter_team_lints: ^3.1.0
lints: ^4.0.0
- path: ^1.9.0
test: ^1.22.1