proof: skip a licence file that isn't UTF-8 instead of failing the build

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Martin BallandClaude Opus 5.5 committed 2026-11-02 21:46:00 +00:00
1 parent 9b6ef1199a
commit 7c3f45dd5e
1 file changed
+7 -1
+7 -1
View File
@@ -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:?})), ");
}
}
}