diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/AndroidDevice.java | 3 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTest.java | 2 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTestRule.java | 2 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkCommon.java | 15 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/android/DeviceBrokerInfo.java (renamed from src/main/java/com/google/devtools/build/lib/rules/android/DeviceBrokerTypeProvider.java) | 23 |
5 files changed, 36 insertions, 9 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDevice.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDevice.java index 057739510b..8f44097450 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDevice.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDevice.java @@ -132,8 +132,7 @@ public class AndroidDevice implements RuleConfiguredTargetFactory { .setRunfilesSupport(runfilesSupport, executable) .addFilesToRun(extraFilesToRun) .addNativeDeclaredProvider(new ExecutionInfo(executionInfo)) - .addProvider( - DeviceBrokerTypeProvider.class, new DeviceBrokerTypeProvider(DEVICE_BROKER_TYPE)) + .addNativeDeclaredProvider(new DeviceBrokerInfo(DEVICE_BROKER_TYPE)) .addProvider( Dex2OatProvider.class, new Dex2OatProvider(cloudDex2oatEnabled)) .build(); diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTest.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTest.java index 7c68827089..64a7cf04b2 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTest.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTest.java @@ -300,7 +300,7 @@ public class AndroidInstrumentationTest implements RuleConfiguredTargetFactory { private static String getDeviceBrokerType(RuleContext ruleContext) { return ruleContext - .getPrerequisite("target_device", Mode.HOST, DeviceBrokerTypeProvider.class) + .getPrerequisite("target_device", Mode.HOST, DeviceBrokerInfo.PROVIDER) .getDeviceBrokerType(); } diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTestRule.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTestRule.java index 07908ad1b1..9dfae4b389 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTestRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTestRule.java @@ -45,7 +45,7 @@ public class AndroidInstrumentationTestRule implements RuleDefinition { .exec() .cfg(HostTransition.INSTANCE) .allowedFileTypes(FileTypeSet.NO_FILE) - .allowedRuleClasses("android_device")) + .mandatoryProviders(DeviceBrokerInfo.PROVIDER.id())) .add( attr("support_apks", LABEL_LIST) .allowedFileTypes(AndroidRuleClasses.APK) diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkCommon.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkCommon.java index be66ad689c..6cd0a855d9 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkCommon.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkCommon.java @@ -15,6 +15,7 @@ package com.google.devtools.build.lib.rules.android; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.config.transitions.SplitTransition; +import com.google.devtools.build.lib.skylarkinterface.Param; import com.google.devtools.build.lib.skylarkinterface.SkylarkCallable; import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; import com.google.devtools.build.lib.vfs.PathFragment; @@ -27,6 +28,20 @@ import com.google.devtools.build.lib.vfs.PathFragment; public class AndroidSkylarkCommon { @SkylarkCallable( + name = "create_device_broker_info", + doc = "Create a device broker info", + parameters = { + @Param( + name = "type", + type = String.class + ) + } + ) + public DeviceBrokerInfo createDeviceBrokerInfo(String deviceBrokerType) { + return new DeviceBrokerInfo(deviceBrokerType); + } + + @SkylarkCallable( name = "resource_source_directory", allowReturnNones = true, doc = diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/DeviceBrokerTypeProvider.java b/src/main/java/com/google/devtools/build/lib/rules/android/DeviceBrokerInfo.java index 7a0b926741..9d05cd274b 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/android/DeviceBrokerTypeProvider.java +++ b/src/main/java/com/google/devtools/build/lib/rules/android/DeviceBrokerInfo.java @@ -1,4 +1,4 @@ -// Copyright 2017 The Bazel Authors. All rights reserved. +// Copyright 2018 The Bazel Authors. All rights reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -13,16 +13,29 @@ // limitations under the License. package com.google.devtools.build.lib.rules.android; -import com.google.devtools.build.lib.analysis.TransitiveInfoProvider; import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable; +import com.google.devtools.build.lib.packages.NativeInfo; +import com.google.devtools.build.lib.packages.NativeProvider; +import com.google.devtools.build.lib.skylarkinterface.SkylarkModule; +import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory; -/** Supplies the device broker type string, passed to the android_test runtime. */ +/** Supplies the device broker type string, passed to the Android test runtime. */ +@SkylarkModule( + name = "DeviceBrokerInfo", + doc = "Information about the device broker", + category = SkylarkModuleCategory.PROVIDER +) @Immutable -public final class DeviceBrokerTypeProvider implements TransitiveInfoProvider { +public final class DeviceBrokerInfo extends NativeInfo { + + private static final String SKYLARK_NAME = "DeviceBrokerInfo"; + public static final NativeProvider<DeviceBrokerInfo> PROVIDER = + new NativeProvider<DeviceBrokerInfo>(DeviceBrokerInfo.class, SKYLARK_NAME) {}; private final String deviceBrokerType; - public DeviceBrokerTypeProvider(String deviceBrokerType) { + public DeviceBrokerInfo(String deviceBrokerType) { + super(PROVIDER); this.deviceBrokerType = deviceBrokerType; } |