From dbb6e9954b6e4423f727feb2719ffc75a93b514b Mon Sep 17 00:00:00 2001 From: Zhongpeng Lin Date: Thu, 31 Mar 2022 10:38:15 -0700 Subject: [PATCH] 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 --- .../devtools/build/lib/bazel/rules/android/android.WORKSPACE | 4 ++-- src/test/py/bazel/query_test.py | 5 +++++ tools/android/BUILD.tools | 2 +- tools/jdk/BUILD.tools | 5 ++++- 4 files changed, 12 insertions(+), 4 deletions(-) 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 553e77b16ba0e7..d5123d5808403a 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( 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 cec898e57ad577..ee52d932ed57a4 100644 --- a/src/test/py/bazel/query_test.py +++ b/src/test/py/bazel/query_test.py @@ -38,6 +38,11 @@ def testSimpleQuery(self): 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 a3899206bb5f67..00d5f4d2845da4 100644 --- a/tools/android/BUILD.tools +++ b/tools/android/BUILD.tools @@ -417,7 +417,7 @@ alias( ) # 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 5aa077ebf6f868..d9f81ededb241e 100644 --- a/tools/jdk/BUILD.tools +++ b/tools/jdk/BUILD.tools @@ -214,7 +214,10 @@ alias( }), ) -exports_files(["BUILD.java_tools"]) +exports_files([ + "BUILD.java_tools", + "jdk.BUILD", +]) alias( name = "genclass",