From 22a252d0647228cecb9fc08de38822975c8e4875 Mon Sep 17 00:00:00 2001 From: Daniel Rainer Date: Tue, 25 Nov 2025 00:36:12 +0100 Subject: [PATCH] gettext: rebuild extract macro on env var change While it's not necessary to rebuild the proc macro for extraction when the env var controlling the output location changes, this way everything using the macro will automatically be rebuilt when this env var changes, making it impossible to forget adding this to other `build.rs` files. For now, keeping the rebuild instructions in fish's main crate's `build.rs` would be fine as well, but if we start breaking this crate into smaller parts, it would become annoying to add the rebuild command in every crate depending on gettext extraction. Closes #12107 --- Cargo.lock | 1 + build.rs | 3 --- crates/gettext-extraction/Cargo.toml | 3 +++ crates/gettext-extraction/build.rs | 3 +++ 4 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 crates/gettext-extraction/build.rs diff --git a/Cargo.lock b/Cargo.lock index a88b4efe9..ab2b3c37c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -204,6 +204,7 @@ name = "fish-gettext-extraction" version = "0.0.0" dependencies = [ "proc-macro2", + "rsconf", ] [[package]] diff --git a/build.rs b/build.rs index e6251ef0b..1848cf0dc 100644 --- a/build.rs +++ b/build.rs @@ -42,9 +42,6 @@ fn main() { fish_build_helper::rebuild_if_embedded_path_changed("share"); - #[cfg(feature = "gettext-extract")] - rsconf::rebuild_if_env_changed("FISH_GETTEXT_EXTRACTION_FILE"); - let build = cc::Build::new(); let mut target = Target::new_from(build).unwrap(); // Keep verbose mode on until we've ironed out rust build script stuff diff --git a/crates/gettext-extraction/Cargo.toml b/crates/gettext-extraction/Cargo.toml index 043bb9aa4..868dafe44 100644 --- a/crates/gettext-extraction/Cargo.toml +++ b/crates/gettext-extraction/Cargo.toml @@ -13,5 +13,8 @@ proc-macro = true [dependencies] proc-macro2.workspace = true +[build-dependencies] +rsconf.workspace = true + [lints] workspace = true diff --git a/crates/gettext-extraction/build.rs b/crates/gettext-extraction/build.rs new file mode 100644 index 000000000..ad9c031c5 --- /dev/null +++ b/crates/gettext-extraction/build.rs @@ -0,0 +1,3 @@ +fn main() { + rsconf::rebuild_if_env_changed("FISH_GETTEXT_EXTRACTION_FILE"); +}