lvgl-rs/lvgl/build.rs

34 lines
771 B
Rust
Raw Normal View History

2020-06-14 08:02:32 +00:00
use lvgl_codegen::{CodeGen, Rusty};
use proc_macro2::TokenStream;
use quote::quote;
2020-06-12 16:20:02 +00:00
use std::env;
2020-06-14 08:02:32 +00:00
use std::fs::File;
use std::io::prelude::*;
use std::path::PathBuf;
2020-06-12 10:41:20 +00:00
fn main() {
2020-06-14 08:02:32 +00:00
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
let rs = out_path.join("generated.rs");
2020-06-12 16:20:02 +00:00
2020-06-14 08:02:32 +00:00
let widgets_impl = lvgl_sys::_bindgen_raw_src();
let codegen = CodeGen::from(widgets_impl).unwrap();
let widgets_impl: Vec<TokenStream> = codegen
.get_widgets()
.iter()
.flat_map(|w| w.code(&()))
.collect();
let code = quote! {
#(#widgets_impl)*
};
let mut file = File::create(rs).unwrap();
writeln!(
file,
"/* automatically generated by lvgl-codegen */\n{}",
code
)
.unwrap();
2020-06-12 10:41:20 +00:00
}