From a9b700c8413ee8cfdacf504112da8b43e4fad7b2 Mon Sep 17 00:00:00 2001 From: Dubiousjim Date: Wed, 10 Jun 2020 17:06:47 -0400 Subject: [PATCH] sys/build.rs: LIBSQLITE3_FLAGS hook Enables compiling bundled sources with different flags. Env variable name modeled after LIBSQLITE3_SYS_BUNDLING. May want to println!("cargo:warning=...") instead of panicking. --- libsqlite3-sys/build.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libsqlite3-sys/build.rs b/libsqlite3-sys/build.rs index 14c5f2a..c4cd5aa 100644 --- a/libsqlite3-sys/build.rs +++ b/libsqlite3-sys/build.rs @@ -127,6 +127,19 @@ mod build_bundled { } println!("cargo:rerun-if-env-changed=SQLITE_MAX_EXPR_DEPTH"); + if let Ok(extras) = env::var("LIBSQLITE3_FLAGS") { + for extra in extras.split_whitespace() { + if extra.starts_with("-D") || extra.starts_with("-U") { + cfg.flag(extra); + } else if extra.starts_with("SQLITE_") { + cfg.flag(&format!("-D{}", extra)); + } else { + panic!("Don't understand {} in LIBSQLITE3_FLAGS", extra); + } + } + } + println!("cargo:rerun-if-env-changed=LIBSQLITE3_FLAGS"); + cfg.compile("libsqlite3.a"); println!("cargo:lib_dir={}", out_dir);