Skip to content

Conversation

@cerisier
Copy link
Contributor

@cerisier cerisier commented Sep 3, 2025

Part of #480

This PR refactors ZigModuleInfo so that --dep and -M cli args are computed transitively from 1 single ZigModuleInfo root.

While doing this, I found that the _mock_args implementation was not compliant with the actual ctx.actions.args implementation, especially when using depset.

I took the opportunity to rewrite those tests using custom rules and diff_test so that we are sure that what we test is actually what is going to end up in the action run.

BREAKING_CHANGE: transitive_args and transitive_inputs fields removed from ZigModuleInfo.

Copy link
Owner

@aherrmann aherrmann left a comment

Choose a reason for hiding this comment

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

Thanks for contributing!

I like those diff stats (+198/-351)!

I notice a depset.to_list though, that should be avoided, see corresponding comment.

@cerisier cerisier changed the title Model ZigModuleInfo as depsets of ZigModuleInfo for transitive deps Refactor ZigModuleInfo to have a single arg rendering path Sep 4, 2025
cerisier and others added 7 commits September 9, 2025 09:09
And model main, srcs and extra_srcs as part of a ZigModuleInfo node.

This will greatly improve upstreaming of zml/rules_zig since many
further developments are based on this.

It has the cool side effect of unifying how --dep and -M cli args
are computed transitively from 1 single ZigModuleInfo root.
While using depsets and postorder ordering, I realized that _mock_args
implementation was different than ctx.actions.args especially in the
case where depsets are using postorder.

In this commit, I suggest removing the need for the mock and instead
test zig_module_specifications with the real implementation of
ctx.actions.args using custom rules and a diff_test.

This guarantees that we are testing the exact same order of args
as they will appear in the command line when ctx.actions.run is
performed.
Otherwise the names are quite generic and can collide or be confused
with other test suite names.
@aherrmann aherrmann force-pushed the cerisier/depset-provider branch from a6b1a83 to 93101c0 Compare September 9, 2025 07:09
@aherrmann aherrmann enabled auto-merge September 9, 2025 07:10
auto-merge was automatically disabled September 9, 2025 10:52

Head branch was pushed to by a user without write access

@aherrmann aherrmann enabled auto-merge September 9, 2025 11:43
Copy link
Owner

@aherrmann aherrmann left a comment

Choose a reason for hiding this comment

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

Thank you again for upstreaming this!

@aherrmann aherrmann merged commit b9c5d0b into aherrmann:main Sep 9, 2025
13 checks passed
@cerisier cerisier deleted the cerisier/depset-provider branch September 9, 2025 11:53
@aherrmann aherrmann changed the title Refactor ZigModuleInfo to have a single arg rendering path feat!: refactor ZigModuleInfo to have a single arg rendering path Sep 15, 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.

2 participants