Manually set bindgen sysroot for Android build
This commit is contained in:
parent
34fc7e4286
commit
310093b38a
9
build.rs
9
build.rs
|
@ -24,6 +24,15 @@ fn main() {
|
||||||
{
|
{
|
||||||
bindings = bindings.layout_tests(false);
|
bindings = bindings.layout_tests(false);
|
||||||
}
|
}
|
||||||
|
if matches!(env::var("CARGO_CFG_TARGET_OS"), Result::Ok(v) if v == "android") {
|
||||||
|
if let Result::Ok(cc) = env::var("TARGET_CXX") {
|
||||||
|
let mut sysroot = PathBuf::from(cc).with_file_name("../sysroot");
|
||||||
|
sysroot = sysroot.canonicalize().unwrap_or_else(|err| {
|
||||||
|
panic!("Failed to locate {}: {}", sysroot.to_string_lossy(), err)
|
||||||
|
});
|
||||||
|
bindings = bindings.clang_arg(format!("--sysroot={}", sysroot.to_string_lossy()));
|
||||||
|
}
|
||||||
|
}
|
||||||
let result = bindings.generate().expect("Unable to generate bindings");
|
let result = bindings.generate().expect("Unable to generate bindings");
|
||||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||||
result.write_to_file(out_path.join("bindings.rs")).expect("Couldn't write bindings!");
|
result.write_to_file(out_path.join("bindings.rs")).expect("Couldn't write bindings!");
|
||||||
|
|
Loading…
Reference in New Issue