From 71ed1ee7c796b6cc0366ed4d39963b9542ac6e58 Mon Sep 17 00:00:00 2001 From: ajmichael Date: Fri, 5 May 2017 05:15:02 +0200 Subject: 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 --- tools/android/BUILD.tools | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'tools') 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 """, +) -- cgit v1.2.3