| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Generates the obfuscated jar and test jar for an apk. | 7 """Generates the obfuscated jar and test jar for an apk. |
| 8 | 8 |
| 9 If proguard is not enabled or 'Release' is not in the configuration name, | 9 If proguard is not enabled or 'Release' is not in the configuration name, |
| 10 obfuscation will be a no-op. | 10 obfuscation will be a no-op. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 parser.add_option('--proguard-jar-path', | 28 parser.add_option('--proguard-jar-path', |
| 29 help='Path to proguard.jar in the sdk') | 29 help='Path to proguard.jar in the sdk') |
| 30 parser.add_option('--input-jars-paths', | 30 parser.add_option('--input-jars-paths', |
| 31 help='Path to jars to include in obfuscated jar') | 31 help='Path to jars to include in obfuscated jar') |
| 32 | 32 |
| 33 parser.add_option('--proguard-configs', | 33 parser.add_option('--proguard-configs', |
| 34 help='Paths to proguard config files') | 34 help='Paths to proguard config files') |
| 35 | 35 |
| 36 parser.add_option('--configuration-name', | 36 parser.add_option('--configuration-name', |
| 37 help='Gyp configuration name (i.e. Debug, Release)') | 37 help='Gyp configuration name (i.e. Debug, Release)') |
| 38 |
| 39 parser.add_option('--debug-build-proguard-enabled', action='store_true', |
| 40 help='--proguard-enabled takes effect on release ' |
| 41 'build, this flag enable the proguard on debug ' |
| 42 'build.') |
| 38 parser.add_option('--proguard-enabled', action='store_true', | 43 parser.add_option('--proguard-enabled', action='store_true', |
| 39 help='Set if proguard is enabled for this target.') | 44 help='Set if proguard is enabled for this target.') |
| 40 | 45 |
| 41 parser.add_option('--obfuscated-jar-path', | 46 parser.add_option('--obfuscated-jar-path', |
| 42 help='Output path for obfuscated jar.') | 47 help='Output path for obfuscated jar.') |
| 43 | 48 |
| 44 parser.add_option('--testapp', action='store_true', | 49 parser.add_option('--testapp', action='store_true', |
| 45 help='Set this if building an instrumentation test apk') | 50 help='Set this if building an instrumentation test apk') |
| 46 parser.add_option('--tested-apk-obfuscated-jar-path', | 51 parser.add_option('--tested-apk-obfuscated-jar-path', |
| 47 help='Path to obfusctated jar of the tested apk') | 52 help='Path to obfusctated jar of the tested apk') |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 options, _ = ParseArgs(argv) | 123 options, _ = ParseArgs(argv) |
| 119 | 124 |
| 120 input_jars = build_utils.ParseGypList(options.input_jars_paths) | 125 input_jars = build_utils.ParseGypList(options.input_jars_paths) |
| 121 | 126 |
| 122 if options.testapp: | 127 if options.testapp: |
| 123 dependency_class_filters = [ | 128 dependency_class_filters = [ |
| 124 '*R.class', '*R$*.class', '*Manifest.class', '*BuildConfig.class'] | 129 '*R.class', '*R$*.class', '*Manifest.class', '*BuildConfig.class'] |
| 125 build_utils.MergeZips( | 130 build_utils.MergeZips( |
| 126 options.test_jar_path, input_jars, dependency_class_filters) | 131 options.test_jar_path, input_jars, dependency_class_filters) |
| 127 | 132 |
| 128 if options.configuration_name == 'Release' and options.proguard_enabled: | 133 if ((options.configuration_name == 'Release' and options.proguard_enabled) or |
| 134 (options.configuration_name == 'Debug' and |
| 135 options.debug_build_proguard_enabled)): |
| 129 DoProguard(options) | 136 DoProguard(options) |
| 130 else: | 137 else: |
| 131 output_files = [ | 138 output_files = [ |
| 132 options.obfuscated_jar_path, | 139 options.obfuscated_jar_path, |
| 133 options.obfuscated_jar_path + '.info', | 140 options.obfuscated_jar_path + '.info', |
| 134 options.obfuscated_jar_path + '.dump', | 141 options.obfuscated_jar_path + '.dump', |
| 135 options.obfuscated_jar_path + '.seeds', | 142 options.obfuscated_jar_path + '.seeds', |
| 136 options.obfuscated_jar_path + '.usage', | 143 options.obfuscated_jar_path + '.usage', |
| 137 options.obfuscated_jar_path + '.mapping'] | 144 options.obfuscated_jar_path + '.mapping'] |
| 138 for f in output_files: | 145 for f in output_files: |
| 139 if os.path.exists(f): | 146 if os.path.exists(f): |
| 140 os.remove(f) | 147 os.remove(f) |
| 141 build_utils.Touch(f) | 148 build_utils.Touch(f) |
| 142 | 149 |
| 143 if options.stamp: | 150 if options.stamp: |
| 144 build_utils.Touch(options.stamp) | 151 build_utils.Touch(options.stamp) |
| 145 | 152 |
| 146 if __name__ == '__main__': | 153 if __name__ == '__main__': |
| 147 sys.exit(main(sys.argv[1:])) | 154 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |