Skip to content

Commit

Permalink
datastuff
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian committed Jan 30, 2023
1 parent cb2fa9a commit 35f0642
Show file tree
Hide file tree
Showing 429 changed files with 140 additions and 99 deletions.
5 changes: 4 additions & 1 deletion Cargo.lock

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

23 changes: 23 additions & 0 deletions components/locid/src/databake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// 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 crate::LanguageIdentifier;
use alloc::string::ToString;
use databake::*;

impl Bake for LanguageIdentifier {
fn bake(&self, env: &CrateEnv) -> TokenStream {
env.insert("icu_locid");
let repr = self.to_string();
if self.variants.len() <= 1 {
quote! {
icu_locid::langid!(#repr)
}
} else {
quote! {
icu_locid::LanguageIdentifier::from_str(#repr).unwrap()
}
}
}
}
3 changes: 3 additions & 0 deletions components/locid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,6 @@ pub mod zerovec;

#[cfg(feature = "serde")]
mod serde;

#[cfg(feature = "databake")]
mod databake;
2 changes: 1 addition & 1 deletion provider/datagen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ simple_logger = { version = "1.12", default-features = false, optional = true }
[dev-dependencies]
dhat = "0.3.0"
icu = { path = "../../components/icu" }
icu_testdata = { path = "../testdata", features = ["buffer", "std"] }
icu_testdata = { path = "../testdata", features = ["buffer"] }

[features]
default = ["bin"]
Expand Down
10 changes: 6 additions & 4 deletions provider/datagen/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ impl SourceData {
pub fn for_test() -> Self {
Self::default()
.with_cldr(
icu_testdata::paths::cldr_json_root(),
concat!(core::env!("CARGO_MANIFEST_DIR"), "/tests/data/cldr").into(),
CldrLocaleSubset::Full,
)
.expect("testdata is valid")
.with_icuexport(icu_testdata::paths::icuexport_toml_root())
.expect("testdata is valid")
.unwrap()
.with_icuexport(
concat!(core::env!("CARGO_MANIFEST_DIR"), "/tests/data/icuexport").into(),
)
.unwrap()
}

/// Adds CLDR data to this `DataSource`. The root should point to a local
Expand Down
Loading

0 comments on commit 35f0642

Please sign in to comment.