From bd2e85ebe5e416210cd38c67e3927477541f1a3c Mon Sep 17 00:00:00 2001 From: Mikey Lombardi Date: Tue, 8 Sep 2026 10:39:33 -0500 Subject: [PATCH] (MAINT) Always rebuild for updated translations Prior to this change the Rust projects in the repository did not automatically rebuild when translation files in the `locales` directory are updated. This caused a frustrating developer experience where the developer was _required_ to update a Rust source code file to trigger a rebuild. If the contributor only needed to update the code to trigger a rebuild they were then required to change the code back afterward. This change ensures that: 1. Every Rust crate in the repository that has a `locales` folder also has a `build.rs` build script file. 1. Every build script for a Rust crate in the repository includes a cargo directive to rebuild the crate when any files in the `locales` directory are modified, including when a new file is created. 1. Changes to translations are picked up immediately, including when working through Rust unit and integration tests. --- dsc-bicep-ext/build.rs | 2 ++ dsc/build.rs | 7 +++++++ lib/dsc-lib-jsonschema/build.rs | 2 ++ lib/dsc-lib-registry/build.rs | 7 +++++++ lib/dsc-lib/build.rs | 7 +++++++ resources/WindowsUpdate/build.rs | 7 +++++++ resources/dism_dsc/build.rs | 7 +++++++ resources/dscecho/build.rs | 7 +++++++ resources/registry/build.rs | 1 + resources/runcommandonset/build.rs | 7 +++++++ resources/sshdconfig/build.rs | 7 +++++++ resources/windows_firewall/build.rs | 7 +++++++ resources/windows_service/build.rs | 7 +++++++ xtask/build.rs | 7 +++++++ 14 files changed, 82 insertions(+) create mode 100644 dsc/build.rs create mode 100644 lib/dsc-lib-registry/build.rs create mode 100644 lib/dsc-lib/build.rs create mode 100644 resources/WindowsUpdate/build.rs create mode 100644 resources/dism_dsc/build.rs create mode 100644 resources/dscecho/build.rs create mode 100644 resources/runcommandonset/build.rs create mode 100644 resources/sshdconfig/build.rs create mode 100644 resources/windows_firewall/build.rs create mode 100644 resources/windows_service/build.rs create mode 100644 xtask/build.rs diff --git a/dsc-bicep-ext/build.rs b/dsc-bicep-ext/build.rs index 7d66e7fec..505fbe77f 100644 --- a/dsc-bicep-ext/build.rs +++ b/dsc-bicep-ext/build.rs @@ -7,6 +7,8 @@ fn main() -> Result<(), Box> { // Prevent this build script from rerunning unless the proto file or build script changes. println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=proto/bicep.proto"); + // Always rebuild if translations are updated. + println!("cargo:rerun-if-changed=locales"); let descriptor_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("bicep.bin"); diff --git a/dsc/build.rs b/dsc/build.rs new file mode 100644 index 000000000..78749624c --- /dev/null +++ b/dsc/build.rs @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +fn main() { + // Always rebuild if translations are updated. + println!("cargo:rerun-if-changed=locales"); +} diff --git a/lib/dsc-lib-jsonschema/build.rs b/lib/dsc-lib-jsonschema/build.rs index 812a42907..a9035378e 100644 --- a/lib/dsc-lib-jsonschema/build.rs +++ b/lib/dsc-lib-jsonschema/build.rs @@ -530,4 +530,6 @@ fn main() { println!("cargo::rerun-if-changed=build.rs"); println!("cargo::rerun-if-changed=.versions.json"); println!("cargo::rerun-if-changed=.versions.ps1"); + // Always rebuild if translations are updated. + println!("cargo:rerun-if-changed=locales"); } diff --git a/lib/dsc-lib-registry/build.rs b/lib/dsc-lib-registry/build.rs new file mode 100644 index 000000000..78749624c --- /dev/null +++ b/lib/dsc-lib-registry/build.rs @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +fn main() { + // Always rebuild if translations are updated. + println!("cargo:rerun-if-changed=locales"); +} diff --git a/lib/dsc-lib/build.rs b/lib/dsc-lib/build.rs new file mode 100644 index 000000000..78749624c --- /dev/null +++ b/lib/dsc-lib/build.rs @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +fn main() { + // Always rebuild if translations are updated. + println!("cargo:rerun-if-changed=locales"); +} diff --git a/resources/WindowsUpdate/build.rs b/resources/WindowsUpdate/build.rs new file mode 100644 index 000000000..78749624c --- /dev/null +++ b/resources/WindowsUpdate/build.rs @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +fn main() { + // Always rebuild if translations are updated. + println!("cargo:rerun-if-changed=locales"); +} diff --git a/resources/dism_dsc/build.rs b/resources/dism_dsc/build.rs new file mode 100644 index 000000000..78749624c --- /dev/null +++ b/resources/dism_dsc/build.rs @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +fn main() { + // Always rebuild if translations are updated. + println!("cargo:rerun-if-changed=locales"); +} diff --git a/resources/dscecho/build.rs b/resources/dscecho/build.rs new file mode 100644 index 000000000..78749624c --- /dev/null +++ b/resources/dscecho/build.rs @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +fn main() { + // Always rebuild if translations are updated. + println!("cargo:rerun-if-changed=locales"); +} diff --git a/resources/registry/build.rs b/resources/registry/build.rs index 977722481..ceb67a462 100644 --- a/resources/registry/build.rs +++ b/resources/registry/build.rs @@ -4,4 +4,5 @@ fn main() { // Prevent this build script from rerunning unnecessarily. println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-changed=locales"); } diff --git a/resources/runcommandonset/build.rs b/resources/runcommandonset/build.rs new file mode 100644 index 000000000..78749624c --- /dev/null +++ b/resources/runcommandonset/build.rs @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +fn main() { + // Always rebuild if translations are updated. + println!("cargo:rerun-if-changed=locales"); +} diff --git a/resources/sshdconfig/build.rs b/resources/sshdconfig/build.rs new file mode 100644 index 000000000..78749624c --- /dev/null +++ b/resources/sshdconfig/build.rs @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +fn main() { + // Always rebuild if translations are updated. + println!("cargo:rerun-if-changed=locales"); +} diff --git a/resources/windows_firewall/build.rs b/resources/windows_firewall/build.rs new file mode 100644 index 000000000..78749624c --- /dev/null +++ b/resources/windows_firewall/build.rs @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +fn main() { + // Always rebuild if translations are updated. + println!("cargo:rerun-if-changed=locales"); +} diff --git a/resources/windows_service/build.rs b/resources/windows_service/build.rs new file mode 100644 index 000000000..78749624c --- /dev/null +++ b/resources/windows_service/build.rs @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +fn main() { + // Always rebuild if translations are updated. + println!("cargo:rerun-if-changed=locales"); +} diff --git a/xtask/build.rs b/xtask/build.rs new file mode 100644 index 000000000..78749624c --- /dev/null +++ b/xtask/build.rs @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +fn main() { + // Always rebuild if translations are updated. + println!("cargo:rerun-if-changed=locales"); +}