Debian Codegraph @

bindings/rust/gpiosim-sys/build.rs

raw symbols SCIP
1 // SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
2 // SPDX-FileCopyrightText: 2022 Linaro Ltd.
3 // SPDX-FileCopyrightText: 2022 Viresh Kumar <[email protected]>
4
5 extern crate bindgen;
6
7 use std::env;
8 use std::path::PathBuf;
9
10 fn generate_bindings() {
11 // Tell cargo to invalidate the built crate whenever following files change
12 println!("cargo:rerun-if-changed=../../../tests/gpiosim/gpiosim.h");
13
14 // The bindgen::Builder is the main entry point
15 // to bindgen, and lets you build up options for
16 // the resulting bindings.
17 let bindings = bindgen::Builder::default()
18 // The input header we would like to generate
19 // bindings for.
20 .header("../../../tests/gpiosim/gpiosim.h")
21 // Tell cargo to invalidate the built crate whenever any of the
22 // included header files changed.
23 .parse_callbacks(Box::new(bindgen::CargoCallbacks))
24 // Finish the builder and generate the bindings.
25 .generate()
26 // Unwrap the Result and panic on failure.
27 .expect("Unable to generate bindings");
28
29 // Write the bindings to the $OUT_DIR/bindings.rs file.
30 let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
31 bindings
32 .write_to_file(out_path.join("bindings.rs"))
33 .expect("Couldn't write bindings!");
34 }
35
36 fn main() {
37 generate_bindings();
38
39 println!("cargo:rustc-link-lib=kmod");
40 println!("cargo:rustc-link-lib=mount");
41 println!("cargo:rustc-link-search=./../../tests/gpiosim/.libs/");
42 println!("cargo:rustc-link-lib=static=gpiosim");
43 }