From 3b3abb3019eef637b932fae967a8d246bf5b6f14 Mon Sep 17 00:00:00 2001 From: Stanislav Ravas Date: Tue, 28 May 2024 21:31:05 +0200 Subject: [PATCH] feat: accept additional cflags from LVGL_CFLAGS env var --- lvgl-sys/build.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lvgl-sys/build.rs b/lvgl-sys/build.rs index 06fd7592..3a8c4c58 100644 --- a/lvgl-sys/build.rs +++ b/lvgl-sys/build.rs @@ -52,6 +52,10 @@ fn main() { #[cfg(feature = "drivers")] let incl_extra = env::var("LVGL_INCLUDE").unwrap_or("/usr/include,/usr/local/include".to_string()); + + let cflags_extra = env::var("LVGL_CFLAGS").unwrap_or_default(); + let cflags_extra = cflags_extra.split(','); + #[cfg(feature = "drivers")] let link_extra = env::var("LVGL_LINK").unwrap_or("SDL2".to_string()); @@ -154,6 +158,11 @@ fn main() { #[cfg(feature = "drivers")] cfg.includes(incl_extra.split(',')); + cflags_extra.clone().for_each(|e| { + let mut it = e.split('='); + cfg.define(it.next().unwrap(), it.next().unwrap_or_default()); + }); + cfg.compile("lvgl"); let mut cc_args = vec![ @@ -230,6 +239,7 @@ fn main() { .ctypes_prefix("cty") .clang_args(&cc_args) .clang_args(&additional_args) + .clang_args(cflags_extra.map(|f| format!("-D{f}"))) .generate() .expect("Unable to generate bindings");