Skip to content
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

Gazelle plugin just deleting srcs from some libraries #454

Open
shahms opened this issue Jul 18, 2023 · 7 comments
Open

Gazelle plugin just deleting srcs from some libraries #454

shahms opened this issue Jul 18, 2023 · 7 comments

Comments

@shahms
Copy link

shahms commented Jul 18, 2023

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"],
+)
+
@achew22
Copy link
Member

achew22 commented Jul 19, 2023

Interesting! Were the old values generated with the gazelle plugin?

@shahms
Copy link
Author

shahms commented Jul 19, 2023

No, these were hand-written rules originally. I'm trying to enable gazelle support for them so we can stop hand-writing so much :-)

@shahms
Copy link
Author

shahms commented Aug 4, 2023

It appears to be because these are files which define a rule which is itself a test rule, thus the files end in "_test.bzl" and are (erroneously) ignored due to:

@achew22
Copy link
Member

achew22 commented Aug 4, 2023

Very interesting find! I believe the logic behind that is that it is possible to make bzl_library tests a la this.

I'm curious what your thoughts on this are? Would you be amenable to naming the file java_verifier.bzl or cc_indexer.bzl?

@shahms
Copy link
Author

shahms commented Aug 5, 2023

yeah, it's just a lot of work to update all of the references

@achew22
Copy link
Member

achew22 commented Aug 8, 2023

You don't want an excuse to fire up rosie 😉 ?

@keith
Copy link
Member

keith commented Nov 6, 2023

I hit this case too, we have a file called swift_binary_test.bzl which contains a swift_binary and swift_test rule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants