5 This file documents the procedures for building with `ICU4X <https://github.com/unicode-org/icu4x>`__.
10 #. Add the ``ac_add_options --enable-icu4x`` mozconfig. (This is the default)
13 Updating the bundled ICU4X data
14 ===============================
16 ICU4X data is bundled directly as a rust crate with ``compiled_data`` feature.
18 But each ``icu_*_data`` crate has all locale data, so it might include unnecessary data. ``icu_segmenter`` uses custom crates in Gecko since it includes unnecessary data such as the word dictionaries for East Asian.
20 The script ``intl/update-icu4x.sh`` can generate and update this binary data. If you want to add the new data type, you modify this script and then, run it.
22 When using ICU4X 1.4.0 data with the latest data that is hard-coded, you have to run the following. The baked data of ``icu_segmenter`` is generated into ``intl/icu_segmenter_data/data``.
26 $ cd $(TOPSRCDIR)/intl
27 $ ./update-icu4x.sh https://github.com/unicode-org/icu4x.git icu@1.4.0 44.0.0 release-74-1 1.4.0
32 If you update ICU4X crate into Gecko, you have to check ``Cargo.toml`` in Gecko's root directory. We might have some hacks to replace crate.io version with a custom version.
37 ICU4X provides ``icu_capi`` crate for C/C++ FFI. ``mozilla::intl::GetDataProvider`` returns ``capi::ICU4XDataProvider`` of ``icu_capi``. It can return valid data until shutting down.
39 Accessing the data provider from Rust
40 =====================================
42 Use ``compiled_data`` feature. You don't consider data provider.
44 Adding new ICU4X features to Gecko
45 ==================================
47 To reduce build time and binary size, embedded ICU4X in Gecko is minimal configuration. If you have to add new features, you have to update some files.
49 #. Adding the feature to ``icu_capi`` entry in ``js/src/rust/shared/Cargo.toml``.
50 #. Modify ``[features]`` section in ``intl/icu_capi/Cargo.toml`` to enable ``compiled_data`` feature of added crate.
51 #. Modify the patch file for ``intl/icu_capi/Cargo.toml`` into ``intl/icu4x-patches``.
52 #. (Optional) Modify ``intl/update-icu4x.sh`` to add generated ICU4X data if you want to modify ICU4X baked data.