Delete the native AndroidDevice rule.
Also delete the AndroidDeviceBrokerInfo provider since it was used as an API surface between AndroidDevice and AndroidTest/AndroidInstrumentationTest which have also been deleted.
RELNOTES: Delete the native AndroidDevice rule. This follows the deletion of the native AndroidTest and AndroidInstrumentationTest rules.
PiperOrigin-RevId: 629734861
Change-Id: Ie66fb738d5644e9206009e37d624e2d06401c000
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
index e662709..afddf66 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
@@ -41,7 +41,6 @@
import com.google.devtools.build.lib.bazel.rules.android.AndroidSdkRepositoryRule;
import com.google.devtools.build.lib.bazel.rules.android.BazelAarImportRule;
import com.google.devtools.build.lib.bazel.rules.android.BazelAndroidBinaryRule;
-import com.google.devtools.build.lib.bazel.rules.android.BazelAndroidDevice;
import com.google.devtools.build.lib.bazel.rules.android.BazelAndroidDeviceScriptFixture;
import com.google.devtools.build.lib.bazel.rules.android.BazelAndroidHostServiceFixture;
import com.google.devtools.build.lib.bazel.rules.android.BazelAndroidLibraryRule;
@@ -65,8 +64,6 @@
import com.google.devtools.build.lib.rules.android.AndroidBinaryNativeLibsInfo;
import com.google.devtools.build.lib.rules.android.AndroidCcLinkParamsProvider;
import com.google.devtools.build.lib.rules.android.AndroidConfiguration;
-import com.google.devtools.build.lib.rules.android.AndroidDeviceBrokerInfo;
-import com.google.devtools.build.lib.rules.android.AndroidDeviceRule;
import com.google.devtools.build.lib.rules.android.AndroidDeviceScriptFixtureRule;
import com.google.devtools.build.lib.rules.android.AndroidDexInfo;
import com.google.devtools.build.lib.rules.android.AndroidFeatureFlagSetProvider;
@@ -365,7 +362,6 @@
builder.addRuleDefinition(new BazelAndroidBinaryRule());
builder.addRuleDefinition(new AarImportBaseRule());
builder.addRuleDefinition(new BazelAarImportRule());
- builder.addRuleDefinition(new AndroidDeviceRule(BazelAndroidDevice.class));
builder.addRuleDefinition(new AndroidLocalTestBaseRule());
builder.addRuleDefinition(new BazelAndroidLocalTestRule());
builder.addRuleDefinition(
@@ -378,7 +374,6 @@
new AndroidStarlarkCommon(),
ApkInfo.PROVIDER,
AndroidInstrumentationInfo.PROVIDER,
- AndroidDeviceBrokerInfo.PROVIDER,
AndroidResourcesInfo.PROVIDER,
AndroidNativeLibsInfo.PROVIDER,
AndroidApplicationResourceInfo.PROVIDER,
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/BazelAndroidDevice.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/android/BazelAndroidDevice.java
deleted file mode 100644
index 13041279..0000000
--- a/src/main/java/com/google/devtools/build/lib/bazel/rules/android/BazelAndroidDevice.java
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2019 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.bazel.rules.android;
-
-import com.google.devtools.build.lib.rules.android.AndroidDevice;
-
-/** Implementation of {@code android_device} with Bazel semantics. */
-public class BazelAndroidDevice extends AndroidDevice {
- public BazelAndroidDevice() {
- super(BazelAndroidSemantics.INSTANCE);
- }
-}
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
deleted file mode 100644
index 5a93561..0000000
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDevice.java
+++ /dev/null
@@ -1,423 +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 static com.google.common.collect.MoreCollectors.onlyElement;
-import static java.util.stream.Collectors.joining;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Streams;
-import com.google.devtools.build.lib.actions.ActionConflictException;
-import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.actions.ResourceSet;
-import com.google.devtools.build.lib.analysis.Allowlist;
-import com.google.devtools.build.lib.analysis.ConfiguredTarget;
-import com.google.devtools.build.lib.analysis.FileProvider;
-import com.google.devtools.build.lib.analysis.FilesToRunProvider;
-import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder;
-import com.google.devtools.build.lib.analysis.RuleConfiguredTargetFactory;
-import com.google.devtools.build.lib.analysis.RuleContext;
-import com.google.devtools.build.lib.analysis.Runfiles;
-import com.google.devtools.build.lib.analysis.RunfilesProvider;
-import com.google.devtools.build.lib.analysis.RunfilesSupport;
-import com.google.devtools.build.lib.analysis.TransitiveInfoCollection;
-import com.google.devtools.build.lib.analysis.actions.CustomCommandLine;
-import com.google.devtools.build.lib.analysis.actions.SpawnAction;
-import com.google.devtools.build.lib.analysis.actions.Substitution;
-import com.google.devtools.build.lib.analysis.actions.Template;
-import com.google.devtools.build.lib.analysis.actions.TemplateExpansionAction;
-import com.google.devtools.build.lib.analysis.test.ExecutionInfo;
-import com.google.devtools.build.lib.collect.nestedset.NestedSet;
-import com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder;
-import com.google.devtools.build.lib.packages.TargetUtils;
-import com.google.devtools.build.lib.packages.Type;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import javax.annotation.Nullable;
-
-/** An implementation for the "android_device" rule. */
-public class AndroidDevice implements RuleConfiguredTargetFactory {
-
- private static final Template STUB_SCRIPT =
- Template.forResource(AndroidDevice.class, "android_device_stub_template.txt");
-
- private static final String DEVICE_BROKER_TYPE = "WRAPPED_EMULATOR";
-
- static final String ALLOWLIST_NAME = "android_device";
-
- // Min resolution
- private static final int MIN_HORIZONTAL = 240;
- private static final int MIN_VERTICAL = 240;
-
- private static final int MIN_RAM = 64;
- private static final int MAX_RAM = 4096;
- private static final int MIN_VM_HEAP = 16;
- private static final int MIN_CACHE = 16;
-
- // http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density
- // this is a much lower pixels-per-inch then even some of the oldest phones.
- private static final int MIN_LCD_DENSITY = 30;
-
- private static final Predicate<Artifact> SOURCE_PROPERTIES_SELECTOR =
- (Artifact artifact) -> "source.properties".equals(artifact.getExecPath().getBaseName());
-
- private static final Predicate<Artifact> SOURCE_PROPERTIES_FILTER =
- Predicates.not(SOURCE_PROPERTIES_SELECTOR);
-
- private final AndroidSemantics androidSemantics;
-
- protected AndroidDevice(AndroidSemantics androidSemantics) {
- this.androidSemantics = androidSemantics;
- }
-
- @Override
- @Nullable
- public ConfiguredTarget create(RuleContext ruleContext)
- throws InterruptedException, RuleErrorException, ActionConflictException {
- androidSemantics.checkForMigrationTag(ruleContext);
- checkAllowlist(ruleContext);
- Artifact executable = ruleContext.createOutputArtifact();
- Artifact metadata =
- ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_DEVICE_EMULATOR_METADATA);
- Artifact images =
- ruleContext.getImplicitOutputArtifact(AndroidRuleClasses.ANDROID_DEVICE_USERDATA_IMAGES);
-
- NestedSetBuilder<Artifact> filesBuilder = NestedSetBuilder.stableOrder();
- filesBuilder.add(executable);
- filesBuilder.add(metadata);
- filesBuilder.add(images);
- NestedSet<Artifact> filesToBuild = filesBuilder.build();
-
- Map<String, String> executionInfo = TargetUtils.getExecutionInfo(ruleContext.getRule());
- AndroidDeviceRuleAttributes deviceAttributes =
- new AndroidDeviceRuleAttributes(ruleContext, ImmutableMap.copyOf(executionInfo));
- if (ruleContext.hasErrors()) {
- return null;
- }
-
- // dependencies needed for the runfiles collector.
- Iterable<Artifact> commonDependencyArtifacts = deviceAttributes.getCommonDependencies();
-
- deviceAttributes.createStubScriptAction(metadata, images, executable, ruleContext);
- deviceAttributes.createBootAction(metadata, images);
-
- FilesToRunProvider unifiedLauncher = deviceAttributes.getUnifiedLauncher();
- Runfiles.Builder runfilesBuilder =
- new Runfiles.Builder(ruleContext.getWorkspaceName())
- .addTransitiveArtifacts(filesToBuild)
- .addArtifacts(commonDependencyArtifacts)
- .addRunfiles(ruleContext, RunfilesProvider.DEFAULT_RUNFILES);
- if (unifiedLauncher.getRunfilesSupport() != null) {
- runfilesBuilder.merge(unifiedLauncher.getRunfilesSupport().getRunfiles());
- } else {
- runfilesBuilder.addArtifact(unifiedLauncher.getExecutable());
- }
- Runfiles runfiles = runfilesBuilder.build();
- RunfilesSupport runfilesSupport =
- RunfilesSupport.withExecutable(ruleContext, runfiles, executable);
- 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)
- .addNativeDeclaredProvider(new ExecutionInfo(executionInfo))
- .addNativeDeclaredProvider(new AndroidDeviceBrokerInfo(DEVICE_BROKER_TYPE))
- .addNativeDeclaredProvider(
- new AndroidDex2OatInfo(
- dex2OatEnabled,
- false /* executeDex2OatOnHost */,
- null /* deviceForPregeneratingOatFilesForTests */,
- null /* framework */,
- null /* dalvikCache */,
- null /* deviceProps */))
- .build();
- }
-
- private static void checkAllowlist(RuleContext ruleContext) throws RuleErrorException {
- if (!Allowlist.isAvailable(ruleContext, ALLOWLIST_NAME)) {
- ruleContext.throwWithRuleError("The android_device rule may not be used in this package");
- }
- }
-
- /**
- * Handles initialization phase validation of attributes, collection of dependencies and creation
- * of actions.
- */
- private static class AndroidDeviceRuleAttributes {
- private final RuleContext ruleContext;
- private final ImmutableMap<String, String> constraints;
-
- private final Artifact adb;
- private final Artifact emulatorArm;
- private final Artifact emulatorX86;
- private final Artifact adbStatic;
- private final ImmutableList<Artifact> emulatorX86Bios;
- private final ImmutableList<Artifact> xvfbSupportFiles;
- private final Artifact mksdcard;
- private final Artifact snapshotFs;
- private final FilesToRunProvider unifiedLauncher;
- private final Artifact androidRuntest;
- private final ImmutableList<Artifact> androidRuntestDeps;
- private final Artifact testingShbase;
- private final ImmutableList<Artifact> testingShbaseDeps;
- private final Optional<Artifact> defaultProperties;
- private final Iterable<Artifact> platformApks;
- private final Artifact sdkPath;
-
- private final int ram;
- private final int cache;
- private final int vmHeap;
- private final int density;
- private final int horizontalResolution;
- private final int verticalResolution;
-
- // These can only be null if there was an error during creation.
- private Iterable<Artifact> systemImages;
- private Artifact sourcePropertiesFile;
- private ImmutableList<Artifact> commonDependencies;
-
- private AndroidDeviceRuleAttributes(
- RuleContext ruleContext, ImmutableMap<String, String> executionInfo) {
- this.ruleContext = ruleContext;
- this.constraints = executionInfo;
- horizontalResolution =
- ruleContext.attributes().get("horizontal_resolution", Type.INTEGER).toIntUnchecked();
- verticalResolution =
- ruleContext.attributes().get("vertical_resolution", Type.INTEGER).toIntUnchecked();
- ram = ruleContext.attributes().get("ram", Type.INTEGER).toIntUnchecked();
- density = ruleContext.attributes().get("screen_density", Type.INTEGER).toIntUnchecked();
- cache = ruleContext.attributes().get("cache", Type.INTEGER).toIntUnchecked();
- vmHeap = ruleContext.attributes().get("vm_heap", Type.INTEGER).toIntUnchecked();
-
- defaultProperties =
- Optional.fromNullable(ruleContext.getPrerequisiteArtifact("default_properties"));
- adb = ruleContext.getPrerequisiteArtifact("$adb");
- emulatorArm = ruleContext.getPrerequisiteArtifact("$emulator_arm");
- emulatorX86 = ruleContext.getPrerequisiteArtifact("$emulator_x86");
- adbStatic = ruleContext.getPrerequisiteArtifact("$adb_static");
- emulatorX86Bios = ruleContext.getPrerequisiteArtifacts("$emulator_x86_bios").list();
- xvfbSupportFiles = ruleContext.getPrerequisiteArtifacts("$xvfb_support").list();
- mksdcard = ruleContext.getPrerequisiteArtifact("$mksd");
- snapshotFs = ruleContext.getPrerequisiteArtifact("$empty_snapshot_fs");
- unifiedLauncher = ruleContext.getExecutablePrerequisite("$unified_launcher");
- androidRuntestDeps = ruleContext.getPrerequisiteArtifacts("$android_runtest").list();
- androidRuntest =
- androidRuntestDeps.stream().filter(Artifact::isSourceArtifact).collect(onlyElement());
- testingShbaseDeps = ruleContext.getPrerequisiteArtifacts("$testing_shbase").list();
- testingShbase =
- testingShbaseDeps
- .stream()
- .filter(
- (Artifact artifact) -> "googletest.sh".equals(artifact.getPath().getBaseName()))
- .collect(onlyElement());
-
- // may be empty
- platformApks = ruleContext.getPrerequisiteArtifacts("platform_apks").list();
- sdkPath = ruleContext.getPrerequisiteArtifact("$sdk_path");
-
- TransitiveInfoCollection systemImagesAndSourceProperties =
- ruleContext.getPrerequisite("system_image");
- if (ruleContext.hasErrors()) {
- return;
- }
-
- List<Artifact> files =
- systemImagesAndSourceProperties
- .getProvider(FileProvider.class)
- .getFilesToBuild()
- .toList();
- sourcePropertiesFile = Iterables.tryFind(files, SOURCE_PROPERTIES_SELECTOR).orNull();
- systemImages = Iterables.filter(files, SOURCE_PROPERTIES_FILTER);
- validateAttributes();
- if (sourcePropertiesFile == null) {
- ruleContext.attributeError(
- "system_image",
- "No source.properties files exist in this "
- + "filegroup ("
- + systemImagesAndSourceProperties.getLabel()
- + ")");
- }
- int numberOfSourceProperties = files.size() - Iterables.size(systemImages);
- if (numberOfSourceProperties > 1) {
- ruleContext.attributeError(
- "system_image",
- "Multiple source.properties files exist in "
- + "this filegroup ("
- + systemImagesAndSourceProperties.getLabel()
- + ")");
- }
- if (ruleContext.hasErrors()) {
- return;
- }
-
- commonDependencies =
- ImmutableList.<Artifact>builder()
- .add(adb)
- .add(sourcePropertiesFile)
- .addAll(systemImages)
- .add(emulatorArm)
- .add(emulatorX86)
- .add(adbStatic)
- .addAll(emulatorX86Bios)
- .addAll(xvfbSupportFiles)
- .add(mksdcard)
- .add(snapshotFs)
- .addAll(androidRuntestDeps)
- .addAll(testingShbaseDeps)
- .addAll(platformApks)
- .build();
- }
-
- /*
- * The stub script will find the workspace directory of its runfiles tree and then execute
- * from there.
- * The stub script gets run via blaze run, blaze-bin or as a part of a test.
- */
- private void createStubScriptAction(
- Artifact metadata, Artifact images, Artifact executable, RuleContext ruleContext) {
- List<Substitution> arguments = new ArrayList<>();
- arguments.add(Substitution.of("%workspace%", ruleContext.getWorkspaceName()));
- arguments.add(
- Substitution.of(
- "%unified_launcher%", unifiedLauncher.getExecutable().getRunfilesPathString()));
- arguments.add(Substitution.of("%adb%", adb.getRunfilesPathString()));
- arguments.add(Substitution.of("%adb_static%", adbStatic.getRunfilesPathString()));
- arguments.add(Substitution.of("%emulator_x86%", emulatorX86.getRunfilesPathString()));
- arguments.add(Substitution.of("%emulator_arm%", emulatorArm.getRunfilesPathString()));
- arguments.add(Substitution.of("%mksdcard%", mksdcard.getRunfilesPathString()));
- arguments.add(Substitution.of("%empty_snapshot_fs%", snapshotFs.getRunfilesPathString()));
- arguments.add(
- Substitution.of(
- "%system_images%",
- Streams.stream(systemImages)
- .map(Artifact::getRunfilesPathString)
- .collect(joining(" "))));
- arguments.add(
- Substitution.of(
- "%bios_files%",
- emulatorX86Bios.stream().map(Artifact::getRunfilesPathString).collect(joining(" "))));
- arguments.add(
- Substitution.of(
- "%source_properties_file%", sourcePropertiesFile.getRunfilesPathString()));
- arguments.add(Substitution.of("%image_input_file%", images.getRunfilesPathString()));
- arguments.add(Substitution.of("%emulator_metadata_path%", metadata.getRunfilesPathString()));
- arguments.add(Substitution.of("%android_runtest%", androidRuntest.getRunfilesPathString()));
- arguments.add(Substitution.of("%testing_shbase%", testingShbase.getRunfilesPathString()));
- arguments.add(Substitution.of("%sdk_path%", sdkPath.getRunfilesPathString()));
-
- ruleContext.registerAction(
- new TemplateExpansionAction(
- ruleContext.getActionOwner(), executable, STUB_SCRIPT, arguments, true));
- }
-
- public FilesToRunProvider getUnifiedLauncher() {
- return unifiedLauncher;
- }
-
- public void createBootAction(Artifact metadata, Artifact images) {
- // the boot action will run during the build so use execpath
- // strings to find all dependent artifacts (there is no nicely created runfiles
- // folder we're executing in).
-
- SpawnAction.Builder spawnBuilder =
- new SpawnAction.Builder()
- .addOutput(metadata)
- .addOutput(images)
- .addInputs(commonDependencies)
- .setMnemonic("AndroidDeviceBoot")
- .setProgressMessage("Creating Android image for %s", ruleContext.getLabel())
- .setExecutionInfo(constraints)
- .setExecutable(unifiedLauncher)
- // Boot resource estimation:
- // RAM: the emulator will use as much ram as has been requested in the device rule
- // (there is a slight overhead for qemu's internals, but this is miniscule).
- // CPU: 100% - the emulator will peg a single cpu during boot because it's a very
- // computation intensive part of the lifecycle.
- .setResources(ResourceSet.createWithRamCpu(ram, 1))
- .addExecutableArguments(
- "--action=boot",
- "--density=" + density,
- "--memory=" + ram,
- "--cache=" + cache,
- "--vm_size=" + vmHeap,
- "--generate_output_dir="
- + images.getExecPath().getParentDirectory().getPathString(),
- "--skin=" + getScreenSize(),
- "--source_properties_file=" + sourcePropertiesFile.getExecPathString(),
- "--system_images=" + Artifact.joinExecPaths(" ", systemImages),
- "--flag_configured_android_tools",
- "--adb=" + adb.getExecPathString(),
- "--emulator_x86=" + emulatorX86.getExecPathString(),
- "--emulator_arm=" + emulatorArm.getExecPathString(),
- "--adb_static=" + adbStatic.getExecPathString(),
- "--mksdcard=" + mksdcard.getExecPathString(),
- "--empty_snapshot_fs=" + snapshotFs.getExecPathString(),
- "--bios_files=" + Artifact.joinExecPaths(",", emulatorX86Bios),
- "--nocopy_system_images",
- "--single_image_file",
- "--android_sdk_path=" + sdkPath.getExecPathString(),
- "--platform_apks=" + Artifact.joinExecPaths(",", platformApks));
-
- CustomCommandLine.Builder commandLine = CustomCommandLine.builder();
- if (defaultProperties.isPresent()) {
- spawnBuilder.addInput(defaultProperties.get());
- commandLine.addPrefixedExecPath("--default_properties_file=", defaultProperties.get());
- }
- spawnBuilder.addCommandLine(commandLine.build());
- ruleContext.registerAction(spawnBuilder.build(ruleContext));
- }
-
- public ImmutableList<Artifact> getCommonDependencies() {
- return commonDependencies;
- }
-
- private void validateAttributes() {
- if (horizontalResolution < MIN_HORIZONTAL) {
- ruleContext.attributeError(
- "horizontal_resolution", "horizontal must be at least: " + MIN_HORIZONTAL);
- }
- if (verticalResolution < MIN_VERTICAL) {
- ruleContext.attributeError(
- "vertical_resolution", "vertical must be at least: " + MIN_VERTICAL);
- }
- if (ram < MIN_RAM) {
- ruleContext.attributeError("ram", "ram must be at least: " + MIN_RAM);
- }
- if (ram > MAX_RAM) {
- ruleContext.attributeError("ram", "ram cannot be greater than: " + MAX_RAM);
- }
- if (density < MIN_LCD_DENSITY) {
- ruleContext.attributeError(
- "screen_density", "density must be at least: " + MIN_LCD_DENSITY);
- }
- if (cache < MIN_CACHE) {
- ruleContext.attributeError("cache", "cache must be at least: " + MIN_CACHE);
- }
- if (vmHeap < MIN_VM_HEAP) {
- ruleContext.attributeError("vm_heap", "vm heap must be at least: " + MIN_VM_HEAP);
- }
- }
-
- private String getScreenSize() {
- return horizontalResolution + "x" + verticalResolution;
- }
- }
-}
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
deleted file mode 100644
index 536273e..0000000
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDeviceBrokerInfo.java
+++ /dev/null
@@ -1,69 +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.BuiltinProvider;
-import com.google.devtools.build.lib.packages.NativeInfo;
-import com.google.devtools.build.lib.starlarkbuildapi.android.AndroidDeviceBrokerInfoApi;
-import net.starlark.java.eval.EvalException;
-
-/** Supplies the device broker type string, passed to the Android test runtime. */
-@Immutable
-public final class AndroidDeviceBrokerInfo extends NativeInfo
- implements AndroidDeviceBrokerInfoApi {
-
- private static final String STARLARK_NAME = "AndroidDeviceBrokerInfo";
-
- /**
- * Provider instance for {@link AndroidDeviceBrokerInfo}.
- */
- public static final AndroidDeviceBrokerInfoProvider PROVIDER =
- new AndroidDeviceBrokerInfoProvider();
-
- private final String deviceBrokerType;
-
- public AndroidDeviceBrokerInfo(String deviceBrokerType) {
- this.deviceBrokerType = deviceBrokerType;
- }
-
- @Override
- public AndroidDeviceBrokerInfoProvider getProvider() {
- return PROVIDER;
- }
-
- /**
- * Returns the type of device broker that is appropriate to use to interact with devices obtained
- * by this artifact.
- */
- public String getDeviceBrokerType() {
- return deviceBrokerType;
- }
-
- /** Provider for {@link AndroidDeviceBrokerInfo}. */
- public static class AndroidDeviceBrokerInfoProvider
- extends BuiltinProvider<AndroidDeviceBrokerInfo>
- implements AndroidDeviceBrokerInfoApiProvider {
-
- private AndroidDeviceBrokerInfoProvider() {
- super(STARLARK_NAME, AndroidDeviceBrokerInfo.class);
- }
-
- @Override
- public AndroidDeviceBrokerInfo createInfo(String type)
- throws EvalException {
- return new AndroidDeviceBrokerInfo(type);
- }
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDeviceRule.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDeviceRule.java
deleted file mode 100644
index 2022151..0000000
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidDeviceRule.java
+++ /dev/null
@@ -1,256 +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 static com.google.devtools.build.lib.packages.Attribute.attr;
-import static com.google.devtools.build.lib.packages.BuildType.LABEL;
-import static com.google.devtools.build.lib.packages.BuildType.LABEL_LIST;
-import static com.google.devtools.build.lib.packages.Type.BOOLEAN;
-import static com.google.devtools.build.lib.packages.Type.INTEGER;
-
-import com.google.devtools.build.lib.analysis.Allowlist;
-import com.google.devtools.build.lib.analysis.BaseRuleClasses;
-import com.google.devtools.build.lib.analysis.RuleDefinition;
-import com.google.devtools.build.lib.analysis.RuleDefinitionEnvironment;
-import com.google.devtools.build.lib.analysis.config.ExecutionTransitionFactory;
-import com.google.devtools.build.lib.packages.RuleClass;
-import com.google.devtools.build.lib.rules.java.JavaSemantics;
-
-/** Rule definition for android_device. */
-public final class AndroidDeviceRule implements RuleDefinition {
-
- private final Class<? extends AndroidDevice> factoryClass;
-
- public AndroidDeviceRule(Class<? extends AndroidDevice> factoryClass) {
- this.factoryClass = factoryClass;
- }
-
- @Override
- public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env) {
- return builder
- /* <!-- #BLAZE_RULE(android_device).IMPLICIT_OUTPUTS -->
- <ul>
- <li><code><var>name</var>_images/userdata.dat</code>:
- Contains image files and snapshots to start the emulator</li>
- <li><code><var>name</var>_images/emulator-meta-data.pb</code>:
- Contains serialized information necessary to pass on to the emulator to
- restart it.</li>
- </ul>
- <!-- #END_BLAZE_RULE.IMPLICIT_OUTPUTS --> */
-
- /* <!-- #BLAZE_RULE(android_device).ATTRIBUTE(vertical_resolution) -->
- The vertical screen resolution in pixels to emulate.
- The minimum value is 240.
- <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
- .add(attr("vertical_resolution", INTEGER).mandatory())
- /* <!-- #BLAZE_RULE(android_device).ATTRIBUTE(horizontal_resolution) -->
- The horizontal screen resolution in pixels to emulate.
- The minimum value is 240.
- <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
- .add(attr("horizontal_resolution", INTEGER).mandatory())
- /* <!-- #BLAZE_RULE(android_device).ATTRIBUTE(ram) -->
- The amount of ram in megabytes to emulate for the device.
- This is for the entire device, not just for a particular app installed on the device. The
- minimum value is 64 megabytes.
- <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
- .add(attr("ram", INTEGER).mandatory())
- /* <!-- #BLAZE_RULE(android_device).ATTRIBUTE(screen_density) -->
- The density of the emulated screen in pixels per inch.
- The minimum value of this is 30 ppi.
- <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
- .add(attr("screen_density", INTEGER).mandatory())
- /* <!-- #BLAZE_RULE(android_device).ATTRIBUTE(cache) -->
- The size in megabytes of the emulator's cache partition.
- The minimum value of this is 16 megabytes.
- <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
- .add(attr("cache", INTEGER).mandatory())
- /* <!-- #BLAZE_RULE(android_device).ATTRIBUTE(vm_heap) -->
- The size in megabytes of the virtual machine heap Android will use for each process.
- The minimum value is 16 megabytes.
- <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
- .add(attr("vm_heap", INTEGER).mandatory())
- /* <!-- #BLAZE_RULE(android_device).ATTRIBUTE(system_image) -->
- A filegroup containing the following files:
- <ul>
- <li>system.img: The system partition</li>
- <li>kernel-qemu: The Linux kernel the emulator will load</li>
- <li>ramdisk.img: The initrd image to use at boot time</li>
- <li>userdata.img: The initial userdata partition</li>
- <li>source.properties: A properties file containing information about the
- images</li>
- </ul>
- These files are part of the android sdk or provided by third parties (for
- example Intel provides x86 images).
- <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
- .add(attr("system_image", LABEL).mandatory().legacyAllowAnyFileType())
- /* <!-- #BLAZE_RULE(android_device).ATTRIBUTE(default_properties) -->
- A single properties file to be placed in /default.prop on the emulator.
- This allows the rule author to further configure the emulator to appear more like
- a real device (In particular controlling its UserAgent strings and other
- behaviour that might cause an application or server to behave differently to
- a specific device). The properties in this file will override read only
- properties typically set by the emulator such as ro.product.model.
- <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
- .add(
- attr("default_properties", LABEL)
- .cfg(ExecutionTransitionFactory.createFactory())
- .allowedFileTypes(JavaSemantics.PROPERTIES))
- /* <!-- #BLAZE_RULE(android_device).ATTRIBUTE(platform_apks) -->
- A list of apks to be installed on the device at boot time.
- <!-- #END_BLAZE_RULE.ATTRIBUTE --> */
- .add(attr("platform_apks", LABEL_LIST).legacyAllowAnyFileType())
- // Do not pregenerate oat files for tests by default unless the device
- // supports it.
- .add(attr("pregenerate_oat_files_for_tests", BOOLEAN).value(false))
- .add(
- attr("$adb_static", LABEL)
- .cfg(ExecutionTransitionFactory.createFactory())
- .value(env.getToolsLabel("//tools/android:adb_static")))
- .add(
- attr("$adb", LABEL)
- .cfg(ExecutionTransitionFactory.createFactory())
- .value(env.getToolsLabel("//tools/android:adb")))
- .add(
- attr("$emulator_arm", LABEL)
- .cfg(ExecutionTransitionFactory.createFactory())
- .value(env.getToolsLabel("//tools/android/emulator:emulator_arm")))
- .add(
- attr("$emulator_x86", LABEL)
- .cfg(ExecutionTransitionFactory.createFactory())
- .value(env.getToolsLabel("//tools/android/emulator:emulator_x86")))
- .add(
- attr("$emulator_x86_bios", LABEL)
- .cfg(ExecutionTransitionFactory.createFactory())
- .value(env.getToolsLabel("//tools/android/emulator:emulator_x86_bios")))
- .add(
- attr("$mksd", LABEL)
- .cfg(ExecutionTransitionFactory.createFactory())
- .exec()
- .value(env.getToolsLabel("//tools/android/emulator:mksd")))
- .add(
- attr("$empty_snapshot_fs", LABEL)
- .cfg(ExecutionTransitionFactory.createFactory())
- .value(env.getToolsLabel("//tools/android/emulator:empty_snapshot_fs")))
- .add(
- attr("$xvfb_support", LABEL)
- .cfg(ExecutionTransitionFactory.createFactory())
- .value(env.getToolsLabel("//tools/android/emulator:xvfb_support")))
- .add(
- attr("$unified_launcher", LABEL)
- .cfg(ExecutionTransitionFactory.createFactory())
- .exec()
- .value(env.getToolsLabel("//tools/android/emulator:unified_launcher")))
- .add(
- attr("$android_runtest", LABEL)
- .cfg(ExecutionTransitionFactory.createFactory())
- .exec()
- .value(env.getToolsLabel("//tools/android:android_runtest")))
- .add(
- attr("$testing_shbase", LABEL)
- .cfg(ExecutionTransitionFactory.createFactory())
- .value(env.getToolsLabel("//tools/android/emulator:shbase")))
- .add(
- attr("$sdk_path", LABEL)
- .cfg(ExecutionTransitionFactory.createFactory())
- .exec()
- .value(env.getToolsLabel("//tools/android/emulator:sdk_path")))
- .add(
- attr("$is_executable", BOOLEAN)
- .value(true)
- .nonconfigurable("Called from RunCommand.isExecutable, which takes a Target"))
- .add(
- Allowlist.getAttributeFromAllowlistName(AndroidDevice.ALLOWLIST_NAME)
- .value(env.getToolsLabel("//tools/android:android_device_allowlist")))
- .removeAttribute("deps")
- .removeAttribute("data")
- .build();
- }
-
- @Override
- public Metadata getMetadata() {
- return RuleDefinition.Metadata.builder()
- .name("android_device")
- .ancestors(BaseRuleClasses.NativeActionCreatingRule.class)
- .factoryClass(factoryClass)
- .build();
- }
-}
-
-/*<!-- #BLAZE_RULE (NAME = android_device, TYPE = OTHER, FAMILY = Android) -->
-
-<p>This rule creates an android emulator configured with the given
- specifications. This emulator may be started via a bazel run
- command or by executing the generated script directly. It is encouraged to depend
- on existing android_device rules rather than defining your own.
-</p>
-<p>This rule is a suitable target for the --run_under flag to bazel test and blaze
- run. It starts an emulator, copies the target being tested/run to the emulator,
- and tests it or runs it as appropriate.
-</p>
-<p><code>android_device</code> supports creating KVM images if the underlying
- <a href="${link android_device.system_image}">system_image</a> is X86 based and is
- optimized for at most the I686 CPU architecture. To use KVM add
- <code> tags = ['requires-kvm'] </code> to the <code>android_device</code> rule.
-</p>
-
-${IMPLICIT_OUTPUTS}
-
-<h4 id="android_device_examples">Examples</h4>
-
-<p>The following example shows how to use android_device.
-<code>//java/android/helloandroid/BUILD</code> contains</p>
-<pre class="code">
-android_device(
- name = "nexus_s",
- cache = 32,
- default_properties = "nexus_s.properties",
- horizontal_resolution = 480,
- ram = 512,
- screen_density = 233,
- system_image = ":emulator_images_android_16_x86",
- vertical_resolution = 800,
- vm_heap = 32,
-)
-
-filegroup(
- name = "emulator_images_android_16_x86",
- srcs = glob(["androidsdk/system-images/android-16/**"]),
-)
-</pre>
- <p><code>//java/android/helloandroid/nexus_s.properties</code> contains:</p>
- <pre class="code">
-ro.product.brand=google
-ro.product.device=crespo
-ro.product.manufacturer=samsung
-ro.product.model=Nexus S
-ro.product.name=soju
-</pre>
-<p>
- This rule will generate images and a start script. You can start the emulator
- locally by executing bazel run :nexus_s -- --action=start. The script exposes
- the following flags:
-</p>
- <ul>
- <li>--adb_port: The port to expose adb on. If you wish to issue adb
- commands to the emulator this is the port you will issue adb connect
- to.</li>
- <li>--emulator_port: The port to expose the emulator's telnet management
- console on.</li>
- <li>--enable_display: Starts the emulator with a display if true (defaults
- to false).</li>
- <li>--action: Either start or kill.</li>
- <li>--apks_to_install: a list of apks to install on the emulator.</li>
- </ul>
-
-<!-- #END_BLAZE_RULE -->*/
diff --git a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidStarlarkCommon.java b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidStarlarkCommon.java
index d2d1f20..b185c75d8 100644
--- a/src/main/java/com/google/devtools/build/lib/rules/android/AndroidStarlarkCommon.java
+++ b/src/main/java/com/google/devtools/build/lib/rules/android/AndroidStarlarkCommon.java
@@ -38,11 +38,6 @@
Artifact, JavaInfo, FilesToRunProvider, ConstraintValueInfo, StarlarkRuleContext> {
@Override
- public AndroidDeviceBrokerInfo createDeviceBrokerInfo(String deviceBrokerType) {
- return new AndroidDeviceBrokerInfo(deviceBrokerType);
- }
-
- @Override
public String getSourceDirectoryRelativePathFromResource(Artifact resource) {
return AndroidCommon.getSourceDirectoryRelativePathFromResource(resource).toString();
}
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidBootstrap.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidBootstrap.java
index 2b7052e..430e80d 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidBootstrap.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidBootstrap.java
@@ -19,7 +19,6 @@
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.packages.semantics.BuildLanguageOptions;
import com.google.devtools.build.lib.starlarkbuildapi.android.AndroidApplicationResourceInfoApi.AndroidApplicationResourceInfoApiProvider;
-import com.google.devtools.build.lib.starlarkbuildapi.android.AndroidDeviceBrokerInfoApi.AndroidDeviceBrokerInfoApiProvider;
import com.google.devtools.build.lib.starlarkbuildapi.android.AndroidInstrumentationInfoApi.AndroidInstrumentationInfoApiProvider;
import com.google.devtools.build.lib.starlarkbuildapi.android.AndroidNativeLibsInfoApi.AndroidNativeLibsInfoApiProvider;
import com.google.devtools.build.lib.starlarkbuildapi.android.AndroidResourcesInfoApi.AndroidResourcesInfoApiProvider;
@@ -45,7 +44,6 @@
AndroidStarlarkCommonApi<?, ?, ?, ?, ?> androidCommon,
ApkInfoApiProvider<?> apkInfoProvider,
AndroidInstrumentationInfoApiProvider<?> androidInstrumentationInfoProvider,
- AndroidDeviceBrokerInfoApiProvider androidDeviceBrokerInfoProvider,
AndroidResourcesInfoApiProvider<?, ?, ?> androidResourcesInfoProvider,
AndroidNativeLibsInfoApiProvider androidNativeLibsInfoProvider,
AndroidApplicationResourceInfoApiProvider<?> androidApplicationResourceInfoApiProvider,
@@ -76,7 +74,6 @@
ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder();
builder.put(ApkInfoApi.NAME, apkInfoProvider);
builder.put(AndroidInstrumentationInfoApi.NAME, androidInstrumentationInfoProvider);
- builder.put(AndroidDeviceBrokerInfoApi.NAME, androidDeviceBrokerInfoProvider);
builder.put(AndroidResourcesInfoApi.NAME, androidResourcesInfoProvider);
builder.put(AndroidNativeLibsInfoApi.NAME, androidNativeLibsInfoProvider);
builder.put(AndroidApplicationResourceInfoApi.NAME, androidApplicationResourceInfoApiProvider);
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidDeviceBrokerInfoApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidDeviceBrokerInfoApi.java
deleted file mode 100644
index 0062791..0000000
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidDeviceBrokerInfoApi.java
+++ /dev/null
@@ -1,61 +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.starlarkbuildapi.android;
-
-import com.google.devtools.build.docgen.annot.StarlarkConstructor;
-import com.google.devtools.build.lib.starlarkbuildapi.core.ProviderApi;
-import com.google.devtools.build.lib.starlarkbuildapi.core.StructApi;
-import net.starlark.java.annot.Param;
-import net.starlark.java.annot.StarlarkBuiltin;
-import net.starlark.java.annot.StarlarkMethod;
-import net.starlark.java.eval.EvalException;
-
-/** Supplies the device broker type string, passed to the Android test runtime. */
-@StarlarkBuiltin(
- name = "AndroidDeviceBrokerInfo",
- doc =
- "Do not use this module. It is intended for migration purposes only. If you depend on it, "
- + "you will be broken when it is removed.",
- documented = false)
-public interface AndroidDeviceBrokerInfoApi extends StructApi {
-
- /** Name of this info object. */
- String NAME = "AndroidDeviceBrokerInfo";
-
- /** Provider for {@link AndroidDeviceBrokerInfoApi}. */
- @StarlarkBuiltin(
- name = "Provider",
- doc =
- "Do not use this module. It is intended for migration purposes only. If you depend on "
- + "it, you will be broken when it is removed.",
- documented = false)
- interface AndroidDeviceBrokerInfoApiProvider extends ProviderApi {
-
- @StarlarkMethod(
- name = "AndroidDeviceBrokerInfo",
- doc = "The <code>AndroidDeviceBrokerInfo</code> constructor.",
- documented = false,
- parameters = {
- @Param(
- name = "type",
- named = true,
- doc =
- "The type of device broker that is appropriate to use to interact with "
- + "devices")
- },
- selfCall = true)
- @StarlarkConstructor
- AndroidDeviceBrokerInfoApi createInfo(String type) throws EvalException;
- }
-}
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidStarlarkCommonApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidStarlarkCommonApi.java
index c188388..9dee0cc 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidStarlarkCommonApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/android/AndroidStarlarkCommonApi.java
@@ -49,12 +49,6 @@
extends StarlarkValue {
@StarlarkMethod(
- name = "create_device_broker_info",
- documented = false,
- parameters = {@Param(name = "type")})
- AndroidDeviceBrokerInfoApi createDeviceBrokerInfo(String deviceBrokerType);
-
- @StarlarkMethod(
name = "resource_source_directory",
allowReturnNones = true,
doc =
diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidDeviceTest.java b/src/test/java/com/google/devtools/build/lib/rules/android/AndroidDeviceTest.java
deleted file mode 100644
index 91f5d76..0000000
--- a/src/test/java/com/google/devtools/build/lib/rules/android/AndroidDeviceTest.java
+++ /dev/null
@@ -1,686 +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 static com.google.common.truth.Truth.assertThat;
-import static com.google.common.truth.Truth.assertWithMessage;
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.devtools.build.lib.actions.Artifact;
-import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
-import com.google.devtools.build.lib.analysis.ConfiguredTarget;
-import com.google.devtools.build.lib.analysis.FilesToRunProvider;
-import com.google.devtools.build.lib.analysis.Runfiles;
-import com.google.devtools.build.lib.analysis.RunfilesProvider;
-import com.google.devtools.build.lib.analysis.actions.SpawnAction;
-import com.google.devtools.build.lib.analysis.actions.TemplateExpansionAction;
-import com.google.devtools.build.lib.analysis.test.ExecutionInfo;
-import com.google.devtools.build.lib.cmdline.RepositoryName;
-import com.google.devtools.build.lib.packages.InputFile;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.regex.Pattern;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.JUnit4;
-
-/** Tests for {@link AndroidDevice}. */
-@RunWith(JUnit4.class)
-public class AndroidDeviceTest extends AndroidBuildViewTestCase {
-
- private static final String SYSTEM_IMAGE_LABEL =
- "//sdk/system_images:emulator_images_android_21_x86";
- private static final String SYSTEM_IMAGE_DIRECTORY = "sdk/system_images/android_21/x86/";
- private static final ImmutableList<String> SYSTEM_IMAGE_FILES =
- ImmutableList.of(
- SYSTEM_IMAGE_DIRECTORY + "kernel-qemu",
- SYSTEM_IMAGE_DIRECTORY + "ramdisk.img",
- SYSTEM_IMAGE_DIRECTORY + "system.img.tar.gz",
- SYSTEM_IMAGE_DIRECTORY + "userdata.img.tar.gz");
- private static final String SOURCE_PROPERTIES = SYSTEM_IMAGE_DIRECTORY + "source.properties";
- private static final String REQUIRES_KVM = "requires-kvm";
-
- @Before
- public void setup() throws Exception {
- scratch.file(
- "sdk/system_images/BUILD",
- """
- filegroup(
- name = "emulator_images_android_21_x86",
- srcs = [
- "android_21/x86/kernel-qemu",
- "android_21/x86/ramdisk.img",
- "android_21/x86/source.properties",
- "android_21/x86/system.img.tar.gz",
- "android_21/x86/userdata.img.tar.gz",
- ],
- )
- """);
- setBuildLanguageOptions("--experimental_google_legacy_api");
- }
-
- private FilesToRunProvider getToolDependency(ConfiguredTarget target, String label)
- throws Exception {
- return getDirectPrerequisite(target, ruleClassProvider.getToolsRepository() + label)
- .getProvider(FilesToRunProvider.class);
- }
-
- private String getToolDependencyExecPathString(ConfiguredTarget target, String label)
- throws Exception {
- return getToolDependency(target, label).getExecutable().getExecPathString();
- }
-
- private String getToolDependencyRunfilesPathString(ConfiguredTarget target, String label)
- throws Exception {
- return getToolDependency(target, label).getExecutable().getRunfilesPathString();
- }
-
- @Test
- public void testWellFormedDevice() throws Exception {
- ConfiguredTarget target =
- scratchConfiguredTarget(
- "tools/android/emulated_device",
- "nexus_6",
- "android_device(",
- " name = 'nexus_6', ",
- " ram = 2048, ",
- " horizontal_resolution = 720, ",
- " vertical_resolution = 1280, ",
- " cache = 32, ",
- " system_image = '" + SYSTEM_IMAGE_LABEL + "',",
- " screen_density = 280, ",
- " vm_heap = 256",
- ")");
-
- Set<String> outputBasenames = new HashSet<>();
- for (Artifact outArtifact : getFilesToBuild(target).toList()) {
- outputBasenames.add(outArtifact.getPath().getBaseName());
- }
-
- assertWithMessage("Not generating expected outputs.")
- .that(outputBasenames)
- .containsExactly("nexus_6", "userdata_images.dat", "emulator-meta-data.pb");
-
- Runfiles runfiles = getDefaultRunfiles(target);
- ConfiguredTarget xvfbFiles =
- getDirectPrerequisite(
- target,
- ruleClassProvider.getToolsRepository() + "//tools/android/emulator:xvfb_support");
- assertThat(ActionsTestUtil.execPaths(runfiles.getArtifacts()))
- .containsAtLeast(
- getToolDependencyExecPathString(xvfbFiles, "//tools/android/emulator:support_file1"),
- getToolDependencyExecPathString(xvfbFiles, "//tools/android/emulator:support_file2"));
-
- SpawnAction action =
- (SpawnAction)
- actionsTestUtil()
- .getActionForArtifactEndingWith(
- actionsTestUtil().artifactClosureOf(getFilesToBuild(target)),
- "nexus_6_images/userdata_images.dat");
-
- String systemImageString = Joiner.on(" ").join(SYSTEM_IMAGE_FILES);
-
- Iterable<String> biosFilesExecPathStrings =
- Iterables.transform(
- getToolDependency(target, "//tools/android/emulator:emulator_x86_bios")
- .getFilesToRun()
- .toList(),
- (artifact) -> artifact.getExecPathString());
-
- assertWithMessage("Invalid boot commandline.")
- .that(action.getArguments())
- .containsExactly(
- getToolDependencyExecPathString(target, "//tools/android/emulator:unified_launcher"),
- "--action=boot",
- "--density=280",
- "--memory=2048",
- "--skin=720x1280",
- "--cache=32",
- "--vm_size=256",
- "--system_images=" + systemImageString,
- "--bios_files=" + Joiner.on(",").join(biosFilesExecPathStrings),
- "--source_properties_file=" + SOURCE_PROPERTIES,
- "--generate_output_dir="
- + targetConfig.getBinFragment(RepositoryName.MAIN)
- + "/tools/android/emulated_device/nexus_6_images",
- "--adb_static=" + getToolDependencyExecPathString(target, "//tools/android:adb_static"),
- "--emulator_x86="
- + getToolDependencyExecPathString(target, "//tools/android/emulator:emulator_x86"),
- "--emulator_arm="
- + getToolDependencyExecPathString(target, "//tools/android/emulator:emulator_arm"),
- "--adb=" + getToolDependencyExecPathString(target, "//tools/android:adb"),
- "--mksdcard="
- + getToolDependencyExecPathString(target, "//tools/android/emulator:mksd"),
- "--empty_snapshot_fs="
- + getToolDependencyExecPathString(
- target, "//tools/android/emulator:empty_snapshot_fs"),
- "--flag_configured_android_tools",
- "--nocopy_system_images",
- "--single_image_file",
- "--android_sdk_path="
- + getToolDependencyExecPathString(target, "//tools/android/emulator:sdk_path"),
- "--platform_apks=");
-
- assertThat(action.getExecutionInfo()).doesNotContainKey(REQUIRES_KVM);
- assertThat(ActionsTestUtil.execPaths(action.getInputs()))
- .containsAtLeast(
- getToolDependencyExecPathString(xvfbFiles, "//tools/android/emulator:support_file1"),
- getToolDependencyExecPathString(xvfbFiles, "//tools/android/emulator:support_file2"));
-
- assertThat(target.get(ExecutionInfo.PROVIDER.getKey())).isNotNull();
- ExecutionInfo executionInfo = target.get(ExecutionInfo.PROVIDER);
- assertThat(executionInfo.getExecutionInfo()).doesNotContainKey(REQUIRES_KVM);
- TemplateExpansionAction stubAction =
- (TemplateExpansionAction) getGeneratingAction(getExecutable(target));
- String stubContents = stubAction.getFileContents();
- assertThat(stubContents)
- .contains(
- String.format(
- "unified_launcher=\"${WORKSPACE_DIR}/%s\"",
- getToolDependencyRunfilesPathString(
- target, "//tools/android/emulator:unified_launcher")));
- assertThat(stubContents)
- .contains(
- String.format(
- "adb=\"${WORKSPACE_DIR}/%s\"",
- getToolDependencyRunfilesPathString(target, "//tools/android:adb")));
- assertThat(stubContents)
- .contains(
- String.format(
- "adb_static=\"${WORKSPACE_DIR}/%s\"",
- getToolDependencyRunfilesPathString(target, "//tools/android:adb_static")));
- assertThat(stubContents)
- .contains(
- String.format(
- "emulator_arm=\"${WORKSPACE_DIR}/%s\"",
- getToolDependencyRunfilesPathString(
- target, "//tools/android/emulator:emulator_arm")));
- assertThat(stubContents)
- .contains(
- String.format(
- "emulator_x86=\"${WORKSPACE_DIR}/%s\"",
- getToolDependencyRunfilesPathString(
- target, "//tools/android/emulator:emulator_x86")));
- assertThat(stubContents)
- .contains("source_properties_file=\"${WORKSPACE_DIR}/" + SOURCE_PROPERTIES + "\"");
- assertThat(stubContents).contains("emulator_system_images=\"" + systemImageString + "\"");
- }
-
- @Test
- public void testWellFormedDevice_withKvm() throws Exception {
- ConfiguredTarget target =
- scratchConfiguredTarget(
- "tools/android/emulated_device",
- "nexus_6",
- "android_device(",
- " name = 'nexus_6', ",
- " ram = 2048, ",
- " horizontal_resolution = 720, ",
- " vertical_resolution = 1280, ",
- " cache = 32, ",
- " system_image = '" + SYSTEM_IMAGE_LABEL + "',",
- " screen_density = 280, ",
- " vm_heap = 256,",
- " tags = ['requires-kvm']",
- ")");
-
- SpawnAction action =
- (SpawnAction)
- actionsTestUtil()
- .getActionForArtifactEndingWith(
- actionsTestUtil().artifactClosureOf(getFilesToBuild(target)),
- "nexus_6_images/userdata_images.dat");
-
- assertThat(action.getExecutionInfo()).containsEntry(REQUIRES_KVM, "");
- assertThat(target.get(ExecutionInfo.PROVIDER.getKey())).isNotNull();
- assertThat(target.get(ExecutionInfo.PROVIDER).getExecutionInfo()).containsKey(REQUIRES_KVM);
- }
-
- @Test
- public void testWellFormedDevice_defaultPropertiesPresent() throws Exception {
- String dummyPropPackage = "tools/android/emulated_device/data";
- String dummyPropFile = "default.properties";
- String dummyPropLabel = String.format("//%s:%s", dummyPropPackage, dummyPropFile);
- scratch.file(String.format("%s/%s", dummyPropPackage, dummyPropFile), "ro.build.id=HiThere");
- scratch.file(
- String.format("%s/BUILD", dummyPropPackage), "exports_files(['default.properties'])");
- ConfiguredTarget target =
- scratchConfiguredTarget(
- "tools/android/emulated_device",
- "nexus_6",
- "android_device(",
- " name = 'nexus_6', ",
- " ram = 2048, ",
- " horizontal_resolution = 720, ",
- " vertical_resolution = 1280, ",
- " cache = 32, ",
- " system_image = '" + SYSTEM_IMAGE_LABEL + "',",
- " screen_density = 280, ",
- " vm_heap = 256,",
- " default_properties = '" + dummyPropLabel + "'",
- ")");
-
- Set<String> outputBasenames = new HashSet<>();
- for (Artifact outArtifact : getFilesToBuild(target).toList()) {
- outputBasenames.add(outArtifact.getPath().getBaseName());
- }
-
- assertWithMessage("Not generating expected outputs.")
- .that(outputBasenames)
- .containsExactly("nexus_6", "userdata_images.dat", "emulator-meta-data.pb");
-
- SpawnAction action =
- (SpawnAction)
- actionsTestUtil()
- .getActionForArtifactEndingWith(
- actionsTestUtil().artifactClosureOf(getFilesToBuild(target)),
- "nexus_6_images/userdata_images.dat");
-
- String systemImageString = Joiner.on(" ").join(SYSTEM_IMAGE_FILES);
- Iterable<String> biosFilesExecPathStrings =
- Iterables.transform(
- getToolDependency(target, "//tools/android/emulator:emulator_x86_bios")
- .getFilesToRun()
- .toList(),
- Artifact::getExecPathString);
-
- assertWithMessage("Invalid boot commandline.")
- .that(action.getArguments())
- .containsExactly(
- getToolDependencyExecPathString(target, "//tools/android/emulator:unified_launcher"),
- "--action=boot",
- "--density=280",
- "--memory=2048",
- "--skin=720x1280",
- "--cache=32",
- "--vm_size=256",
- "--system_images=" + systemImageString,
- "--bios_files=" + Joiner.on(",").join(biosFilesExecPathStrings),
- "--source_properties_file=" + SOURCE_PROPERTIES,
- "--generate_output_dir="
- + targetConfig.getBinFragment(RepositoryName.MAIN)
- + "/tools/android/emulated_device/nexus_6_images",
- "--adb_static=" + getToolDependencyExecPathString(target, "//tools/android:adb_static"),
- "--emulator_x86="
- + getToolDependencyExecPathString(target, "//tools/android/emulator:emulator_x86"),
- "--emulator_arm="
- + getToolDependencyExecPathString(target, "//tools/android/emulator:emulator_arm"),
- "--adb=" + getToolDependencyExecPathString(target, "//tools/android:adb"),
- "--mksdcard="
- + getToolDependencyExecPathString(target, "//tools/android/emulator:mksd"),
- "--empty_snapshot_fs="
- + getToolDependencyExecPathString(
- target, "//tools/android/emulator:empty_snapshot_fs"),
- "--flag_configured_android_tools",
- "--nocopy_system_images",
- "--single_image_file",
- "--android_sdk_path="
- + getToolDependencyExecPathString(target, "//tools/android/emulator:sdk_path"),
- "--platform_apks=",
- "--default_properties_file=" + String.format("%s/%s", dummyPropPackage, dummyPropFile));
-
- TemplateExpansionAction stubAction =
- (TemplateExpansionAction) getGeneratingAction(getExecutable(target));
- String stubContents = stubAction.getFileContents();
- assertThat(stubContents)
- .contains(
- String.format(
- "unified_launcher=\"${WORKSPACE_DIR}/%s\"",
- getToolDependencyRunfilesPathString(
- target, "//tools/android/emulator:unified_launcher")));
- assertThat(stubContents)
- .contains(
- String.format(
- "adb=\"${WORKSPACE_DIR}/%s\"",
- getToolDependencyRunfilesPathString(target, "//tools/android:adb")));
- assertThat(stubContents)
- .contains(
- String.format(
- "adb_static=\"${WORKSPACE_DIR}/%s\"",
- getToolDependencyRunfilesPathString(target, "//tools/android:adb_static")));
- assertThat(stubContents)
- .contains(
- String.format(
- "emulator_arm=\"${WORKSPACE_DIR}/%s\"",
- getToolDependencyRunfilesPathString(
- target, "//tools/android/emulator:emulator_arm")));
- assertThat(stubContents)
- .contains(
- String.format(
- "emulator_x86=\"${WORKSPACE_DIR}/%s\"",
- getToolDependencyRunfilesPathString(
- target, "//tools/android/emulator:emulator_x86")));
- assertThat(stubContents)
- .contains("source_properties_file=\"${WORKSPACE_DIR}/" + SOURCE_PROPERTIES + "\"");
- assertThat(stubContents).contains("emulator_system_images=\"" + systemImageString + "\"");
- assertThat(stubContents)
- .contains(
- String.format(
- "android_sdk_path=\"${WORKSPACE_DIR}/%s\"",
- getToolDependencyRunfilesPathString(target, "//tools/android/emulator:sdk_path")));
-
- assertThat(
- target.getProvider(RunfilesProvider.class).getDefaultRunfiles().getArtifacts().toList())
- .contains(
- getToolDependency(target, "//tools/android/emulator:unified_launcher").getExecutable());
- }
-
- @Test
- public void testPlatformApksFlag_multipleApks() throws Exception {
- String dummyPlatformApkPackage = "tools/android/emulated_device/data";
- List<String> dummyPlatformApkFiles =
- Lists.newArrayList("dummy1.apk", "dummy2.apk", "dummy3.apk", "dummy4.apk");
- List<String> platformApkFullPaths = Lists.newArrayList();
- List<String> dummyPlatformApkLabels = Lists.newArrayList();
- for (String dummyPlatformApkFile : dummyPlatformApkFiles) {
- String platformApkFullPath =
- String.format("%s/%s", dummyPlatformApkPackage, dummyPlatformApkFile);
- platformApkFullPaths.add(platformApkFullPath);
- String dummyPlatformApkLabel =
- String.format("'//%s:%s'", dummyPlatformApkPackage, dummyPlatformApkFile);
- dummyPlatformApkLabels.add(dummyPlatformApkLabel);
- scratch.file(
- String.format("%s/%s", dummyPlatformApkPackage, dummyPlatformApkFile),
- dummyPlatformApkFile);
- }
- scratch.file(
- String.format("%s/BUILD", dummyPlatformApkPackage),
- "exports_files(['dummy1.apk', 'dummy2.apk', 'dummy3.apk', 'dummy4.apk'])");
- ConfiguredTarget target =
- scratchConfiguredTarget(
- "tools/android/emulated_device",
- "nexus_6",
- "android_device(",
- " name = 'nexus_6', ",
- " ram = 2048, ",
- " horizontal_resolution = 720, ",
- " vertical_resolution = 1280, ",
- " cache = 32, ",
- " system_image = '" + SYSTEM_IMAGE_LABEL + "',",
- " screen_density = 280, ",
- " vm_heap = 256,",
- " platform_apks = [" + Joiner.on(", ").join(dummyPlatformApkLabels) + "]",
- ")");
-
- SpawnAction action =
- (SpawnAction)
- actionsTestUtil()
- .getActionForArtifactEndingWith(
- actionsTestUtil().artifactClosureOf(getFilesToBuild(target)),
- "nexus_6_images/userdata_images.dat");
-
- assertWithMessage("Missing platform_apks flag")
- .that(action.getArguments())
- .contains("--platform_apks=" + Joiner.on(",").join(platformApkFullPaths));
- }
-
- @Test
- public void testPlatformApksFlag() throws Exception {
- String dummyPlatformApkPackage = "tools/android/emulated_device/data";
- String dummyPlatformApkFile = "dummy.apk";
- String dummyPlatformApkLabel =
- String.format("//%s:%s", dummyPlatformApkPackage, dummyPlatformApkFile);
- scratch.file(String.format("%s/%s", dummyPlatformApkPackage, dummyPlatformApkFile), "dummyApk");
- scratch.file(
- String.format("%s/BUILD", dummyPlatformApkPackage), "exports_files(['dummy.apk'])");
- ConfiguredTarget target =
- scratchConfiguredTarget(
- "tools/android/emulated_device",
- "nexus_6",
- "android_device(",
- " name = 'nexus_6', ",
- " ram = 2048, ",
- " horizontal_resolution = 720, ",
- " vertical_resolution = 1280, ",
- " cache = 32, ",
- " system_image = '" + SYSTEM_IMAGE_LABEL + "',",
- " screen_density = 280, ",
- " vm_heap = 256,",
- " platform_apks = ['" + dummyPlatformApkLabel + "']",
- ")");
-
- SpawnAction action =
- (SpawnAction)
- actionsTestUtil()
- .getActionForArtifactEndingWith(
- actionsTestUtil().artifactClosureOf(getFilesToBuild(target)),
- "nexus_6_images/userdata_images.dat");
-
- assertWithMessage("Missing platform_apks flag")
- .that(action.getArguments())
- .contains(
- "--platform_apks="
- + String.format("%s/%s", dummyPlatformApkPackage, dummyPlatformApkFile));
- }
-
- @Test
- public void testBadAttributes() throws Exception {
- checkError(
- "bad/ram",
- "bad_ram",
- "ram must be",
- "android_device(name = 'bad_ram', ",
- " ram = -1, ",
- " vm_heap = 24, ",
- " cache = 123, ",
- " system_image = '" + SYSTEM_IMAGE_LABEL + "',",
- " screen_density = 456, ",
- " horizontal_resolution = 640, ",
- " vertical_resolution = 800) ");
- checkError(
- "bad/vm",
- "bad_vm",
- "heap must be",
- "android_device(name = 'bad_vm', ",
- " ram = 512, ",
- " vm_heap = -24, ",
- " cache = 123, ",
- " system_image = '" + SYSTEM_IMAGE_LABEL + "',",
- " screen_density = 456, ",
- " horizontal_resolution = 640, ",
- " vertical_resolution = 800) ");
- checkError(
- "bad/cache",
- "bad_cache",
- "cache must be",
- "android_device(name = 'bad_cache', ",
- " ram = 512, ",
- " vm_heap = 24, ",
- " cache = -123, ",
- " system_image = '" + SYSTEM_IMAGE_LABEL + "',",
- " screen_density = 456, ",
- " horizontal_resolution = 640, ",
- " vertical_resolution = 800) ");
- checkError(
- "bad/density",
- "bad_density",
- "density must be",
- "android_device(name = 'bad_density', ",
- " ram = 512, ",
- " vm_heap = 24, ",
- " cache = 23, ",
- " system_image = '" + SYSTEM_IMAGE_LABEL + "',",
- " screen_density = -456, ",
- " horizontal_resolution = 640, ",
- " vertical_resolution = 800) ");
- checkError(
- "bad/horizontal",
- "bad_horizontal",
- "horizontal must be",
- "android_device(name = 'bad_horizontal', ",
- " ram = 512, ",
- " vm_heap = 24, ",
- " cache = 23, ",
- " system_image = '" + SYSTEM_IMAGE_LABEL + "',",
- " screen_density = -456, ",
- " horizontal_resolution = 100, ",
- " vertical_resolution = 800) ");
- checkError(
- "bad/vertical",
- "bad_vertical",
- "vertical must be",
- "android_device(name = 'bad_vertical', ",
- " ram = 512, ",
- " vm_heap = 24, ",
- " cache = 23, ",
- " screen_density = -456, ",
- " system_image = '" + SYSTEM_IMAGE_LABEL + "',",
- " horizontal_resolution = 640, ",
- " vertical_resolution = 100) ");
- checkError(
- "bad/bogus_default_prop",
- "bogus_default_prop",
- "no such package",
- "android_device(name = 'bogus_default_prop', ",
- " ram = 512, ",
- " vm_heap = 24, ",
- " cache = 23, ",
- " screen_density = 311, ",
- " system_image = '" + SYSTEM_IMAGE_LABEL + "',",
- " default_properties = '//something/somewhere',",
- " horizontal_resolution = 640, ",
- " vertical_resolution = 100) ");
- checkError(
- "bad/multi_default_prop",
- "multi_default_prop",
- "expected a single artifact",
- "android_device(name = 'multi_default_prop', ",
- " ram = 512, ",
- " vm_heap = 24, ",
- " cache = 23, ",
- " screen_density = 311, ",
- " system_image = '" + SYSTEM_IMAGE_LABEL + "',",
- " default_properties = '" + SYSTEM_IMAGE_LABEL + "',",
- " horizontal_resolution = 640, ",
- " vertical_resolution = 100) ");
- checkError(
- "bad/filegroup",
- "bad_filegroup",
- "No source.properties",
- "filegroup(name = 'empty',",
- " srcs = [])",
- "android_device(name = 'bad_filegroup', ",
- " ram = 512, ",
- " vm_heap = 24, ",
- " cache = 23, ",
- " screen_density = -456, ",
- " system_image = ':empty',",
- " horizontal_resolution = 640, ",
- " vertical_resolution = 100) ");
- checkError(
- "bad/filegroup_2",
- "bad_filegroup2",
- "Multiple source.properties",
- "filegroup(name = 'empty',",
- " srcs = ['source.properties', 'foo/source.properties'])",
- "android_device(name = 'bad_filegroup2', ",
- " ram = 512, ",
- " vm_heap = 24, ",
- " cache = 23, ",
- " screen_density = -456, ",
- " system_image = ':empty',",
- " horizontal_resolution = 640, ",
- " vertical_resolution = 100) ");
- }
-
- @Test
- public void testPackageWhitelist() throws Exception {
- ConfiguredTarget validPackageAndroidDevice =
- scratchConfiguredTarget(
- "foo",
- "nexus_6",
- "android_device(",
- " name = 'nexus_6', ",
- " ram = 2048, ",
- " horizontal_resolution = 720, ",
- " vertical_resolution = 1280, ",
- " cache = 32, ",
- " system_image = '" + SYSTEM_IMAGE_LABEL + "',",
- " screen_density = 280, ",
- " vm_heap = 256",
- ")");
- assertThat(validPackageAndroidDevice).isNotNull();
- InputFile mockedAndroidToolsBuildFile =
- (InputFile) getTarget(ruleClassProvider.getToolsRepository() + "//tools/android:BUILD");
- String mockedAndroidToolsBuildFileLocation =
- mockedAndroidToolsBuildFile.getPath().getPathString();
- String mockedAndroidToolsContent =
- scratch
- .readFile(mockedAndroidToolsBuildFileLocation)
- .replaceAll(Pattern.quote("packages = ['public']"), "packages = ['//bar/...']")
- // TODO(b/254084490): Migrate Google-internal usage of "//..." in test mock to be
- // "public" instead.
- .replaceAll(Pattern.quote("packages = ['//...']"), "packages = ['//bar/...']");
- scratch.overwriteFile(mockedAndroidToolsBuildFileLocation, mockedAndroidToolsContent);
- invalidatePackages();
- checkError(
- "baz",
- "nexus_6",
- "The android_device rule may not be used in this package",
- "android_device(",
- " name = 'nexus_6', ",
- " ram = 2048, ",
- " horizontal_resolution = 720, ",
- " vertical_resolution = 1280, ",
- " cache = 32, ",
- " system_image = '" + SYSTEM_IMAGE_LABEL + "',",
- " screen_density = 280, ",
- " vm_heap = 256",
- ")");
- }
-
- @Test
- public void testAndroidDeviceBrokerInfoExposedToStarlark() throws Exception {
- scratch.file(
- "tools/android/emulated_device/BUILD",
- "android_device(",
- " name = 'nexus_6', ",
- " ram = 2048, ",
- " horizontal_resolution = 720, ",
- " vertical_resolution = 1280, ",
- " cache = 32, ",
- " system_image = '" + SYSTEM_IMAGE_LABEL + "',",
- " screen_density = 280, ",
- " vm_heap = 256,",
- " tags = ['requires-kvm']",
- ")");
- scratch.file(
- "javatests/com/app/starlarktest/starlarktest.bzl",
- """
- mystring = provider(fields = ["content"])
-
- def _impl(ctx):
- return [mystring(content = ctx.attr.dep[AndroidDeviceBrokerInfo])]
-
- starlarktest = rule(implementation = _impl, attrs = {"dep": attr.label()})
- """);
- scratch.file(
- "javatests/com/app/starlarktest/BUILD",
- """
- load(":starlarktest.bzl", "starlarktest")
-
- starlarktest(
- name = "mytest",
- dep = "//tools/android/emulated_device:nexus_6",
- )
- """);
- ConfiguredTarget ct = getConfiguredTarget("//javatests/com/app/starlarktest:mytest");
- assertThat(ct).isNotNull();
- }
-}
diff --git a/src/test/java/com/google/devtools/build/lib/rules/android/BUILD b/src/test/java/com/google/devtools/build/lib/rules/android/BUILD
index 22ef60f..918092f 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/android/BUILD
+++ b/src/test/java/com/google/devtools/build/lib/rules/android/BUILD
@@ -282,25 +282,6 @@
],
)
-java_test(
- name = "AndroidDeviceTest",
- srcs = ["AndroidDeviceTest.java"],
- deps = [
- ":AndroidBuildViewTestCase",
- "//src/main/java/com/google/devtools/build/lib/actions:artifacts",
- "//src/main/java/com/google/devtools/build/lib/analysis:actions/template_expansion_action",
- "//src/main/java/com/google/devtools/build/lib/analysis:analysis_cluster",
- "//src/main/java/com/google/devtools/build/lib/analysis:configured_target",
- "//src/main/java/com/google/devtools/build/lib/analysis:test/execution_info",
- "//src/main/java/com/google/devtools/build/lib/cmdline",
- "//src/main/java/com/google/devtools/build/lib/packages",
- "//src/test/java/com/google/devtools/build/lib/actions/util",
- "//third_party:guava",
- "//third_party:junit4",
- "//third_party:truth",
- ],
-)
-
java_library(
name = "AndroidMultidexBaseTest",
srcs = ["AndroidMultidexBaseTest.java"],