Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,25 @@ fn main() {
}
}

if target_os == "android" {
let min_sdk = env::var("ANDROID_MIN_SDK").expect("ANDROID_MIN_SDK not set");
let ndk = env::var("ANDROID_NDK_HOME").expect("ANDROID_NDK_HOME not set");
let host_tag = match (env::consts::OS, env::consts::ARCH) {
("windows", "x86_64") => "windows-x86_64",
("windows", "x86") => "windows-x86",
("linux", "x86_64") => "linux-x86_64",
("linux", "x86") => "linux-x86",
("macos", "aarch64") => "darwin-x86_64",//fat binary
("macos", "x86_64") => "darwin-x86_64",
_ => panic!("Unsupported platform"),
};
let is_windows = env::consts::OS == "windows";
let clang = format!("{ndk}\\toolchains\\llvm\\prebuilt\\{host_tag}\\bin\\aarch64-linux-android{min_sdk}-clang") + if is_windows { ".cmd" } else { "" };
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fails on linux due to path separators

Copy link

@xuxiaocheng0201 xuxiaocheng0201 May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try the ci.yml I wrote above. It doesn't need this PR.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a custom build process with macroquad, but thanks for info, I will try replicating it

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For anyone finding this through search: the way to make rquickjs work with macroquad android target is to modify the cargo-quad-apk like this:

juh9870/cargo-quad-apk-bindgen@3ed23b9

env::set_var("CC", clang);
let sys = format!("--sysroot={ndk}\\toolchains\\llvm\\prebuilt\\{host_tag}\\sysroot");
bindgen_cflags.push(sys);
}

if target_os == "wasi" {
// pretend we're emscripten - there are already ifdefs that match
// also, wasi doesn't ahve FE_DOWNWARD or FE_UPWARD
Expand Down
Loading