mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-18 22:01:28 +00:00
Switch over to ANDROID_HOME
Keep ANDROID_SDK_ROOT as a fallback
This commit is contained in:
parent
33cb39c8af
commit
b26db8cee6
10
build.py
10
build.py
@ -55,8 +55,13 @@ if is_windows:
|
|||||||
if not sys.version_info >= (3, 8):
|
if not sys.version_info >= (3, 8):
|
||||||
error("Requires Python 3.8+")
|
error("Requires Python 3.8+")
|
||||||
|
|
||||||
if "ANDROID_SDK_ROOT" not in os.environ:
|
try:
|
||||||
error("Please set Android SDK path to environment variable ANDROID_SDK_ROOT!")
|
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:
|
if shutil.which("sccache") is not None:
|
||||||
os.environ["RUSTC_WRAPPER"] = "sccache"
|
os.environ["RUSTC_WRAPPER"] = "sccache"
|
||||||
@ -80,7 +85,6 @@ default_targets = ["magisk", "magiskinit", "magiskboot", "magiskpolicy"]
|
|||||||
support_targets = default_targets + ["resetprop"]
|
support_targets = default_targets + ["resetprop"]
|
||||||
rust_targets = ["magisk", "magiskinit", "magiskboot", "magiskpolicy"]
|
rust_targets = ["magisk", "magiskinit", "magiskboot", "magiskpolicy"]
|
||||||
|
|
||||||
sdk_path = Path(os.environ["ANDROID_SDK_ROOT"])
|
|
||||||
ndk_root = sdk_path / "ndk"
|
ndk_root = sdk_path / "ndk"
|
||||||
ndk_path = ndk_root / "magisk"
|
ndk_path = ndk_root / "magisk"
|
||||||
ndk_build = ndk_path / "ndk-build"
|
ndk_build = ndk_path / "ndk-build"
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
- On Windows, download the install the latest Git version on the [official website](https://git-scm.com/download/win).<br>
|
- 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.
|
Make sure to **"Enable symbolic links"** during installation.
|
||||||
- Install Android Studio and follow the instructions and go through the initial setup.
|
- 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:
|
- 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.
|
- 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.
|
- You can also setup JDK 17 yourself, but this guide will not cover the instructions.
|
||||||
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
### Developing Rust
|
### 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:
|
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
|
```bash
|
||||||
# Link the ONDK toolchain with the name "magisk"
|
# 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
|
# Set magisk as default
|
||||||
rustup default magisk
|
rustup default magisk
|
||||||
```
|
```
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
emu="$ANDROID_SDK_ROOT/emulator/emulator"
|
set -xe
|
||||||
avd="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager"
|
. scripts/test_common.sh
|
||||||
|
|
||||||
emu_args_base='-no-window -no-audio -no-boot-anim -gpu swiftshader_indirect -read-only -no-snapshot'
|
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'
|
lsposed_url='https://github.com/LSPosed/LSPosed/releases/download/v1.9.2/LSPosed-v1.9.2-7024-zygisk-release.zip'
|
||||||
emu_pid=
|
emu_pid=
|
||||||
@ -134,8 +135,8 @@ run_test() {
|
|||||||
|
|
||||||
# System image variable and paths
|
# System image variable and paths
|
||||||
local pkg="system-images;android-$ver;$type;$arch"
|
local pkg="system-images;android-$ver;$type;$arch"
|
||||||
local img_dir="$ANDROID_SDK_ROOT/system-images/android-$ver/$type/$arch"
|
local sys_img_dir="$ANDROID_HOME/system-images/android-$ver/$type/$arch"
|
||||||
local ramdisk="$img_dir/ramdisk.img"
|
local ramdisk="$sys_img_dir/ramdisk.img"
|
||||||
|
|
||||||
# Old Linux kernels will not boot with memory larger than 3GB
|
# Old Linux kernels will not boot with memory larger than 3GB
|
||||||
local memory
|
local memory
|
||||||
@ -181,10 +182,7 @@ run_test() {
|
|||||||
rm -f magisk_patched.img
|
rm -f magisk_patched.img
|
||||||
}
|
}
|
||||||
|
|
||||||
set -xe
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
. scripts/test_common.sh
|
|
||||||
|
|
||||||
export -f wait_for_boot
|
export -f wait_for_boot
|
||||||
export -f wait_for_bootanim
|
export -f wait_for_bootanim
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -xe
|
||||||
|
. scripts/test_common.sh
|
||||||
|
|
||||||
cvd_args='-daemon -enable_sandbox=false -memory_mb=8192 -report_anonymous_usage_stats=n'
|
cvd_args='-daemon -enable_sandbox=false -memory_mb=8192 -report_anonymous_usage_stats=n'
|
||||||
magisk_args='-init_boot_image=magisk_patched.img'
|
magisk_args='-init_boot_image=magisk_patched.img'
|
||||||
|
|
||||||
@ -96,9 +99,6 @@ run_test() {
|
|||||||
rm -f magisk_patched.img*
|
rm -f magisk_patched.img*
|
||||||
}
|
}
|
||||||
|
|
||||||
set -xe
|
|
||||||
. scripts/test_common.sh
|
|
||||||
|
|
||||||
if [ -z $CF_HOME ]; then
|
if [ -z $CF_HOME ]; then
|
||||||
print_error "! Environment variable CF_HOME is required"
|
print_error "! Environment variable CF_HOME is required"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -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
|
boot_timeout=600
|
||||||
|
|
||||||
print_title() {
|
print_title() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user