[niepce] rust: cleanup cbindgen build
- From: Hubert Figuière <hub src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [niepce] rust: cleanup cbindgen build
- Date: Sat, 18 Jan 2020 05:25:49 +0000 (UTC)
commit 55653d3f92176f4a4ab3bb285bb09301c4a04abb
Author: Hubert Figuière <hub figuiere net>
Date: Sun Jan 5 14:41:56 2020 -0500
rust: cleanup cbindgen build
build.rs | 13 +++++--------
crates/npc-engine/build.rs | 13 +++++--------
crates/npc-fwk/build.rs | 13 +++++--------
3 files changed, 15 insertions(+), 24 deletions(-)
---
diff --git a/build.rs b/build.rs
index 15b01e2..32c3d8c 100644
--- a/build.rs
+++ b/build.rs
@@ -10,7 +10,7 @@ fn main() {
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()
+ cbindgen::Builder::new()
.with_include_guard("niepce_rust_bindings_h")
.with_namespace("ffi")
.with_language(cbindgen::Language::Cxx)
@@ -20,12 +20,9 @@ fn main() {
.exclude_item("GtkToolbar")
.exclude_item("GFileInfo")
.exclude_item("RgbColour")
- .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");
- }
+ .with_crate(&crate_dir)
+ .generate()
+ .expect("Couldn't generate bindings")
+ .write_to_file(&target_file);
}
}
diff --git a/crates/npc-engine/build.rs b/crates/npc-engine/build.rs
index 245c7d1..7051f65 100644
--- a/crates/npc-engine/build.rs
+++ b/crates/npc-engine/build.rs
@@ -62,7 +62,7 @@ fn main() {
let target_dir = env::var("CARGO_TARGET_DIR").unwrap_or(String::from("./target"));
let mut target_file = PathBuf::from(target_dir);
target_file.push("eng_bindings.h");
- let cbuilder = cbindgen::Builder::new()
+ cbindgen::Builder::new()
.with_include_guard("niepce_rust_eng_bindings_h")
.with_namespace("ffi")
.with_language(cbindgen::Language::Cxx)
@@ -72,12 +72,9 @@ fn main() {
.exclude_item("GtkToolbar")
.exclude_item("GFileInfo")
.exclude_item("RgbColour")
- .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");
- }
+ .with_crate(&crate_dir)
+ .generate()
+ .expect("Couldn't generate bindings")
+ .write_to_file(&*target_file.to_string_lossy());
}
}
diff --git a/crates/npc-fwk/build.rs b/crates/npc-fwk/build.rs
index 7254026..0126961 100644
--- a/crates/npc-fwk/build.rs
+++ b/crates/npc-fwk/build.rs
@@ -10,7 +10,7 @@ fn main() {
let target_dir = env::var("CARGO_TARGET_DIR").unwrap_or(String::from("./target"));
let mut target_file = PathBuf::from(target_dir);
target_file.push("fwk_bindings.h");
- let cbuilder = cbindgen::Builder::new()
+ cbindgen::Builder::new()
.with_include_guard("niepce_fwk_rust_bindings_h")
.with_namespace("ffi")
.with_language(cbindgen::Language::Cxx)
@@ -19,12 +19,9 @@ fn main() {
.exclude_item("GtkWindow")
.exclude_item("GtkToolbar")
.exclude_item("GFileInfo")
- .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");
- }
+ .with_crate(&crate_dir)
+ .generate()
+ .expect("Unable to generate bindings")
+ .write_to_file(&target_file);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]