Skip to content

feat: alias each platform's toolchain in the proxy repository - #452

Open
TrapsterDK wants to merge 1 commit into
bazel-contrib:mainfrom
TrapsterDK:toolchain-proxy-aliases
Open

TrapsterDK wants to merge 1 commit into
bazel-contrib:mainfrom
TrapsterDK:toolchain-proxy-aliases

Conversation

@TrapsterDK

Copy link
Copy Markdown
Contributor

Fixes #451.

Change

rb_toolchain_repository_proxy now writes one alias() per platform next to each toolchain(). The alias is named after the platform (:x86_64_linux, :arm64_darwin, ..., or :default in single-platform mode) and points at @<name>_<platform>//:toolchain. A module can then declare its own toolchain() targets on top of @ruby_toolchains//:<platform>, for example with target_settings, without use_repo of every per-platform repository.

  • ruby/private/toolchain/repository_proxy.bzl: the BUILD content comes from a new proxy_build_content() function, which also writes the aliases. The rule doc describes them.
  • register_toolchains("@ruby_toolchains//:all") is unchanged. Wildcard registration skips the aliases because they are not toolchain() targets.

Testing

  • New ruby/tests/repository_proxy_tests.bzl checks the aliases in multi-platform and single-platform mode. This is the regression test.
  • The examples still register @ruby_toolchains//:all, so the CI jobs that use them cover the registration.
  • I did not run Bazel locally; CI on this PR runs the tests and buildifier.

Assisted by Claude.

The `<name>_toolchains` proxy repository now also has one `alias()` per
platform, named after the platform, that points at the toolchain target
of that platform's repository. A module can declare its own `toolchain()`
targets on top of them, for example with `target_settings`, instead of
registering `//:all`.

Fixes bazel-contrib#451
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central YAML; Path: .coderabbit.yaml
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: eecc3634-03b3-4d3f-a56c-1ab0bb0cf974
Commits

Reviewing files that changed from the base of the PR and between 8412409 and d7d9b62.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The proxy repository now generates a matching alias for each toolchain entry. Platform entries use their platform suffix, while entries without a platform use default. Tests cover both alias forms.

Changes: Proxy repository aliases

Layer / File(s) Summary
Generate toolchain declarations and aliases
ruby/private/toolchain/repository_proxy.bzl
proxy_build_content generates toolchain declarations and matching aliases. The repository rule uses this helper, and its documentation describes per-platform aliases in custom toolchain() declarations.
Test generated aliases
ruby/tests/repository_proxy_tests.bzl, ruby/tests/BUILD
Tests check platform-specific aliases and the default alias. The test BUILD file loads and invokes the test suite.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Suggested reviewers: p0deje

Merge Risk: Minimal · previous review 84124

This adds per-platform aliases to the proxy repository so modules can define their own toolchain targets. Existing @ruby_toolchains//:all registration is left unchanged. No merge-blocking risk was found.

Security architecture risk: Minimal · up to 84124

The new labels let downstream builds reuse existing Ruby toolchains without importing each platform repository. They point to the same toolchain targets and do not change the constraints on existing registrations. The source review found no material new security or failure-containment risk.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — Modules that can resolve the proxy repository gain a direct label for the existing public Ruby toolchain target without needing a separate mapping for its interpreter repository. This expands build-label reachability, not the set of configured interpreter targets.

Trust Boundaries and Controls

  • observed — Execution-platform constraints remain on the proxy's existing toolchain declarations. The alias names the underlying target directly; a downstream module that declares its own toolchain controls that declaration's constraints.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "feat: alias each platform's toolchain in the proxy repository" matches the main change. The PR adds one platform-named alias() beside each toolchain() in the proxy repository, and the summa…
Description check Passed The description states the change: one alias() per platform beside each toolchain(), named after the platform or :default in single-platform mode, pointing at @_//:toolchain. It also n…
Linked Issues check Passed Issue #451 requires: (1) one alias() per platform in the proxy repository, named after the platform or :default in single-platform mode; (2) each alias points to @<name>_<platform>//:toolchain; (3…
Out of Scope Changes check Passed All changes map to #451. The repository_proxy.bzl change adds the alias template, moves BUILD generation into proxy_build_content(), and updates the rule documentation. The new repository_proxy_tests.…
Full details: Title check

