Switch over to ANDROID_HOME

Keep ANDROID_SDK_ROOT as a fallback
This commit is contained in:
topjohnwu 2024-07-21 00:53:13 -07:00
parent 33cb39c8af
commit b26db8cee6
5 changed files with 27 additions and 18 deletions

View File

@ -55,8 +55,13 @@ if is_windows:
if not sys.version_info >= (3, 8):
error("Requires Python 3.8+")
if "ANDROID_SDK_ROOT" not in os.environ:
error("Please set Android SDK path to environment variable ANDROID_SDK_ROOT!")
try:
sdk_path = Path(os.environ["ANDROID_HOME"])
except KeyError:
try:
sdk_path = Path(os.environ["ANDROID_SDK_ROOT"])
except KeyError:
error("Please set Android SDK path to environment variable ANDROID_HOME")
if shutil.which("sccache") is not None:
os.environ["RUSTC_WRAPPER"] = "sccache"
@ -80,7 +85,6 @@ default_targets = ["magisk", "magiskinit", "magiskboot", "magiskpolicy"]
support_targets = default_targets + ["resetprop"]
rust_targets = ["magisk", "magiskinit", "magiskboot", "magiskpolicy"]
sdk_path = Path(os.environ["ANDROID_SDK_ROOT"])
ndk_root = sdk_path / "ndk"
ndk_path = ndk_root / "magisk"
ndk_build = ndk_path / "ndk-build"

View File

@ -18,7 +18,7 @@
- On Windows, download the install the latest Git version on the [official website](https://git-scm.com/download/win).<br>
Make sure to **"Enable symbolic links"** during installation.
- Install Android Studio and follow the instructions and go through the initial setup.
- Set environment variable `ANDROID_SDK_ROOT` to the Android SDK folder. This path can be found in Android Studio settings.
- Set environment variable `ANDROID_HOME` to the Android SDK folder. This path can be found in Android Studio settings.
- Setup JDK:
- The recommended option is to set environment variable `ANDROID_STUDIO` to the path where your Android Studio is installed. The build script will automatically find and use the bundled JDK.
- You can also setup JDK 17 yourself, but this guide will not cover the instructions.
@ -40,7 +40,7 @@
### Developing Rust
The Magisk NDK package [ONDK](https://github.com/topjohnwu/ondk) (the one installed with `./build.py ndk`) bundles a complete Rust toolchain, so *building* the Magisk project itself does not require any further configuration. However, if you'd like to work on the Rust codebase with proper support, you'd need some setup as most development tools are built around `rustup`.
The Magisk NDK package [ONDK](https://github.com/topjohnwu/ondk) (the one installed with `./build.py ndk`) bundles a complete Rust toolchain, so _building_ the Magisk project itself does not require any further configuration. However, if you'd like to work on the Rust codebase with proper support, you'd need some setup as most development tools are built around `rustup`.
Let's first setup `rustup` to use our custom ONDK Rust toolchain by default:
@ -49,7 +49,7 @@ Let's first setup `rustup` to use our custom ONDK Rust toolchain by default:
```bash
# Link the ONDK toolchain with the name "magisk"
rustup toolchain link magisk "$ANDROID_SDK_ROOT/ndk/magisk/toolchains/rust"
rustup toolchain link magisk "$ANDROID_HOME/ndk/magisk/toolchains/rust"
# Set magisk as default
rustup default magisk
```

View File

@ -1,7 +1,8 @@
#!/usr/bin/env bash
emu="$ANDROID_SDK_ROOT/emulator/emulator"
avd="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager"
set -xe
. scripts/test_common.sh
emu_args_base='-no-window -no-audio -no-boot-anim -gpu swiftshader_indirect -read-only -no-snapshot'
lsposed_url='https://github.com/LSPosed/LSPosed/releases/download/v1.9.2/LSPosed-v1.9.2-7024-zygisk-release.zip'
emu_pid=
@ -134,8 +135,8 @@ run_test() {
# System image variable and paths
local pkg="system-images;android-$ver;$type;$arch"
local img_dir="$ANDROID_SDK_ROOT/system-images/android-$ver/$type/$arch"
local ramdisk="$img_dir/ramdisk.img"
local sys_img_dir="$ANDROID_HOME/system-images/android-$ver/$type/$arch"
local ramdisk="$sys_img_dir/ramdisk.img"
# Old Linux kernels will not boot with memory larger than 3GB
local memory
@ -181,10 +182,7 @@ run_test() {
rm -f magisk_patched.img
}
set -xe
trap cleanup EXIT
. scripts/test_common.sh
export -f wait_for_boot
export -f wait_for_bootanim

View File

@ -1,5 +1,8 @@
#!/usr/bin/env bash
set -xe
. scripts/test_common.sh
cvd_args='-daemon -enable_sandbox=false -memory_mb=8192 -report_anonymous_usage_stats=n'
magisk_args='-init_boot_image=magisk_patched.img'
@ -96,9 +99,6 @@ run_test() {
rm -f magisk_patched.img*
}
set -xe
. scripts/test_common.sh
if [ -z $CF_HOME ]; then
print_error "! Environment variable CF_HOME is required"
exit 1

View File

@ -1,6 +1,13 @@
export PATH="$PATH:$ANDROID_SDK_ROOT/platform-tools"
if [ -z $ANDROID_HOME ]; then
export ANDROID_HOME=$ANDROID_SDK_ROOT
fi
export PATH="$PATH:$ANDROID_HOME/platform-tools"
sdk="$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
emu="$ANDROID_HOME/emulator/emulator"
avd="$ANDROID_HOME/cmdline-tools/latest/bin/avdmanager"
sdk="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager"
boot_timeout=600
print_title() {