buildtools
buildtools copied to clipboard
buildozer: add command line flag to override build file names
Lots of places in the code still assume BUILD is the build file name, as such this is mainly useful to add additional build file names.
Can one of the admins verify this patch?
Hi, why do you need this? I thought checking for Bazel/Buck/Pants files would be enough. Is there another scenario?
Thanks
Ah sorry, missed your comment.
We have an older repo which uses a different name for build files (TARGETS) and thought this might be more desirable than adding another name to the list.
We have some wrappers (supporting a narrower UI) that we use to make this work currently by temporarily copying the original to use the BUILD basename, so this change isn't that big of a deal. It just means we can't run buildozer directly.
I would prefer to avoid adding a new flag for that. Is it an option to rename your files in the old repo?
I have this issue too – we have packages that contain both a BUILD and a BUILD.bazel file, one for blaze and one for bazel. It'd be nice if we could select the right file when running buildozer.
buildifier on master now parses BUILD.bazel files as BUILD files. In #400, I extend the heuristic to match filenames commonly used for external workspace BUILD files.
This is a few years old now, but as a data point, I've run into a case within Meta's codebase where the hardcoded list is problematic.
In a part of the repo where we use Buck, we have a particular directory with the following two files:
BUCKbuild(some random shell script not related to the Buck build)
In a Mac environment (where the filesystem is case insensitive), buildozer errors when we ask it to edit the BUCK file in this directory, because it thinks build is a BUILD file (and BUILD always takes precedence over BUCK per BuildFileNames). It seems like we'd have to either patch our buildozer binary to reorder BuildFileNames, or reorganise our repo to avoid the issue. A flag would allow us to specify the ordering dynamically when invoking buildozer.