This repository was archived by the owner on Sep 30, 2024. It is now read-only.
bazel: add utility macro for wrapping single-file tools#62930
Merged
Conversation
jhchabran
reviewed
May 27, 2024
Contributor
|
@Strum355 in case you didn't see it, there's a breakage on pgutils. |
jhchabran
approved these changes
May 27, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, we provide single-file tools such as
ctags,gsutiletc via ansh_binarywrapper, to have a single target to reference that automatically does platform selection of the underlying tool.Due to some unfortunate reason, the underlying srcs (which is a single file) of an
sh_binaryare also exposed as outputs (rather than just as typical runfiles) alongside the script that wraps. This is sometimes problematic when doing location expansion (e.g.$(location ...)) due to these only allowing a single output (dont ask why this works in some contexts but not others, I dont know).To address this, we create a wrapper macro + rule to replicate what we want from
sh_binary(automatic platform selection + tool naming), while only exposing a singular file.See example of currently required approach to consuming a tool: BUILD.bazel & main_test.go.
With this change,
rlocationpath(singular) can be used instead (or any of the other singular nouns in different contexts), as well as nostrings.Split/strings.Fieldsbeing requiredTest plan
bazel cquery --output=files //dev/tools:dropdbyields 1 vs 2 files.Also updated the rule behind
//internal/database:generate_schemasdue to the workaround in it for the fact that the underlying srcs was also exposed. The correctness is verified by running said target (locally + CI)