From 569423b92270b13b4ea7e2e9e391e145ebdc95bb Mon Sep 17 00:00:00 2001 From: Wim Pomp Date: Fri, 12 Sep 2025 19:04:25 +0200 Subject: [PATCH] Try fix some build/publish issues. --- Cargo.toml | 1 + build.rs | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7414c9e..e6887ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,3 +41,4 @@ strip = "symbols" [features] sitk_no_build = [] # do not build all the C++ stuff, just use the rust code to make docs etc. +copy_autocxx_src = [] # copy the generated autocxx-ffi-default-gen.rs to src for inclusion in the repo diff --git a/build.rs b/build.rs index 10ca01e..8b63eb0 100644 --- a/build.rs +++ b/build.rs @@ -74,10 +74,11 @@ fn main() -> Result<(), Box> { cpp_string.replace_all(&cxx, "pub mod simple {\nuse crate::ffi::ToCppString;"); write!(f, "{}", cxx)?; } - fs::copy(dst.join(&cxx_file), "src/autocxx-ffi-default-gen_unfmt.rs")?; - Command::new("rustfmt").arg(&cxx_file).status()?; - fs::copy(dst.join(&cxx_file), "src/autocxx-ffi-default-gen.rs")?; - + if cfg!(feature = "copy_autocxx_src") { + fs::copy(dst.join(&cxx_file), "src/autocxx-ffi-default-gen_unfmt.rs")?; + Command::new("rustfmt").arg(&cxx_file).status()?; + fs::copy(dst.join(&cxx_file), "src/autocxx-ffi-default-gen.rs")?; + } println!("cargo:warning=merged_lib={}", merged_lib.join("build").display()); println!("cargo:rustc-link-search={}", merged_lib.join("build").display()); println!("cargo:rustc-link-lib=static=sitk_ffi_extra");