Skip to content

Migrate to bzlmod with Valdi registry and release tags#12

Merged
clholgat merged 22 commits intomainfrom
valdi-widgets-bzlmod
May 7, 2026
Merged

Migrate to bzlmod with Valdi registry and release tags#12
clholgat merged 22 commits intomainfrom
valdi-widgets-bzlmod

Conversation

@clholgat
Copy link
Copy Markdown
Collaborator

@clholgat clholgat commented Apr 30, 2026

Summary

  • Switch Valdi pinning from commit SHA to release tag (beta-0.1.0)
  • Replace manual Apple CC + LLVM toolchain setup with valdi_toolchains extension
  • Add Valdi custom Bazel registry for patched deps (eliminates local patch copies for rules_swift, rules_kotlin, rules_android_ndk)
  • Remove unused patch files (rules_swift, rules_kotlin, rules_android_ndk, valdi_remove_llvm_extension); only websocketpp.patch remains
  • Drop refs/tags/ from archive URLs so branch names and commit SHAs work too (e.g. VALDI_TAG = "main" for bleeding edge)
  • Delete WORKSPACE (bzlmod-only, Bazel 7+)
  • Add rules_ts extension for @npm_typescript visibility (needed by ts_project in widgets)
  • Fix CI workflow: patch .bazelrc registry to local Valdi checkout, stub open_source_archives.bzl, enable git-lfs

Test plan

  • Full macOS app build (12k actions) against local Valdi checkout
  • GitHub Actions CI passing (all 5 test targets)

🤖 Generated with Claude Code

cholgateSC and others added 11 commits April 30, 2026 11:25
Migrate from WORKSPACE-only to bzlmod:
- Add MODULE.bazel declaring valdi dependency and sub-module overrides
- Bundle third-party patches (rules_swift, rules_kotlin, rules_android_ndk,
  websocketpp) needed because Valdi's single_version_override entries only
  apply when Valdi is the root module
- Remove --noenable_bzlmod from .bazelrc
- Fix per_file_copt patterns for bzlmod compatibility
- WORKSPACE kept for backwards compatibility

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The beta-0.0.3 release predates the macos_deps feature in valdi_module.
Point to the same commit SHA the WORKSPACE uses.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Each archive_override sub-module downloads the full Valdi tarball
separately, causing timeouts in CI. Clone Valdi once and use
--override_module flags to point all sub-modules to the local checkout.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The llvm extension in toolchains_llvm enforces that only the root module
can invoke it. Since Valdi_Widgets is the root module (not Valdi),
we must declare and configure the extension here.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The toolchains_llvm extension enforces root-module-only usage. When Valdi
is a dependency (not root), its use_extension call fails. Patch it out
of Valdi's MODULE.bazel and declare the extension from Valdi_Widgets
(the actual root module) instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The --override_module flags bypass archive_override patches, so the
llvm extension removal patch wasn't being applied. Patch the local
Valdi clone directly via sed before running bazel.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Valdi's MODULE.bazel already declares the rules_ts extension with
npm_typescript. Declaring it again from Valdi_Widgets causes a
duplicate repo error. Keep only the bazel_dep for visibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
At commit 45b28375, three sub-module MODULE.bazel files are missing
deps that were added later: snap_client_toolchains needs snap_platforms,
android_macros needs rules_android, and rules_hdrs needs rules_pkg.
Append the missing entries in the CI patch step.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The sub-module MODULE.bazel files may not end with a trailing newline,
causing echo >> to concatenate on the same line. Use printf with a
leading \n to ensure proper line separation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
android_macros already has bazel_dep(name = "rules_android") at the
pinned commit — appending it again causes a duplicate repo name error.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Root module toolchain registrations shadow dependency module
registrations. Since Valdi (a dependency) registers Apple CC before
LLVM for ObjC compilation priority, the root module must do the same
or the LLVM toolchain (root-registered) will be selected for ObjC
targets, which fails.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clholgat clholgat marked this pull request as ready for review April 30, 2026 21:42
cholgateSC and others added 3 commits April 30, 2026 14:43
Pin protobuf (27.0), rules_apple (4.0.0), rules_pkg (0.9.1), and
zlib (1.3.2) to prevent MVS from escalating to incompatible versions
when Valdi's own overrides are ignored as a non-root module.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
abseil-cpp headers use Clang nullability extensions that trigger
-Werror in both target and exec (tool) configurations. Add the
suppression flags matching Valdi's own .bazelrc.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Switch from commit SHA to release tag (beta-0.1.0) for Valdi pinning.
Replace manual Apple CC + LLVM toolchain setup with Valdi's unified
valdi_toolchains extension. Remove stale valdi_remove_llvm_extension
patch. Add Valdi custom Bazel registry for patched deps (rules_swift,
rules_kotlin, rules_android_ndk). Remove WORKSPACE (bzlmod only).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clholgat clholgat changed the title Add MODULE.bazel for bzlmod support Migrate to bzlmod with Valdi registry and release tags May 6, 2026
The Bazel registry now provides pre-patched rules_swift, rules_kotlin,
and rules_android_ndk. The valdi_toolchains extension handles LLVM
setup so valdi_remove_llvm_extension.patch is also unnecessary. Only
websocketpp.patch remains (still needed).

Also drop refs/tags/ from the Valdi archive URL so branch names and
commit SHAs work too (e.g. VALDI_TAG = "main" for bleeding edge).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clholgat clholgat requested a review from gioneill May 6, 2026 20:02
cholgateSC and others added 7 commits May 6, 2026 13:37
WORKSPACE was deleted in our branch (bzlmod migration) and modified on
main. Keeping the deletion since we're bzlmod-only now.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The pinned commit predates the Bazel registry and missing bazel_dep
fixes. Checking out main and passing --registry=file://$VALDI/registry
gives CI access to pre-patched deps (rules_swift, websocketpp, etc.)
without manual sed workarounds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The .bazelrc points at a registry URL for a release tag that may not
exist yet. BCR (listed second) resolves rules_swift before the local
registry appended via --registry CLI flag, so the unpatched version
is used. Fix by sed-replacing the .bazelrc URL with file://$VALDI/registry
so the patched registry is checked first.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ts_project in widgets/BUILD.bazel needs @npm_typescript, which is
created by the rules_ts extension. Valdi declares its own, but bzlmod
scopes use_repo to the declaring module — consumers must redeclare.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Valdi's MODULE.bazel already calls rules_ts_ext.deps() which creates
the npm_typescript repo. In bzlmod, extension repos are global — a
second .deps() tag causes a duplicate repo error. Widgets only needs
use_repo to import the repo Valdi already creates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The public Valdi mirror doesn't include open_source_archives.bzl
(Copybara strips it), but valdi_compiler_repos_extension.bzl loads it.
Create an empty ARCHIVES stub so the extension falls back to empty
repos — the compiler binaries are in the checkout path anyway.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
libresvg.a is tracked by git-lfs. Without lfs: true, the checkout
gets 133-byte pointer files instead of actual binaries, causing
"unknown file type" linker errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clholgat clholgat merged commit b60da5c into main May 7, 2026
2 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.

3 participants