Magisk

Building and Development

Setup Environment

Building

IDE Support

Developing Rust

The Magisk NDK package 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:

# Link the ONDK toolchain with the name "magisk"
rustup toolchain link magisk "$ANDROID_HOME/ndk/magisk/toolchains/rust"
# Set magisk as default
rustup default magisk

If you plan to use VSCode, you can then install the rust-analyzer plugin and everything should be good to go. If you plan to use Jetbrain IDEs (e.g. Rustrover, or its Rust Plugin), due to its poor support with custom toolchains, we need some additional setup:

rustup toolchain install nightly
# Add some components that is also included in ONDK
rustup +nightly component add rust-src clippy
# We choose ~/.cargo/wrapper here as an example (and a good recommendation)
# Pick any path you like, you just need to use this path in the next step
./build.py rustup ~/.cargo/wrapper

Signing and Distribution