Skip to content

disable build order only if dependency linking inheritance is disabled#7018

Merged
waruqi merged 2 commits intodevfrom
linkdeps
Nov 12, 2025
Merged

disable build order only if dependency linking inheritance is disabled#7018
waruqi merged 2 commits intodevfrom
linkdeps

Conversation

@waruqi
Copy link
Member

@waruqi waruqi commented Nov 12, 2025

#6925

Disable the entire inheritance

It will disable to inherit dep links, public configuration in deps

add_deps("foo", {inherit = false})

Only disable link inheritance

It will disable to inherit links in deps.

Additionally, since it does not require inheritance of links, it does not restrict the build order between targets and dependencies.

add_deps("foo", {links = false})

Disable some dependency configurations

add_deps("foo", {links = false, includedirs = false, defines = false})

It disables public configurations from dependencies such as links/includedirs/defines.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @waruqi, 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 enhances Xmake's dependency management by allowing more granular control over how configurations and build orders are inherited from dependencies. It specifically addresses an issue where build order was being enforced even when dependency linking was disabled, ensuring that the build system behaves as expected when users opt out of certain inheritance behaviors.

Highlights

  • Conditional Dependency Inheritance: Introduced a mechanism to conditionally inherit configurations from dependencies. This allows users to explicitly disable inheritance for specific settings, such as links, using add_deps("foo", {links = false}).
  • Build Order Management: Modified the build order configuration to respect the dependency linking inheritance setting. Build order is now only established if dependency linking is not explicitly disabled, preventing unnecessary build constraints.
  • Refined Target Fence Logic: Improved the target_fence policy application in deep order job additions. The policy is now only considered for 'prepare' or 'build' job kinds when target_fence is not already defined, making the behavior more precise.
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 correctly implements the ability to disable build order dependencies when dependency linking is disabled, which resolves the linked issue. The changes in xmake/core/project/target.lua and xmake/modules/private/action/build/target.lua are logical and well-implemented. The accompanying refactoring in _add_targetjobs_deep_orders is also a good improvement, making the logic clearer and fixing a subtle bug. I have one minor suggestion to improve the code by removing a redundant function call. Overall, this is a solid contribution.

Comment on lines +121 to +124
local target_fence = opt.target_fence
if target_fence == nil and (job_kind == "prepare" or job_kind == "build") then
target_fence = dep:policy("build.fence") or dep:policy("build.across_targets_in_parallel") == false
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

The logic here is an improvement over the previous version. However, the expression dep:policy("build.across_targets_in_parallel") == false is evaluated on line 123, and it appears to be evaluated again on line 129 to display a deprecation warning. This is redundant.

To avoid this repeated call, you could store the result of the policy check in a variable and reuse it. This would make the code slightly more efficient and adhere to the DRY (Don't Repeat Yourself) principle.

For example, you could modify this block like so:

    local target_fence = opt.target_fence
    local across_targets_in_parallel_disabled
    if target_fence == nil and (job_kind == "prepare" or job_kind == "build") then
        across_targets_in_parallel_disabled = dep:policy("build.across_targets_in_parallel") == false
        target_fence = dep:policy("build.fence") or across_targets_in_parallel_disabled
    end

You could then reuse the across_targets_in_parallel_disabled variable on line 129. As that line is outside the current diff, I cannot provide a direct suggestion for it.

@waruqi waruqi added this to the v3.0.5 milestone Nov 12, 2025
@waruqi waruqi merged commit d4205f6 into dev Nov 12, 2025
44 checks passed
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.

1 participant