• 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.utils;
5 
6 import com.android.tools.r8.Resource;
7 import java.util.Set;
8 
9 /** Defines way the output is formed. */
10 public enum OutputMode {
11   Indexed {
12     @Override
getOutputPath(Resource resource, int index)13     String getOutputPath(Resource resource, int index) {
14       return index == 0 ? "classes.dex" : ("classes" + (index + 1) + ".dex");
15     }
16   },
17   FilePerClass {
18     @Override
getOutputPath(Resource resource, int index)19     String getOutputPath(Resource resource, int index) {
20       Set<String> classDescriptors = resource.getClassDescriptors();
21       assert classDescriptors != null;
22       assert classDescriptors.size() == 1;
23       String classDescriptor = classDescriptors.iterator().next();
24       assert DescriptorUtils.isClassDescriptor(classDescriptor);
25       return classDescriptor.substring(1, classDescriptor.length() - 1) + ".dex";
26     }
27   };
28 
getOutputPath(Resource resource, int index)29   abstract String getOutputPath(Resource resource, int index);
30 }
31