| 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 # pylint: disable=C0301 | 7 # pylint: disable=C0301 |
| 8 """Package resources into an apk. | 8 """Package resources into an apk. |
| 9 | 9 |
| 10 See https://android.googlesource.com/platform/tools/base/+/master/legacy/ant-tas
ks/src/main/java/com/android/ant/AaptExecTask.java | 10 See https://android.googlesource.com/platform/tools/base/+/master/legacy/ant-tas
ks/src/main/java/com/android/ant/AaptExecTask.java |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 parser.add_option('--configuration-name', | 33 parser.add_option('--configuration-name', |
| 34 help='Gyp\'s configuration name (Debug or Release).') | 34 help='Gyp\'s configuration name (Debug or Release).') |
| 35 | 35 |
| 36 parser.add_option('--android-manifest', help='AndroidManifest.xml path') | 36 parser.add_option('--android-manifest', help='AndroidManifest.xml path') |
| 37 parser.add_option('--version-code', help='Version code for apk.') | 37 parser.add_option('--version-code', help='Version code for apk.') |
| 38 parser.add_option('--version-name', help='Version name for apk.') | 38 parser.add_option('--version-name', help='Version name for apk.') |
| 39 parser.add_option('--resource-zips', | 39 parser.add_option('--resource-zips', |
| 40 help='zip files containing resources to be packaged') | 40 help='zip files containing resources to be packaged') |
| 41 parser.add_option('--asset-dir', | 41 parser.add_option('--asset-dir', |
| 42 help='directories containing assets to be packaged') | 42 help='directories containing assets to be packaged') |
| 43 parser.add_option('--no-compress', help='disables compression for the ' |
| 44 'given comma separated list of extensions') |
| 43 | 45 |
| 44 parser.add_option('--apk-path', | 46 parser.add_option('--apk-path', |
| 45 help='Path to output (partial) apk.') | 47 help='Path to output (partial) apk.') |
| 46 | 48 |
| 47 (options, args) = parser.parse_args() | 49 (options, args) = parser.parse_args() |
| 48 | 50 |
| 49 if args: | 51 if args: |
| 50 parser.error('No positional arguments should be given.') | 52 parser.error('No positional arguments should be given.') |
| 51 | 53 |
| 52 # Check that required options have been provided. | 54 # Check that required options have been provided. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 '--version-name', options.version_name, | 99 '--version-name', options.version_name, |
| 98 '-M', options.android_manifest, | 100 '-M', options.android_manifest, |
| 99 '--no-crunch', | 101 '--no-crunch', |
| 100 '-f', | 102 '-f', |
| 101 '--auto-add-overlay', | 103 '--auto-add-overlay', |
| 102 | 104 |
| 103 '-I', android_jar, | 105 '-I', android_jar, |
| 104 '-F', options.apk_path, | 106 '-F', options.apk_path, |
| 105 ] | 107 ] |
| 106 | 108 |
| 109 if options.no_compress: |
| 110 for ext in options.no_compress.split(','): |
| 111 package_command += ['-0', ext] |
| 112 |
| 107 if os.path.exists(options.asset_dir): | 113 if os.path.exists(options.asset_dir): |
| 108 package_command += ['-A', options.asset_dir] | 114 package_command += ['-A', options.asset_dir] |
| 109 | 115 |
| 110 dep_zips = build_utils.ParseGypList(options.resource_zips) | 116 dep_zips = build_utils.ParseGypList(options.resource_zips) |
| 111 for z in dep_zips: | 117 for z in dep_zips: |
| 112 subdir = os.path.join(temp_dir, os.path.basename(z)) | 118 subdir = os.path.join(temp_dir, os.path.basename(z)) |
| 113 if os.path.exists(subdir): | 119 if os.path.exists(subdir): |
| 114 raise Exception('Resource zip name conflict: ' + os.path.basename(z)) | 120 raise Exception('Resource zip name conflict: ' + os.path.basename(z)) |
| 115 build_utils.ExtractAll(z, path=subdir) | 121 build_utils.ExtractAll(z, path=subdir) |
| 116 MoveImagesToNonMdpiFolders(subdir) | 122 MoveImagesToNonMdpiFolders(subdir) |
| 117 package_command += ['-S', subdir] | 123 package_command += ['-S', subdir] |
| 118 | 124 |
| 119 if 'Debug' in options.configuration_name: | 125 if 'Debug' in options.configuration_name: |
| 120 package_command += ['--debug-mode'] | 126 package_command += ['--debug-mode'] |
| 121 | 127 |
| 122 build_utils.CheckOutput( | 128 build_utils.CheckOutput( |
| 123 package_command, print_stdout=False, print_stderr=False) | 129 package_command, print_stdout=False, print_stderr=False) |
| 124 | 130 |
| 125 | 131 |
| 126 if __name__ == '__main__': | 132 if __name__ == '__main__': |
| 127 main() | 133 main() |
| OLD | NEW |