[niepce] rust: allow skipping cbindgen
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] rust: allow skipping cbindgen
- Date: Fri, 16 Mar 2018 02:51:31 +0000 (UTC)
commit 6c8088e283d5ec695f921ce3bb3c97884a383c8c
Author: Hubert Figuière <hub figuiere net>
Date: Sun Mar 4 11:49:57 2018 -0500
rust: allow skipping cbindgen
- have SKIP_CBINDINGS env defined to skip cbindgen
build.rs | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
---
diff --git a/build.rs b/build.rs
index 368465a..a11db44 100644
--- a/build.rs
+++ b/build.rs
@@ -47,23 +47,25 @@ fn main() {
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
- // Use cbindgen to generate C bindings.
- let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
- let target_dir = env::var("CARGO_TARGET_DIR").unwrap_or(String::from("./target"));
- let mut target_file = PathBuf::from(target_dir);
- target_file.push("bindings.h");
- let cbuilder = cbindgen::Builder::new()
- .with_include_guard("niepce_rust_bindings_h")
- .with_namespace("ffi")
- .with_language(cbindgen::Language::Cxx)
- .with_parse_deps(true)
- .with_parse_exclude(&["exempi", "chrono"])
- .exclude_item("GtkWindow")
- .with_crate(&crate_dir);
+ if env::var("SKIP_CBINDINGS").is_err() {
+ // Use cbindgen to generate C bindings.
+ let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
+ let target_dir = env::var("CARGO_TARGET_DIR").unwrap_or(String::from("./target"));
+ let mut target_file = PathBuf::from(target_dir);
+ target_file.push("bindings.h");
+ let cbuilder = cbindgen::Builder::new()
+ .with_include_guard("niepce_rust_bindings_h")
+ .with_namespace("ffi")
+ .with_language(cbindgen::Language::Cxx)
+ .with_parse_deps(true)
+ .with_parse_exclude(&["exempi", "chrono"])
+ .exclude_item("GtkWindow")
+ .with_crate(&crate_dir);
- if let Ok(bindings) = cbuilder.generate() {
- bindings.write_to_file(&*target_file.to_string_lossy());
- } else {
- println!("Couldn't generate bindings");
+ if let Ok(bindings) = cbuilder.generate() {
+ bindings.write_to_file(&*target_file.to_string_lossy());
+ } else {
+ println!("Couldn't generate bindings");
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]