• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 The Chromium OS Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 extern crate bindgen;
5 
6 use std::fs::File;
7 use std::io::Write;
8 use std::path::PathBuf;
9 
main()10 fn main() {
11     let bindings = bindgen::Builder::default()
12         .header("wrapper.h")
13         .derive_debug(false)
14         .clang_arg("-I../../../sound-open-firmware-private/src/include")
15         .whitelist_type("sof_abi_hdr")
16         .whitelist_type("sof_ipc_ctrl_cmd")
17         .generate()
18         .expect("Unable to generate bindings");
19 
20     let header = b"// Copyright 2020 The Chromium OS Authors. All rights reserved.
21 // Use of this source code is governed by a BSD-style license that can be
22 // found in the LICENSE file.
23 /*
24  * generated from files in sound-open-firmware-private/src/include:
25  * kernel/header.h
26  * ipc/control.h
27  */
28 
29 ";
30 
31     // Write the bindings to the $OUT_DIR/bindings.rs file.
32     let out_path = PathBuf::from("../src").join("bindings.rs");
33 
34     let mut output_file =
35         File::create(&out_path).expect(&format!("Couldn't create {:?}", out_path));
36     output_file
37         .write_all(header)
38         .expect("Couldn't write header");
39     output_file
40         .write_all(bindings.to_string().as_bytes())
41         .expect("Couldn't write bindings");
42 }
43