aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google
diff options
context:
space:
mode:
authorGravatar ajmichael <ajmichael@google.com>2017-05-31 22:34:34 +0200
committerGravatar László Csomor <laszlocsomor@google.com>2017-06-01 14:08:29 +0200
commit22d05ebc9f4ce3194233e7dfd12bf079ce88ee07 (patch)
treeeb75d09cc0662bfd744bd76d25b533c57df0e5d5 /src/main/java/com/google
parent7fa955b83d86d8f03d339c58446806b6e0e51bf1 (diff)
Add //external:has_androidsdk config_setting.
This will be used to add some tests and targets to the Bazel codebase that build and run successfully when android_sdk_repository is in the WORKSPACE and silently skip if it is not. Example deps of a library that links against dx.jar: ``` deps = select({ "//external:has_androidsdk": ["//external:android/dx_jar_import"], "//conditions:default": [], }), ``` Also adds tests that config_setting works as expected when propagated through an alias or bind rule. RELNOTES: None PiperOrigin-RevId: 157627472
Diffstat (limited to 'src/main/java/com/google')
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryRule.java3
-rw-r--r--src/main/java/com/google/devtools/build/lib/bazel/rules/android/android.WORKSPACE4
2 files changed, 7 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryRule.java
index 45948f5fd7..ba0f237085 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryRule.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/AndroidSdkRepositoryRule.java
@@ -48,6 +48,9 @@ public class AndroidSdkRepositoryRule implements RuleDefinition {
builder.put(
"android/dx_jar_import", Label.parseAbsoluteUnchecked(prefix + "dx_jar_import"));
builder.put("android_sdk_for_testing", Label.parseAbsoluteUnchecked(prefix + "files"));
+ builder.put(
+ "has_androidsdk",
+ Label.parseAbsoluteUnchecked("@bazel_tools//tools/android:always_true"));
return builder.build();
}
};
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 51fdfef483..ed2ea23885 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
@@ -3,3 +3,7 @@ bind(name = "android/dx_jar_import", actual = "@bazel_tools//tools/android:no_an
bind(name = "android/crosstool", actual = "@bazel_tools//tools/cpp:toolchain")
bind(name = "android_sdk_for_testing", actual = "//:dummy")
bind(name = "android_ndk_for_testing", actual = "//:dummy")
+
+# This value is overridden by android_sdk_repository function to allow targets
+# to select on whether or not android_sdk_repository has run.
+bind(name = "has_androidsdk", actual = "@bazel_tools//tools/android:always_false")