From ef250445c192c5fd8630e9b29f2589b467b80e81 Mon Sep 17 00:00:00 2001 From: Joseph Ross Date: Tue, 26 Jun 2018 14:41:29 -0700 Subject: [PATCH] Fix Android cross-compile build: `cargo build --target armv7-linux-androideabi` --- lmdb-sys/build.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lmdb-sys/build.rs b/lmdb-sys/build.rs index 8ae769a..b1bd80e 100644 --- a/lmdb-sys/build.rs +++ b/lmdb-sys/build.rs @@ -11,11 +11,16 @@ fn main() { lmdb.push("liblmdb"); if !pkg_config::find_library("liblmdb").is_ok() { - cc::Build::new() - .file(lmdb.join("mdb.c")) - .file(lmdb.join("midl.c")) - // https://github.com/LMDB/lmdb/blob/LMDB_0.9.21/libraries/liblmdb/Makefile#L25 - .opt_level(2) - .compile("liblmdb.a") + let target = env::var("TARGET").expect("No TARGET found"); + let mut build = cc::Build::new(); + if target.contains("android") { + build.define("ANDROID", "1"); + } + build + .file(lmdb.join("mdb.c")) + .file(lmdb.join("midl.c")) + // https://github.com/LMDB/lmdb/blob/LMDB_0.9.21/libraries/liblmdb/Makefile#L25 + .opt_level(2) + .compile("liblmdb.a") } }