Skip to content

Commit

Permalink
feat: accept additional cflags from LVGL_CFLAGS env var
Browse files Browse the repository at this point in the history
  • Loading branch information
elrafoon authored and rafaelcaricio committed Jun 15, 2024
1 parent 9829aef commit 3b3abb3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lvgl-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -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![
Expand Down Expand Up @@ -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");

Expand Down

0 comments on commit 3b3abb3

Please sign in to comment.