ffi #jni_main slice 2: AOT pipeline — .java + javac + d8 → classes.dex in APK
Compilation.lowering_jni_main_decls is populated by lowerToIR (iterating foreign_class_map for is_main && !is_foreign && runtime==jni_class, deduped by foreign_path); each entry carries the pre-rendered Java source from jni_java_emit.emitJavaSource. createApk extended: when the emission list is non-empty, write each .java under <stage>/java/<pkg>/<Class>.java, javac --release 11 to <stage>/classes/, d8 --release --lib <android_jar> --output <stage> to produce <stage>/classes.dex, then zip the .dex into the unaligned APK at root level. javac discovery: $JAVA_HOME/bin/javac first, then `which javac`. Manifest still hardcodes android.app.NativeActivity (slice 3 wires the user's class name + android:hasCode="true"), so the bundled .dex is present but unreferenced at runtime. End-to-end verified via dexdump on the smoke example's APK — Lco/swipelab/sxjnimain/SxApp; extending NativeActivity shows up in classes.dex. Non-#jni_main APK builds (99-android-egl-clear.sx) produce the same shape as before. Cross-compile tuple added for examples/ffi-jni-main-01-emit.sx (compile-only — APK exercise is manual).
This commit is contained in:
@@ -612,7 +612,7 @@ fn compileWithTimer(allocator: std.mem.Allocator, io: std.Io, input_path: []cons
|
||||
// Wrap into an .apk if requested (Android).
|
||||
if (merged_config.apk_path) |ap| {
|
||||
timer.mark();
|
||||
sx.target.createApk(allocator, io, final_output, merged_config) catch std.process.exit(1);
|
||||
sx.target.createApk(allocator, io, final_output, merged_config, comp.getJniMainEmissions()) catch std.process.exit(1);
|
||||
timer.record("apk");
|
||||
std.debug.print("apk: {s}\n", .{ap});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user