Conversation
There was a problem hiding this comment.
Pull Request Overview
Migrates toolchain setup from static template files to dynamic Starlark macros, enhancing configurability and paving the way for future feature extensions.
- Replace
rctx.templatecalls withrctx.fileto emit BUILD files using the new macros - Introduce
declare_toolsanddeclare_toolchainmacros underimpl/ - Remove legacy
.tplfiles (toolchain.BUILD.tpl,bins.BUILD.tpl)
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| toolchains_cc.bzl | Use rctx.file with inlined BUILD snippets and new macros |
| toolchain.BUILD.tpl | Remove deprecated toolchain template |
| bins.BUILD.tpl | Remove deprecated binaries template |
| impl/declare_tools.bzl | Implement declare_tools macro for tool declarations |
| impl/declare_toolchain.bzl | Implement declare_toolchain macro for Bazel toolchains |
| examples/hello_world/MODULE.bazel | Bump rules_cc version dependency |
Comments suppressed due to low confidence (2)
impl/declare_toolchain.bzl:61
- [nitpick] Replace the subjective comment with a neutral explanation, e.g., "Use LLVM linker for improved performance and features over the system linker."
# no sane person wants to use ld.
impl/declare_tools.bzl:111
- Add unit tests or integration tests for the
declare_toolsmacro to ensure it generates the expected targets and filegroups.
declare_tools = macro(
| load("@rules_cc//cc/toolchains:tool_map.bzl", "cc_tool_map") | ||
|
|
||
| def _declare_tools(name, visibility, all_files): | ||
| print("Declaring tools for toolchain: {}".format(name)) |
There was a problem hiding this comment.
[nitpick] Remove the debug print call or replace it with Bazel's logging mechanism to avoid spamming output during builds.
Suggested change
| print("Declaring tools for toolchain: {}".format(name)) | |
| print("[INFO] Declaring tools for toolchain: {}".format(name)) |
| ) | ||
|
|
||
| # TODO: currently cant declare this in the macro because this rule creates | ||
| # a target that doesnt following the naming rules of macros. |
There was a problem hiding this comment.
Fix the grammar and spelling: "doesnt following" → "does not follow".
Suggested change
| # a target that doesnt following the naming rules of macros. | |
| # a target that does not follow the naming rules of macros. |
Symbolic macros handle the toolchain definition in pure starlark rather than as a text file. The improves configurability of the toolchain definition. As more features get added, handling configuration in starlark will become necessary.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symbolic macros handle the toolchain definition in pure starlark rather than as a text file. The improves configurability of the toolchain definition. As more features get added, handling configuration in starlark will become necessary.