Skip to content

Commit

Permalink
Add icu_provider_fs feature to datagen; bump to 1.2.2 (unicode-org#3354)
Browse files Browse the repository at this point in the history
* Add icu_provider_fs feature to datagen

* Update provider/datagen/src/bin/datagen.rs

Co-authored-by: Shane F. Carr <shane@unicode.org>

* rename to fs

* fix

* gn + lock + changelog

---------

Co-authored-by: Shane F. Carr <shane@unicode.org>
  • Loading branch information
Manishearth and sffc authored Apr 20, 2023
1 parent f66e237 commit 98a47f3
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 7 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# Changelog

## icu4x 1.2.1 (Apr 17, 2023)

## icu4x 1.2.1 & 1.2.2 (Apr 17, 2023)

Note: A subset of crates received patch releases in the 1.2 stream.

- `icu_capi`
- Fixed [#3344](https://github.com/unicode-org/icu4x/pull/3344), `buffer_provider` feature accidentally pulling in extra crates
- `icu_datagen`
- `icu_datagen` 1.2.1
- Fixed [#3339](https://github.com/unicode-org/icu4x/pull/3339), incorrect Cargo features
- `icu_datagen` 1.2.2
- Fixed [#3354](https://github.com/unicode-org/icu4x/pull/3354), ability to run datagen without support for `icu_provider_fs::FsDataProvider`
- `icu_locid_transform`
- Fixed [#3332](https://github.com/unicode-org/icu4x/issues/3332), missing `+?Sized` bound
- `icu_segmenter`
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

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

5 changes: 3 additions & 2 deletions provider/datagen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[package]
name = "icu_datagen"
description = "Generate data for ICU4X DataProvider"
version = "1.2.1"
version = "1.2.2"
authors = ["The ICU4X Project Developers"]
edition = "2021"
readme = "README.md"
Expand Down Expand Up @@ -51,7 +51,7 @@ icu_timezone = { version = "1.2.0", path = "../../components/timezone", features
icu_provider = { version = "1.2.0", path = "../core", features = ["std", "log_error_context", "datagen"]}
icu_provider_adapters = { version = "1.2.0", path = "../adapters", features = ["datagen"] }
icu_provider_blob = { version = "1.2.0", path = "../blob", features = ["export"] }
icu_provider_fs = { version = "1.2.0", path = "../fs", features = ["export"] }
icu_provider_fs = { version = "1.2.0", path = "../fs", features = ["export"], optional = true }

# Other
cached-path = { version = ">=0.5, <0.7", optional = true }
Expand Down Expand Up @@ -106,6 +106,7 @@ use_wasm = ["icu_codepointtrie_builder/wasm"]
# rule based segmenter data will not be generated.
use_icu4c = ["icu_codepointtrie_builder/icu4c"]
networking = ["dep:cached-path"]
fs = ["dep:icu_provider_fs"]

[[bin]]
name = "icu4x-datagen"
Expand Down
5 changes: 5 additions & 0 deletions provider/datagen/src/bin/datagen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mod cli {

#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Debug)]
pub(crate) enum Format {
#[cfg_attr(feature = "fs", value(hide = true))]
Dir,
Blob,
Mod,
Expand Down Expand Up @@ -84,6 +85,7 @@ struct Cli {

#[arg(short, long, value_enum, default_value_t = cli::Syntax::Json)]
#[arg(help = "--format=dir only: serde serialization format.")]
#[cfg_attr(feature = "fs", arg(hide = true))]
syntax: cli::Syntax,

#[arg(short, long)]
Expand Down Expand Up @@ -333,6 +335,9 @@ fn main() -> eyre::Result<()> {
if v == cli::Format::DeprecatedDefault {
log::warn!("Defaulting to --format=dir. This will become a required parameter in the future.");
}
#[cfg(not(feature = "fs"))]
eyre::bail!("--format=dir only available with the `fs` Cargo feature");
#[cfg(feature = "fs")]
icu_datagen::Out::Fs {
output_path: matches
.output
Expand Down
9 changes: 9 additions & 0 deletions provider/datagen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ impl CldrLocaleSubset {
/// [Out::Fs] serialization formats.
pub mod syntax {
#[doc(no_inline)]
#[cfg(feature = "fs")]
pub use icu_provider_fs::export::serializers::bincode::Serializer as Bincode;
#[doc(no_inline)]
#[cfg(feature = "fs")]
pub use icu_provider_fs::export::serializers::json::Serializer as Json;
#[doc(no_inline)]
#[cfg(feature = "fs")]
pub use icu_provider_fs::export::serializers::postcard::Serializer as Postcard;
}

Expand All @@ -122,6 +125,7 @@ use icu_provider::datagen::*;
use icu_provider::prelude::*;
use icu_provider_adapters::empty::EmptyDataProvider;
use icu_provider_adapters::filter::Filterable;
#[cfg(feature = "fs")]
use icu_provider_fs::export::serializers::AbstractSerializer;
use prelude::*;
use rayon::prelude::*;
Expand Down Expand Up @@ -315,6 +319,9 @@ impl Default for BakedOptions {
#[non_exhaustive]
pub enum Out {
/// Output to a file system tree
///
/// **Enabled with the `fs` Cargo feature.**
#[cfg(feature = "fs")]
Fs {
/// The root path.
output_path: PathBuf,
Expand Down Expand Up @@ -348,6 +355,7 @@ pub enum Out {
impl core::fmt::Debug for Out {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
#[cfg(feature = "fs")]
Self::Fs {
output_path,
serializer,
Expand Down Expand Up @@ -407,6 +415,7 @@ pub fn datagen(
.into_iter()
.map(|out| -> Result<Box<dyn DataExporter>, DataError> {
Ok(match out {
#[cfg(feature = "fs")]
Out::Fs {
output_path,
serializer,
Expand Down
4 changes: 3 additions & 1 deletion provider/datagen/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,9 @@ impl SerdeCache {
for<'de> S: serde::Deserialize<'de> + 'static + Send + Sync,
{
self.read_and_parse(path, |bytes| {
serde_json::from_slice(bytes).map_err(DataError::from)
serde_json::from_slice(bytes)
.map_err(std::io::Error::from)
.map_err(DataError::from)
})
}

Expand Down
2 changes: 1 addition & 1 deletion tools/testdata-scripts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2021"
[dependencies]
crlify = { path = "../../utils/crlify" }
databake = { path = "../../utils/databake" }
icu_datagen = { path = "../../provider/datagen", default-features = false }
icu_datagen = { path = "../../provider/datagen", default-features = false, features = ["fs"] }
icu_locid = { path = "../../components/locid", features = ["databake"] }
icu_provider = { path = "../../provider/core" }
repodata = { path = "../../provider/repodata" }
Expand Down

0 comments on commit 98a47f3

Please sign in to comment.