Skip to content

Commit 4078471

Browse files
Have bindgen generate code suitable for compiling with rustc 1.72.0
1 parent 3351c5c commit 4078471

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

build.rs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
1+
use bindgen::{RustEdition, RustTarget};
2+
use std::env;
3+
use std::path::Path;
4+
15
#[cfg(target_os = "macos")]
26
fn main() {
3-
use std::env;
4-
use std::path::Path;
5-
6-
let bindings = bindgen::builder()
7-
.header_contents("libproc_rs.h", "#include <libproc.h>")
8-
.layout_tests(false)
9-
.clang_args(&["-x", "c++", "-I", "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/"])
10-
.generate()
11-
.expect("Failed to build libproc bindings");
7+
match RustTarget::stable(72, 0) {
8+
Ok(rust_target) => {
9+
let bindings = bindgen::builder()
10+
.header_contents("libproc_rs.h", "#include <libproc.h>")
11+
.rust_target(rust_target)
12+
.rust_edition(RustEdition::Edition2018)
13+
.layout_tests(false)
14+
.clang_args(&["-x", "c++", "-I", "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/"])
15+
.generate()
16+
.expect("Failed to build libproc bindings");
1217

13-
let output_path = Path::new(&env::var("OUT_DIR")
14-
.expect("OUT_DIR env var was not defined"))
15-
.join("osx_libproc_bindings.rs");
18+
let output_path = Path::new(&env::var("OUT_DIR")
19+
.expect("OUT_DIR env var was not defined"))
20+
.join("osx_libproc_bindings.rs");
1621

17-
bindings
18-
.write_to_file(output_path)
19-
.expect("Failed to write libproc bindings");
22+
bindings
23+
.write_to_file(output_path)
24+
.expect("Failed to write libproc bindings");
25+
}
26+
_ => eprintln!("Error executing bindgen")
27+
}
2028
}
2129

2230
#[cfg(any(target_os = "linux", target_os = "redox", target_os = "android"))]

0 commit comments

Comments
 (0)