bazelbuild / bazelbuild/bazel-skylib

Gazelle plugin just deleting `srcs` from some libraries

Open
#454 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
444
Forks
202
PR merge metrics
No merged PRs in 30d

Description

When running the bzl_library Gazelle plugin over https://github.com/kythe/kythe/blob/master/tools/build_rules/verifier_test/BUILD it ends up modifying that file to just delete the `srcs` attribute from the respective `bzl_library` targets and it's not obvious to me why.

```
$ bazel run //:gazelle -- -mode diff tools/build_rules/verifier_test/
--- tools/build_rules/verifier_test/BUILD 1970-01-01 00:00:00.000000001 +0000
+++ tools/build_rules/verifier_test/BUILD 1970-01-01 00:00:00.000000001 +0000
@@ -17,7 +17,6 @@

bzl_library(
name = "cc_indexer_test_bzl",
- srcs = ["cc_indexer_test.bzl"],
deps = [
":verifier_test_bzl",
"@bazel_skylib//lib:paths",
@@ -27,13 +26,11 @@

bzl_library(
name = "java_verifier_test_bzl",
- srcs = ["java_verifier_test.bzl"],
deps = [":verifier_test_bzl"],
)

bzl_library(
name = "verifier_test_bzl",
- srcs = ["verifier_test.bzl"],
deps = [
"@bazel_skylib//lib:shell",
],
@@ -41,21 +38,19 @@

bzl_library(
name = "jvm_verifier_test_bzl",
- srcs = ["jvm_verifier_test.bzl"],
deps = [":verifier_test_bzl"],
)

bzl_library(
- name = "kzip_archive_bzl",
- srcs = ["kzip_archive.bzl"],
-)
-
-bzl_library(
name = "rust_indexer_test_bzl",
- srcs = ["rust_indexer_test.bzl"],
deps = [
":verifier_test_bzl",
"@bazel_skylib//lib:paths",
],
)

+bzl_library(
+ name = "kzip_archive",
+ srcs = ["kzip_archive.bzl"],
+)
+
```

Contributor guide

Open the contributing guide

Research direction

Start by running `bazel run //:gazelle -- -mode diff tools/build_rules/verifier_test/` and inspect `tools/build_rules/verifier_test/BUILD`. Trace the bzl_library Gazelle plugin behavior for the affected targets, including the `kzip_archive_bzl` rename. Done means the plugin no longer deletes valid `srcs` attributes or unexpectedly renames the target.

Written by the indexing model from the issue text.

Assessment

Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.