• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4 package com.android.tools.r8;
5 
6 import com.android.tools.r8.utils.AndroidApp;
7 import com.android.tools.r8.utils.OutputMode;
8 import com.google.common.collect.ImmutableList;
9 import java.io.IOException;
10 import java.nio.file.Path;
11 
12 abstract class BaseOutput {
13 
14   private final AndroidApp app;
15   private final OutputMode outputMode;
16 
BaseOutput(AndroidApp app, OutputMode outputMode)17   BaseOutput(AndroidApp app, OutputMode outputMode) {
18     this.app = app;
19     this.outputMode = outputMode;
20   }
21 
22   // Internal access to the underlying app.
getAndroidApp()23   AndroidApp getAndroidApp() {
24     return app;
25   }
26 
27   // Internal access to the options.
getOutputMode()28   public OutputMode getOutputMode() {
29     return outputMode;
30   }
31 
32   /**
33    * Get the list of compiled DEX resources.
34    *
35    * <p>The order of the list corresponds to the usual naming convention:
36    *
37    * <pre>
38    *   resources.get(0)     ~=~ classes.dex  (the main dex file)
39    *   resources.get(N - 1) ~=~ classesN.dex (where N > 0).
40    * </pre>
41    *
42    * @return list of compiled DEX resources.
43    */
getDexResources()44   public ImmutableList<Resource> getDexResources() {
45     return ImmutableList.copyOf(app.getDexProgramResources());
46   }
47 
48   /**
49    * Write the output resources to a zip-archive or directory.
50    *
51    * @param output Path to an existing directory or a zip-archive.
52    */
write(Path output)53   public abstract void write(Path output) throws IOException;
54 }
55