aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar ajmichael <ajmichael@google.com>2017-05-05 05:15:02 +0200
committerGravatar Damien Martin-Guillerez <dmarting@google.com>2017-05-05 15:27:26 +0200
commit71ed1ee7c796b6cc0366ed4d39963b9542ac6e58 (patch)
treee42096edbd6db3fffd9b0e6ed746ef86f4becea1 /tools
parent14747a8bf2d35846d75ac9058e1b514a89f68f07 (diff)
Improve error message when building Android rules without an SDK.
Fixes https://github.com/bazelbuild/bazel/issues/509. Example output: ``` $ bazel build //:all INFO: Found 1 target... ERROR: /usr/local/google/home/ajmichael/.cache/bazel/_bazel_ajmichael/7fcc7480abc634522e5c0cfe6b85b583/external/bazel_tools/tools/android/BUILD:236:1: Executing genrule @bazel_tools//tools/android:no_android_sdk_repository_error failed: Process exited with status 1 [sandboxed]. This build requires an Android SDK. Please add the android_sdk_repository rule to your WORKSPACE. Use --strategy=Genrule=standalone to disable sandboxing for the failing actions. Target //:lib failed to build Use --verbose_failures to see the command lines of failed build steps. INFO: Elapsed time: 0.327s, Critical Path: 0.10s ``` RELNOTES: Attempting to build an Android target without setting up android_sdk_repository will now produce a helpful error message. PiperOrigin-RevId: 155158667
Diffstat (limited to 'tools')
-rw-r--r--tools/android/BUILD.tools31
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/android/BUILD.tools b/tools/android/BUILD.tools
index 782fea920e..8c7bc618a3 100644
--- a/tools/android/BUILD.tools
+++ b/tools/android/BUILD.tools
@@ -210,3 +210,34 @@ alias(
name = "databinding_annotation_processor",
actual = "@android_databinding//:annotation_processor",
)
+
+# This is the default binding of //external:android/sdk. If someone attempts to
+# build a rule that depends on //external:android/sdk without setting up
+# android_sdk_repository in their WORKSPACE, the genrule will fail with a
+# helpful error message.
+android_sdk(
+ name = "poison_pill_android_sdk",
+ proguard = ":error_message",
+ aapt = ":error_message",
+ dx = ":error_message",
+ main_dex_list_creator = ":error_message",
+ adb = ":error_message",
+ framework_aidl = ":error_message",
+ aidl = ":error_message",
+ android_jar = ":error_message.jar",
+ shrinked_android_jar = ":error_message.jar",
+ annotations_jar = ":error_message.jar",
+ main_dex_classes = ":error_message",
+ apksigner = ":error_message",
+ zipalign = ":error_message",
+ resource_extractor = "error_message",
+)
+
+genrule(
+ name = "no_android_sdk_repository_error",
+ outs = ["error_message", "error_message.jar"],
+ cmd = """echo \
+ This build requires an Android SDK. Please add the android_sdk_repository \
+ rule to your WORKSPACE. ; \
+ exit 1 """,
+)