Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default_info_files rule & DirectoryPathInfo support in write_source_files and diff_test #48

Merged

Conversation

gregmagolan
Copy link
Collaborator

@gregmagolan gregmagolan commented Mar 14, 2022

This will makes write_source_files more useful.

A bit of refactoring to update write_source_files to take a single in_file and out_file to simplify the implementation of the rule so that adding DirectoryPathInfo does not over complicate it. The macro API of write_source_files remains unchanged. The complication of updating multiple files is moved to the macro where additional_update_targets is used to support updating multiple files. You now get 1 diff_test target for 1 update target in the graph which is also nice.

@gregmagolan gregmagolan changed the title Add DefaultOutputPathInfo provider and update write_source_files to accept it Add default_info_files rule Mar 14, 2022
@gregmagolan gregmagolan force-pushed the write_source_files_feats branch 3 times, most recently from 24cfaa7 to a4f0e7e Compare March 14, 2022 17:36
@gregmagolan gregmagolan marked this pull request as ready for review March 14, 2022 17:38
@gregmagolan gregmagolan changed the title Add default_info_files rule Add default_info_files rule & DirectoryPathInfo support in write_source_files and diff_test Mar 14, 2022
lib/private/docs.bzl Outdated Show resolved Hide resolved
Comment on lines 193 to 203
if not single_target:
_write_source_files(
name = name,
additional_update_targets = update_targets + additional_update_targets,
is_windows = select({
"@bazel_tools//src/conditions:host_windows": True,
"//conditions:default": False,
}),
visibility = kwargs.get("visibility"),
tags = kwargs.get("tags"),
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Cool 👍

Comment on lines 5 to 6
_WriteSourceFilesInfo = provider(
WriteSourceFilesInfo = provider(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we expose this if it isn't used elsewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The rename was mainly so the error message when a target doesn't provide this is clearer. David at Robinhood recently tried to pipe a generated_file_test into the additional_update_targets of a write_source_files. It should error out and say that a WriteSourceFilesInfo provider must be provided.

I suppose we could just accept any old "binary" here but I think I prefer to set the provider as required so that uses are forced to be homogeneous

Copy link
Collaborator

@kormide kormide left a comment

Choose a reason for hiding this comment

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

Overall looks good to me. Just had the question about changing the labels for the docs rule.

Comment on lines 1 to 8
"""A rule that provides file(s) from a target's DefaultInfo
"""

load(
"//lib/private:default_info_files.bzl",
_default_info_files = "default_info_files",
_make_default_info_files = "make_default_info_files",
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

@alexeagle I think this is what we discussed doing for your proto write_source_files case but then decided not to do it. I suppose you could use this now that we have it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍 Piping the output of protobuf rules into write_source_files was the motivation for all of this

@gregmagolan gregmagolan force-pushed the write_source_files_feats branch 3 times, most recently from a70121c to ef16d76 Compare March 15, 2022 00:30
…ccept it

Also update write_source_files to accept DirectoryPathInfo
@gregmagolan gregmagolan merged commit 3b93ee0 into bazel-contrib:main Mar 15, 2022
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