aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Lukacs Berki <lberki@google.com>2015-05-29 10:50:25 +0000
committerGravatar Lukacs Berki <lberki@google.com>2015-05-29 10:54:36 +0000
commit662166f30f3827e1a025a7d58b000d1cc12cab9f (patch)
tree9965953523ab16659b1f2710c5b356562f8bbb9c /src/main/java/com
parentac4f942bf0c0d5c61125650784dca67b65268506 (diff)
Initial checkin of the "mobile-install" command.
This was omitted when the bulk of the code was moved in order not to pollute the output of "bazel help" with a useless command, but now it is in the way of testing Android functionality. -- MOS_MIGRATED_REVID=94747309
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java2
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/MobileInstallCommand.java94
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/mobile-install.txt6
3 files changed, 102 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java
index 825b035e80..8c9a518963 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeRuntime.java
@@ -75,6 +75,7 @@ import com.google.devtools.build.lib.runtime.commands.CanonicalizeCommand;
import com.google.devtools.build.lib.runtime.commands.CleanCommand;
import com.google.devtools.build.lib.runtime.commands.HelpCommand;
import com.google.devtools.build.lib.runtime.commands.InfoCommand;
+import com.google.devtools.build.lib.runtime.commands.MobileInstallCommand;
import com.google.devtools.build.lib.runtime.commands.ProfileCommand;
import com.google.devtools.build.lib.runtime.commands.QueryCommand;
import com.google.devtools.build.lib.runtime.commands.RunCommand;
@@ -1574,6 +1575,7 @@ public final class BlazeRuntime {
new CleanCommand(),
new HelpCommand(),
new InfoCommand(),
+ new MobileInstallCommand(),
new ProfileCommand(),
new QueryCommand(),
new RunCommand(),
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/MobileInstallCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/MobileInstallCommand.java
new file mode 100644
index 0000000000..b68adb859e
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/MobileInstallCommand.java
@@ -0,0 +1,94 @@
+// Copyright 2015 Google Inc. 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.runtime.commands;
+
+import com.google.common.collect.ImmutableList;
+import com.google.devtools.build.lib.analysis.OutputGroupProvider;
+import com.google.devtools.build.lib.buildtool.BuildRequest;
+import com.google.devtools.build.lib.rules.android.WriteAdbArgsAction;
+import com.google.devtools.build.lib.runtime.BlazeCommand;
+import com.google.devtools.build.lib.runtime.BlazeRuntime;
+import com.google.devtools.build.lib.runtime.Command;
+import com.google.devtools.build.lib.util.AbruptExitException;
+import com.google.devtools.build.lib.util.ExitCode;
+import com.google.devtools.common.options.Option;
+import com.google.devtools.common.options.OptionPriority;
+import com.google.devtools.common.options.OptionsBase;
+import com.google.devtools.common.options.OptionsParser;
+import com.google.devtools.common.options.OptionsParsingException;
+import com.google.devtools.common.options.OptionsProvider;
+
+import java.util.List;
+
+/**
+ * Implementation of the 'mobile-install' command.
+ */
+ @Command(name = "mobile-install",
+ builds = true,
+ options = { MobileInstallCommand.Options.class, WriteAdbArgsAction.Options.class },
+ inherits = { BuildCommand.class },
+ shortDescription = "Installs targets to mobile devices.",
+ completion = "label",
+ allowResidue = true,
+ help = "resource:mobile-install.txt")
+public class MobileInstallCommand implements BlazeCommand {
+ /**
+ * Command line options for the 'mobile-install' command.
+ */
+ public static final class Options extends OptionsBase {
+ @Option(name = "split_apks",
+ defaultValue = "false",
+ category = "undocumented")
+ public boolean splitApks;
+
+ @Option(name = "incremental",
+ category = "mobile-install",
+ defaultValue = "false",
+ help = "Whether to do an incremental install. If true, try to avoid unnecessary additional "
+ + "work by reading the state of the device the code is to be installed on and using "
+ + "that information to avoid unnecessary work. If false (the default), always do a "
+ + "full install.")
+ public boolean incremental;
+ }
+
+ @Override
+ public ExitCode exec(BlazeRuntime runtime, OptionsProvider options) {
+ List<String> targets = ProjectFileSupport.getTargets(runtime, options);
+ BuildRequest request = BuildRequest.create(
+ this.getClass().getAnnotation(Command.class).name(), options,
+ runtime.getStartupOptionsProvider(), targets,
+ runtime.getReporter().getOutErr(), runtime.getCommandId(), runtime.getCommandStartTime());
+ return runtime.getBuildTool().processRequest(request, null).getExitCondition();
+ }
+
+ @Override
+ public void editOptions(BlazeRuntime runtime, OptionsParser optionsParser)
+ throws AbruptExitException {
+ try {
+ String outputGroup =
+ optionsParser.getOptions(Options.class).splitApks ? "mobile_install_split"
+ : optionsParser.getOptions(Options.class).incremental ? "mobile_install_incremental"
+ : "mobile_install_full";
+
+ optionsParser.parse(OptionPriority.COMMAND_LINE,
+ "Options required by the mobile-install command",
+ ImmutableList.of(
+ "--output_groups=-" + OutputGroupProvider.DEFAULT,
+ "--output_groups=-" + OutputGroupProvider.HIDDEN_TOP_LEVEL,
+ "--output_groups=" + outputGroup));
+ } catch (OptionsParsingException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+}
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/mobile-install.txt b/src/main/java/com/google/devtools/build/lib/runtime/commands/mobile-install.txt
new file mode 100644
index 0000000000..a8b0f36def
--- /dev/null
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/mobile-install.txt
@@ -0,0 +1,6 @@
+
+Usage: %{product} %{command} <options> <target>
+
+Installs a target to an Android device. Currently experimental.
+
+%{options}