What happened
Running perry compile --target android on Windows fails with two errors: Perry constructs an NDK toolchain path using the wrong host tag (linux-x86_64 instead of windows-x86_64), and native C dependencies fail to compile because Perry never sets CC_<target> environment variables for Android builds.
What you expected
Perry should resolve the NDK toolchain path using the correct host tag for the build machine (windows-x86_64 on Windows), and pass the relevant CC_<target> environment variables to cargo build so that cc-rs can compile native dependencies such as libsqlite3-sys and libmimalloc-sys — in the same way it already does for HarmonyOS via harmonyos_cross_env.
Minimal reproduction
Any valid Perry UI project triggers this. No specific source change is needed.
// any valid Perry UI project entry point, e.g. src/index.ts
Command you ran:
perry compile src/index.ts --target android
Environment
- Perry version: 0.5.924 (also reproduced on
main as of latest)
- Host OS: Windows 11 (x86_64)
- Target: android
- Rust toolchain (if building from source):
- Installed via:
- NDK version: 30.0.14904198
ANDROID_NDK_HOME: C:\Users\<user>\AppData\Local\Android\Sdk\ndk\30.0.14904198
Diagnostic output
Perry fails to locate the NDK clang binary:
Error: Android NDK clang not found at: C:\Users\<user>\AppData\Local\Android\Sdk\ndk\30.0.14904198/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang
Separately, because Perry never sets CC_<target> for Android (unlike HarmonyOS), cc-rs has no compiler to use and fails independently:
error occurred in cc-rs: failed to find tool "clang.exe": program not found (see https://docs.rs/cc/latest/cc/#compile-time-requirements for help)
Anything else
There are two independent bugs:
Bug 1 — Wrong NDK host tag (affects platform_cmd.rs and mod.rs)
The following two files share the same pattern that causes Windows to fall through to linux-x86_64:
crates/perry/src/commands/compile/link/platform_cmd.rs:433 — hard error; build stops here on Windows
crates/perry/src/commands/compile/link/mod.rs:704 — JNI stub compilation; silently skipped on failure (unwrap_or(false)), but produces a broken binary
// current (both files)
let host_tag = if cfg!(target_os = "macos") {
"darwin-x86_64"
} else {
"linux-x86_64" // Windows falls through here
};
// proposed fix
let host_tag = if cfg!(target_os = "macos") {
"darwin-x86_64"
} else if cfg!(target_os = "windows") {
"windows-x86_64"
} else {
"linux-x86_64"
};
Bug 2 — Missing android_cross_env (causes the cc-rs error)
For HarmonyOS, mod.rs:1313 and optimized_libs.rs:565 both call harmonyos_cross_env() to set CC_<target>, CXX_<target>, etc. before invoking cargo build. No equivalent exists for Android, so cc-rs never receives the NDK clang path and cannot compile native C dependencies.
The fix requires adding an android_cross_env function in library_search.rs (parallel to harmonyos_cross_env) and calling it at the same two sites:
// mod.rs — to be added alongside the existing is_harmonyos block
if is_android {
if let Some(ndk) = std::env::var_os("ANDROID_NDK_HOME") {
for (k, v) in library_search::android_cross_env(Path::new(&ndk), target) {
cargo_cmd.env(k, v);
}
}
}
Also, the error message in platform_cmd.rs currently shows a macOS-style example path ($HOME/Library/Android/sdk/...), which is unhelpful for Windows users and should be updated.
What happened
Running
perry compile --target androidon Windows fails with two errors: Perry constructs an NDK toolchain path using the wrong host tag (linux-x86_64instead ofwindows-x86_64), and native C dependencies fail to compile because Perry never setsCC_<target>environment variables for Android builds.What you expected
Perry should resolve the NDK toolchain path using the correct host tag for the build machine (
windows-x86_64on Windows), and pass the relevantCC_<target>environment variables tocargo buildso thatcc-rscan compile native dependencies such aslibsqlite3-sysandlibmimalloc-sys— in the same way it already does for HarmonyOS viaharmonyos_cross_env.Minimal reproduction
Any valid Perry UI project triggers this. No specific source change is needed.
// any valid Perry UI project entry point, e.g. src/index.tsCommand you ran:
Environment
mainas of latest)ANDROID_NDK_HOME:C:\Users\<user>\AppData\Local\Android\Sdk\ndk\30.0.14904198Diagnostic output
Perry fails to locate the NDK clang binary:
Separately, because Perry never sets
CC_<target>for Android (unlike HarmonyOS),cc-rshas no compiler to use and fails independently:Anything else
There are two independent bugs:
Bug 1 — Wrong NDK host tag (affects
platform_cmd.rsandmod.rs)The following two files share the same pattern that causes Windows to fall through to
linux-x86_64:crates/perry/src/commands/compile/link/platform_cmd.rs:433— hard error; build stops here on Windowscrates/perry/src/commands/compile/link/mod.rs:704— JNI stub compilation; silently skipped on failure (unwrap_or(false)), but produces a broken binaryBug 2 — Missing
android_cross_env(causes thecc-rserror)For HarmonyOS,
mod.rs:1313andoptimized_libs.rs:565both callharmonyos_cross_env()to setCC_<target>,CXX_<target>, etc. before invokingcargo build. No equivalent exists for Android, socc-rsnever receives the NDK clang path and cannot compile native C dependencies.The fix requires adding an
android_cross_envfunction inlibrary_search.rs(parallel toharmonyos_cross_env) and calling it at the same two sites:Also, the error message in
platform_cmd.rscurrently shows a macOS-style example path ($HOME/Library/Android/sdk/...), which is unhelpful for Windows users and should be updated.