diff --git a/build.rs b/build.rs index e96a43e30..2dc77affc 100644 --- a/build.rs +++ b/build.rs @@ -28,37 +28,13 @@ pub mod dynamic; #[path = "build/static.rs"] pub mod r#static; -/// Copies a file. -#[cfg(feature = "runtime")] -fn copy(source: &str, destination: &Path) { - use std::fs::File; - use std::io::{Read, Write}; - - let mut string = String::new(); - File::open(source) - .unwrap() - .read_to_string(&mut string) - .unwrap(); - File::create(destination) - .unwrap() - .write_all(string.as_bytes()) - .unwrap(); -} - /// Copies the code used to find and link to `libclang` shared libraries into /// the build output directory so that it may be used when linking at runtime. #[cfg(feature = "runtime")] fn main() { - use std::env; - if cfg!(feature = "static") { panic!("`runtime` and `static` features can't be combined"); } - - let out = env::var("OUT_DIR").unwrap(); - copy("build/macros.rs", &Path::new(&out).join("macros.rs")); - copy("build/common.rs", &Path::new(&out).join("common.rs")); - copy("build/dynamic.rs", &Path::new(&out).join("dynamic.rs")); } /// Finds and links to the required libraries dynamically or statically. diff --git a/src/link.rs b/src/link.rs index 58e64b507..895131a36 100644 --- a/src/link.rs +++ b/src/link.rs @@ -190,7 +190,7 @@ https://docs.rs/clang-sys/latest/clang_sys/{0}/index.html Instructions for installing `libclang` can be found here: https://rust-lang.github.io/rust-bindgen/requirements.html -"#, +"#, stringify!($name), library .version() @@ -226,9 +226,9 @@ https://rust-lang.github.io/rust-bindgen/requirements.html pub fn load_manually() -> Result { #[allow(dead_code)] mod build { - include!(concat!(env!("OUT_DIR"), "/macros.rs")); - pub mod common { include!(concat!(env!("OUT_DIR"), "/common.rs")); } - pub mod dynamic { include!(concat!(env!("OUT_DIR"), "/dynamic.rs")); } + include!("../build/macros.rs"); + pub mod common { include!("../build/common.rs"); } + pub mod dynamic { include!("../build/dynamic.rs"); } } let (directory, filename) = build::dynamic::find(true)?;