Skip to content

Commit

Permalink
iterate
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian committed Jan 4, 2023
1 parent b3e4bd5 commit f279f87
Show file tree
Hide file tree
Showing 13 changed files with 331 additions and 335 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions ffi/capi_cdylib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ icu_provider = { version = "1.0.0", path = "../../provider/core", default-featur
# Please keep features/cargo-all-features lists in sync with the icu_capi crate
[features]
default = ["icu_capi/default"]
any_provider = ["icu_capi/any_provider"]
buffer_provider = ["icu_capi/buffer_provider"]
baked_provider = ["icu_capi/baked_provider"]
buffer_provider = ["icu_capi/buffer_provider"]
provider_fs = ["icu_capi/provider_fs"] # Indirectly implies buffer_provider
provider_test = ["icu_capi/provider_test"]
logging = ["icu_capi/logging"]
Expand Down
3 changes: 1 addition & 2 deletions ffi/capi_staticlib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ icu_provider = { version = "1.0.0", path = "../../provider/core", default-featur
# Please keep features/cargo-all-features lists in sync with the icu_capi crate
[features]
default = ["icu_capi/default"]
any_provider = ["icu_capi/any_provider"]
buffer_provider = ["icu_capi/buffer_provider"]
baked_provider = ["icu_capi/baked_provider"]
buffer_provider = ["icu_capi/buffer_provider"]
provider_fs = ["icu_capi/provider_fs"] # Indirectly implies buffer_provider
provider_test = ["icu_capi/provider_test"]
logging = ["icu_capi/logging"]
Expand Down
15 changes: 7 additions & 8 deletions ffi/diplomat/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ all-features = true
skip_optional_dependencies = true
# Bench feature gets tested separately and is only relevant for CI.
# logging enables a feature of a dependency that has no externally visible API changes
# baked_provider requires datagen.
denylist = ["bench", "logging", "baked_provider"]
denylist = ["bench", "logging"]

# Please keep the features list in sync with the icu_capi_staticlib/icu_capi_cdylib crates
[features]
default = ["any_provider"]
any_provider = []
default = ["baked_provider"]
baked_provider = ["dep:zerovec"]
buffer_provider = [
"dep:icu_provider_blob",
"dep:serde",
Expand All @@ -54,14 +53,12 @@ buffer_provider = [
"icu_provider/serde",
"icu_provider_adapters/serde",
"icu_segmenter/serde",
"icu_testdata?/buffer",
]
provider_fs = ["dep:icu_provider_fs", "buffer_provider"]
provider_test = ["dep:icu_testdata"]
provider_test = ["dep:icu_testdata", "buffer_provider"]
logging = ["icu_provider/log_error_context", "dep:log"]
# Use the env_logger functionality to log based on environment variables
simple_logger = ["dep:simple_logger"]
baked_provider = ["any_provider", "dep:zerovec"]

# meta feature for things we enable by default in C and C++
cpp_default = ["provider_test", "logging", "simple_logger"]
Expand Down Expand Up @@ -93,7 +90,7 @@ writeable = { version = "0.5", path = "../../utils/writeable/" }
icu_provider_blob = { version = "1.0.0", path = "../../provider/blob", optional = true }
serde = { version = "1.0", default-features = false, optional = true }

icu_testdata = { version = "1.0.0", path = "../../provider/testdata", optional = true, features = ["icu_segmenter"] }
icu_testdata = { version = "1.0.0", path = "../../provider/testdata", optional = true, features = ["buffer"] }

zerovec = { version = "*", path = "../../utils/zerovec", optional = true}

Expand All @@ -104,6 +101,8 @@ zerovec = { version = "*", path = "../../utils/zerovec", optional = true}
diplomat = { git = "https://github.com/rust-diplomat/diplomat", rev = "d3010a4b88a0f37d23e3c64cf5500cedc4e8cdf0" }
diplomat-runtime = { git = "https://github.com/rust-diplomat/diplomat", rev = "d3010a4b88a0f37d23e3c64cf5500cedc4e8cdf0" }

[build-dependencies]
icu_datagen = { version = "1.0", path = "../../provider/datagen", features = ["icu_segmenter"]}

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
# Logging is automagical in wasm, we only need this for native
Expand Down
34 changes: 34 additions & 0 deletions ffi/diplomat/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

use icu_datagen::*;
use std::path::PathBuf;

fn main() {
if std::env::var("CARGO_FEATURE_BAKED_PROVIDER").is_ok()
&& std::env::var("ICU4X_FFI_BAKED_ROOT").is_err()
{
let mod_directory = PathBuf::from(std::env::var_os("OUT_DIR").unwrap()).join("empty_bake");
println!(
"cargo:rustc-env=ICU4X_FFI_BAKED_ROOT={}",
mod_directory.display()
);

if !mod_directory.exists() {
icu_datagen::datagen(
Some(&[]),
&[],
&SourceData::default(),
vec![Out::Module {
mod_directory,
insert_feature_gates: false,
use_separate_crates: true,
overwrite: false,
pretty: false,
}],
)
.unwrap();
}
}
}
18 changes: 9 additions & 9 deletions ffi/diplomat/c/examples/fixeddecimal_tiny/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ GCC := gcc
CLANG := clang-14
LLD := lld-14

ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
export ICU4X_FFI_BAKED_ROOT = $(dir $(realpath $(lastword $(MAKEFILE_LIST))))baked

../../../../../target/debug/libicu_capi_staticlib.a: $(ALL_RUST) baked/mod.rs
ICU4X_FFI_BAKED_ROOT=$(ROOT_DIR)/baked/mod.rs cargo build -p icu_capi_staticlib --no-default-features --features baked_provider
../../../../../target/debug/libicu_capi_staticlib.a: $(ALL_RUST) $(ICU4X_FFI_BAKED_ROOT)
cargo build -p icu_capi_staticlib --no-default-features --features baked_provider

icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib_tiny.a: $(ALL_RUST) baked/mod.rs
icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/debug/libicu_capi_staticlib_tiny.a: $(ALL_RUST) $(ICU4X_FFI_BAKED_ROOT)
cd icu_capi_staticlib_tiny && \
ICU4X_FFI_BAKED_ROOT=$(ROOT_DIR)/baked/mod.rs RUSTFLAGS="-Clinker-plugin-lto -Clinker=$(CLANG) -Ccodegen-units=1 -Clink-arg=-flto -Cpanic=abort" cargo +${ICU4X_NIGHTLY_TOOLCHAIN} panic-abort-build --target x86_64-unknown-linux-gnu
RUSTFLAGS="-Clinker-plugin-lto -Clinker=$(CLANG) -Ccodegen-units=1 -Clink-arg=-flto -Cpanic=abort" cargo +$(ICU4X_NIGHTLY_TOOLCHAIN) panic-abort-build --target x86_64-unknown-linux-gnu

icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/release-opt-size/libicu_capi_staticlib_tiny.a: $(ALL_RUST) baked/mod.rs
icu_capi_staticlib_tiny/target/x86_64-unknown-linux-gnu/release-opt-size/libicu_capi_staticlib_tiny.a: $(ALL_RUST) $(ICU4X_FFI_BAKED_ROOT)
cd icu_capi_staticlib_tiny && \
ICU4X_FFI_BAKED_ROOT=$(ROOT_DIR)/baked/mod.rs RUSTFLAGS="-Clinker-plugin-lto -Clinker=$(CLANG) -Ccodegen-units=1 -Clink-arg=-flto -Cpanic=abort" cargo +${ICU4X_NIGHTLY_TOOLCHAIN} panic-abort-build --target x86_64-unknown-linux-gnu --profile=release-opt-size
RUSTFLAGS="-Clinker-plugin-lto -Clinker=$(CLANG) -Ccodegen-units=1 -Clink-arg=-flto -Cpanic=abort" cargo +$(ICU4X_NIGHTLY_TOOLCHAIN) panic-abort-build --target x86_64-unknown-linux-gnu --profile=release-opt-size

baked/mod.rs:
cargo run -p icu_datagen --features bin,icu_segmenter -- --locales en bn --all-keys --cldr-tag 42.0.0 --icuexport-tag release-72-1 --format mod --out baked --use-separate-crates
$(ICU4X_FFI_BAKED_ROOT):
cargo run -p icu_datagen --features bin,icu_segmenter -- --locales en bn --keys "decimal/symbols@1" --cldr-root ../../../../../provider/testdata/data/cldr/ --format mod --use-separate-crates --pretty --out ${ICU4X_FFI_BAKED_ROOT}

# Naive target: no optimizations, full std
optim0.elf: ../../../../../target/debug/libicu_capi_staticlib.a $(ALL_HEADERS) test.c
Expand Down
2 changes: 1 addition & 1 deletion ffi/diplomat/cpp/docs/source/provider_ffi.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions ffi/diplomat/cpp/include/ICU4XDataProvider.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ffi/diplomat/js/docs/source/provider_ffi.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ffi/diplomat/js/include/ICU4XDataProvider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class ICU4XDataProvider {
* Constructs a {@link ICU4XDataProvider `ICU4XDataProvider`} containing baked data.
* When compiling the Rust library, set the `ICU4X_FFI_BAKED_ROOT` environment variable to the baked data's `mod.rs`'s path.
* When compiling the Rust library, set the `ICU4X_FFI_BAKED_ROOT` environment variable to the baked data folder.
*/
static create_baked(): ICU4XDataProvider;

Expand Down
Loading

0 comments on commit f279f87

Please sign in to comment.