Skip to content

Fix xmake tests modules#6993

Merged
waruqi merged 3 commits intoxmake-io:devfrom
Arthapz:fix-xmake_tests_modules
Nov 6, 2025
Merged

Fix xmake tests modules#6993
waruqi merged 3 commits intoxmake-io:devfrom
Arthapz:fix-xmake_tests_modules

Conversation

@Arthapz
Copy link
Member

@Arthapz Arthapz commented Nov 4, 2025

fixes #6991

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Arthapz, 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 primarily focuses on stabilizing and expanding xmake's support for C++ modules. It introduces new, dedicated test suites to thoroughly verify module compilation and dependency resolution. Concurrently, it refines the internal mechanisms for managing module build dependencies and caching, addressing potential issues that could arise during complex build scenarios. Furthermore, the changes enhance the system's ability to correctly identify and configure C++ standard libraries across a wider range of platforms and toolchains, contributing to more robust and reliable C++ module builds.

Highlights

  • New C++ Module Test Cases: Two new comprehensive test projects, xmake_tests1 and xmake_tests2, have been added to thoroughly validate C++ module build and dependency scanning functionality across various compilers including Clang, GCC, and MSVC.
  • Improved Module Dependency Handling: The builder.lua logic has been enhanced to safely handle job dependencies by incorporating a check for their existence in the job graph before processing, which prevents potential errors during build operations.
  • Refined Module Caching Mechanism: The scanner.lua file now clones sourcebatch objects before caching them. This ensures that cached data remains immutable, preventing unintended modifications and improving the reliability of the caching system.
  • Expanded C++ Runtime Library Detection: Updates to support.lua introduce broader detection capabilities for C++ runtime libraries (libc++, libstdc++, msstl) across an extended range of platforms (e.g., Android, macOS, Linux, Windows) and various runtime types.
  • General Code Refinements: Numerous minor formatting adjustments, such as consistent use of single quotes for string literals, and the removal of commented-out code and trailing blank lines, have been implemented to improve overall code quality and readability.
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 addresses the issue of incorrect dependency handling for C++ modules during xmake test runs. The main fixes involve clearing cached job dependencies and ensuring that dependencies are only considered if they are part of the current build graph. These changes prevent unnecessary rebuilds and fix the test execution flow. The addition of new test cases is a great way to verify the fix and prevent future regressions. I've found one critical issue where undefined variables are used, which will cause a runtime error. I've also pointed out some opportunities for code cleanup by removing dead code and leftover debugging comments.

Comment on lines +129 to +132
if jobgraph:has(dependent_job) then
jobdeps[dependent_job] = jobdeps[dependent_job] or {}
table.insert(jobdeps[dependent_job], buildfilejob)
end
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This check is a crucial part of the fix. By ensuring a dependent_job exists in the current jobgraph before adding it as a dependency, you correctly isolate the test build's dependency graph from the main build graph. This prevents xmake test from incorrectly flagging dependencies that aren't relevant to the test, which was causing the unnecessary rebuilds. Great fix!

if sourcebatch_scanner then
sourcebatch_scanner.sourcefiles = {}
end
support.memcache():set2(target:fullname(), "jobdeps", nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Clearing the jobdeps from the memcache in after_scan is the core of the fix for the reported issue. This correctly ensures that stale dependency information from a previous build does not interfere with a subsequent xmake test run. This is a solid improvement.

@Arthapz Arthapz force-pushed the fix-xmake_tests_modules branch 2 times, most recently from b1e8873 to af23147 Compare November 4, 2025 11:35
@Arthapz Arthapz force-pushed the fix-xmake_tests_modules branch from af23147 to ce72389 Compare November 4, 2025 11:36
@Arthapz Arthapz marked this pull request as ready for review November 5, 2025 11:05
@waruqi waruqi merged commit 169c7dd into xmake-io:dev Nov 6, 2025
22 checks passed
@waruqi waruqi added this to the v3.0.5 milestone Nov 6, 2025
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.

add_tests with build_should_pass causes jobgraph error with module dependencies

2 participants