android: AAssetManager bootstrap + APK asset bundling + scissor TODO
platform/android.sx: `sx_android_bootstrap(app)` now also reads the ANativeActivity's `assetManager` (offset 64) and `internalDataPath` (offset 32) into module globals so consumers can route file I/O through the APK's bundled `assets/` tree. target.zig (`createApk`): also zips the project's `./assets/` directory into the APK alongside `lib/<arch>/`. Resolves relative to the user's CWD at invoke time — matches the convention chess uses (assets/ next to main.sx). gles3.sx: scissor is currently a no-op on Android. The renderer's ScrollView clip_push path feeds bounds that land outside the framebuffer (clipping everything off-screen). With scissor disabled the chess board + pieces render correctly. TODO recorded in the file to fix the bounds path properly.
This commit is contained in:
@@ -331,6 +331,16 @@ pub fn createApk(allocator: std.mem.Allocator, io: std.Io, so_path: []const u8,
|
||||
// and zip is on every macOS/Linux host by default.
|
||||
try runProcessIn(allocator, io, stage, &.{ "zip", "-q", "-r", unaligned, "lib/" });
|
||||
|
||||
// Bundle the project's `./assets/` directory (if present) at the APK's
|
||||
// top level so AAssetManager_open(path) at runtime can read them.
|
||||
// Resolves relative to the user's CWD at invocation time — matches the
|
||||
// convention chess uses (assets/ next to main.sx).
|
||||
if (std.Io.Dir.openDir(.cwd(), io, "assets", .{})) |dir_handle| {
|
||||
var dh = dir_handle;
|
||||
dh.close(io);
|
||||
try runProcess(allocator, io, &.{ "zip", "-q", "-r", unaligned, "assets/" });
|
||||
} else |_| {}
|
||||
|
||||
// zipalign → aligned apk.
|
||||
const aligned = try std.fmt.allocPrint(allocator, "{s}.aligned", .{apk_path});
|
||||
try runProcess(allocator, io, &.{ zipalign, "-f", "4", unaligned, aligned });
|
||||
|
||||
Reference in New Issue
Block a user