fix(build): broken android target build caused by ndk upgrade
This commit is contained in:
parent
548f358fdb
commit
f90d63ccde
3 changed files with 24 additions and 3 deletions
2
.github/workflows/android-armv7.yml
vendored
2
.github/workflows/android-armv7.yml
vendored
|
@ -60,5 +60,5 @@ jobs:
|
||||||
export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang"
|
export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang"
|
||||||
yarn build:test:android:armv7
|
yarn build:test:android:armv7
|
||||||
du -sh examples/napi/index.node
|
du -sh examples/napi/index.node
|
||||||
${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip examples/napi/index.node
|
${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip examples/napi/index.node
|
||||||
du -sh examples/napi/index.node
|
du -sh examples/napi/index.node
|
||||||
|
|
16
crates/build/src/android.rs
Normal file
16
crates/build/src/android.rs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
use std::env;
|
||||||
|
use std::fs;
|
||||||
|
use std::io::{Error, Write};
|
||||||
|
use std::path;
|
||||||
|
|
||||||
|
// Workaround from https://github.com/rust-lang/rust/pull/85806#issuecomment-1096266946
|
||||||
|
pub fn setup() -> Result<(), Error> {
|
||||||
|
let out_dir = env::var("OUT_DIR").expect("OUT_DIR not set");
|
||||||
|
let mut dist = path::PathBuf::from(&out_dir);
|
||||||
|
dist.push("libgcc.a");
|
||||||
|
let mut libgcc = fs::File::create(&dist)?;
|
||||||
|
libgcc.write(b"INPUT(-lunwind)")?;
|
||||||
|
drop(libgcc);
|
||||||
|
println!("cargo:rustc-link-search={}", &out_dir);
|
||||||
|
Ok(())
|
||||||
|
}
|
|
@ -1,8 +1,13 @@
|
||||||
|
mod android;
|
||||||
mod macos;
|
mod macos;
|
||||||
|
|
||||||
pub fn setup() {
|
pub fn setup() {
|
||||||
println!("cargo:rerun-if-env-changed=DEBUG_GENERATED_CODE");
|
println!("cargo:rerun-if-env-changed=DEBUG_GENERATED_CODE");
|
||||||
if let Ok("macos") = std::env::var("CARGO_CFG_TARGET_OS").as_deref() {
|
match std::env::var("CARGO_CFG_TARGET_OS").as_deref() {
|
||||||
|
Ok("macos") => {
|
||||||
macos::setup();
|
macos::setup();
|
||||||
}
|
}
|
||||||
|
Ok("android") => if let Ok(_) = android::setup() {},
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue