Skip to content

Migrate from using template files to using symbolic macros.#10

Merged
reutermj merged 1 commit intomainfrom
macros
Jun 29, 2025
Merged

Migrate from using template files to using symbolic macros.#10
reutermj merged 1 commit intomainfrom
macros

Conversation

@reutermj
Copy link
Copy Markdown
Owner

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.

Copilot AI review requested due to automatic review settings June 29, 2025 15:46
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.template calls with rctx.file to emit BUILD files using the new macros
  • Introduce declare_tools and declare_toolchain macros under impl/
  • Remove legacy .tpl files (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_tools macro 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))
Copy link

Copilot AI Jun 29, 2025

Choose a reason for hiding this comment

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

[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))

Copilot uses AI. Check for mistakes.
)

# TODO: currently cant declare this in the macro because this rule creates
# a target that doesnt following the naming rules of macros.
Copy link

Copilot AI Jun 29, 2025

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
@reutermj reutermj merged commit 97022fa into main Jun 29, 2025
4 checks passed
@reutermj reutermj deleted the macros branch June 29, 2025 15:48
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.
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.

2 participants