Skip to content

Commit fb9861b

Browse files
authored
Make gazelle consider only BUILD.bazel files (#48455)
### What does this PR do? Configure the `//:gazelle` target with `-build_file_name=BUILD.bazel`. ### Motivation When `gazelle` runs inside a Linux container on macOS via Docker Desktop, the workspace is typically mounted on a case-insensitive filesystem where `BUILD` and `build` are indistinguishable. This causes spurious errors such as: ```sh bazel run //:gazelle; echo $? ... gazelle: open /dda/.gitlab/windows/build: no such file or directory open /dda/rtloader/build: no such file or directory 1 ``` Whereas the cause strictly resides in a filesystem layer/driver (docker/desktop-feedback#251, recently imported from docker/for-mac#7218), portable tools have been taking countermeasures. Bazel 9, for instance, revamped their filesystem cache to better accomodate case-insensitive filesystems (bazelbuild/bazel#26842), which led us to switch to it (#47742), but that only covers Bazel's own I/O, not the processes it spawns, of which `gazelle`. For that purpose, Gazelle happens to [explicitly recommend](https://github.com/bazel-contrib/bazel-gazelle/blob/4a7caee10fbd2da9bb059f3ce7c2cac8d0050e53/reference.md?plain=1#L251) setting its `build_file_name` directive to `BUILD.bazel`: > If a repository contains files named `build` that aren't related to Bazel, it may help to set this to `"BUILD.bazel"`, especially on case-insensitive file systems. ### Additional Notes For consistency with the narrowed scope, this change renames `compliance/rules/BUILD` to `compliance/rules/BUILD.bazel` (the only plain `BUILD` file still present in the tree). Co-authored-by: regis.desgroppes <regis.desgroppes@datadoghq.com>
1 parent 867176f commit fb9861b

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

BUILD.bazel

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,10 @@ ALL_BUILD_TAGS = [
446446
# gazelle:prefix github.com/DataDog/datadog-agent
447447
gazelle(
448448
name = "gazelle",
449-
args = ["-external=static"], # don't use the network: https://github.com/bazel-contrib/bazel-gazelle/issues/1385
449+
args = [
450+
"-build_file_name=BUILD.bazel", # avoid BUILD/build mess: https://github.com/docker/desktop-feedback/issues/251
451+
"-external=static", # don't use the network: https://github.com/bazel-contrib/bazel-gazelle/issues/1385
452+
],
450453
build_tags = ALL_BUILD_TAGS,
451454
gazelle = ":gazelle_binary",
452455
)

0 commit comments

Comments
 (0)