Explanation

The title "feat: alias each platform's toolchain in the proxy repository" matches the main change. The PR adds one platform-named alias() beside each toolchain() in the proxy repository, and the summary confirms proxy_build_content() writes these aliases. The title is specific and concise.

Full details: Description check

Explanation

The description states the change: one alias() per platform beside each toolchain(), named after the platform or :default in single-platform mode, pointing at @<name>_<platform>//:toolchain. It also names the modified file, the new proxy_build_content() function, and the new regression test file, so it is directly related to the changeset.

Full details: Linked Issues check

Explanation

Issue #451 requires: (1) one alias() per platform in the proxy repository, named after the platform or :default in single-platform mode; (2) each alias points to @&lt;name&gt;_&lt;platform&gt;//:toolchain; (3) @ruby_toolchains//:all keeps working. At head, proxy_build_content() in ruby/private/toolchain/repository_proxy.bzl emits an alias(name = suffix, actual = "@&lt;repo&gt;//:toolchain") after each toolchain() block. The suffix is the platform key, or default when the platform is empty. The rule calls this function for its BUILD content. Requirements (1) and (2) are met in source. The PR does not change the registration path, so requirement (3) rests on the author's claim that Bazel wildcard registration skips non-toolchain() targets. This review did not run Bazel to confirm that behavior. The unit tests in ruby/tests/repository_proxy_tests.bzl cover both multi-platform and single-platform output. They were not executed in this review. Unknown platform keys still fail, as before.

Full details: Out of Scope Changes check

Explanation

All changes map to #451. The repository_proxy.bzl change adds the alias template, moves BUILD generation into proxy_build_content(), and updates the rule documentation. The new repository_proxy_tests.bzl tests the alias output, and ruby/tests/BUILD loads and runs that suite. No unrelated functional changes appear in the reviewed sources.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central YAML; Path: .coderabbit.yaml
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: 2fbb372b-46a2-4a48-9096-d85968051e6b
Commits

Reviewing files that changed from the base of the PR and between 81a3c0a and 8412409.

Files selected for processing: 3

  • ruby/private/toolchain/repository_proxy.bzl
  • ruby/tests/BUILD
  • ruby/tests/repository_proxy_tests.bzl

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

TrapsterDK added a commit to devhusdk/rules_dx that referenced this pull request Nov 28, 2026
…les_ruby

The rules_dx extension still creates @dx_ruby_toolchains, but rules_dx now
registers its own toolchain() targets from @dx_toolchains//ruby, typed by
//ruby:toolchain_type and pointing at the per-platform aliases that
bazel-contrib/rules_ruby#452 adds to the proxy repo. rules_ruby's
//ruby:toolchain_type becomes an alias of ours, so its rules still resolve.
The gate patch and the dx_hub_builds copy of the proxy BUILD are no longer
needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xut2hvdpJxYihWhnWtH8yv
TrapsterDK added a commit to devhusdk/rules_dx that referenced this pull request Nov 28, 2026
…les_ruby (#14985)

The rules_dx extension still creates @dx_ruby_toolchains, but rules_dx now
registers its own toolchain() targets from @dx_toolchains//ruby, typed by
//ruby:toolchain_type and pointing at the per-platform aliases that
bazel-contrib/rules_ruby#452 adds to the proxy repo. rules_ruby's
//ruby:toolchain_type becomes an alias of ours, so its rules still resolve.
The gate patch and the dx_hub_builds copy of the proxy BUILD are no longer
needed.


Claude-Session: https://claude.ai/code/session_01Xut2hvdpJxYihWhnWtH8yv

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@TrapsterDK
TrapsterDK force-pushed the toolchain-proxy-aliases branch from 8412409 to d7d9b62 Compare November 28, 2026 12:35
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.

Expose per-platform aliases in the ruby_toolchains proxy repository

1 participant