aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/rules
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules')
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidDevice.java9
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidDeviceBrokerInfo.java65
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidDex2OatInfo.java62
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTest.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidInstrumentationTestRule.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/AndroidSkylarkCommon.java18
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/DeviceBrokerInfo.java49
-rw-r--r--src/main/java/com/google/devtools/build/lib/rules/android/Dex2OatProvider.java35
8 files changed, 140 insertions, 102 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 76c22c7426..f47ebfdf71 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
@@ -128,17 +128,16 @@ public class AndroidDevice implements RuleConfiguredTargetFactory {
RunfilesSupport.withExecutable(ruleContext, runfiles, executable);
NestedSet<Artifact> extraFilesToRun =
NestedSetBuilder.create(Order.STABLE_ORDER, runfilesSupport.getRunfilesMiddleman());
- boolean cloudDex2oatEnabled = ruleContext.attributes().get(
- "pregenerate_oat_files_for_tests", Type.BOOLEAN);
+ boolean dex2OatEnabled =
+ ruleContext.attributes().get("pregenerate_oat_files_for_tests", Type.BOOLEAN);
return new RuleConfiguredTargetBuilder(ruleContext)
.setFilesToBuild(filesToBuild)
.addProvider(RunfilesProvider.class, RunfilesProvider.simple(runfiles))
.setRunfilesSupport(runfilesSupport, executable)
.addFilesToRun(extraFilesToRun)
.addNativeDeclaredProvider(new ExecutionInfo(executionInfo))
- .addNativeDeclaredProvider(new DeviceBrokerInfo(DEVICE_BROKER_TYPE))
- .addProvider(
- Dex2OatProvider.class, new Dex2OatProvider(cloudDex2oatEnabled))
+ .addNativeDeclaredProvider(new AndroidDeviceBrokerInfo(DEVICE_BROKER_TYPE))
+ .addNativeDeclaredProvider(new AndroidDex2OatInfo(dex2OatEnabled))
.build();
}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDeviceBrokerInfo.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDeviceBrokerInfo.java
new file mode 100644
index 0000000000..321dc19b98
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDeviceBrokerInfo.java
@@ -0,0 +1,65 @@
+// 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.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.build.lib.rules.android;
+
+import com.google.common.collect.ImmutableList;
+import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
+import com.google.devtools.build.lib.events.Location;
+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.syntax.FunctionSignature;
+import com.google.devtools.build.lib.syntax.SkylarkType;
+
+/** Supplies the device broker type string, passed to the Android test runtime. */
+@SkylarkModule(name = "AndroidDeviceBrokerInfo", doc = "", documented = false)
+@Immutable
+public final class AndroidDeviceBrokerInfo extends NativeInfo {
+
+ private static final String SKYLARK_NAME = "AndroidDeviceBrokerInfo";
+ private static final FunctionSignature.WithValues<Object, SkylarkType> SIGNATURE =
+ FunctionSignature.WithValues.create(
+ FunctionSignature.of(
+ /*numMandatoryPositionals=*/ 0,
+ /*numOptionalPositionals=*/ 0,
+ /*numMandatoryNamedOnly=*/ 1,
+ /*starArg=*/ false,
+ /*kwArg=*/ false,
+ "type"),
+ /*defaultValues=*/ null,
+ /*types=*/ ImmutableList.of(SkylarkType.of(String.class))); // instrumentation_apk
+ public static final NativeProvider<AndroidDeviceBrokerInfo> PROVIDER =
+ new NativeProvider<AndroidDeviceBrokerInfo>(
+ AndroidDeviceBrokerInfo.class, SKYLARK_NAME, SIGNATURE) {
+ @Override
+ protected AndroidDeviceBrokerInfo createInstanceFromSkylark(Object[] args, Location loc) {
+ return new AndroidDeviceBrokerInfo(/*deviceBrokerType=*/ (String) args[0]);
+ }
+ };
+
+ private final String deviceBrokerType;
+
+ public AndroidDeviceBrokerInfo(String deviceBrokerType) {
+ super(PROVIDER);
+ this.deviceBrokerType = deviceBrokerType;
+ }
+
+ /**
+ * Returns the type of device broker that is appropriate to use to interact with devices obtained
+ * by this artifact.
+ */
+ public String getDeviceBrokerType() {
+ return deviceBrokerType;
+ }
+}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDex2OatInfo.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDex2OatInfo.java
new file mode 100644
index 0000000000..0e3d499088
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDex2OatInfo.java
@@ -0,0 +1,62 @@
+// Copyright 2017 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.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package com.google.devtools.build.lib.rules.android;
+
+import com.google.common.collect.ImmutableList;
+import com.google.devtools.build.lib.events.Location;
+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.syntax.FunctionSignature;
+import com.google.devtools.build.lib.syntax.SkylarkType;
+
+/**
+ * Supplies the pregenerate_oat_files_for_tests attribute of type boolean provided by android_device
+ * rule.
+ */
+@SkylarkModule(name = "AndroidDex2OatInfo", doc = "", documented = false)
+public class AndroidDex2OatInfo extends NativeInfo {
+
+ private static final String SKYLARK_NAME = "AndroidDex2OatInfo";
+ private static final FunctionSignature.WithValues<Object, SkylarkType> SIGNATURE =
+ FunctionSignature.WithValues.create(
+ FunctionSignature.of(
+ /*numMandatoryPositionals=*/ 0,
+ /*numOptionalPositionals=*/ 0,
+ /*numMandatoryNamedOnly=*/ 1,
+ /*starArg=*/ false,
+ /*kwArg=*/ false,
+ "enabled"),
+ /*defaultValues=*/ null,
+ /*types=*/ ImmutableList.of(SkylarkType.of(Boolean.class))); // instrumentation_apk
+ public static final NativeProvider<AndroidDex2OatInfo> PROVIDER =
+ new NativeProvider<AndroidDex2OatInfo>(AndroidDex2OatInfo.class, SKYLARK_NAME, SIGNATURE) {
+ @Override
+ protected AndroidDex2OatInfo createInstanceFromSkylark(Object[] args, Location loc) {
+ return new AndroidDex2OatInfo(/*dex2OatEnabled=*/ (Boolean) args[0]);
+ }
+ };
+
+ private final boolean dex2OatEnabled;
+
+ public AndroidDex2OatInfo(boolean dex2OatEnabled) {
+ super(PROVIDER);
+ this.dex2OatEnabled = dex2OatEnabled;
+ }
+
+ /** Returns if the device should run cloud dex2oat. */
+ public boolean isDex2OatEnabled() {
+ return dex2OatEnabled;
+ }
+}
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 91f7c7be9e..6a1523c5d5 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
@@ -287,7 +287,7 @@ public class AndroidInstrumentationTest implements RuleConfiguredTargetFactory {
private static String getDeviceBrokerType(RuleContext ruleContext) {
return ruleContext
- .getPrerequisite("target_device", Mode.HOST, DeviceBrokerInfo.PROVIDER)
+ .getPrerequisite("target_device", Mode.HOST, AndroidDeviceBrokerInfo.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 99b0df851c..c33d060953 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
@@ -44,7 +44,7 @@ public class AndroidInstrumentationTestRule implements RuleDefinition {
.exec()
.cfg(HostTransition.INSTANCE)
.allowedFileTypes(FileTypeSet.NO_FILE)
- .mandatoryProviders(DeviceBrokerInfo.PROVIDER.id()))
+ .mandatoryProviders(AndroidDeviceBrokerInfo.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 6cd0a855d9..1211c81237 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
@@ -23,22 +23,18 @@ import com.google.devtools.build.lib.vfs.PathFragment;
/** Common utilities for Skylark rules related to Android. */
@SkylarkModule(
name = "android_common",
- doc = "Common utilities and fucntionality related to Android rules."
+ doc = "Common utilities and functionality related to Android rules."
)
public class AndroidSkylarkCommon {
@SkylarkCallable(
- name = "create_device_broker_info",
- doc = "Create a device broker info",
- parameters = {
- @Param(
- name = "type",
- type = String.class
- )
- }
+ name = "create_device_broker_info",
+ doc = "",
+ documented = false,
+ parameters = {@Param(name = "type", type = String.class)}
)
- public DeviceBrokerInfo createDeviceBrokerInfo(String deviceBrokerType) {
- return new DeviceBrokerInfo(deviceBrokerType);
+ public AndroidDeviceBrokerInfo createDeviceBrokerInfo(String deviceBrokerType) {
+ return new AndroidDeviceBrokerInfo(deviceBrokerType);
}
@SkylarkCallable(
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/DeviceBrokerInfo.java b/src/main/java/com/google/devtools/build/lib/rules/android/DeviceBrokerInfo.java
deleted file mode 100644
index 9d05cd274b..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/android/DeviceBrokerInfo.java
+++ /dev/null
@@ -1,49 +0,0 @@
-// 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.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-package com.google.devtools.build.lib.rules.android;
-
-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. */
-@SkylarkModule(
- name = "DeviceBrokerInfo",
- doc = "Information about the device broker",
- category = SkylarkModuleCategory.PROVIDER
-)
-@Immutable
-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 DeviceBrokerInfo(String deviceBrokerType) {
- super(PROVIDER);
- this.deviceBrokerType = deviceBrokerType;
- }
-
- /**
- * Returns the type of device broker that is appropriate to use to interact with devices obtained
- * by this artifact.
- */
- public String getDeviceBrokerType() {
- return deviceBrokerType;
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/Dex2OatProvider.java b/src/main/java/com/google/devtools/build/lib/rules/android/Dex2OatProvider.java
deleted file mode 100644
index e6d83c1eac..0000000000
--- a/src/main/java/com/google/devtools/build/lib/rules/android/Dex2OatProvider.java
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2017 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.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-package com.google.devtools.build.lib.rules.android;
-
-import com.google.devtools.build.lib.analysis.TransitiveInfoProvider;
-
-/** Supplies the pregenerate_oat_files_for_tests attribute of type boolean provided by
- * android_device rule.
- */
-public class Dex2OatProvider implements TransitiveInfoProvider {
-
- private final boolean cloudDex2oatEnabled;
-
- public Dex2OatProvider(boolean cloudDex2oatEnabled) {
- this.cloudDex2oatEnabled = cloudDex2oatEnabled;
- }
-
- /**
- * Returns if the device should run cloud dex2oat.
- */
- public boolean isCloudDex2oatEnabled() {
- return cloudDex2oatEnabled;
- }
-}