buildtools icon indicating copy to clipboard operation
buildtools copied to clipboard

buildozer: add command line flag to override build file names

Open andrewjcg opened this issue 7 years ago • 7 comments

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.

andrewjcg avatar Dec 05 '17 08:12 andrewjcg

Can one of the admins verify this patch?

bazel-io avatar Dec 05 '17 08:12 bazel-io

Hi, why do you need this? I thought checking for Bazel/Buck/Pants files would be enough. Is there another scenario?

Thanks

laurentlb avatar Dec 19 '17 14:12 laurentlb

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.

andrewjcg avatar Dec 26 '17 22:12 andrewjcg

I would prefer to avoid adding a new flag for that. Is it an option to rename your files in the old repo?

laurentlb avatar Dec 28 '17 16:12 laurentlb

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.

mprobst avatar Dec 30 '17 10:12 mprobst

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.

benjaminp avatar Oct 26 '18 05:10 benjaminp

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:

  • BUCK
  • build (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.

motiz88 avatar Feb 21 '22 20:02 motiz88