Skip to content

fix(stage): skip zig-pkg/.labelle when hardlinking a local package - #421

Merged
apotema merged 2 commits into
mainfrom
fix/local-stage-skip-zigpkg
Jun 30, 2026
Merged

fix(stage): skip zig-pkg/.labelle when hardlinking a local package#421
apotema merged 2 commits into
mainfrom
fix/local-stage-skip-zigpkg

Conversation

@apotema

@apotema apotema commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Local-package staging crashed on real repo checkouts

hardlinkTree (the local-package stager) skipped .zig-cache/zig-out/.git but copied zig-pkg/ and .labelle/. Staging a local backend package that's an actual repo checkout then recursed into:

  • zig-pkg/<hash>/upstream/…/node_modules/… — deep enough that copyFile hit NameTooLong, which crashed staging (and tripped an invalid free unwinding the error).
  • .labelle/ — if a backend repo ships an example inside itself (labelle-bgfx/examples/*), staging the package while generating that example copied the example's own generated output back into the stage.

Neither is part of a package's importable modules. Skip both alongside the existing build/VCS dirs.

Why

Unblocks bgfx's examples living in labelle-bgfx (per the extraction) and resolving the backend via the local checkout — labelle generate for labelle-bgfx/examples/{bgfx,bgfx-android} now succeeds (was: assembler panic).

Adds a hardlinkTree regression test (zig-pkg/.labelle/.git/.zig-cache/zig-out skipped; real files staged). zig build test green.

Summary by CodeRabbit

  • Chores

    • Simplified CI by removing an unused macOS backend job and updating Android build caching for better reuse.
    • Excluded additional generated/cache directories from package staging.
  • Refactor

    • Moved the bgfx desktop backend out of the in-tree build flow, reducing bundled backend code and templates.
  • Tests

    • Updated test coverage to reflect the new bgfx packaging and build setup.

apotema added 2 commits June 30, 2026 11:38
…hase 6c)

bgfx is now resolved out-of-tree (`.backend = .bgfx` → the labelle-bgfx provider,
flipped in #419 and on-device-validated), so the in-tree `backends/bgfx/` slot is
dead weight. Delete it (~the whole src/templates/libs/manifest tree) and the
coverage that built it in-tree:

- Remove the `bgfx-build` CI job (`cd backends/bgfx && zig build test` + the
  standalone example). The bgfx backend's unit tests now run in labelle-bgfx's
  own CI (labelle-bgfx#1); its desktop+android builds are still exercised here
  via the examples-integration `bgfx-external` step and the `bgfx-android-build`
  job (both fetch the package).
- `bgfx-android-build` cache key now hashes the example + config (it pinned the
  deleted `backends/bgfx/build.zig.zon`).
- Drop the desktop bgfx-artifacts unit test (no in-tree package to resolve;
  coverage moved to labelle-bgfx + the splice tests) and the bgfx case from the
  in-tree-template preview regression list.

Other backends keep their bundled slots; only bgfx leaves. First backend fully
out of the assembler bundle.
hardlinkTree skipped .zig-cache/zig-out/.git but copied zig-pkg/ and .labelle/.
Staging a local backend package that's a real repo checkout (e.g. a backend repo
shipping an example inside itself) then walked:
  - zig-pkg/<hash>/upstream/.../node_modules/... — deep enough that copyFile hit
    NameTooLong, which crashed staging (and tripped an invalid free on the way out).
  - .labelle/ — the in-repo example's own generated output, copied back into the stage.

Neither is part of a package's importable modules, so skip both alongside the
existing build/VCS dirs. Unblocks examples that live inside a backend package repo
(labelle-bgfx/examples/*) resolving the backend via its local checkout.
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR removes the entire in-tree backends/bgfx directory: all Zig source modules, build scripts (build.zig, build.zig.zon), templates, examples, C shims, and the backend manifest. CI drops the standalone macOS bgfx build/test job and updates the Android cache keys. hardlinkTree in src/deps_linker.zig gains skip rules for zig-pkg, .labelle, and .git.

Changes

bgfx backend extraction

Layer / File(s) Summary
CI and deps_linker staging
.github/workflows/ci.yml, src/deps_linker.zig, test/build_zig_tests.zig, test/preview_mode_tests.zig
Removes macOS bgfx-build CI job; updates bgfx-android-build cache keys to hash project.labelle and src/config.zig; expands hardlinkTree skip list to include zig-pkg, .labelle, and .git; adds regression test asserting those dirs are absent from staged output; removes in-tree bgfx test cases from build_zig_tests.zig and preview_mode_tests.zig.
bgfx backend source deletion
backends/bgfx/src/*, backends/bgfx/build.zig, backends/bgfx/build.zig.zon, backends/bgfx/backend.manifest.zon, backends/bgfx/build_fragments/*, backends/bgfx/templates/*, backends/bgfx/libs/*
Deletes all in-tree bgfx modules: window, input, audio, gfx subsystem (draw/font/programs/texture/types/astc/state), video pipeline (desktop/android/yuv/planes/player/fit/backend), Android lifecycle glue, shaders, C shims, and build/link/manifest configuration.
bgfx examples deletion
backends/bgfx/example/*
Removes the standalone bgfx desktop and Android video example apps, including main.zig, gamepad_overlay.zig, android_video.zig, build.zig, build.zig.zon, and apk_video/AndroidManifest.xml.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐇 Hop, hop, the bgfx code flies away,
Out of the tree to its own cozy lair,
No more Metal examples making CI delay,
Cache keys updated with elegant flair.
The rabbit rejoices — less to maintain here!

🚥 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 matches the main change: hardlinkTree now skips zig-pkg and .labelle during local package staging.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/local-stage-skip-zigpkg

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the dependency linker in src/deps_linker.zig to skip zig-pkg and .labelle directories during staging, preventing potential path limit errors and redundant file copying. A new unit test has been added to verify this behavior. Additionally, tests and template checks for the bgfx backend have been removed from test/build_zig_tests.zig and test/preview_mode_tests.zig because bgfx has been extracted into an out-of-tree repository (labelle-bgfx). There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/deps_linker.zig`:
- Around line 388-391: The staging logic in deps_linker.zig is treating every
zig-pkg subtree as disposable, which breaks declared path dependencies
referenced by build.zig.zon. Update the directory-skip/copy behavior in the
staging flow so it is manifest-aware: inspect the package manifest and preserve
or selectively copy any zig-pkg entries that are referenced, rather than
excluding the entire zig-pkg tree. Keep the fix localized to the entry
filtering/rewrite path around the directory walk and rewriteZonPaths handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: cce2df5f-7de6-4672-929e-c454380a13c9

📥 Commits

Reviewing files that changed from the base of the PR and between c305745 and 918a1be.

📒 Files selected for processing (52)
  • .github/workflows/ci.yml
  • backends/bgfx/backend.manifest.zon
  • backends/bgfx/build.zig
  • backends/bgfx/build.zig.zon
  • backends/bgfx/build_fragments/backend_dep.txt
  • backends/bgfx/build_fragments/link.txt
  • backends/bgfx/example/android_video.zig
  • backends/bgfx/example/apk_video/AndroidManifest.xml
  • backends/bgfx/example/build.zig
  • backends/bgfx/example/build.zig.zon
  • backends/bgfx/example/gamepad_overlay.zig
  • backends/bgfx/example/main.zig
  • backends/bgfx/libs/miniaudio/miniaudio.c
  • backends/bgfx/libs/miniaudio/miniaudio.h
  • backends/bgfx/src/android.zig
  • backends/bgfx/src/android_app.zig
  • backends/bgfx/src/audio.zig
  • backends/bgfx/src/audio_device.zig
  • backends/bgfx/src/audio_device_android.zig
  • backends/bgfx/src/gfx.zig
  • backends/bgfx/src/gfx/astc.zig
  • backends/bgfx/src/gfx/draw.zig
  • backends/bgfx/src/gfx/font.zig
  • backends/bgfx/src/gfx/programs.zig
  • backends/bgfx/src/gfx/state.zig
  • backends/bgfx/src/gfx/texture.zig
  • backends/bgfx/src/gfx/types.zig
  • backends/bgfx/src/input.zig
  • backends/bgfx/src/platform.zig
  • backends/bgfx/src/shaders.zig
  • backends/bgfx/src/stb_image.h
  • backends/bgfx/src/stb_image_impl.c
  • backends/bgfx/src/stb_shim.h
  • backends/bgfx/src/video/android.zig
  • backends/bgfx/src/video/android_audio.zig
  • backends/bgfx/src/video/apk/AndroidManifest.xml
  • backends/bgfx/src/video/apk/build_apk.sh
  • backends/bgfx/src/video/apk/decode_shim.h
  • backends/bgfx/src/video/apk/native.zig
  • backends/bgfx/src/video/backend.zig
  • backends/bgfx/src/video/desktop.zig
  • backends/bgfx/src/video/fit.zig
  • backends/bgfx/src/video/planes.zig
  • backends/bgfx/src/video/player.zig
  • backends/bgfx/src/video/test_decode.zig
  • backends/bgfx/src/video/yuv.zig
  • backends/bgfx/src/window.zig
  • backends/bgfx/templates/android.txt
  • backends/bgfx/templates/desktop.txt
  • src/deps_linker.zig
  • test/build_zig_tests.zig
  • test/preview_mode_tests.zig
💤 Files with no reviewable changes (46)
  • backends/bgfx/build_fragments/link.txt
  • backends/bgfx/src/gfx.zig
  • backends/bgfx/src/video/apk/build_apk.sh
  • backends/bgfx/src/gfx/types.zig
  • backends/bgfx/src/video/test_decode.zig
  • backends/bgfx/example/build.zig.zon
  • backends/bgfx/example/main.zig
  • backends/bgfx/libs/miniaudio/miniaudio.c
  • backends/bgfx/example/gamepad_overlay.zig
  • backends/bgfx/example/build.zig
  • backends/bgfx/src/video/apk/AndroidManifest.xml
  • backends/bgfx/src/stb_shim.h
  • backends/bgfx/example/android_video.zig
  • backends/bgfx/build.zig.zon
  • backends/bgfx/src/gfx/astc.zig
  • backends/bgfx/src/gfx/state.zig
  • backends/bgfx/src/video/android.zig
  • backends/bgfx/src/video/apk/decode_shim.h
  • backends/bgfx/src/platform.zig
  • backends/bgfx/backend.manifest.zon
  • backends/bgfx/example/apk_video/AndroidManifest.xml
  • backends/bgfx/src/audio_device_android.zig
  • backends/bgfx/src/video/player.zig
  • backends/bgfx/src/video/android_audio.zig
  • backends/bgfx/build_fragments/backend_dep.txt
  • backends/bgfx/src/shaders.zig
  • backends/bgfx/src/gfx/draw.zig
  • backends/bgfx/src/video/planes.zig
  • backends/bgfx/src/gfx/font.zig
  • backends/bgfx/src/video/yuv.zig
  • backends/bgfx/src/video/desktop.zig
  • backends/bgfx/src/video/fit.zig
  • backends/bgfx/src/video/apk/native.zig
  • backends/bgfx/templates/desktop.txt
  • backends/bgfx/src/gfx/programs.zig
  • backends/bgfx/src/stb_image_impl.c
  • backends/bgfx/templates/android.txt
  • backends/bgfx/src/android.zig
  • backends/bgfx/src/video/backend.zig
  • backends/bgfx/src/input.zig
  • backends/bgfx/src/android_app.zig
  • backends/bgfx/build.zig
  • backends/bgfx/src/audio.zig
  • backends/bgfx/src/window.zig
  • backends/bgfx/src/gfx/texture.zig
  • backends/bgfx/src/audio_device.zig

Comment thread src/deps_linker.zig
Comment on lines 388 to +391
if (std.mem.eql(u8, entry.name, ".zig-cache") or
std.mem.eql(u8, entry.name, "zig-out") or
std.mem.eql(u8, entry.name, "zig-pkg") or
std.mem.eql(u8, entry.name, ".labelle") or

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Preserve declared zig-pkg/* path deps when staging.

This now drops every zig-pkg/ subtree, but staged packages still need whatever their build.zig.zon points at. If a local package vendors a dep under zig-pkg/*, the staged manifest will reference content that no longer exists, and rewriteZonPaths cannot repair that because it only rewrites paths. We already use that layout in CI for labelle-cli/zig-pkg/labelle-gui, so the new assumption that zig-pkg/ is always disposable is too strong. Please make this skip manifest-aware, or copy only the referenced zig-pkg entries instead of dropping the whole directory.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/deps_linker.zig` around lines 388 - 391, The staging logic in
deps_linker.zig is treating every zig-pkg subtree as disposable, which breaks
declared path dependencies referenced by build.zig.zon. Update the
directory-skip/copy behavior in the staging flow so it is manifest-aware:
inspect the package manifest and preserve or selectively copy any zig-pkg
entries that are referenced, rather than excluding the entire zig-pkg tree. Keep
the fix localized to the entry filtering/rewrite path around the directory walk
and rewriteZonPaths handling.

@apotema
apotema merged commit 55b2abd into main Jun 30, 2026
5 checks passed
@apotema
apotema deleted the fix/local-stage-skip-zigpkg branch June 30, 2026 15:14
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