unicode-org / icu4x

Solving i18n for client-side and resource-constrained environments.
https://icu4x.unicode.org
Other
1.3k stars 166 forks source link

Split `icu_datagen` into a crate for the driver and a crate for the provider #4721

Closed robertbastian closed 1 week ago

robertbastian commented 3 months ago

These two components are fairly independent, and there is now a use case for the datagen driver that doesn't use the CLDR/ICU backed provider (icu_datagen_dart). It would be nice to be able to build it without pulling in all the logic and dependencies for parsing CLDR.

Idea:

robertbastian commented 3 months ago

Actually, data "generation" happens in the provider crate, so maybe the driver crate should be icu_export (with ExportDriver), and the provider crate icu_provider_datagen (icu_datagen if we don't want to retire the crate name, however all our crates that define providers start with icu_provider_)

sffc commented 3 months ago

The most modular setup would probably be

  1. icu_datagen_transform defines DatagenProvider
  2. icu_datagen_driver defines DatagenDriver
  3. icu_datagen defines the icu4x-datagen binary
robertbastian commented 3 months ago

That's my proposal, just with different names.

robertbastian commented 3 months ago

We could also move icu_provider::datagen into the driver crate.

robertbastian commented 3 months ago

Latest proposal:

sffc commented 3 months ago

ICU4X-WG discussion:

Macro structure brainstorm:

macro_rules! make_exportable {
    ([$($marker:path,)*], [$($experimental_marker,)*]) => {
        #[cfg(feature = "experimental_components")]
        icu_provider::make_exportable_provider!([$($marker,)* $($experimental_marker,)*]);
        #[cfg(not(feature = "experimental_components"))]
        icu_provider::make_exportable_provider!([$($marker,)*]);
    }
}

// uses call-site Cargo features
registry!(make_exportable);

macro_rules cb {
    ($($marker:path),*)) => {
        fn all_keys() -> ... {
            HashSet::from_iter([
                $($marker),* $<marker>::KEY.path()
            ])
        }
    }
}

Shane's version:

Conclusion:

LGTM: @robertbastian @sffc

robertbastian commented 2 weeks ago

Discussion:

icu_provider_export = { version = "~1.5.0", path = "provider/export" }
# DatagenDriver -> ExportDriver
icu_provider = { version = "~1.5.0", path = "provider/core" }
    icu_provider_macros = { version = "~1.5.0", path = "provider/core/macros" }
icu_provider_adapters = { version = "~1.5.0", path = "provider/adapters" }
icu_provider_baked = { version = "~1.5.0", path = "provider/baked" }
icu_provider_blob = { version = "~1.5.0", path = "provider/blob" }
icu_provider_fs = { version = "~1.5.0", path = "provider/fs" }

icu_provider_source = { version = "~1.5.0", path = "provider/source" }
# DatagenProvider -> SourceDataProvider
icu_provider_registry = { version = "~1.5.0", path = "provider/registry" }

LGTM: @sffc @robertbastian