Fixing dependencies of //external package
We need to query `kind('source file', deps(//external:*))` for sparse checkout, but were block by two issues:
* `//external:remotejdk11_linux` depends on `tools/jdk/jdk.BUILD`, but it was not exported. Although this is not a problem for build, queries like `kind('source file', deps(//external:remotejdk11_linux))` would fail.
* `//external:android_sdk_for_testing` is an alias for `//:dummy`, which is not available in other repositories. This also caused #8175.
This pull request fixed both, including #8175.
Closes #15134.
PiperOrigin-RevId: 438605051
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android.WORKSPACE b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android.WORKSPACE
index 553e77b..d5123d5 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android.WORKSPACE
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/android.WORKSPACE
@@ -20,12 +20,12 @@
bind(
name = "android_sdk_for_testing",
- actual = "//:dummy",
+ actual = "@bazel_tools//tools/android:empty",
)
bind(
name = "android_ndk_for_testing",
- actual = "//:dummy",
+ actual = "@bazel_tools//tools/android:empty",
)
bind(
diff --git a/src/test/py/bazel/query_test.py b/src/test/py/bazel/query_test.py
index cec898e..ee52d93 100644
--- a/src/test/py/bazel/query_test.py
+++ b/src/test/py/bazel/query_test.py
@@ -38,6 +38,11 @@
self._AssertQueryOutput('deps(//foo:top-rule, 1)', '//foo:top-rule',
'//foo:dep-rule')
+ def testQueryFilesUsedByRepositoryRules(self):
+ self.ScratchFile('WORKSPACE')
+ self._AssertQueryOutputContains("kind('source file', deps(//external:*))",
+ '@bazel_tools//tools/jdk:jdk.BUILD')
+
def testBuildFilesForExternalRepos_Simple(self):
self.ScratchFile('WORKSPACE', [
'load("//:deps.bzl", "repos")',
diff --git a/tools/android/BUILD.tools b/tools/android/BUILD.tools
index a389920..00d5f4d 100644
--- a/tools/android/BUILD.tools
+++ b/tools/android/BUILD.tools
@@ -417,7 +417,7 @@
)
# This is the default value of databinding_annotation_processor if the user does
-# not provide one.
+# not provide one. Also used by the bind rules in android.WORKSPACE.
filegroup(name = "empty")
alias(
diff --git a/tools/jdk/BUILD.tools b/tools/jdk/BUILD.tools
index 5aa077e..d9f81ed 100644
--- a/tools/jdk/BUILD.tools
+++ b/tools/jdk/BUILD.tools
@@ -214,7 +214,10 @@
}),
)
-exports_files(["BUILD.java_tools"])
+exports_files([
+ "BUILD.java_tools",
+ "jdk.BUILD",
+])
alias(
name = "genclass",