From 7c3f45dd5ef91a6f75f09b99267dae6e30fb1044 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Mon, 2 Nov 2026 21:46:00 +0000 Subject: [PATCH] proof: skip a licence file that isn't UTF-8 instead of failing the build Co-Authored-By: Claude Opus 5.5 --- crates/proof/build.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/proof/build.rs b/crates/proof/build.rs index 8ff77fc4..391de460 100644 --- a/crates/proof/build.rs +++ b/crates/proof/build.rs @@ -152,8 +152,14 @@ fn main() { files.sort(); for f in files { println!("cargo::rerun-if-changed={}", f.display()); + // `include_str!` fails the whole build on a file that isn't UTF-8 (a Latin-1 + // licence text) and can't name a path that isn't either: leave such a file out. + let (Some(path), true) = (f.to_str(), std::fs::read_to_string(&f).is_ok()) else { + println!("cargo::{level}=CRAFT_I18N_DIR: {} is not UTF-8; its licence text is not embedded", f.display()); + continue; + }; let title = format!("{locale}: {}", f.file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default()); - let _ = write!(licences, "({title:?}, include_str!({:?})), ", f.display().to_string()); + let _ = write!(licences, "({title:?}, include_str!({path:?})), "); } } }