Skip to content

refactor(toolchain): Separate gcc/clang registration from definition#6935

Merged
waruqi merged 1 commit intoxmake-io:devfrom
romeoxbm:toolchain-gcc-clang-separation
Oct 17, 2025
Merged

refactor(toolchain): Separate gcc/clang registration from definition#6935
waruqi merged 1 commit intoxmake-io:devfrom
romeoxbm:toolchain-gcc-clang-separation

Conversation

@romeoxbm
Copy link
Contributor

This PR refactors the internal structure of the GCC and Clang toolchain definitions to separate their registration logic from their definition logic.
The change resolves redundant registration issues and improves both clarity and performance in versioned toolchains.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @romeoxbm, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the internal structure of how GCC and Clang toolchains are defined and registered within the system. By decoupling the toolchain definition logic from its registration, the change aims to streamline the management of different compiler versions, reduce potential redundancies, and ultimately improve the overall maintainability and efficiency of the toolchain system.

Highlights

  • Refactoring Toolchain Definitions: The core logic for GCC and Clang toolchain definitions has been extracted from their respective xmake.lua files into new dedicated files: toolchain_clang.lua and toolchain_gcc.lua. This separates the detailed definition logic from the version-specific registration.
  • Improved Clarity and Performance: This architectural change is designed to resolve redundant toolchain registration issues, leading to enhanced clarity in the codebase and improved performance, especially for managing versioned toolchains.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

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

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 effectively refactors the GCC and Clang toolchain definitions by separating the definition logic from the registration calls. This is a great improvement that resolves redundant toolchain registration issues and enhances the clarity and maintainability of the codebase. The changes are well-structured and correctly implemented across all versioned toolchain files. I have a couple of minor suggestions to simplify path handling in toolchain_clang.lua.


on_check(function (toolchain)
if toolchain:is_plat("windows") then
local rootdir = path.join(path.directory(os.scriptdir()), "clang")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The calculation of rootdir can be simplified. Since os.scriptdir() already points to the xmake/toolchains/clang/ directory where check.lua is located, you can directly assign it to rootdir.

                local rootdir = os.scriptdir()

toolchain:add("runtimes", "MT", "MTd", "MD", "MDd")
end
if toolchain:is_plat("windows", "mingw") then
local rootdir = path.join(path.directory(os.scriptdir()), "clang")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The calculation of rootdir can be simplified. Since os.scriptdir() already points to the xmake/toolchains/clang/ directory where load.lua is located, you can directly assign it to rootdir.

                local rootdir = os.scriptdir()

@waruqi waruqi added this to the v3.0.5 milestone Oct 17, 2025
@waruqi waruqi merged commit 91b05f8 into xmake-io:dev Oct 17, 2025
22 of 26 checks passed
@romeoxbm romeoxbm deleted the toolchain-gcc-clang-separation branch October 17, 2025 07:23
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