diff options
author | 2023-01-31 23:31:35 +0000 | |
---|---|---|
committer | 2023-01-31 23:31:35 +0000 | |
commit | 3d401dae9535cf142cdebb0cc46cb17feed6eb30 (patch) | |
tree | 84aa38cc6760fc0f54f6f8d3acef86d4cf2e0aa5 /system/rust/build.rs | |
parent | caa5be2f685b7d52c850986d1b7eb19a71e655d2 (diff) |
[Private GATT] Initial boilerplate
Bug: 255880936
Test: compiles
Change-Id: Ia835784365e6fa6cf8a4bd23c088b1fb2dbe0ed9
Diffstat (limited to 'system/rust/build.rs')
-rw-r--r-- | system/rust/build.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/system/rust/build.rs b/system/rust/build.rs new file mode 100644 index 0000000000..f0e49e69df --- /dev/null +++ b/system/rust/build.rs @@ -0,0 +1,30 @@ +use std::{ + env, + fs::File, + path::Path, + process::{Command, Stdio}, +}; + +fn main() { + let out_dir = env::var_os("OUT_DIR").unwrap(); + let dest_path = Path::new(&out_dir).join("_packets.rs"); + let dest_file = File::create(dest_path).unwrap(); + + let pdl = Command::new("pdl") + .args(&["--output-format", "rust_no_alloc", "src/packets.pdl"]) + .stdout(Stdio::piped()) + .spawn() + .unwrap(); + + let mut rustfmt = + Command::new("rustfmt").stdin(pdl.stdout.unwrap()).stdout(dest_file).spawn().unwrap(); + + rustfmt.wait().unwrap(); + + if let Some(err) = rustfmt.stderr { + panic!("{:?}", err); + } + + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-changed=src/packets.pdl"); +} |