Skip to content

fix: add build.rs to crates with version-gated code lacking auto-detection#363

Open
clydegerber wants to merge 1 commit into
google:mainfrom
clydegerber:fix/version-detection-build-scripts
Open

fix: add build.rs to crates with version-gated code lacking auto-detection#363
clydegerber wants to merge 1 commit into
google:mainfrom
clydegerber:fix/version-detection-build-scripts

Conversation

@clydegerber
Copy link
Copy Markdown
Contributor

Summary

Adds build.rs to rust_icu_ecma402, rust_icu_ulistformatter, and rust_icu_unumberformatter. These crates have #[cfg(feature = "icu_version_XX_plus")]-gated code but lacked their own build.rs, so they relied on downstream feature propagation rather than ICU auto-detection from pkg-config.

The new build.rs files follow the same pattern as rust_icu_uloc/build.rs, calling rust_icu_release::run() to emit cargo:rustc-cfg flags based on the installed ICU version.

Also:

  • Adds a "ICU version feature detection" section to CONTRIBUTING.md documenting how version-gated code is wired up.
  • Simplifies the macos-test Makefile target, since the affected crates now self-configure.

Test plan

  • cargo test -p rust_icu_ulistformatter runs the previously-skipped version-gated test
  • CI passes

This commit was created by an automated coding assistant, with human supervision.

…ction

rust_icu_ulistformatter, rust_icu_unumberformatter, and rust_icu_ecma402
contained #[cfg(feature = "icu_version_XX_plus")]-gated code but had no
build.rs. Without a build.rs calling rust_icu_release::run(), the installed
ICU version is never queried for these crates and the version cfg flags are
never emitted, causing version-gated code and tests to be silently excluded
when building with default features, even if a modern ICU version is installed.

Add a build.rs (following the pattern established in rust_icu_uloc) and the
corresponding [build-dependencies] to each affected crate.

With all version-gated crates now having a build.rs for auto-detection, the
macos-test Makefile target no longer needs to pass explicit version feature
flags; simplify it to use default features for the dynamic-link pass and
--features=static for the static-link pass. The Makefile is taken from the
fix/macos-native-bindgen branch which also updates the brew prefix detection
and adds PKG_CONFIG_PATH and RUSTFLAGS for the Homebrew ICU installation.

Document the two-mechanism version detection design in CONTRIBUTING.md so
future contributors know to add a build.rs when adding version-gated code.

This commit was created by an automated coding assistant, with human
supervision.
@filmil
Copy link
Copy Markdown
Member

filmil commented May 18, 2026

I'm not sure what to think about the proliferation of build.rs. But I do admit that it resolves a headache.

Flip side, most XX values are now smaller than the minimum ICU version we support, so maybe we can instead just remove those feature flags.

Thoughts?

@clydegerber
Copy link
Copy Markdown
Contributor Author

Removing the obsolete feature flags is a good call. I'll work it up.

@clydegerber
Copy link
Copy Markdown
Contributor Author

I created a new PR (364) for this approach. I can close whichever one we don't want to go with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants