mirror of
https://github.com/storytold/craft-anything.git
synced 2026-11-05 20:47:45 +01:00
Fail builds when required Windows resource embedding fails (#427)
The app build scripts stop the build when required Windows resources fail to embed (cargo::error instead of the ignored cargo:error). Fixes #264.
This commit is contained in:
@@ -22,7 +22,7 @@ fn main() {
|
||||
res.set_manifest(MANIFEST).set("OriginalFilename", "craft-anything-cli.exe").set("InternalName", "craft-anything-cli");
|
||||
if let Err(e) = res.compile() {
|
||||
if std::env::var_os("CRAFT_ANYTHING_REQUIRE_WINRES").is_some() {
|
||||
println!("cargo:error=embedding Windows resources failed: {e}");
|
||||
println!("cargo::error=embedding Windows resources failed: {e}");
|
||||
return;
|
||||
}
|
||||
println!("cargo:warning=craft-anything-cli.exe built without its DPI-aware manifest: {e}");
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//! The app build scripts must fail the build (Cargo's `cargo::error` instruction) when Windows
|
||||
//! resources are required. The single-colon `cargo:error=` form is ignored by Cargo as metadata.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
fn read(rel: &str) -> String {
|
||||
let path = Path::new(env!("CARGO_MANIFEST_DIR")).join(rel);
|
||||
std::fs::read_to_string(&path).unwrap_or_default()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn required_windows_resource_failure_uses_cargo_error_directive() {
|
||||
for rel in ["build.rs", "../craft-anything/build.rs"] {
|
||||
let src = read(rel);
|
||||
assert!(!src.is_empty(), "{rel} should be readable");
|
||||
assert!(!src.contains("cargo:error="), "{rel} emits the ignored single-colon error directive");
|
||||
assert!(src.contains("cargo::error="), "{rel} must emit cargo::error= when resources are required");
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ fn main() {
|
||||
.set("InternalName", "craft-anything");
|
||||
if let Err(e) = res.compile() {
|
||||
if std::env::var_os("CRAFT_ANYTHING_REQUIRE_WINRES").is_some() {
|
||||
println!("cargo:error=embedding Windows resources failed: {e}");
|
||||
println!("cargo::error=embedding Windows resources failed: {e}");
|
||||
return;
|
||||
}
|
||||
println!("cargo:warning=craft-anything.exe built without icon/version resources: {e}");
|
||||
|
||||
Reference in New Issue
Block a user