Skip to content

To BUILD or to BUILD.bazel, that is the question #866

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

Closed
justinsb opened this issue Oct 2, 2017 · 3 comments
Closed

To BUILD or to BUILD.bazel, that is the question #866

justinsb opened this issue Oct 2, 2017 · 3 comments

Comments

@justinsb
Copy link

justinsb commented Oct 2, 2017

#576 renamed BUILD -> BUILD.bazel, so gazelle is now generating BUILD.bazel files. But most/all docs still reference BUILD, not BUILD.bazel, and it's a little confusing to me. I presume the docs are just lagging, and we should use BUILD.bazel everywhere now? Is there a link to why we should use BUILD.bazel?

@jayconrod
Copy link
Contributor

We're in the process of updating our documentation (#810). We should fix this.

BUILD.bazel should be preferred for new projects. Bazel recognizes both names but prefers BUILD.bazel if both are present. The problem with BUILD is that it frequently collides with files or directories named "build" on case-insensitive file systems in projects that didn't previously use Bazel. The BUILD.bazel name was introduced about a year ago to avoid that collision.

@justinsb
Copy link
Author

justinsb commented Oct 2, 2017

Thanks @jayconrod - that makes a lot of sense. It was also the main https://bazel.build/ site that still has a lot of BUILD references, FYI.

@ianthehat
Copy link
Contributor

We have now switched to the new documentation, which I believe only uses BUILD.bazel files.
There are still some reference to BUILD files but they mean "files in the BUILD language", rather than "files named BUILD". If you find anywhere that you think is wrong now, please file a specific bug or send us a pull request to fix it.

Bazel does not take a stance on BUILD vs BUILD.bazel. We (rules_go) have chosen to strongly favor the latter because as Jay said it is far less likely to cause issues in existing repositories. This is more important for us because we are automatically generating these files.

hostilefork added a commit to hostilefork/bazel-playground that referenced this issue Apr 8, 2021
Best practices currently suggest calling the files BUILD.bazel and not
simply BUILD.

This is more explicit and creates less contention in projects that
have `build/` directories (which is quite common).  On case-insensitive
filesystems this can be particularly problematic.

Auto-generating tools (such as "Gazelle") are making files called
BUILD.bazel as well, so this is suggested for consistency in all non
legacy projects.

If both BUILD and BUILD.bazel files are present, the BUILD.bazel will
be preferred...further cementing its status as "canon".

bazel-contrib/rules_go#866
bazelbuild/bazel#4517
bdhess added a commit to GoogleCloudPlatform/kms-integrations that referenced this issue Aug 2, 2021
Discussion at bazel-contrib/rules_go#866

Change-Id: I4b0f02e6aa68998e8876733f73b40a9a16f7e158
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants