mirror of https://github.com/aya-rs/aya
aya-gen: add bindgen module and utils to write to file
parent
16975e87d8
commit
99447bcc0d
@ -0,0 +1,13 @@
|
||||
use bindgen::{self, Builder, EnumVariation};
|
||||
|
||||
pub fn builder() -> Builder {
|
||||
let bindgen = bindgen::builder()
|
||||
.use_core()
|
||||
.ctypes_prefix("::aya_bpf_cty")
|
||||
.layout_tests(false)
|
||||
.clang_arg("-Wno-unknown-attributes")
|
||||
.default_enum_style(EnumVariation::Consts)
|
||||
.prepend_enum_name(false);
|
||||
|
||||
bindgen
|
||||
}
|
@ -1,3 +1,19 @@
|
||||
use std::{
|
||||
fs::File,
|
||||
io::{self, Write},
|
||||
path::Path,
|
||||
};
|
||||
|
||||
pub mod bindgen;
|
||||
pub mod btf_types;
|
||||
pub mod getters;
|
||||
pub mod rustfmt;
|
||||
|
||||
pub fn write_to_file<T: AsRef<Path>>(path: T, code: &str) -> Result<(), io::Error> {
|
||||
let mut file = File::create(path)?;
|
||||
file.write_all(code.as_bytes())
|
||||
}
|
||||
|
||||
pub fn write_to_file_fmt<T: AsRef<Path>>(path: T, code: &str) -> Result<(), io::Error> {
|
||||
write_to_file(path, &rustfmt::format(code)?)
|
||||
}
|
||||
|
Loading…
Reference in New Issue