This repository has been archived by the owner on Aug 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
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 #120 from c4dt/fix-build
fix: fix build script to take env variables into account
- Loading branch information
Showing
2 changed files
with
19 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,27 @@ | ||
// inspired by https://github.com/p2panda/meli/pull/21/files | ||
// adapted version of meli's fix https://github.com/p2panda/meli/pull/21/files | ||
|
||
use std::env; | ||
use std::path; | ||
|
||
fn main() { | ||
// NDK > 25 does not link to `libgcc` anymore | ||
// see https://github.com/p2panda/meli/pull/21/files | ||
if env::var("CARGO_CFG_TARGET_ARCH").unwrap() == "x86_64" | ||
&& env::var("CARGO_CFG_TARGET_OS").unwrap() == "android" | ||
{ | ||
let home: String = env::var("HOME").unwrap(); | ||
println!("cargo:rustc-link-search={home}/Android/Sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.7/lib/linux/"); | ||
const VERSION: &str = "25.2.9519653"; | ||
let mut android_ndk_home: String = env::var("ANDROID_NDK_HOME").unwrap(); | ||
// check if default version is pinned version | ||
if !android_ndk_home.contains(VERSION) { | ||
let mut splits: Vec<&str> = android_ndk_home.as_str().split('/').collect(); | ||
splits.pop(); // remove default version | ||
android_ndk_home = format!("{}/{}", &splits.join("/"), VERSION); | ||
} | ||
if !path::Path::new(&android_ndk_home).exists() { | ||
panic!( | ||
"build cannot succeed: '{}' does not exist", | ||
android_ndk_home | ||
); | ||
} | ||
println!("cargo:rustc-link-search={android_ndk_home}/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/14.0.7/lib/linux/"); | ||
println!("cargo:rustc-link-lib=static=clang_rt.builtins-x86_64-android"); | ||
} | ||
} |