Skip to content

Commit 9b957d1

Browse files
Merge branch 'main' into japanext
2 parents 592d46e + e0c2dad commit 9b957d1

File tree

17 files changed

+161
-238
lines changed

17 files changed

+161
-238
lines changed

.github/workflows/artifacts-build.yml

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ jobs:
648648
runs-on: ${{ matrix.os }}
649649
env:
650650
FEATURES: ${{ matrix.include_data == true && 'default_components,experimental,buffer_provider,compiled_data' || 'default_components,experimental,buffer_provider' }}
651-
FILENAME_SUFFIX: ${{ matrix.compiletype == 'static' && matrix.include_data == true && '-with_data' || '' }}
651+
FILENAME_SUFFIX: ${{ matrix.include_data == true && '-with_data' || '' }}
652652

653653
steps:
654654
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
@@ -661,13 +661,10 @@ jobs:
661661
- name: Show the selected Rust toolchain
662662
run: rustup show
663663

664-
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
665-
with:
666-
sdk: main
667-
668664
- name: Setup additional linkers
669665
if: matrix.os == 'ubuntu-latest'
670666
run: |
667+
sudo apt-get update
671668
sudo apt-get install gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf gcc-riscv64-linux-gnu gcc-i686-linux-gnu
672669
mkdir -p .cargo
673670
echo "[target]" >> .cargo/config.toml
@@ -683,18 +680,16 @@ jobs:
683680
- name: Build Linux
684681
if: matrix.os == 'ubuntu-latest'
685682
run: |
686-
(cd ffi/dart && dart pub get)
687-
688683
mkdir bin
689-
690-
dart ffi/dart/lib/src/hook_helpers/build_libs.dart --working_directory . --file bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-armv7-linux-androideabi --target armv7-linux-androideabi --compile_type ${{ matrix.compiletype }} --cargo_features ${{ env.FEATURES }}
691-
dart ffi/dart/lib/src/hook_helpers/build_libs.dart --working_directory . --file bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-aarch64-linux-android --target aarch64-linux-android --compile_type ${{ matrix.compiletype }} --cargo_features ${{ env.FEATURES }}
692-
dart ffi/dart/lib/src/hook_helpers/build_libs.dart --working_directory . --file bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-i686-linux-android --target i686-linux-android --compile_type ${{ matrix.compiletype }} --cargo_features ${{ env.FEATURES }}
693-
dart ffi/dart/lib/src/hook_helpers/build_libs.dart --working_directory . --file bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-x86_64-linux-android --target x86_64-linux-android --compile_type ${{ matrix.compiletype }} --cargo_features ${{ env.FEATURES }}
694-
dart ffi/dart/lib/src/hook_helpers/build_libs.dart --working_directory . --file bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-armv7-unknown-linux-gnueabihf --target armv7-unknown-linux-gnueabihf --compile_type ${{ matrix.compiletype }} --cargo_features ${{ env.FEATURES }}
695-
dart ffi/dart/lib/src/hook_helpers/build_libs.dart --working_directory . --file bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-aarch64-unknown-linux-gnu --target aarch64-unknown-linux-gnu --compile_type ${{ matrix.compiletype }} --cargo_features ${{ env.FEATURES }}
696-
dart ffi/dart/lib/src/hook_helpers/build_libs.dart --working_directory . --file bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-riscv64gc-unknown-linux-gnu --target riscv64gc-unknown-linux-gnu --compile_type ${{ matrix.compiletype }} --cargo_features ${{ env.FEATURES }}
697-
dart ffi/dart/lib/src/hook_helpers/build_libs.dart --working_directory . --file bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-x86_64-unknown-linux-gnu --target x86_64-unknown-linux-gnu --compile_type ${{ matrix.compiletype }} --cargo_features ${{ env.FEATURES }}
684+
685+
OUT="bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}--armv7-linux-androideabi" TARGET="armv7-linux-androideabi" TYPE="${{ matrix.compiletype }}" bash ffi/capi/build.sh
686+
OUT="bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}--aarch64-linux-android" TARGET="aarch64-linux-android" TYPE="${{ matrix.compiletype }}" bash ffi/capi/build.sh
687+
OUT="bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}--i686-linux-android" TARGET="i686-linux-android" TYPE="${{ matrix.compiletype }}" bash ffi/capi/build.sh
688+
OUT="bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}--x86_64-linux-android" TARGET="x86_64-linux-android" TYPE="${{ matrix.compiletype }}" bash ffi/capi/build.sh
689+
OUT="bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}--armv7-unknown-linux-gnueabihf" TARGET="armv7-unknown-linux-gnueabihf" TYPE="${{ matrix.compiletype }}" bash ffi/capi/build.sh
690+
OUT="bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}--aarch64-unknown-linux-gnu" TARGET="aarch64-unknown-linux-gnu" TYPE="${{ matrix.compiletype }}" bash ffi/capi/build.sh
691+
OUT="bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}--riscv64gc-unknown-linux-gnu" TARGET="riscv64gc-unknown-linux-gnu" TYPE="${{ matrix.compiletype }}" bash ffi/capi/build.sh
692+
OUT="bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}--x86_64-unknown-linux-gnu" TARGET="x86_64-unknown-linux-gnu" TYPE="${{ matrix.compiletype }}" bash ffi/capi/build.sh
698693
699694
- name: Build Linux data
700695
if: matrix.os == 'ubuntu-latest' && matrix.compiletype == 'static' && matrix.include_data == false
@@ -715,14 +710,12 @@ jobs:
715710
- name: Build Mac
716711
if: matrix.os == 'macos-latest'
717712
run: |
718-
(cd ffi/dart && dart pub get)
719-
720713
mkdir bin
721714
722-
dart ffi/dart/lib/src/hook_helpers/build_libs.dart --working_directory . --file bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-aarch64-apple-ios --target aarch64-apple-ios --compile_type ${{ matrix.compiletype }} --cargo_features ${{ env.FEATURES }}
723-
dart ffi/dart/lib/src/hook_helpers/build_libs.dart --working_directory . --file bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-x86_64-apple-ios --target x86_64-apple-ios --compile_type ${{ matrix.compiletype }} --cargo_features ${{ env.FEATURES }}
724-
dart ffi/dart/lib/src/hook_helpers/build_libs.dart --working_directory . --file bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-aarch64-apple-darwin --target aarch64-apple-darwin --compile_type ${{ matrix.compiletype }} --cargo_features ${{ env.FEATURES }}
725-
dart ffi/dart/lib/src/hook_helpers/build_libs.dart --working_directory . --file bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-x86_64-apple-darwin --target x86_64-apple-darwin --compile_type ${{ matrix.compiletype }} --cargo_features ${{ env.FEATURES }}
715+
OUT="bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-aarch64-apple-ios" TARGET="aarch64-apple-ios" TYPE="${{ matrix.compiletype }}" bash ffi/capi/build.sh
716+
OUT="bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-x86_64-apple-ios" TARGET="x86_64-apple-ios" TYPE="${{ matrix.compiletype }}" bash ffi/capi/build.sh
717+
OUT="bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-aarch64-apple-darwin" TARGET="aarch64-apple-darwin" TYPE="${{ matrix.compiletype }}" bash ffi/capi/build.sh
718+
OUT="bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-x86_64-apple-darwin" TARGET="x86_64-apple-darwin" TYPE="${{ matrix.compiletype }}" bash ffi/capi/build.sh
726719
727720
- name: Build Mac data
728721
if: matrix.os == 'macos-latest' && matrix.compiletype == 'static' && matrix.include_data == false
@@ -741,20 +734,15 @@ jobs:
741734
742735
- name: Build Windows
743736
if: matrix.os == 'windows-latest'
737+
shell: bash
744738
run: |
745-
pushd ffi/dart
746-
dart pub get
747-
popd
748-
749739
mkdir bin
750740
751-
dart ffi/dart/lib/src/hook_helpers/build_libs.dart --working_directory . --file bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-aarch64-pc-windows-msvc --target aarch64-pc-windows-msvc --compile_type ${{ matrix.compiletype }} --cargo_features ${{ env.FEATURES }}
752-
dart ffi/dart/lib/src/hook_helpers/build_libs.dart --working_directory . --file bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-i686-pc-windows-msvc --target i686-pc-windows-msvc --compile_type ${{ matrix.compiletype }} --cargo_features ${{ env.FEATURES }}
753-
dart ffi/dart/lib/src/hook_helpers/build_libs.dart --working_directory . --file bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-x86_64-pc-windows-msvc --target x86_64-pc-windows-msvc --compile_type ${{ matrix.compiletype }} --cargo_features ${{ env.FEATURES }}
741+
OUT="bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-aarch64-pc-windows-msvc" TARGET="aarch64-pc-windows-msvc" TYPE="${{ matrix.compiletype }}" bash ffi/capi/build.sh
742+
OUT="bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-i686-pc-windows-msvc" TARGET="i686-pc-windows-msvc" TYPE="${{ matrix.compiletype }}" bash ffi/capi/build.sh
743+
OUT="bin/icu4x-2-${{ matrix.compiletype }}${{ env.FILENAME_SUFFIX }}-x86_64-pc-windows-msvc" TARGET="x86_64-pc-windows-msvc" TYPE="${{ matrix.compiletype }}" bash ffi/capi/build.sh
754744
755-
DEL bin\*.dll.exp
756-
DEL bin\*.dll.lib
757-
DEL bin\*.pdb
745+
rm -f bin/*{.dll.exp,.dll.lib,.pdb}
758746
759747
- name: Build Windows data
760748
if: matrix.os == 'windows-latest' && matrix.compiletype == 'static' && matrix.include_data == false

.github/workflows/build-test.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ jobs:
176176

177177
# Job-specific dependencies
178178
- name: Install harfbuzz
179-
run: sudo apt install libharfbuzz-dev
179+
run: |
180+
sudo apt update
181+
sudo apt install libharfbuzz-dev
180182
181183
# Actual job
182184
- name: Run `cargo make ci-job-test-cargo`
@@ -341,7 +343,10 @@ jobs:
341343

342344
# Actual job
343345
- name: Run `cargo make ci-job-test-dart`
344-
run: cargo make ci-job-test-dart
346+
shell: bash
347+
run: |
348+
export PATH=$PATH:/c/Program\ Files/Git/bin # make bash available on Windows
349+
cargo make ci-job-test-dart
345350
346351
- name: Run `cargo make ci-job-test-dart` in local mode
347352
run: |

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
- Document deprecated APIs (unicode-org#6890)
133133
- FFI for most new APIs
134134
- `ListFormatter::format` now takes a `diplomat::span<const diplomat::string_view_for_slice>` instead of a `diplomat::span<std::string_view>` to handle soundness issues on some platforms (unicode-org#6974)
135-
- Dart version `2.1.0-dev.0`
135+
- Dart version `2.1.0-dev.0`, `2.1.0-dev.1`
136136
- NPM version `2.1.0`
137137
- Utils
138138
- General

components/calendar/src/cal/hijri.rs

Lines changed: 25 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ use crate::types::DateFields;
1313
use crate::types::Month;
1414
use crate::{types, Calendar, Date};
1515
use crate::{AsCalendar, RangeError};
16-
use calendrical_calculations::islamic::{
17-
ISLAMIC_EPOCH_FRIDAY, ISLAMIC_EPOCH_THURSDAY, WELL_BEHAVED_ASTRONOMICAL_RANGE,
18-
};
1916
use calendrical_calculations::rata_die::RataDie;
2017
use core::fmt::Debug;
2118
use icu_locale_core::preferences::extensions::unicode::keywords::{
@@ -166,96 +163,21 @@ impl Rules for AstronomicalSimulation {
166163
fn year(&self, extended_year: i32) -> HijriYear {
167164
if let Some(data) = HijriYear::lookup(
168165
extended_year,
169-
simulated_mecca_data::STARTING_YEAR,
170-
simulated_mecca_data::DATA,
166+
match self.location {
167+
SimulatedLocation::Mecca => simulated_mecca_data::STARTING_YEAR,
168+
},
169+
match self.location {
170+
SimulatedLocation::Mecca => simulated_mecca_data::DATA,
171+
},
171172
) {
172-
return data;
173-
}
174-
175-
let location = match self.location {
176-
SimulatedLocation::Mecca => calendrical_calculations::islamic::MECCA,
177-
};
178-
179-
let start_day = calendrical_calculations::islamic::fixed_from_observational_islamic(
180-
extended_year,
181-
1,
182-
1,
183-
location,
184-
);
185-
let next_start_day = calendrical_calculations::islamic::fixed_from_observational_islamic(
186-
extended_year + 1,
187-
1,
188-
1,
189-
location,
190-
);
191-
match (next_start_day - start_day) as u16 {
192-
355 | 354 => (),
193-
353 => {
194-
icu_provider::log::trace!(
195-
"({}) Found year {extended_year} AH with length {}. See <https://github.com/unicode-org/icu4x/issues/4930>",
196-
self.debug_name(),
197-
next_start_day - start_day
198-
);
199-
}
200-
other => {
201-
debug_assert!(
202-
!WELL_BEHAVED_ASTRONOMICAL_RANGE.contains(&start_day),
203-
"({}) Found year {extended_year} AH with length {}!",
204-
self.debug_name(),
205-
other
206-
)
173+
data
174+
} else {
175+
TabularAlgorithm {
176+
leap_years: TabularAlgorithmLeapYears::TypeII,
177+
epoch: TabularAlgorithmEpoch::Friday,
207178
}
179+
.year(extended_year)
208180
}
209-
210-
let month_lengths = {
211-
let mut excess_days = 0;
212-
let mut month_lengths = core::array::from_fn(|month_idx| {
213-
let days_in_month =
214-
calendrical_calculations::islamic::observational_islamic_month_days(
215-
extended_year,
216-
month_idx as u8 + 1,
217-
location,
218-
);
219-
match days_in_month {
220-
29 => false,
221-
30 => true,
222-
31 => {
223-
icu_provider::log::trace!(
224-
"({}) Found year {extended_year} AH with month length {days_in_month} for month {}.",
225-
self.debug_name(),
226-
month_idx + 1
227-
);
228-
excess_days += 1;
229-
true
230-
}
231-
_ => {
232-
debug_assert!(
233-
!WELL_BEHAVED_ASTRONOMICAL_RANGE.contains(&start_day),
234-
"({}) Found year {extended_year} AH with month length {days_in_month} for month {}!",
235-
self.debug_name(),
236-
month_idx + 1
237-
);
238-
false
239-
}
240-
}
241-
});
242-
// To maintain invariants for calendar arithmetic, if astronomy finds
243-
// a 31-day month, "move" the day to the first 29-day month in the
244-
// same year to maintain all months at 29 or 30 days.
245-
if excess_days != 0 {
246-
debug_assert!(
247-
excess_days == 1 || !WELL_BEHAVED_ASTRONOMICAL_RANGE.contains(&start_day),
248-
"({}) Found year {extended_year} AH with more than one excess day!",
249-
self.debug_name()
250-
);
251-
if let Some(l) = month_lengths.iter_mut().find(|l| !(**l)) {
252-
*l = true;
253-
}
254-
}
255-
month_lengths
256-
};
257-
HijriYear::try_new(extended_year, start_day, month_lengths)
258-
.unwrap_or_else(|| UmmAlQura.year(extended_year))
259181
}
260182
}
261183

@@ -498,8 +420,8 @@ pub enum TabularAlgorithmEpoch {
498420
impl TabularAlgorithmEpoch {
499421
fn rata_die(self) -> RataDie {
500422
match self {
501-
Self::Thursday => ISLAMIC_EPOCH_THURSDAY,
502-
Self::Friday => ISLAMIC_EPOCH_FRIDAY,
423+
Self::Thursday => calendrical_calculations::islamic::ISLAMIC_EPOCH_THURSDAY,
424+
Self::Friday => calendrical_calculations::islamic::ISLAMIC_EPOCH_FRIDAY,
503425
}
504426
}
505427
}
@@ -1275,27 +1197,27 @@ mod test {
12751197
DateCase {
12761198
year: -1245,
12771199
month: 12,
1278-
day: 10,
1200+
day: 9,
12791201
},
12801202
DateCase {
12811203
year: -813,
12821204
month: 2,
1283-
day: 25,
1205+
day: 23,
12841206
},
12851207
DateCase {
12861208
year: -568,
12871209
month: 4,
1288-
day: 2,
1210+
day: 1,
12891211
},
12901212
DateCase {
12911213
year: -501,
12921214
month: 4,
1293-
day: 7,
1215+
day: 6,
12941216
},
12951217
DateCase {
12961218
year: -157,
12971219
month: 10,
1298-
day: 18,
1220+
day: 17,
12991221
},
13001222
DateCase {
13011223
year: -47,
@@ -1330,7 +1252,7 @@ mod test {
13301252
DateCase {
13311253
year: 687,
13321254
month: 2,
1333-
day: 21,
1255+
day: 20,
13341256
},
13351257
DateCase {
13361258
year: 697,
@@ -1339,8 +1261,8 @@ mod test {
13391261
},
13401262
DateCase {
13411263
year: 793,
1342-
month: 6,
1343-
day: 29,
1264+
month: 7,
1265+
day: 1,
13441266
},
13451267
DateCase {
13461268
year: 839,
@@ -1350,7 +1272,7 @@ mod test {
13501272
DateCase {
13511273
year: 897,
13521274
month: 6,
1353-
day: 2,
1275+
day: 1,
13541276
},
13551277
DateCase {
13561278
year: 960,
@@ -1370,7 +1292,7 @@ mod test {
13701292
DateCase {
13711293
year: 1091,
13721294
month: 6,
1373-
day: 3,
1295+
day: 2,
13741296
},
13751297
DateCase {
13761298
year: 1128,
@@ -1380,7 +1302,7 @@ mod test {
13801302
DateCase {
13811303
year: 1182,
13821304
month: 2,
1383-
day: 4,
1305+
day: 3,
13841306
},
13851307
DateCase {
13861308
year: 1234,

components/datetime/src/provider/pattern/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ pub use item::{GenericPatternItem, PatternItem};
2828
/// The granularity of time represented in a [`Pattern`](runtime::Pattern).
2929
/// Ordered from least granular to most granular for comparison.
3030
#[derive(
31-
Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, yoke::Yokeable, zerofrom::ZeroFrom,
31+
Default, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, yoke::Yokeable, zerofrom::ZeroFrom,
3232
)]
3333
#[cfg_attr(feature = "datagen", derive(serde::Serialize, databake::Bake))]
3434
#[cfg_attr(feature = "datagen", databake(path = icu_datetime::provider::pattern))]
3535
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
3636
#[non_exhaustive]
3737
pub enum TimeGranularity {
3838
/// No time is in the pattern.
39+
#[default]
3940
None,
4041
/// Smallest time unit = hours.
4142
Hours,
@@ -47,12 +48,6 @@ pub enum TimeGranularity {
4748
Nanoseconds,
4849
}
4950

50-
impl Default for TimeGranularity {
51-
fn default() -> Self {
52-
Self::None
53-
}
54-
}
55-
5651
impl TimeGranularity {
5752
/// Returns [`true`] if the most granular time being displayed will align with
5853
/// the top of the hour, otherwise returns [`false`].

components/experimental/src/dimension/currency/options.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ impl From<Width> for CurrencyFormatterOptions {
2323
}
2424
}
2525

26-
#[derive(Debug, Eq, PartialEq, Clone, Copy, Hash)]
26+
#[derive(Default, Debug, Eq, PartialEq, Clone, Copy, Hash)]
2727
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
2828
#[non_exhaustive]
2929
pub enum Width {
3030
/// Format the currency with the standard (short) currency symbol.
3131
///
3232
/// For example, 1 USD formats as "$1.00" in en-US and "US$1" in most other locales.
3333
#[cfg_attr(feature = "serde", serde(rename = "short"))]
34+
#[default]
3435
Short,
3536

3637
/// Format the currency with the narrow currency symbol.
@@ -42,9 +43,3 @@ pub enum Width {
4243
#[cfg_attr(feature = "serde", serde(rename = "narrow"))]
4344
Narrow,
4445
}
45-
46-
impl Default for Width {
47-
fn default() -> Self {
48-
Self::Short
49-
}
50-
}

0 commit comments

Comments
 (0)