Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add icu4x-key-extract for Static Data Slicing #1460

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions tools/datagen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,38 @@ More details on each tool can be found by running `--help`.

## Examples

Generate ICU4X JSON file tree:
Generate ICU4X Postcard blob (single file) for all keys and all locales:

```bash
# Run from the icu4x project folder
$ cargo run --bin icu4x-datagen -- \
--cldr-tag 39.0.0 \
--all-keys \
--all-locales \
--out /tmp/icu4x_data/json
--cldr-tag 39.0.0 \
--all-keys \
--all-locales \
--format blob \
--out /tmp/icu4x_data/icu4x_data.postcard
```

Generate ICU4X Postcard blob (single file):
Extract the keys from an executable into a key file:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "Extract the keys used by an executable into a key file"


```bash
# Run from the icu4x project folder
$ cargo run --bin icu4x-datagen -- \
--cldr-tag 39.0.0 \
--all-keys \
--all-locales \
--format blob \
--out /tmp/icu4x_data/icu4x_data.postcard
$ cargo build --example work_log
$ cargo run --bin icu4x-key-extract -- \
-i target/debug/examples/work_log
-o /tmp/icu4x_data/work_log+keys.txt
```

Generate ICU4X Bincode file tree:
Generate ICU4X JSON file tree from the key file for Spanish and German:

```bash
# Run from the icu4x project folder
$ cargo run --bin icu4x-datagen -- \
--cldr-tag 39.0.0 \
--all-keys \
--all-locales \
--syntax bincode \
--out /tmp/icu4x_data/bincode
--cldr-tag 39.0.0 \
--key-file /tmp/icu4x_data/work_log+keys.txt \
--locales es \
--locales de \
--out /tmp/icu4x_data/work_log_json
```

## More Information
Expand Down
68 changes: 34 additions & 34 deletions tools/datagen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,45 @@
//!
//! 1. `icu4x-datagen`: Read source data (CLDR JSON) and dump ICU4X-format data.
//! 2. `icu4x-testdata-download`: Download fresh CLDR JSON for testdata.
//! 3. `icu4x-key-extract`: Extract `ResourceKey` objects present in a compiled executable.
//!
//! More details on each tool can be found by running `--help`.
//!
//! # Examples
//!
//! Generate ICU4X JSON file tree:
//!
//!```bash
//!# Run from the icu4x project folder
//!$ cargo run --bin icu4x-datagen -- \
//! --cldr-tag 39.0.0 \
//! --all-keys \
//! --all-locales \
//! --out /tmp/icu4x_data/json
//!```
//!
//! Generate ICU4X Postcard blob (single file):
//!
//!```bash
//!# Run from the icu4x project folder
//!$ cargo run --bin icu4x-datagen -- \
//! --cldr-tag 39.0.0 \
//! --all-keys \
//! --all-locales \
//! --format blob \
//! --out /tmp/icu4x_data/icu4x_data.postcard
//!```
//!
//! Generate ICU4X Bincode file tree:
//!
//!```bash
//!# Run from the icu4x project folder
//!$ cargo run --bin icu4x-datagen -- \
//! --cldr-tag 39.0.0 \
//! --all-keys \
//! --all-locales \
//! --syntax bincode \
//! --out /tmp/icu4x_data/bincode
//!```
//! Generate ICU4X Postcard blob (single file) for all keys and all locales:
//!
//! ```bash
//! # Run from the icu4x project folder
//! $ cargo run --bin icu4x-datagen -- \
//! --cldr-tag 39.0.0 \
//! --all-keys \
//! --all-locales \
//! --format blob \
//! --out /tmp/icu4x_data/icu4x_data.postcard
//! ```
//!
//! Extract the keys from an executable into a key file:
//!
//! ```bash
//! # Run from the icu4x project folder
//! $ cargo build --example work_log
//! $ cargo run --bin icu4x-key-extract -- \
//! -i target/debug/examples/work_log
//! -o /tmp/icu4x_data/work_log+keys.txt
//! ```
//!
//! Generate ICU4X JSON file tree from the key file for Spanish and German:
//!
//! ```bash
//! # Run from the icu4x project folder
//! $ cargo run --bin icu4x-datagen -- \
//! --cldr-tag 39.0.0 \
//! --key-file /tmp/icu4x_data/work_log+keys.txt \
//! --locales es \
//! --locales de \
//! --out /tmp/icu4x_data/work_log_json
//! ```

fn main() {
panic!("Please run a more specific binary")
Expand Down