|
| 1 | +use bindgen::{RustEdition, RustTarget}; |
| 2 | +use std::env; |
| 3 | +use std::path::Path; |
| 4 | + |
1 | 5 | #[cfg(target_os = "macos")] |
2 | 6 | 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"); |
12 | 17 |
|
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"); |
16 | 21 |
|
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 | + } |
20 | 28 | } |
21 | 29 |
|
22 | 30 | #[cfg(any(target_os = "linux", target_os = "redox", target_os = "android"))] |
|
0 commit comments