1 // Copyright 2022, The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 use std::env;
16 use std::process::Command;
17
main()18 fn main() {
19 println!("cargo:rerun-if-changed=uci_packets.pdl");
20
21 // Generate the rust code by bluetooth_packetgen.
22 // The binary should be compiled by `m bluetooth_packetgen -j32` before calling cargo.
23 let out_dir = env::var_os("OUT_DIR").unwrap();
24 let output = Command::new("env")
25 .arg("bluetooth_packetgen")
26 .arg("--out=".to_owned() + out_dir.as_os_str().to_str().unwrap())
27 .arg("--include=.")
28 .arg("--rust")
29 .arg("uci_packets.pdl")
30 .output()
31 .unwrap();
32
33 eprintln!(
34 "Status: {}, stdout: {}, stderr: {}",
35 output.status,
36 String::from_utf8_lossy(output.stdout.as_slice()),
37 String::from_utf8_lossy(output.stderr.as_slice())
38 );
39 }
40