diff options
author | 2017-07-11 09:16:42 +0200 | |
---|---|---|
committer | 2017-07-11 10:56:21 +0200 | |
commit | e9b39df07f693f44bed5df13e4d38c1d774995f1 (patch) | |
tree | 259fc033f9649ba0d8ed81ab9fa5925710dde16f /src/tools/android/java/com/google/devtools/build/android/AndroidDataWriter.java | |
parent | d290eceb3bd98b483280740d79258737572df349 (diff) |
Android BusyBox: use the JunctionCreator
Use the recently added JunctionCreator class in
the Android BusyBox.
Query the current OS's name, where the BusyBox
process runs (using System.getProperty("os.name"))
and instantiate the corresponding JunctionCreator
implementation.
This allows the BusyBox to work around path length
limitations on Windows; see
WindowsJunctionCreator.
See https://github.com/bazelbuild/bazel/issues/3264
Change-Id: Ifc1a3c86971e64c2f42bcec2988b7e9239a1d29a
PiperOrigin-RevId: 161494557
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/AndroidDataWriter.java')
-rw-r--r-- | src/tools/android/java/com/google/devtools/build/android/AndroidDataWriter.java | 30 |
1 files changed, 8 insertions, 22 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/AndroidDataWriter.java b/src/tools/android/java/com/google/devtools/build/android/AndroidDataWriter.java index 2e2f85e286..91de790772 100644 --- a/src/tools/android/java/com/google/devtools/build/android/AndroidDataWriter.java +++ b/src/tools/android/java/com/google/devtools/build/android/AndroidDataWriter.java @@ -29,6 +29,9 @@ import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.MoreExecutors; import com.google.devtools.build.android.AndroidResourceMerger.MergingException; import com.google.devtools.build.android.AndroidResourceMergingAction.Options; +import com.google.devtools.build.android.junctions.JunctionCreator; +import com.google.devtools.build.android.junctions.NoopJunctionCreator; +import com.google.devtools.build.android.junctions.WindowsJunctionCreator; import com.google.devtools.build.android.xml.Namespaces; import java.io.BufferedWriter; import java.io.File; @@ -70,9 +73,12 @@ public class AndroidDataWriter implements AndroidDataWritingVisitor { @Override public Boolean call() throws Exception { - try { + try (JunctionCreator junc = + System.getProperty("os.name").toLowerCase().startsWith("windows") + ? new WindowsJunctionCreator(Files.createTempDirectory("pngcrunch")) + : new NoopJunctionCreator()) { Files.createDirectories(destinationPath.getParent()); - cruncher.crunchPng(0, source.toFile(), destinationPath.toFile()); + cruncher.crunchPng(0, junc.create(source).toFile(), junc.create(destinationPath).toFile()); } catch (PngException e) { throw MergingException.wrapException(e); } @@ -198,26 +204,6 @@ public class AndroidDataWriter implements AndroidDataWritingVisitor { NOOP_CRUNCHER, MoreExecutors.newDirectExecutorService()); } - - /** - * Creates a new writer for processing android libraries. - * - * <p>This writer has stub png cruncher that touches empty files for png resources. - * - * @param manifestDirectory The base directory for the AndroidManifest. - * @param resourceDirectory The directory to copy resources into. - * @param assetsDirectory The directory to copy assets into. - * @param executorService An execution service for multi-threaded writing. - * @return A new {@link AndroidDataWriter}. - */ - public static AndroidDataWriter createForLibrary( - Path manifestDirectory, - Path resourceDirectory, - Path assetsDirectory, - ListeningExecutorService executorService) { - return createWith( - manifestDirectory, resourceDirectory, assetsDirectory, STUB_CRUNCHER, executorService); - } /** * Creates a new writer. |