Skip to content

feat(#461): manifest-v2 PR4 — shared platform-packager (apk/web) - #465

Merged
apotema merged 1 commit into
mainfrom
feat/453-manifest-v2-pr4-packager
Jul 1, 2026
Merged

apotema merged 1 commit into
mainfrom
feat/453-manifest-v2-pr4-packager

Conversation

@apotema

@apotema apotema commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor

PR 4 of the manifest-v2 epic (#461, #453 item 3). The shared platform-packager, prereq for the sokol android/ios/wasm conversions (PR 5-7). Additive; enum path byte-unchanged.

Packager (src/codegen/packager.zig)

emitPackage(package: Package, w) switches on the BackendManifestV2.Package union:

  • .binary → no-op (desktop installs the exe directly)
  • .apk → Android apk-stage + zip + apksigner
  • .web → emcc install/run wiring

Packaging text lives in packager-owned @embedFile fixtures — src/templates/package_apk.txt + package_web.txt — exact byte-copies of the enum-path .android_package / .wasm_footer sections (extracted via getSection boundaries; .wasm_footer legitimately carries the build-fn close + override helper defs, reproduced to match writeSection).

v2 seam

manifest_v2_splice.zig gains platformEntry + renderPackageV2 — packaging is driven off the typed PlatformEntry.package (no switch (cfg.platform)). build_files.zig calls it on the v2 desktop path before the footer; desktop .binary is a no-op, so PR 3's desktop byte anchor is undisturbed. Absent platform → error.V2PlatformUnsupported.

Enum path unchanged (lower-risk option)

Left .android_package/.wasm_footer sections in build_zig.txt (untouched — not in the diff); the enum path still writeSections them, the packager reproduces their output. PR 12 deletes the enum sections, leaving the fixtures as source of truth.

Byte-identity tests (the point)

emitPackage(.apk) == live .android_package, emitPackage(.web) == live .wasm_footer (via getSection on embedded build_zig.txt) + fixture drift guard + .binary no-op + seam tests. Verified live (corrupting the apk fixture fails the test). This byte-identity is what makes PR 5/7's golden cells achievable.

zig build test + zig build exit 0. No backend converted to v2 android/wasm yet (PR 5-7).

Ref #461, #453.

https://claude.ai/code/session_017pW3ifKf9wgxNg4viy6okw

Summary by CodeRabbit

  • New Features

    • Added support for packaging desktop, Android, and web builds through a shared release flow.
    • Android builds now produce a signed APK as part of the packaging process.
    • Web builds now include a standardized run step for easier execution after build.
  • Bug Fixes

    • Improved consistency between packaging outputs to reduce drift across platforms.
    • Unified shared web module handling for more reliable builds across related components.

…pe (#453 PR 4)

Factor the apk/web packaging out of the enum-path template into a shared
packager that a v2 manifest's `.platforms[p].package` recipe references. Lands
BEFORE the Android/wasm backend conversions (PRs 5-7) so their `.package`
delegation is ready and their golden cells are achievable (design §7).

- src/codegen/packager.zig: `emitPackage(Package, w)` maps `.binary` (desktop,
  no-op), `.apk` (Android), `.web` (wasm) to the exact packaging text. The text
  is held as packager-owned @embedfile fixtures (templates/package_apk.txt /
  package_web.txt), byte-copies of the enum `.android_package` / `.wasm_footer`
  sections.
- src/codegen/manifest_v2_splice.zig: `renderPackageV2` + `platformEntry` seam —
  the v2 codegen delegates packaging off the typed `PlatformEntry.package`
  recipe (no `switch (cfg.platform)`).
- src/build_files.zig: wire the seam on the v2 desktop path (no-op for `.binary`,
  so the PR-3 desktop byte anchor is undisturbed).

Enum-path choice: left `.android_package`/`.wasm_footer` sections in place (the
lower-risk option) — the enum path still `writeSection`s them and the packager
reproduces their output. When PR 12 deletes the enum sections, the fixtures
remain the source of truth.

Byte-identity tests assert `emitPackage(.apk)` == `.android_package` section and
`emitPackage(.web)` == `.wasm_footer` section against the live template, plus a
drift guard on the fixtures — the anchor that makes PR 5/7's golden cells match
the enum baseline. `zig build test` and `zig build` both green; enum-path
generation byte-unchanged (build_zig.txt untouched).

Claude-Session: https://claude.ai/code/session_017pW3ifKf9wgxNg4viy6okw
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 20439963-610c-411c-bd67-1e7e44a664db

📥 Commits

Reviewing files that changed from the base of the PR and between d6138bd and 502bf23.

📒 Files selected for processing (6)
  • src/build_files.zig
  • src/codegen/manifest_v2_splice.zig
  • src/codegen/packager.zig
  • src/root.zig
  • src/templates/package_apk.txt
  • src/templates/package_web.txt

📝 Walkthrough

Walkthrough

Adds a manifest-v2 packaging seam invoked from build_files.zig, delegating to new manifest_v2_splice functions (platformEntry, renderPackageV2) that call a new shared packager.zig module. packager.zig embeds byte-identical APK/Web templates and provides emitPackage. New package_apk.txt and package_web.txt templates define platform-specific build steps. root.zig forces test discovery of packager.zig.

Changes

Shared v2 packaging path

Layer / File(s) Summary
Build seam wiring and platform dispatch
src/build_files.zig, src/codegen/manifest_v2_splice.zig
Adds conditional v2-manifest packaging insertion before footer emission, plus platformEntry and renderPackageV2 functions with tests covering desktop/android/wasm and an unsupported-platform error case.
Packager module and embedded fixtures
src/codegen/packager.zig, src/root.zig
Introduces emitPackage switching on .binary/.apk/.web, embeds apk_package_zig and web_package_zig fixtures, adds byte-identity and drift-guard tests against live templates, and wires the module into forced test discovery.
APK packaging build template
src/templates/package_apk.txt
Defines Android keystore/build-tools lookup, ABI derivation, libgame.so staging, APK repacking, and apksigner signing wired into a package step.
Web packaging build template
src/templates/package_web.txt
Defines a "run" step depending on emcc_step, an overrideImport helper, and unifyGfxSubpackageCore for unifying gfx sub-package core imports.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related issues

Poem

A rabbit hops through build files deep,
Splicing packages while others sleep. 🐇
APK and Web, byte for byte the same,
No-op for desktop, that's the game.
Templates tucked in, tests all green —
The tidiest burrow this code has seen!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: a shared manifest-v2 platform packager for apk/web.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/453-manifest-v2-pr4-packager

Comment @coderabbitai help to get the list of available commands.

@apotema
apotema merged commit 115f82a into main Jul 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant