From 3afd5eee181dd86f0a497f7572cd369811bf037d Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Thu, 19 Sep 2024 14:01:50 -0500 Subject: [PATCH 1/2] cppwinrt --- crates/libs/cppwinrt/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/libs/cppwinrt/src/lib.rs b/crates/libs/cppwinrt/src/lib.rs index e82643e2da..39cc01adfe 100644 --- a/crates/libs/cppwinrt/src/lib.rs +++ b/crates/libs/cppwinrt/src/lib.rs @@ -14,7 +14,7 @@ where let mut path = std::env::temp_dir(); path.push(format!("cppwinrt-{VERSION}.exe")); - std::fs::write(&path, std::include_bytes!("../cppwinrt.exe")).unwrap(); + _ = std::fs::write(&path, std::include_bytes!("../cppwinrt.exe")); let mut command = std::process::Command::new(&path); command.args(args); let output = command.output().expect("failed to run cppwinrt"); From ee5b934328fe8e008f219b156f0789bb89e62e10 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Thu, 19 Sep 2024 14:07:02 -0500 Subject: [PATCH 2/2] safer --- crates/libs/cppwinrt/src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/libs/cppwinrt/src/lib.rs b/crates/libs/cppwinrt/src/lib.rs index 39cc01adfe..2e993dd825 100644 --- a/crates/libs/cppwinrt/src/lib.rs +++ b/crates/libs/cppwinrt/src/lib.rs @@ -14,7 +14,13 @@ where let mut path = std::env::temp_dir(); path.push(format!("cppwinrt-{VERSION}.exe")); - _ = std::fs::write(&path, std::include_bytes!("../cppwinrt.exe")); + let bytes = std::include_bytes!("../cppwinrt.exe"); + + // Concurrent builds can cause this to fail, so we just make sure the bytes match on failure. + if std::fs::write(&path, bytes).is_err() { + assert_eq!(*bytes, *std::fs::read(&path).unwrap()); + } + let mut command = std::process::Command::new(&path); command.args(args); let output = command.output().expect("failed to run cppwinrt");