step A(android): add cc=1 build-dep + compile single trivial hello.c
First incremental variable on the path back to Oboe integration. Changes
are deliberately minimal: add cc = "1" to [build-dependencies] (cargo
build-deps resolve against the host so the line is unconditional), and
on the Android target run a single cc::Build step that compiles
cpp/hello.c — a 6-line file that defines one function (`wzp_hello_stub`)
that is never called from Rust.
Goal: verify that merely introducing a C static library into the .so
via cc::Build does not regress the working build (#17, commit 5309938
= build #6 behaviour: launches, renders home screen, registers on
relay). If this build still works, we know cc::Build pipelines alone
are fine and can move to the next variable.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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 = [] }
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
14
desktop/src-tauri/cpp/hello.c
Normal file
14
desktop/src-tauri/cpp/hello.c
Normal file
@@ -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 <stdint.h>
|
||||
|
||||
int32_t wzp_hello_stub(void) {
|
||||
return 42;
|
||||
}
|
||||
Reference in New Issue
Block a user