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");