aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/xcode-common
diff options
context:
space:
mode:
authorGravatar Dave MacLachlan <dmaclach@google.com>2015-10-07 03:18:21 +0000
committerGravatar Lukacs Berki <lberki@google.com>2015-10-07 07:12:03 +0000
commit8c353e461c2f7bd01b2993c253005ad523c5a039 (patch)
tree32121f1788c36390d5bcd602a9ab7c7b6bc20035 /src/tools/xcode-common
parentc383d034d32231f2eaf58aa3efed562574d5fc32 (diff)
Delete old java based tools for ibtool, actool, momc, etc.
RELNOTES: -- MOS_MIGRATED_REVID=104826820
Diffstat (limited to 'src/tools/xcode-common')
-rw-r--r--src/tools/xcode-common/BUILD1
-rw-r--r--src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/Arguments.java57
-rw-r--r--src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/ArgumentsParsing.java99
-rw-r--r--src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/BUILD18
-rw-r--r--src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/Wrapper.java55
-rw-r--r--src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/Wrappers.java185
6 files changed, 0 insertions, 415 deletions
diff --git a/src/tools/xcode-common/BUILD b/src/tools/xcode-common/BUILD
index bfd7849aef..9018fdcfeb 100644
--- a/src/tools/xcode-common/BUILD
+++ b/src/tools/xcode-common/BUILD
@@ -6,6 +6,5 @@ filegroup(
"//src/tools/xcode-common/java/com/google/devtools/build/xcode/common:srcs",
"//src/tools/xcode-common/java/com/google/devtools/build/xcode/util:srcs",
"//src/tools/xcode-common/java/com/google/devtools/build/xcode/zip:srcs",
- "//src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput:srcs",
],
)
diff --git a/src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/Arguments.java b/src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/Arguments.java
deleted file mode 100644
index b9a03e60e4..0000000000
--- a/src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/Arguments.java
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2014 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.xcode.zippingoutput;
-
-import com.google.common.collect.ImmutableList;
-import com.google.devtools.build.xcode.util.Value;
-
-/**
- * Arguments that have been parsed from a do-something-and-zip-output wrapper.
- */
-public class Arguments extends Value<Arguments> {
-
- private final String outputZip;
- private final String bundleRoot;
- private final String subtoolCmd;
- private final ImmutableList<String> subtoolExtraArgs;
-
- Arguments(
- String outputZip,
- String bundleRoot,
- String subtoolCmd,
- ImmutableList<String> subtoolExtraArgs) {
- super(outputZip, bundleRoot, subtoolCmd, subtoolExtraArgs);
- this.outputZip = outputZip;
- this.bundleRoot = bundleRoot;
- this.subtoolCmd = subtoolCmd;
- this.subtoolExtraArgs = subtoolExtraArgs;
- }
-
- public String outputZip() {
- return outputZip;
- }
-
- public String bundleRoot() {
- return bundleRoot;
- }
-
- public String subtoolCmd() {
- return subtoolCmd;
- }
-
- public ImmutableList<String> subtoolExtraArgs() {
- return subtoolExtraArgs;
- }
-}
diff --git a/src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/ArgumentsParsing.java b/src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/ArgumentsParsing.java
deleted file mode 100644
index b7b9da26dc..0000000000
--- a/src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/ArgumentsParsing.java
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright 2014 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.xcode.zippingoutput;
-
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-import com.google.devtools.build.xcode.util.Value;
-
-import java.nio.file.FileSystem;
-import java.nio.file.Files;
-import java.util.Locale;
-
-/**
- * Arguments passed to the do-something-then-zip wrapper tool.
- */
-class ArgumentsParsing extends Value<ArgumentsParsing> {
-
- private final Optional<String> error;
- private final Optional<Arguments> arguments;
-
- private ArgumentsParsing(Optional<String> error, Optional<Arguments> arguments) {
- super(error, arguments);
- this.error = error;
- this.arguments = arguments;
- }
-
- public Optional<String> error() {
- return error;
- }
-
- public Optional<Arguments> arguments() {
- return arguments;
- }
-
- private static final int MIN_ARGS = 3;
-
- /**
- * @param args raw arguments passed to wrapper tool through the {@code main} method
- * @param subtoolName name of the subtool, such as "actool"
- * @return an instance based on results of parsing the given arguments.
- */
- public static ArgumentsParsing parse(FileSystem fileSystem, String[] args, String wrapperName,
- String subtoolName) {
- String capitalizedSubtool = subtoolName.toUpperCase(Locale.US);
- if (args.length < MIN_ARGS) {
- return new ArgumentsParsing(Optional.of(String.format(
- "Expected at least %1$d args.\n"
- + "Usage: java %2$s OUTZIP ARCHIVEROOT (%3$s_CMD %3$s ARGS)\n"
- + "Runs %4$s and zips the results.\n"
- + "OUTZIP - the path to place the output zip file.\n"
- + "ARCHIVEROOT - the path in the zip to place the output, or an empty\n"
- + " string for the root of the zip. e.g. 'Payload/foo.app'. If\n"
- + " this tool outputs a single file, ARCHIVEROOT is the name of\n"
- + " the only file in the zip file.\n"
- + "%3$s_CMD - path to the subtool.\n"
- + " e.g. /Applications/Xcode.app/Contents/Developer/usr/bin/actool\n"
- + "%3$s ARGS - the arguments to pass to %4$s besides the\n"
- + " one that specifies the output directory.\n",
- MIN_ARGS, wrapperName, capitalizedSubtool, subtoolName)),
- Optional.<Arguments>absent());
- }
- String outputZip = args[0];
- String archiveRoot = args[1];
- String subtoolCmd = args[2];
- if (archiveRoot.startsWith("/")) {
- return new ArgumentsParsing(
- Optional.of(String.format("Archive root cannot start with /: '%s'\n", archiveRoot)),
- Optional.<Arguments>absent());
- }
-
- // TODO(bazel-team): Remove this hack when the released version of Bazel uses the correct momc
- // path for device builds.
- subtoolCmd = subtoolCmd.replace("/iPhoneOS.platform/", "/iPhoneSimulator.platform/");
- if (!Files.isRegularFile(fileSystem.getPath(subtoolCmd))) {
- return new ArgumentsParsing(
- Optional.of(String.format(
- "The given %s_CMD does not exist: '%s'\n", capitalizedSubtool, subtoolCmd)),
- Optional.<Arguments>absent());
- }
- return new ArgumentsParsing(
- Optional.<String>absent(),
- Optional.<Arguments>of(
- new Arguments(
- outputZip, archiveRoot, subtoolCmd,
- ImmutableList.copyOf(args).subList(MIN_ARGS, args.length))));
- }
-}
diff --git a/src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/BUILD b/src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/BUILD
deleted file mode 100644
index 01981be67f..0000000000
--- a/src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/BUILD
+++ /dev/null
@@ -1,18 +0,0 @@
-package(default_visibility = ["//src:__subpackages__"])
-
-filegroup(
- name = "srcs",
- srcs = glob(["**"]),
-)
-
-java_library(
- name = "zippingoutput",
- srcs = glob(["*.java"]),
- deps = [
- "//src/java_tools/singlejar:libSingleJar",
- "//src/tools/xcode-common/java/com/google/devtools/build/xcode/util",
- "//src/tools/xcode-common/java/com/google/devtools/build/xcode/zip",
- "//third_party:guava",
- "//third_party:jsr305",
- ],
-)
diff --git a/src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/Wrapper.java b/src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/Wrapper.java
deleted file mode 100644
index e10139c565..0000000000
--- a/src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/Wrapper.java
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright 2014 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.xcode.zippingoutput;
-
-/**
- * Defines a zipping wrapper for a tool. A wrapper is a tool that runs some subcommand that writes
- * its output (usually multiple files in a non-trivial directory structure) to some directory, and
- * then zips the output of that subtool into a timestamp-less zip file whose location is specified
- * on the command line.
- * <p>
- * The arguments passed are passed in this form:
- * <pre>
- * java {wrapper_name} OUTZIP ARCHIVEROOT (SUBTOOL_CMD SUBTOOL ARGS)
- * </pre>
- * Where SUBTOOL ARGS are the arguments to pass to SUBTOOL_CMD unchanged, except the argument that
- * specifies the output directory. Note that the arguments are positional and do not use flags in
- * the form of -f or --foo, except for those flags passed directly to and interpreted by the
- * subtool itself.
- * <p>
- * A wrapper has some simple metadata the name of the wrapped tool
- * and how to transform {@link Arguments} passed to the wrapper tool into arguments for the subtool.
- */
-public interface Wrapper {
- /** The name of the wrapper, such as {@code ActoolZip}. */
- String name();
-
- /** The subtool name, such as {@code actool}. */
- String subtoolName();
-
- /**
- * Returns the command (i.e. argv), including the executable file, to be executed.
- * @param arguments the parsed arguments passed to the wrapper tool
- * @param outputDirectory the output directory which the subtool should write tool
- */
- Iterable<String> subCommand(Arguments arguments, String outputDirectory);
-
- /**
- * Indicates whether the output directory must exist before invoking the wrapped tool, this being
- * dependent on the nature of the tool only. Note that the directory immediately containing the
- * output directory is guaranteed to always exist, regardless of this method's return value.
- */
- boolean outputDirectoryMustExist();
-}
diff --git a/src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/Wrappers.java b/src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/Wrappers.java
deleted file mode 100644
index c4bf2e4c3a..0000000000
--- a/src/tools/xcode-common/java/com/google/devtools/build/xcode/zippingoutput/Wrappers.java
+++ /dev/null
@@ -1,185 +0,0 @@
-// Copyright 2014 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.xcode.zippingoutput;
-
-import com.google.common.base.Function;
-import com.google.common.collect.ImmutableList;
-import com.google.common.io.CharStreams;
-import com.google.devtools.build.singlejar.ZipCombiner;
-import com.google.devtools.build.xcode.zip.ZipInputEntry;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.FileSystem;
-import java.nio.file.FileSystems;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import javax.annotation.Nullable;
-
-/** Utility code for working with {@link Wrapper}s. */
-public class Wrappers {
- private Wrappers() {
- throw new UnsupportedOperationException("static-only");
- }
-
- /**
- * Takes the string and canonicalizes if it is a path that exists on the file system.
- * If it does not exist on the file system, returns the string passed in unchanged.
- */
- public static final Function<String, String> CANONICALIZE_IF_PATH =
- new Function<String, String>() {
- @Override
- public String apply(String path) {
- if (!path.startsWith("-")) {
- File file = new File(path);
- if (file.exists()) {
- try {
- return file.getCanonicalPath();
- } catch (IOException e) {
- // Pass through to return raw path
- }
- }
- }
- return path;
- }
- };
-
- /**
- * Executes the command specified by argsArray and wrapper, writing the output directly to this
- * Java process's stdout/stderr. Calling this method should be the last thing you do in
- * {@code main}, because it may exit prematurely with {@link System#exit(int)}.
- */
- public static void executePipingOutput(String[] argsArray, Wrapper wrapper)
- throws IOException, InterruptedException {
- try {
- execute(argsArray, wrapper, true);
- } catch (CommandFailedException e) {
- handleException(e);
- }
- }
-
- /**
- * Runs the given wrapper using command-line arguments passed to the {@code main} method, and
- * returns the stdout and stderr of the process.
- *
- * @throws CommandFailedException if the command did not successfully run
- */
- public static OutErr executeCapturingOutput(String[] argsArray, Wrapper wrapper)
- throws CommandFailedException, IOException, InterruptedException {
- return execute(argsArray, wrapper, false);
- }
-
- /**
- * Outputs stdout and stderr, then exits with a non-zero status code.
- */
- public static void handleException(CommandFailedException e) {
- e.outErr.print();
- System.err.print(e.getMessage());
- System.exit(1);
- }
-
- @Nullable
- private static OutErr execute(String[] argsArray, Wrapper wrapper, boolean printOutput)
- throws CommandFailedException, IOException, InterruptedException {
- FileSystem filesystem = FileSystems.getDefault();
- ArgumentsParsing argsParsing = ArgumentsParsing.parse(
- filesystem, argsArray, wrapper.name(), wrapper.subtoolName());
- for (String error : argsParsing.error().asSet()) {
- throw new CommandFailedException(error, OutErr.empty());
- }
- if (!argsParsing.arguments().isPresent()) {
- throw new IllegalStateException("No arguments or error present");
- }
- Arguments args = argsParsing.arguments().get();
- Path tempDir = getTempDir(filesystem);
- Path outputDir = Files.createTempDirectory(tempDir, "ZippingOutput");
- Path rootedOutputDir = outputDir.resolve(args.bundleRoot());
- Files.createDirectories(
- wrapper.outputDirectoryMustExist() ? rootedOutputDir : rootedOutputDir.getParent());
-
- ImmutableList<String> subCommandArguments =
- ImmutableList.copyOf(wrapper.subCommand(args, rootedOutputDir.toString()));
- ProcessBuilder processBuilder = new ProcessBuilder(subCommandArguments);
- if (printOutput) {
- processBuilder = processBuilder.inheritIO();
- }
- Process subProcess = processBuilder.start();
- int exit = subProcess.waitFor();
- OutErr outErr = new OutErr(
- streamToString(subProcess.getInputStream()),
- streamToString(subProcess.getErrorStream()));
- if (exit != 0) {
- throw new CommandFailedException("", outErr);
- }
-
- try (OutputStream out = Files.newOutputStream(Paths.get(args.outputZip()));
- ZipCombiner combiner = new ZipCombiner(out)) {
- ZipInputEntry.addAll(combiner, ZipInputEntry.fromDirectory(outputDir));
- }
- return outErr;
- }
-
- private static String streamToString(InputStream stream) throws IOException {
- return CharStreams.toString(new InputStreamReader(stream, StandardCharsets.UTF_8));
- }
-
- private static Path getTempDir(FileSystem filesystem) {
- String tempDir = System.getenv("TMPDIR");
- if (tempDir == null) {
- tempDir = "/tmp";
- }
- return filesystem.getPath(tempDir);
- }
-
- /** Thrown if command exception fails for some reason. */
- public static class CommandFailedException extends Exception {
- private OutErr outErr;
-
- public CommandFailedException(String message, OutErr outErr) {
- super(message);
- this.outErr = outErr;
- }
-
- public OutErr outErr() {
- return outErr;
- }
- }
-
- /** Stdout and stderr of a process. */
- public static class OutErr {
- public final String stdout;
- public final String stderr;
-
- public OutErr(String stdout, String stderr) {
- this.stdout = stdout;
- this.stderr = stderr;
- }
-
- public static OutErr empty() {
- return new OutErr("", "");
- }
-
- public void print() {
- System.out.print(stdout);
- System.err.print(stderr);
- }
- }
-}