Skip to content

Commit

Permalink
ndk-build: Consider ANDROID_SDK_ROOT as deprecated instead of ANDROID…
Browse files Browse the repository at this point in the history
…_HOME

According to the official documentation [1] `ndk-build` is considering
the wrong variable as deprecated.  The wrong message was introduced in
[#39] which bizarrely failed to quote any reference matterial on the
matter, making it impossible to understand whether this has always been
the case or recently switched in precedence.

[1]: https://developer.android.com/studio/command-line/variables
[#39]: #39
  • Loading branch information
MarijnS95 committed Sep 12, 2022
1 parent 17a1450 commit f9dc492
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions ndk-build/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Inherit `ndk_gdb()` function from `cargo-apk` with the appropriate script extension across platforms. ([#330](https://github.com/rust-windowing/android-ndk-rs/pull/330), [#258](https://github.com/rust-windowing/android-ndk-rs/pull/258))
- Provide `adb` path to `ndk-gdb`, allowing it to run without `adb` in `PATH`. ([#343](https://github.com/rust-windowing/android-ndk-rs/pull/343))
- Remove quotes from `Android.mk` to fix `ndk-gdb` on Windows. ([#344](https://github.com/rust-windowing/android-ndk-rs/pull/344))
- Consider `ANDROID_SDK_ROOT` as deprecated instead of `ANDROID_HOME`. ([#346](https://github.com/rust-windowing/android-ndk-rs/pull/346))

# 0.7.0 (2022-07-05)

Expand Down
18 changes: 10 additions & 8 deletions ndk-build/src/ndk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ pub struct Ndk {
impl Ndk {
pub fn from_env() -> Result<Self, NdkError> {
let sdk_path = {
let mut sdk_path = std::env::var("ANDROID_HOME").ok();
let sdk_path = std::env::var("ANDROID_SDK_ROOT").ok();
if sdk_path.is_some() {
println!(
"Warning: You use environment variable ANDROID_HOME that is deprecated. \
Please, remove it and use ANDROID_SDK_ROOT instead. Now ANDROID_HOME is used"
eprintln!(
"Warning: Environment variable ANDROID_SDK_ROOT is deprecated \
(https://developer.android.com/studio/command-line/variables#envar). \
It will be used until it is unset and replaced by ANDROID_HOME."
);
}
if sdk_path.is_none() {
sdk_path = std::env::var("ANDROID_SDK_ROOT").ok();
}

PathBuf::from(sdk_path.ok_or(NdkError::SdkNotFound)?)
PathBuf::from(
sdk_path
.or_else(|| std::env::var("ANDROID_HOME").ok())
.ok_or(NdkError::SdkNotFound)?,
)
};

let ndk_path = {
Expand Down

0 comments on commit f9dc492

Please sign in to comment.