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

Buildozer needs a conditional operator #127

Open
manuelF opened this issue Aug 21, 2017 · 2 comments
Open

Buildozer needs a conditional operator #127

manuelF opened this issue Aug 21, 2017 · 2 comments

Comments

@manuelF
Copy link

manuelF commented Aug 21, 2017

Say I need to set testing_only to 1 for all java testing libraries. These libraries are identified by having a //java/junit dependency

buildozer \
'set testing_only 1' \
 $(find -L ~/my_project -name BUILD | sed"s/\/BUILD/:%java_library/" )

I can't identify here any of these testing libraries. It would be great for me if I could add some condition using a 'where' keyword:

buildozer \
'set testing_only 1' \
'where ("//java/junit" in deps and testing_only != 1)'
 $(find -L ~/my_project -name BUILD | sed"s/\/BUILD/:%java_library/" )

The semantics of where is basically to match the entire build rule and, if it doesn't match the condition, then skip it from the atomic mutation.

Multiple 'where' operators would be either 'and'-ed or a parse error.

This would make a ton of refactors much easier instead of doing constant git manipulations to have better specificity especially for BUILD files with many tests.

@srawlins
Copy link

For now this can done with bazel query and xargs, but I agree it would be very helpful to have this where functionality. Very powerful.

@aiuto
Copy link
Contributor

aiuto commented Aug 3, 2021

I think the most powerful would be a combination of the conditional and the find, so that it would be possible to write a single buildozer script that would work on both *ix and windows. That is, do not rely on xargs or find or sed.

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

No branches or pull requests

3 participants