Skip to content

Commit 889d08d

Browse files
committed
Update 1.5 content based on 1.5 branch docs and new script's transform
1 parent 3db2e7e commit 889d08d

File tree

7 files changed

+209
-286
lines changed

7 files changed

+209
-286
lines changed

src/content/docs/1_5/tutorials/cargo.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: Configuring Cargo.toml
33
---
44

5+
6+
57
ICU4X makes heavy use of small crates and Cargo features in order to be highly modular. This tutorial is intended to help you set up a Cargo.toml file to download what you need for ICU4X.
68

79
## Basic Cargo.toml with compiled data
@@ -15,29 +17,33 @@ icu = "1.5"
1517

1618
In your main.rs, you can use all stable ICU4X components for the recommended set of locales, which get compiled into the library.
1719

20+
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/release%2F1.5/tutorials/./crates/default)
1821

1922
## Cargo.toml with custom compiled data
2023

2124
If you wish to use custom compiled data for ICU4X, no changes to Cargo.toml are required. Instead, set the `ICU4X_DATA_DIR` environment variable to the
2225
datagen output during your build:
2326

2427
```command
25-
icu4x-datagen --format baked --markers all --locales ru --out baked_data
28+
icu4x-datagen --format mod --keys all --locales ru --out baked_data
2629
ICU4X_DATA_DIR=$(pwd)/baked_data cargo build --release
2730
```
2831

32+
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/release%2F1.5/tutorials/./crates/custom_compiled)
2933

3034
## Cargo.toml with experimental modules
3135

3236
Experimental modules are published in a separate `icu_experimental` crate:
3337

3438
```toml
3539
[dependencies]
36-
icu = { version = "1.5", features = ["experimental"] }
40+
icu = "1.5"
41+
icu_experimental = "0"
3742
```
3843

3944
In your main.rs, you can now use e.g. the `icu_experimental::displaynames` module.
4045

46+
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/release%2F1.5/tutorials/./crates/experimental)
4147

4248
## Cargo.toml with Buffer Provider
4349

@@ -49,8 +55,9 @@ icu = { version = "1.5", features = ["serde"] }
4955
icu_provider_blob = "1.5"
5056
```
5157

52-
To learn about building ICU4X data, including whether to check in the data blob file to your repository, see [Data management](/icu4x-docs/1_5/tutorials/data-management).
58+
To learn about building ICU4X data, including whether to check in the data blob file to your repository, see [data-management.md](/icu4x-docs/1_5/tutorials/./data-management).
5359

60+
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/release%2F1.5/tutorials/./crates/buffer)
5461

5562
## Cargo.toml with `Sync`
5663

@@ -63,6 +70,7 @@ icu = { version = "1.5", features = ["sync"] }
6370

6471
You can now use most ICU4X types when `Send + Sync` are required, such as when sharing across threads.
6572

73+
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/release%2F1.5/tutorials/./crates/sync)
6674

6775
## Cargo.toml with `build.rs` data generation
6876

@@ -72,20 +80,20 @@ If you wish to use data generation in a `build.rs` script, you need to manually
7280
[dependencies]
7381
icu = { version = "1.5", default-features = false } # turn off compiled_data
7482
icu_provider = "1.5" # for databake
75-
icu_provider_baked = "1.5" # for databake
7683
zerovec = "0.9" # for databake
7784

7885
# for build.rs:
7986
[build-dependencies]
8087
icu = "1.5"
81-
icu_provider_export = "1.5"
82-
icu_provider_source = "1.5"
88+
icu_datagen = "1.5"
8389
```
8490

85-
This example has an additional section for auto-generating the data in build.rs. In your build.rs, invoke the ICU4X Datagen API with the set of markers you require. Don't worry; if using databake, you will get a compiler error if you don't specify enough markers.
91+
This example has an additional section for auto-generating the data in build.rs. In your build.rs, invoke the ICU4X Datagen API with the set of keys you require. Don't worry; if using databake, you will get a compiler error if you don't specify enough keys.
8692

8793
The build.rs approach has several downsides and should only be used if Cargo is the only build system you can use, and you cannot check in your data:
88-
* The build script with the whole of `icu_provider_source` in it is slow to build
89-
* If you're using networking features of `icu_provider_source` (behind the `networking` Cargo feature), the build script will access the network
90-
* Using the data requires ICU4X's [`_unstable`](https://docs.rs/icu_provider/latest/icu_provider/constructors/index.html) APIs with a custom data provider, and that `icu_provider_source` is the same *minor* version as the `icu` crate.
94+
* The build script with the whole of `icu_datagen` in it is slow to build
95+
* If you're using networking features of `icu_datagen` (behind the `networking` Cargo feature), the build script will access the network
96+
* Using the data requires ICU4X's [`_unstable`](https://docs.rs/icu_provider/latest/icu_provider/constructors/index.html) APIs with a custom data provider, and that `icu_datagen` is the same *minor* version as the `icu` crate.
9197
* `build.rs` output is not written to the console so it will appear that the build is hanging
98+
99+
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/release%2F1.5/tutorials/./crates/baked)

0 commit comments

Comments
 (0)