summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormikaelpeltier <mikaelpeltier@google.com>2014-07-29 11:30:51 +0200
committermikaelpeltier <mikaelpeltier@google.com>2014-07-29 11:30:51 +0200
commit510c93a03fc7ad16280e264c1b11fb85e0527b57 (patch)
tree0b590ae164772b7475da7d2cdd838c7024513f00
parentb3a1996a72139ba3770fce388b7235849884ed83 (diff)
downloadtoolchain_jack-510c93a03fc7ad16280e264c1b11fb85e0527b57.tar.gz
toolchain_jack-510c93a03fc7ad16280e264c1b11fb85e0527b57.tar.bz2
toolchain_jack-510c93a03fc7ad16280e264c1b11fb85e0527b57.zip
Merge dex writers and always use ResourceWriter
Change-Id: I654bb9ce9a1af2a990172ed9164ec28d2a420ad0
-rw-r--r--jack/src/com/android/jack/Jack.java25
-rw-r--r--jack/src/com/android/jack/backend/ResourceWriter.java7
-rw-r--r--jack/src/com/android/jack/backend/dex/DexFileWriter.java29
-rw-r--r--jack/src/com/android/jack/backend/dex/DexZipWriter.java87
-rw-r--r--jack/src/com/android/jack/scheduling/feature/DexNonZipOutput.java29
-rw-r--r--jack/src/com/android/jack/scheduling/feature/DexZipOutput.java29
6 files changed, 32 insertions, 174 deletions
diff --git a/jack/src/com/android/jack/Jack.java b/jack/src/com/android/jack/Jack.java
index 35a0e4f0..9d8b3f42 100644
--- a/jack/src/com/android/jack/Jack.java
+++ b/jack/src/com/android/jack/Jack.java
@@ -31,7 +31,6 @@ import com.android.jack.backend.dex.ClassDefItemBuilder;
import com.android.jack.backend.dex.DexFileBuilder;
import com.android.jack.backend.dex.DexFileProduct;
import com.android.jack.backend.dex.DexFileWriter;
-import com.android.jack.backend.dex.DexZipWriter;
import com.android.jack.backend.dex.EncodedFieldBuilder;
import com.android.jack.backend.dex.EncodedMethodBuilder;
import com.android.jack.backend.dex.FieldAnnotationBuilder;
@@ -95,8 +94,6 @@ import com.android.jack.scheduling.adapter.JFieldAdapter;
import com.android.jack.scheduling.adapter.JMethodAdapter;
import com.android.jack.scheduling.adapter.JPackageAdapter;
import com.android.jack.scheduling.feature.CompiledTypeStats;
-import com.android.jack.scheduling.feature.DexNonZipOutput;
-import com.android.jack.scheduling.feature.DexZipOutput;
import com.android.jack.scheduling.feature.DxLegacy;
import com.android.jack.scheduling.feature.JackFileOutput;
import com.android.jack.scheduling.feature.Resources;
@@ -484,12 +481,6 @@ public abstract class Jack {
request.addProduction(StructurePrinting.class);
}
- if (options.outputToZip()) {
- request.addFeature(DexZipOutput.class);
- } else {
- request.addFeature(DexNonZipOutput.class);
- }
-
if (config.get(Options.GENERATE_JACK_FILE).booleanValue()) {
request.addFeature(JackFileOutput.class);
}
@@ -545,11 +536,7 @@ public abstract class Jack {
if (targetProduction.contains(OneDexPerTypeProduct.class)) {
planBuilder.append(OneDexPerTypeWriter.class);
}
- if (features.contains(DexZipOutput.class)) {
- planBuilder.append(DexZipWriter.class);
- } else {
- planBuilder.append(DexFileWriter.class);
- }
+ planBuilder.append(DexFileWriter.class);
} else {
assert targetProduction.contains(DexFileProduct.class)
|| targetProduction.contains(OneDexPerTypeProduct.class);
@@ -557,16 +544,10 @@ public abstract class Jack {
if (targetProduction.contains(OneDexPerTypeProduct.class)) {
planBuilder.append(OneDexPerTypeWriter.class);
}
- if (features.contains(DexZipOutput.class)) {
- planBuilder.append(DexZipWriter.class);
- } else {
- planBuilder.append(DexFileWriter.class);
- }
+ planBuilder.append(DexFileWriter.class);
}
- if (features.contains(Resources.class)
- && (features.contains(DexZipOutput.class)
- || targetProduction.contains(JackFormatProduct.class))) {
+ if (features.contains(Resources.class)) {
planBuilder.append(ResourceWriter.class);
}
diff --git a/jack/src/com/android/jack/backend/ResourceWriter.java b/jack/src/com/android/jack/backend/ResourceWriter.java
index bde0725b..924471a3 100644
--- a/jack/src/com/android/jack/backend/ResourceWriter.java
+++ b/jack/src/com/android/jack/backend/ResourceWriter.java
@@ -60,8 +60,11 @@ public class ResourceWriter implements RunnableSchedulable<JSession> {
} else {
assert ThreadConfig.get(Options.GENERATE_DEX_FILE).booleanValue();
Container containerType = ThreadConfig.get(Options.DEX_OUTPUT_CONTAINER_TYPE);
- assert containerType == Container.ZIP;
- outputVDir = ThreadConfig.get(Options.DEX_OUTPUT_ZIP);
+ if (containerType == Container.DIR) {
+ outputVDir = ThreadConfig.get(Options.DEX_OUTPUT_DIR);
+ } else {
+ outputVDir = ThreadConfig.get(Options.DEX_OUTPUT_ZIP);
+ }
}
}
diff --git a/jack/src/com/android/jack/backend/dex/DexFileWriter.java b/jack/src/com/android/jack/backend/dex/DexFileWriter.java
index bc10fbb5..c5305179 100644
--- a/jack/src/com/android/jack/backend/dex/DexFileWriter.java
+++ b/jack/src/com/android/jack/backend/dex/DexFileWriter.java
@@ -20,15 +20,15 @@ import com.android.jack.JackIOException;
import com.android.jack.Options;
import com.android.jack.dx.dex.file.DexFile;
import com.android.jack.ir.ast.JSession;
-import com.android.jack.scheduling.feature.DexNonZipOutput;
import com.android.jack.scheduling.marker.DexFileMarker;
import com.android.sched.item.Description;
import com.android.sched.item.Name;
import com.android.sched.schedulable.Constraint;
import com.android.sched.schedulable.Produce;
import com.android.sched.schedulable.RunnableSchedulable;
-import com.android.sched.schedulable.Support;
import com.android.sched.util.config.ThreadConfig;
+import com.android.sched.util.log.LoggerFactory;
+import com.android.sched.vfs.Container;
import com.android.sched.vfs.OutputVDir;
import com.android.sched.vfs.OutputVFile;
import com.android.sched.vfs.VPath;
@@ -36,6 +36,8 @@ import com.android.sched.vfs.VPath;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.OutputStream;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import javax.annotation.Nonnull;
@@ -46,13 +48,26 @@ import javax.annotation.Nonnull;
@Name("DexFileWriter")
@Constraint(need = {DexFileMarker.Complete.class})
@Produce(DexFileProduct.class)
-@Support(DexNonZipOutput.class)
public class DexFileWriter extends DexWriter implements RunnableSchedulable<JSession> {
+ @Nonnull
public static final String DEX_FILENAME = "classes.dex";
@Nonnull
- private final OutputVDir outputVDir = ThreadConfig.get(Options.DEX_OUTPUT_DIR);
+ private final Logger logger = LoggerFactory.getLogger();
+
+ @Nonnull
+ private final OutputVDir outputVDir;
+
+ {
+ assert ThreadConfig.get(Options.GENERATE_DEX_FILE).booleanValue();
+ Container container = ThreadConfig.get(Options.DEX_OUTPUT_CONTAINER_TYPE);
+ if (container == Container.DIR) {
+ outputVDir = ThreadConfig.get(Options.DEX_OUTPUT_DIR);
+ } else {
+ outputVDir = ThreadConfig.get(Options.DEX_OUTPUT_ZIP);
+ }
+ }
@Override
public void run(@Nonnull JSession session) throws Exception {
@@ -72,7 +87,11 @@ public class DexFileWriter extends DexWriter implements RunnableSchedulable<JSes
}
}
} finally {
- osDex.close();
+ try {
+ osDex.close();
+ } catch (IOException e) {
+ logger.log(Level.WARNING, "Failed to close output stream on '" + dexVFile + "'", e);
+ }
}
}
}
diff --git a/jack/src/com/android/jack/backend/dex/DexZipWriter.java b/jack/src/com/android/jack/backend/dex/DexZipWriter.java
deleted file mode 100644
index 41942b6f..00000000
--- a/jack/src/com/android/jack/backend/dex/DexZipWriter.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * 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.android.jack.backend.dex;
-
-import com.android.jack.JackIOException;
-import com.android.jack.Options;
-import com.android.jack.dx.dex.file.DexFile;
-import com.android.jack.ir.ast.JSession;
-import com.android.jack.scheduling.feature.DexZipOutput;
-import com.android.jack.scheduling.marker.DexFileMarker;
-import com.android.sched.item.Description;
-import com.android.sched.item.Name;
-import com.android.sched.schedulable.Constraint;
-import com.android.sched.schedulable.Produce;
-import com.android.sched.schedulable.RunnableSchedulable;
-import com.android.sched.schedulable.Support;
-import com.android.sched.util.config.ThreadConfig;
-import com.android.sched.util.log.LoggerFactory;
-import com.android.sched.vfs.OutputVDir;
-import com.android.sched.vfs.OutputVFile;
-import com.android.sched.vfs.VPath;
-
-import java.io.BufferedOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.annotation.Nonnull;
-
-/**
- * Write dex into a zip.
- */
-@Description("Write dex into a zip")
-@Name("DexZipWriter")
-@Constraint(need = {DexFileMarker.Complete.class})
-@Produce(DexFileProduct.class)
-@Support(DexZipOutput.class)
-public class DexZipWriter extends DexWriter implements RunnableSchedulable<JSession> {
-
- @Nonnull
- private static final String DEX_NAME = "classes.dex";
-
- @Nonnull
- private final OutputVDir outputVDir = ThreadConfig.get(Options.DEX_OUTPUT_ZIP);
-
- @Nonnull
- private final Logger logger = LoggerFactory.getLogger();
-
- @Override
- public void run(@Nonnull JSession session) throws Exception {
- DexFile dexFile = getDexFile(session);
- OutputVFile vFile = outputVDir.createOutputVFile(new VPath(DEX_NAME, '/'));
- OutputStream osDex = new BufferedOutputStream(vFile.openWrite());
-
- try {
- if (emitOneDexPerType) {
- mergeDexPerType(dexFile, osDex);
- } else {
- dexFile.prepare();
- dexFile.writeTo(osDex, null, false);
- }
- } catch (IOException e) {
- throw new JackIOException("Could not write Dex file to output '" + vFile + "'", e);
- } finally {
- try {
- osDex.close();
- } catch (IOException e) {
- logger.log(Level.WARNING, "Failed to close output stream on '" + vFile + "'", e);
- }
- }
- }
-}
diff --git a/jack/src/com/android/jack/scheduling/feature/DexNonZipOutput.java b/jack/src/com/android/jack/scheduling/feature/DexNonZipOutput.java
deleted file mode 100644
index 08279573..00000000
--- a/jack/src/com/android/jack/scheduling/feature/DexNonZipOutput.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * 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.android.jack.scheduling.feature;
-
-import com.android.sched.item.Description;
-import com.android.sched.item.Feature;
-import com.android.sched.item.Name;
-
-/**
- * Dex non-zip output
- */
-@Description("Dex non-zip output")
-@Name("DexNonZipOutput")
-public class DexNonZipOutput implements Feature {
-}
diff --git a/jack/src/com/android/jack/scheduling/feature/DexZipOutput.java b/jack/src/com/android/jack/scheduling/feature/DexZipOutput.java
deleted file mode 100644
index 65ee1b8a..00000000
--- a/jack/src/com/android/jack/scheduling/feature/DexZipOutput.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * 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.android.jack.scheduling.feature;
-
-import com.android.sched.item.Description;
-import com.android.sched.item.Feature;
-import com.android.sched.item.Name;
-
-/**
- * Dex zip output
- */
-@Description("Dex zip output")
-@Name("DexZipOutput")
-public class DexZipOutput implements Feature {
-}