Skip to content

Commit 8d63e87

Browse files
authored
Switch to copying ICU4X Dart files (#860)
* Switch to copying ICU4X files instead of using symlinks * Switch files to copies * Switch to Dart fix branch * Use dart format * Format files * Add changelog entry * Add flags to building libraries * Add gitattributes * Add newline
1 parent 332b1a3 commit 8d63e87

File tree

129 files changed

+14497
-146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+14497
-146
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pkgs/intl4x/lib/src/bindings linguist-generated=true

.github/workflows/intl4x_artifacts.yml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ permissions:
66
on:
77
push:
88
tags:
9-
- 'intl4x-v.*'
9+
- 'intl4x-icu*'
10+
schedule:
11+
- cron: '0 0 * * 0' # weekly
1012
workflow_dispatch:
1113

1214
jobs:
1315
dart-libs:
14-
name: "Build Dart binaries"
16+
name: Build Dart binaries
1517
strategy:
1618
fail-fast: false
1719
matrix:
@@ -21,7 +23,7 @@ jobs:
2123
steps:
2224
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
2325
with:
24-
submodules: 'true'
26+
submodules: true
2527

2628
- name: Install Rust toolchains
2729
run: |
@@ -59,14 +61,14 @@ jobs:
5961
cd ffi/dart
6062
dart pub get
6163
cd ../..
62-
dart run ffi/dart/tool/build_libs.dart bin/android_arm android_arm
63-
dart run ffi/dart/tool/build_libs.dart bin/android_arm64 android_arm64
64-
dart run ffi/dart/tool/build_libs.dart bin/android_ia32 android_ia32
65-
dart run ffi/dart/tool/build_libs.dart bin/android_x64 android_x64
66-
dart run ffi/dart/tool/build_libs.dart bin/linux_arm linux_arm
67-
dart run ffi/dart/tool/build_libs.dart bin/linux_arm64 linux_arm64
68-
dart run ffi/dart/tool/build_libs.dart bin/linux_riscv64 linux_riscv64
69-
dart run ffi/dart/tool/build_libs.dart bin/linux_x64 linux_x64
64+
dart run ffi/dart/tool/build_libs.dart bin/android_arm android_arm dynamic default_components,experimental_components
65+
dart run ffi/dart/tool/build_libs.dart bin/android_arm64 android_arm64 dynamic default_components,experimental_components
66+
dart run ffi/dart/tool/build_libs.dart bin/android_ia32 android_ia32 dynamic default_components,experimental_components
67+
dart run ffi/dart/tool/build_libs.dart bin/android_x64 android_x64 dynamic default_components,experimental_components
68+
dart run ffi/dart/tool/build_libs.dart bin/linux_arm linux_arm dynamic default_components,experimental_components
69+
dart run ffi/dart/tool/build_libs.dart bin/linux_arm64 linux_arm64 dynamic default_components,experimental_components
70+
dart run ffi/dart/tool/build_libs.dart bin/linux_riscv64 linux_riscv64 dynamic default_components,experimental_components
71+
dart run ffi/dart/tool/build_libs.dart bin/linux_x64 linux_x64 dynamic default_components,experimental_components
7072
7173
cargo run -p icu_datagen -- --locales full --keys all --format blob --out bin/full.postcard
7274
@@ -93,11 +95,11 @@ jobs:
9395
cd ffi/dart
9496
dart pub get
9597
cd ../..
96-
dart run ffi/dart/tool/build_libs.dart bin/ios_arm ios_arm
97-
dart run ffi/dart/tool/build_libs.dart bin/ios_arm64 ios_arm64
98-
dart run ffi/dart/tool/build_libs.dart bin/ios_x64 ios_x64
99-
dart run ffi/dart/tool/build_libs.dart bin/macos_arm64 macos_arm64
100-
dart run ffi/dart/tool/build_libs.dart bin/macos_x64 macos_x64
98+
dart run ffi/dart/tool/build_libs.dart bin/ios_arm ios_arm dynamic default_components,experimental_components
99+
dart run ffi/dart/tool/build_libs.dart bin/ios_arm64 ios_arm64 dynamic default_components,experimental_components
100+
dart run ffi/dart/tool/build_libs.dart bin/ios_x64 ios_x64 dynamic default_components,experimental_components
101+
dart run ffi/dart/tool/build_libs.dart bin/macos_arm64 macos_arm64 dynamic default_components,experimental_components
102+
dart run ffi/dart/tool/build_libs.dart bin/macos_x64 macos_x64 dynamic default_components,experimental_components
101103
102104
cd provider/datagen # avoid global feature resolution
103105
rustup target add aarch64-apple-darwin
@@ -119,9 +121,9 @@ jobs:
119121
cd ffi/dart
120122
dart pub get
121123
cd ../..
122-
dart run ffi/dart/tool/build_libs.dart bin/windows_arm64 windows_arm64
123-
dart run ffi/dart/tool/build_libs.dart bin/windows_ia32 windows_ia32
124-
dart run ffi/dart/tool/build_libs.dart bin/windows_x64 windows_x64
124+
dart run ffi/dart/tool/build_libs.dart bin/windows_arm64 windows_arm64 dynamic default_components,experimental_components
125+
dart run ffi/dart/tool/build_libs.dart bin/windows_ia32 windows_ia32 dynamic default_components,experimental_components
126+
dart run ffi/dart/tool/build_libs.dart bin/windows_x64 windows_x64 dynamic default_components,experimental_components
125127
126128
cd provider/datagen # avoid global feature resolution
127129
rustup target add aarch64-pc-windows-msvc
@@ -155,4 +157,4 @@ jobs:
155157
with:
156158
files: '**'
157159
fail_on_unmatched_files: true
158-
body: "Build artifacts for `package:intl4x`, based on ICU4X at ref ${{ env.icu_version }}"
160+
body: "Build artifacts for `package:intl4x`, based on ICU4X at ref ${{ github.ref_name }}"

pkgs/intl4x/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.9.2-wip
2+
3+
- Copy files instead of symlinking, for easier upgrading.
4+
15
## 0.9.1
26

37
- Small fixes in imports

pkgs/intl4x/lib/src/bindings/AnyCalendarKind.g.dart

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
// generated by diplomat-tool
2+
3+
part of 'lib.g.dart';
4+
5+
/// The various calendar types currently supported by [`Calendar`]
6+
///
7+
/// See the [Rust documentation for `AnyCalendarKind`](https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendarKind.html) for more information.
8+
enum AnyCalendarKind {
9+
/// The kind of an Iso calendar
10+
iso,
11+
12+
/// The kind of a Gregorian calendar
13+
gregorian,
14+
15+
/// The kind of a Buddhist calendar
16+
buddhist,
17+
18+
/// The kind of a Japanese calendar with modern eras
19+
japanese,
20+
21+
/// The kind of a Japanese calendar with modern and historic eras
22+
japaneseExtended,
23+
24+
/// The kind of an Ethiopian calendar, with Amete Mihret era
25+
ethiopian,
26+
27+
/// The kind of an Ethiopian calendar, with Amete Alem era
28+
ethiopianAmeteAlem,
29+
30+
/// The kind of a Indian calendar
31+
indian,
32+
33+
/// The kind of a Coptic calendar
34+
coptic,
35+
36+
/// The kind of a Dangi calendar
37+
dangi,
38+
39+
/// The kind of a Chinese calendar
40+
chinese,
41+
42+
/// The kind of a Hebrew calendar
43+
hebrew,
44+
45+
/// The kind of a Islamic civil calendar
46+
islamicCivil,
47+
48+
/// The kind of a Islamic observational calendar
49+
islamicObservational,
50+
51+
/// The kind of a Islamic tabular calendar
52+
islamicTabular,
53+
54+
/// The kind of a Islamic Umm al-Qura calendar
55+
islamicUmmAlQura,
56+
57+
/// The kind of a Persian calendar
58+
persian,
59+
60+
/// The kind of a Roc calendar
61+
roc;
62+
63+
/// Read the calendar type off of the -u-ca- extension on a locale.
64+
///
65+
/// Returns nothing if there is no calendar on the locale or if the locale's calendar
66+
/// is not known or supported.
67+
///
68+
/// See the [Rust documentation for `get_for_locale`](https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendarKind.html#method.get_for_locale) for more information.
69+
static AnyCalendarKind? getForLocale(Locale locale) {
70+
final result = _ICU4XAnyCalendarKind_get_for_locale(locale._ffi);
71+
if (!result.isOk) {
72+
return null;
73+
}
74+
return AnyCalendarKind.values[result.union.ok];
75+
}
76+
77+
/// Obtain the calendar type given a BCP-47 -u-ca- extension string.
78+
///
79+
/// Returns nothing if the calendar is not known or supported.
80+
///
81+
/// See the [Rust documentation for `get_for_bcp47_value`](https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendarKind.html#method.get_for_bcp47_value) for more information.
82+
static AnyCalendarKind? getForBcp47(String s) {
83+
final temp = ffi2.Arena();
84+
final sView = s.utf8View;
85+
final result =
86+
_ICU4XAnyCalendarKind_get_for_bcp47(sView.allocIn(temp), sView.length);
87+
temp.releaseAll();
88+
if (!result.isOk) {
89+
return null;
90+
}
91+
return AnyCalendarKind.values[result.union.ok];
92+
}
93+
94+
/// Obtain the string suitable for use in the -u-ca- extension in a BCP47 locale.
95+
///
96+
/// See the [Rust documentation for `as_bcp47_string`](https://docs.rs/icu/latest/icu/calendar/enum.AnyCalendarKind.html#method.as_bcp47_string) for more information.
97+
///
98+
/// Throws [Error] on failure.
99+
String get bcp47 {
100+
final writeable = _Writeable();
101+
final result = _ICU4XAnyCalendarKind_bcp47(index, writeable._ffi);
102+
if (!result.isOk) {
103+
throw Error.values.firstWhere((v) => v._ffi == result.union.err);
104+
}
105+
return writeable.finalize();
106+
}
107+
}
108+
109+
@meta.ResourceIdentifier('ICU4XAnyCalendarKind_get_for_locale')
110+
@ffi.Native<_ResultInt32Void Function(ffi.Pointer<ffi.Opaque>)>(
111+
isLeaf: true, symbol: 'ICU4XAnyCalendarKind_get_for_locale')
112+
// ignore: non_constant_identifier_names
113+
external _ResultInt32Void _ICU4XAnyCalendarKind_get_for_locale(
114+
ffi.Pointer<ffi.Opaque> locale);
115+
116+
@meta.ResourceIdentifier('ICU4XAnyCalendarKind_get_for_bcp47')
117+
@ffi.Native<_ResultInt32Void Function(ffi.Pointer<ffi.Uint8>, ffi.Size)>(
118+
isLeaf: true, symbol: 'ICU4XAnyCalendarKind_get_for_bcp47')
119+
// ignore: non_constant_identifier_names
120+
external _ResultInt32Void _ICU4XAnyCalendarKind_get_for_bcp47(
121+
ffi.Pointer<ffi.Uint8> sData, int sLength);
122+
123+
@meta.ResourceIdentifier('ICU4XAnyCalendarKind_bcp47')
124+
@ffi.Native<_ResultVoidInt32 Function(ffi.Int32, ffi.Pointer<ffi.Opaque>)>(
125+
isLeaf: true, symbol: 'ICU4XAnyCalendarKind_bcp47')
126+
// ignore: non_constant_identifier_names
127+
external _ResultVoidInt32 _ICU4XAnyCalendarKind_bcp47(
128+
int self, ffi.Pointer<ffi.Opaque> writeable);

pkgs/intl4x/lib/src/bindings/Bcp47ToIanaMapper.g.dart

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// generated by diplomat-tool
2+
3+
part of 'lib.g.dart';
4+
5+
/// An object capable of mapping from a BCP-47 time zone ID to an IANA ID.
6+
///
7+
/// See the [Rust documentation for `IanaBcp47RoundTripMapper`](https://docs.rs/icu/latest/icu/timezone/struct.IanaBcp47RoundTripMapper.html) for more information.
8+
final class Bcp47ToIanaMapper implements ffi.Finalizable {
9+
final ffi.Pointer<ffi.Opaque> _ffi;
10+
11+
// These are "used" in the sense that they keep dependencies alive
12+
// ignore: unused_field
13+
final core.List<Object> _selfEdge;
14+
15+
// This takes in a list of lifetime edges (including for &self borrows)
16+
// corresponding to data this may borrow from. These should be flat arrays containing
17+
// references to objects, and this object will hold on to them to keep them alive and
18+
// maintain borrow validity.
19+
Bcp47ToIanaMapper._fromFfi(this._ffi, this._selfEdge) {
20+
if (_selfEdge.isEmpty) {
21+
_finalizer.attach(this, _ffi.cast());
22+
}
23+
}
24+
25+
static final _finalizer = ffi.NativeFinalizer(
26+
ffi.Native.addressOf(_ICU4XBcp47ToIanaMapper_destroy));
27+
28+
/// See the [Rust documentation for `new`](https://docs.rs/icu/latest/icu/timezone/struct.IanaBcp47RoundTripMapper.html#method.new) for more information.
29+
///
30+
/// Throws [Error] on failure.
31+
factory Bcp47ToIanaMapper(DataProvider provider) {
32+
final result = _ICU4XBcp47ToIanaMapper_create(provider._ffi);
33+
if (!result.isOk) {
34+
throw Error.values.firstWhere((v) => v._ffi == result.union.err);
35+
}
36+
return Bcp47ToIanaMapper._fromFfi(result.union.ok, []);
37+
}
38+
39+
/// Writes out the canonical IANA time zone ID corresponding to the given BCP-47 ID.
40+
///
41+
/// See the [Rust documentation for `bcp47_to_iana`](https://docs.rs/icu/latest/icu/timezone/struct.IanaBcp47RoundTripMapperBorrowed.html#method.bcp47_to_iana) for more information.
42+
///
43+
/// Throws [Error] on failure.
44+
String operator [](String value) {
45+
final temp = ffi2.Arena();
46+
final valueView = value.utf8View;
47+
final writeable = _Writeable();
48+
final result = _ICU4XBcp47ToIanaMapper_get(
49+
_ffi, valueView.allocIn(temp), valueView.length, writeable._ffi);
50+
temp.releaseAll();
51+
if (!result.isOk) {
52+
throw Error.values.firstWhere((v) => v._ffi == result.union.err);
53+
}
54+
return writeable.finalize();
55+
}
56+
}
57+
58+
@meta.ResourceIdentifier('ICU4XBcp47ToIanaMapper_destroy')
59+
@ffi.Native<ffi.Void Function(ffi.Pointer<ffi.Void>)>(
60+
isLeaf: true, symbol: 'ICU4XBcp47ToIanaMapper_destroy')
61+
// ignore: non_constant_identifier_names
62+
external void _ICU4XBcp47ToIanaMapper_destroy(ffi.Pointer<ffi.Void> self);
63+
64+
@meta.ResourceIdentifier('ICU4XBcp47ToIanaMapper_create')
65+
@ffi.Native<_ResultOpaqueInt32 Function(ffi.Pointer<ffi.Opaque>)>(
66+
isLeaf: true, symbol: 'ICU4XBcp47ToIanaMapper_create')
67+
// ignore: non_constant_identifier_names
68+
external _ResultOpaqueInt32 _ICU4XBcp47ToIanaMapper_create(
69+
ffi.Pointer<ffi.Opaque> provider);
70+
71+
@meta.ResourceIdentifier('ICU4XBcp47ToIanaMapper_get')
72+
@ffi.Native<
73+
_ResultVoidInt32 Function(ffi.Pointer<ffi.Opaque>,
74+
ffi.Pointer<ffi.Uint8>, ffi.Size, ffi.Pointer<ffi.Opaque>)>(
75+
isLeaf: true, symbol: 'ICU4XBcp47ToIanaMapper_get')
76+
// ignore: non_constant_identifier_names
77+
external _ResultVoidInt32 _ICU4XBcp47ToIanaMapper_get(
78+
ffi.Pointer<ffi.Opaque> self,
79+
ffi.Pointer<ffi.Uint8> valueData,
80+
int valueLength,
81+
ffi.Pointer<ffi.Opaque> writeable);

pkgs/intl4x/lib/src/bindings/Bidi.g.dart

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)