Skip to content

Commit

Permalink
Fix linking to fetch the libraries from Github (#877)
Browse files Browse the repository at this point in the history
* Fix linking to fetch the libraries from Github

* Merge branch 'main' into fetchDyLibsOnly

* Set version

* Only generate datagen and data files for static

* Regenerate hashes

* Add changelog

* Add todo
  • Loading branch information
mosuem authored Aug 22, 2024
1 parent b23879b commit 4796ea1
Show file tree
Hide file tree
Showing 7 changed files with 102 additions and 64 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/intl4x_artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ jobs:
dart run ffi/dart/tool/build_libs.dart bin/linux_riscv64_${{ matrix.compiletype }} linux_riscv64 ${{ matrix.compiletype }} icu_collator,icu_datetime,icu_list,icu_decimal,icu_plurals,experimental_components${{ env.DATA }}
dart run ffi/dart/tool/build_libs.dart bin/linux_x64_${{ matrix.compiletype }} linux_x64 ${{ matrix.compiletype }} icu_collator,icu_datetime,icu_list,icu_decimal,icu_plurals,experimental_components${{ env.DATA }}
- name: Build Linux data
if: matrix.os == 'ubuntu-latest' && matrix.compiletype == 'static'
run: |
cargo run -p icu_datagen -- --locales full --keys all --format blob --out bin/full.postcard
cd provider/datagen # avoid global feature resolution
Expand Down Expand Up @@ -108,6 +111,9 @@ jobs:
dart run ffi/dart/tool/build_libs.dart bin/macos_arm64_${{ matrix.compiletype }} macos_arm64 ${{ matrix.compiletype }} icu_collator,icu_datetime,icu_list,icu_decimal,icu_plurals,experimental_components${{ env.DATA }}
dart run ffi/dart/tool/build_libs.dart bin/macos_x64_${{ matrix.compiletype }} macos_x64 ${{ matrix.compiletype }} icu_collator,icu_datetime,icu_list,icu_decimal,icu_plurals,experimental_components${{ env.DATA }}
- name: Build Mac data
if: matrix.os == 'macos-latest' && matrix.compiletype == 'static'
run: |
cd provider/datagen # avoid global feature resolution
rustup target add aarch64-apple-darwin
cargo build --release --bin icu4x-datagen --no-default-features --features bin,blob_exporter,blob_input,rayon,experimental_components --target aarch64-apple-darwin
Expand All @@ -132,6 +138,9 @@ jobs:
dart run ffi/dart/tool/build_libs.dart bin/windows_ia32_${{ matrix.compiletype }} windows_ia32 ${{ matrix.compiletype }} icu_collator,icu_datetime,icu_list,icu_decimal,icu_plurals,experimental_components${{ env.DATA }}
dart run ffi/dart/tool/build_libs.dart bin/windows_x64_${{ matrix.compiletype }} windows_x64 ${{ matrix.compiletype }} icu_collator,icu_datetime,icu_list,icu_decimal,icu_plurals,experimental_components${{ env.DATA }}
- name: Build Windows data
if: matrix.os == 'windows-latest' && matrix.compiletype == 'static'
run: |
cd provider/datagen # avoid global feature resolution
rustup target add aarch64-pc-windows-msvc
cargo build --release --bin icu4x-datagen --no-default-features --features bin,blob_exporter,blob_input,rayon,experimental_components --target aarch64-pc-windows-msvc
Expand Down
4 changes: 4 additions & 0 deletions pkgs/intl4x/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.10.1

- Upgrade to new artifacts.

## 0.10.0

- Upgrade minimum SDK to `3.6.0-0`.
Expand Down
23 changes: 13 additions & 10 deletions pkgs/intl4x/hook/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,30 @@ final class FetchMode extends BuildMode {

@override
Future<Uri> build() async {
final target = '${config.targetOS}_${config.targetArchitecture}';
final libraryType = 'dynamic'; //TODO: Add `static` when using link hooks.
final target = [
config.targetOS,
config.targetArchitecture,
libraryType,
].join('_');
final uri = Uri.parse(
'https://github.com/dart-lang/i18n/releases/download/$version/$target');
final request = await HttpClient().getUrl(uri);
final response = await request.close();
if (response.statusCode != 200) {
throw ArgumentError('The request to $uri failed');
}
final dynamicLibrary = File.fromUri(
final library = File.fromUri(
config.outputDirectory.resolve(config.targetOS.dylibFileName('icu4x')));
await dynamicLibrary.create();
await response.pipe(dynamicLibrary.openWrite());
await library.create();
await response.pipe(library.openWrite());

final bytes = await dynamicLibrary.readAsBytes();
final bytes = await library.readAsBytes();
final fileHash = sha256.convert(bytes).toString();
final expectedFileHash = fileHashes[(
config.targetOS,
config.targetArchitecture,
)];
final expectedFileHash =
fileHashes[(config.targetOS, config.targetArchitecture, libraryType)];
if (fileHash == expectedFileHash) {
return dynamicLibrary.uri;
return library.uri;
} else {
throw Exception(
'The pre-built binary for the target $target at $uri has a hash of '
Expand Down
84 changes: 58 additions & 26 deletions pkgs/intl4x/lib/src/hook_helpers/hashes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,69 @@

import 'package:native_assets_cli/native_assets_cli.dart';

const fileHashes = <(OS, Architecture), String>{
(OS.android, Architecture.arm):
const fileHashes = <(OS, Architecture, String), String>{
(OS.linux, Architecture.arm, 'dynamic'):
'6ec82cb099ef709d1e8c66232d39f58c814a53774f48f8b64a764aae8f334b5d',
(OS.linux, Architecture.arm, 'static'):
'477bdc9b9fdf17a03a02e0c447c628589c5a4e60eeb4792d0906ad410965d7b9',
(OS.linux, Architecture.arm64, 'dynamic'):
'9a4949f77209adcf7791bf257684f953f89fb36bdb00c52ee54e14590436ba47',
(OS.linux, Architecture.arm64, 'static'):
'a66d606106a48abf85e226fde4ce3a91732bbbf5ac812b556acc84ded07f1f7d',
(OS.linux, Architecture.riscv64, 'dynamic'):
'9b85cf853f444efa5b3ef91a5768b57760033a2d4925abca6035db48a83809d1',
(OS.linux, Architecture.riscv64, 'static'):
'c24d54228c8def4df39130c8b29cc14efb80cf1b6aa53944d332371a910a495f',
(OS.linux, Architecture.x64, 'dynamic'):
'fd487400dcacb3b0c8feffcfec33badc0b9b5840d22d6a0005780dc85a48faa8',
(OS.linux, Architecture.x64, 'static'):
'e31df98b342f2d6704e3e5044d7fd98859d1503b20f70a71a1cb16ae0e7bf1fc',
(OS.windows, Architecture.arm64, 'dynamic'):
'57de333da821ab322d14292b60eef6d3718f526595e23256663381e9b4079ba3',
(OS.windows, Architecture.arm64, 'static'):
'3f4ab1d049a47be7cc5ae0ef5c0b31b8cd8fef48d9e5c2d786dc369bee8ae36a',
(OS.windows, Architecture.ia32, 'dynamic'):
'ac89af848d8fadc587f2b53622256b9a27424c4c8b8eeb984ce7653f8651f6b9',
(OS.windows, Architecture.ia32, 'static'):
'6a0faf438a90e0d815cd0ce0d7d9d5cd0149a966481641bceb3b6a1d64e02a52',
(OS.windows, Architecture.x64, 'dynamic'):
'fa8d4cf36dc0be244ddcae01822cda3561f87c7933c51667b9d7c95cee6ade0e',
(OS.windows, Architecture.x64, 'static'):
'220654958a23eab3e3d6307ed7bd834f49137dee7a21ae9b05ee6dc666277cfd',
(OS.android, Architecture.arm, 'dynamic'):
'a14fd80a9f3bf2a208a125d75a1b6a7315911f258df56ab1992c8b45c9d2d0e8',
(OS.android, Architecture.arm64):
(OS.android, Architecture.arm, 'static'):
'3f3ba266a1f598e2caa794cb631c140251a6ad871580f67fe1498bce6352c234',
(OS.android, Architecture.arm64, 'dynamic'):
'6af7c598c2c271bf98742006a5fdc43d0298f2047e4db694c46d8cc433dbbdd0',
(OS.android, Architecture.ia32):
(OS.android, Architecture.arm64, 'static'):
'48bd4c2b5358f7e66ecca8236bddf01e51fc31eb522fb1599a30e80180800495',
(OS.android, Architecture.ia32, 'dynamic'):
'e65d69207035123fb1d3fb2bb50427720da7407cd15e26f163fc8297da017df1',
(OS.android, Architecture.x64):
(OS.android, Architecture.ia32, 'static'):
'65f6c8298f14db341e59c8c277294240271fcb05af7c150eed22a17dcf77715b',
(OS.android, Architecture.x64, 'dynamic'):
'f36899c73b114255321d65aaf92e159be2e78682b2a6d5181c77c74e8bdf9714',
(OS.iOS, Architecture.arm):
(OS.android, Architecture.x64, 'static'):
'146530b72ea8ac8c3a0aed58156cc169fdf6261bcd6daa8bb8a5958d021eeba8',
(OS.macOS, Architecture.arm64, 'dynamic'):
'c20e9c55a926496928952cbb16638fb0eec1e609cc25f3c7d04a170946152b4b',
(OS.macOS, Architecture.arm64, 'static'):
'fc2a9ec58c260fb05969a8c5dae93f6b856edf2d6a1d33dcc03889984dbbbf45',
(OS.macOS, Architecture.x64, 'dynamic'):
'603f46a97ac2ad1d5a6a5c06b013283a5a76a8e8fd4e337561bfe71e536ee95d',
(OS.macOS, Architecture.x64, 'static'):
'08e8d0d5716f3826721d85dbfbec3bcabd211dc5c9394b2ba72f9b68796da001',
(OS.iOS, Architecture.arm, 'dynamic'):
'2b830c4a0f2d9ba924d66b5a634695c0f7c582fc2ee4b1c2f56dda1d6de75168',
(OS.iOS, Architecture.arm64):
(OS.iOS, Architecture.arm, 'static'):
'271e4b528b1918b7eec9459804191b7ccd9c83b9fef234f9105e49cc45cc0b5c',
(OS.iOS, Architecture.arm64, 'dynamic'):
'bba88339a5bff91f558c7e01402fa2d7146e36cb5e448874bd77382c5f8164a3',
(OS.iOS, Architecture.x64):
(OS.iOS, Architecture.arm64, 'static'):
'c396c3acf90c462abc7f858687ad0edd1625bdc1bc150993c84b6d76df942c33',
(OS.iOS, Architecture.x64, 'dynamic'):
'4b23970d8c08401152705b52b7e830bf79434c7a5ee180b5413820e9df961218',
(OS.linux, Architecture.arm):
'6ec82cb099ef709d1e8c66232d39f58c814a53774f48f8b64a764aae8f334b5d',
(OS.linux, Architecture.arm64):
'9a4949f77209adcf7791bf257684f953f89fb36bdb00c52ee54e14590436ba47',
(OS.linux, Architecture.riscv64):
'9b85cf853f444efa5b3ef91a5768b57760033a2d4925abca6035db48a83809d1',
(OS.linux, Architecture.x64):
'fd487400dcacb3b0c8feffcfec33badc0b9b5840d22d6a0005780dc85a48faa8',
(OS.macOS, Architecture.arm64):
'c20e9c55a926496928952cbb16638fb0eec1e609cc25f3c7d04a170946152b4b',
(OS.macOS, Architecture.x64):
'603f46a97ac2ad1d5a6a5c06b013283a5a76a8e8fd4e337561bfe71e536ee95d',
(OS.windows, Architecture.arm64):
'c0962d443478693c364b4e67cebc01bee04edc63da6f5c0cec85eb14b36bfc93',
(OS.windows, Architecture.ia32):
'dccc67f886aa79cf265967cf3ff597fb8bf367c4bd47ead4d282c1080a659a92',
(OS.windows, Architecture.x64):
'a67e444cc8788416f51c003d4e79e8805eab9de3ec6b44067aa74a1d7a41a107'
(OS.iOS, Architecture.x64, 'static'):
'6e4e4072126b3017c6a532575a165d1a80b2bccb59a24108682483935c98ff19'
};
2 changes: 1 addition & 1 deletion pkgs/intl4x/lib/src/hook_helpers/version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

const version = 'intl4x-icu-v.0.9.2+1-artifacts';
const version = 'intl4x-icu-v.0.9.2+3-artifacts';
2 changes: 1 addition & 1 deletion pkgs/intl4x/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: intl4x
description: >-
A lightweight modular library for internationalization (i18n) functionality.
version: 0.10.0
version: 0.10.1
repository: https://github.com/dart-lang/i18n/tree/main/pkgs/intl4x
platforms:
web:
Expand Down
42 changes: 16 additions & 26 deletions pkgs/intl4x/tool/regenerate_hashes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@ final httpClient = HttpClient();

Future<void> main(List<String> args) async {
print('Checking hashes for $version');
final fileHashes = <(OS, Architecture), String>{};
final fileHashes = <(String, Architecture, String), String>{};
final dynamicLibrary = File.fromUri(Directory.systemTemp.uri.resolve('lib'));
await dynamicLibrary.create();
for (final os in OS.values) {
for (final os in ['linux', 'windows', 'fuchsia', 'android', 'macOS', 'iOS']) {
for (final architecture in Architecture.values) {
final target = '${os}_$architecture';
print('Checking hash for $target');
final success = await _fetchLibrary(target, httpClient, dynamicLibrary);
if (success) {
final bytes = await dynamicLibrary.readAsBytes();
final fileHash = sha256.convert(bytes).toString();
fileHashes[(os, architecture)] = fileHash;
print('Hash is $fileHash');
} else {
print('Could not fetch library');
for (final libraryType in ['dynamic', 'static']) {
final target = [os, architecture, libraryType].join('_');
print('Checking hash for $target');
final success = await _fetchLibrary(target, httpClient, dynamicLibrary);
if (success) {
final bytes = await dynamicLibrary.readAsBytes();
final fileHash = sha256.convert(bytes).toString();
fileHashes[(os, architecture, libraryType)] = fileHash;
print('Hash is $fileHash');
} else {
print('Could not fetch library');
}
}
}
}
Expand All @@ -40,9 +42,9 @@ Future<void> main(List<String> args) async {
import 'package:native_assets_cli/native_assets_cli.dart';
const fileHashes = <(OS, Architecture), String>{
const fileHashes = <(OS, Architecture, String), String>{
${fileHashes.map((key, value) => MapEntry(
('OS.${key.$1.varName}', 'Architecture.${key.$2}'),
('OS.${key.$1}', 'Architecture.${key.$2}', "'${key.$3}'"),
"'$value'",
)).entries.map(
(e) => ' ${e.key}:\n ${e.value}',
Expand All @@ -65,15 +67,3 @@ Future<bool> _fetchLibrary(
await response.pipe(dynamicLibrary.openWrite());
return true;
}

extension OSExt on OS {
String get varName => switch (this) {
OS.linux => 'linux',
OS.windows => 'windows',
OS.fuchsia => 'fuchsia',
OS.android => 'android',
OS.macOS => 'macOS',
OS.iOS => 'iOS',
OS() => throw UnimplementedError(),
};
}

0 comments on commit 4796ea1

Please sign in to comment.