diff --git a/desktop/src-tauri/Cargo.toml b/desktop/src-tauri/Cargo.toml index 26bc58f..bcb5c02 100644 --- a/desktop/src-tauri/Cargo.toml +++ b/desktop/src-tauri/Cargo.toml @@ -17,6 +17,10 @@ path = "src/main.rs" [build-dependencies] tauri-build = { version = "2", features = [] } +# Step A: minimal cc addition — lets build.rs compile cpp/hello.c on Android. +# build-dependencies are resolved against the HOST, not the target, so this +# line is unconditional (the actual cc::Build call is gated on TARGET). +cc = "1" [dependencies] tauri = { version = "2", features = [] } diff --git a/desktop/src-tauri/build.rs b/desktop/src-tauri/build.rs index 16a154b..66c1e81 100644 --- a/desktop/src-tauri/build.rs +++ b/desktop/src-tauri/build.rs @@ -1,9 +1,7 @@ use std::process::Command; fn main() { - // Capture short git hash so the running app can prove which build it is. - // Falls back to "unknown" if git isn't available (e.g. when building from - // a tarball without a .git dir). + // ─── Embedded git hash ───────────────────────────────────────────────── let git_hash = Command::new("git") .args(["rev-parse", "--short", "HEAD"]) .output() @@ -14,10 +12,22 @@ fn main() { .unwrap_or_else(|| "unknown".into()); println!("cargo:rustc-env=WZP_GIT_HASH={git_hash}"); - // Re-run if the HEAD pointer or its target moves so the embedded hash - // tracks reality between builds. println!("cargo:rerun-if-changed=../../.git/HEAD"); println!("cargo:rerun-if-changed=../../.git/refs/heads"); + // ─── Step A: single trivial cpp/hello.c compiled via cc::Build ───────── + // We deliberately add this on Android only so we can verify that the + // cc::Build → static archive → rustc-link pipeline itself does not + // regress the working build #17. cpp/hello.c defines `wzp_hello_stub` + // which is never called from Rust — if the crash comes back just from + // adding a tiny C static lib, we know the build pipeline is the issue. + let target = std::env::var("TARGET").unwrap_or_default(); + if target.contains("android") { + println!("cargo:rerun-if-changed=cpp/hello.c"); + cc::Build::new() + .file("cpp/hello.c") + .compile("wzp_hello"); + } + tauri_build::build() } diff --git a/desktop/src-tauri/cpp/hello.c b/desktop/src-tauri/cpp/hello.c new file mode 100644 index 0000000..e218c9b --- /dev/null +++ b/desktop/src-tauri/cpp/hello.c @@ -0,0 +1,14 @@ +/* hello.c — minimal C file compiled via cc::Build on Android. + * + * Step A of the incremental Oboe integration: this file exists only to + * exercise the cc::Build → static lib → rustc-link pipeline and prove + * that introducing any C static library into our .so doesn't by itself + * trigger the tao::ndk_glue pthread_create crash we hit on earlier + * attempts. The function is deliberately never called from Rust. + */ + +#include + +int32_t wzp_hello_stub(void) { + return 42; +}