Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1207 from napi-rs/fix-android-build
fix: android builds broken by actions default ndk version bump
- Loading branch information
Showing
4 changed files
with
25 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)?; | ||
let _ = libgcc.write(b"INPUT(-lunwind)")?; | ||
drop(libgcc); | ||
println!("cargo:rustc-link-search={}", &out_dir); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
mod android; | ||
mod macos; | ||
|
||
pub fn setup() { | ||
println!("cargo:rerun-if-env-changed=DEBUG_GENERATED_CODE"); | ||
if let Ok("macos") = std::env::var("CARGO_CFG_TARGET_OS").as_deref() { | ||
macos::setup(); | ||
match std::env::var("CARGO_CFG_TARGET_OS").as_deref() { | ||
Ok("macos") => { | ||
macos::setup(); | ||
} | ||
Ok("android") => if android::setup().is_ok() {}, | ||
_ => {} | ||
} | ||
} |