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 19 matching lines...) Expand all Loading... |
30 parser.add_option('--android-sdk', help='path to the Android SDK folder') | 30 parser.add_option('--android-sdk', help='path to the Android SDK folder') |
31 parser.add_option('--android-sdk-tools', | 31 parser.add_option('--android-sdk-tools', |
32 help='path to the Android SDK build tools folder') | 32 help='path to the Android SDK build tools folder') |
33 | 33 |
34 parser.add_option('--configuration-name', | 34 parser.add_option('--configuration-name', |
35 help='Gyp\'s configuration name (Debug or Release).') | 35 help='Gyp\'s configuration name (Debug or Release).') |
36 | 36 |
37 parser.add_option('--android-manifest', help='AndroidManifest.xml path') | 37 parser.add_option('--android-manifest', help='AndroidManifest.xml path') |
38 parser.add_option('--version-code', help='Version code for apk.') | 38 parser.add_option('--version-code', help='Version code for apk.') |
39 parser.add_option('--version-name', help='Version name for apk.') | 39 parser.add_option('--version-name', help='Version name for apk.') |
| 40 parser.add_option( |
| 41 '--shared-resources', |
| 42 action='store_true', |
| 43 help='Make a resource package that can be loaded by a different' |
| 44 'application at runtime to access the package\'s resources.') |
40 parser.add_option('--resource-zips', | 45 parser.add_option('--resource-zips', |
41 help='zip files containing resources to be packaged') | 46 help='zip files containing resources to be packaged') |
42 parser.add_option('--asset-dir', | 47 parser.add_option('--asset-dir', |
43 help='directories containing assets to be packaged') | 48 help='directories containing assets to be packaged') |
44 parser.add_option('--no-compress', help='disables compression for the ' | 49 parser.add_option('--no-compress', help='disables compression for the ' |
45 'given comma separated list of extensions') | 50 'given comma separated list of extensions') |
46 | 51 |
47 parser.add_option('--apk-path', | 52 parser.add_option('--apk-path', |
48 help='Path to output (partial) apk.') | 53 help='Path to output (partial) apk.') |
49 | 54 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 '--auto-add-overlay', | 130 '--auto-add-overlay', |
126 | 131 |
127 '-I', android_jar, | 132 '-I', android_jar, |
128 '-F', options.apk_path, | 133 '-F', options.apk_path, |
129 '--ignore-assets', build_utils.AAPT_IGNORE_PATTERN, | 134 '--ignore-assets', build_utils.AAPT_IGNORE_PATTERN, |
130 ] | 135 ] |
131 | 136 |
132 if options.no_compress: | 137 if options.no_compress: |
133 for ext in options.no_compress.split(','): | 138 for ext in options.no_compress.split(','): |
134 package_command += ['-0', ext] | 139 package_command += ['-0', ext] |
| 140 if options.shared_resources: |
| 141 package_command.append('--shared-lib') |
135 | 142 |
136 if os.path.exists(options.asset_dir): | 143 if os.path.exists(options.asset_dir): |
137 package_command += ['-A', options.asset_dir] | 144 package_command += ['-A', options.asset_dir] |
138 | 145 |
139 dep_zips = build_utils.ParseGypList(options.resource_zips) | 146 dep_zips = build_utils.ParseGypList(options.resource_zips) |
140 for z in dep_zips: | 147 for z in dep_zips: |
141 subdir = os.path.join(temp_dir, os.path.basename(z)) | 148 subdir = os.path.join(temp_dir, os.path.basename(z)) |
142 if os.path.exists(subdir): | 149 if os.path.exists(subdir): |
143 raise Exception('Resource zip name conflict: ' + os.path.basename(z)) | 150 raise Exception('Resource zip name conflict: ' + os.path.basename(z)) |
144 build_utils.ExtractAll(z, path=subdir) | 151 build_utils.ExtractAll(z, path=subdir) |
145 package_command += PackageArgsForExtractedZip(subdir) | 152 package_command += PackageArgsForExtractedZip(subdir) |
146 | 153 |
147 if 'Debug' in options.configuration_name: | 154 if 'Debug' in options.configuration_name: |
148 package_command += ['--debug-mode'] | 155 package_command += ['--debug-mode'] |
149 | 156 |
150 build_utils.CheckOutput( | 157 build_utils.CheckOutput( |
151 package_command, print_stdout=False, print_stderr=False) | 158 package_command, print_stdout=False, print_stderr=False) |
152 | 159 |
153 if options.depfile: | 160 if options.depfile: |
154 build_utils.WriteDepfile( | 161 build_utils.WriteDepfile( |
155 options.depfile, | 162 options.depfile, |
156 build_utils.GetPythonDependencies()) | 163 build_utils.GetPythonDependencies()) |
157 | 164 |
158 | 165 |
159 if __name__ == '__main__': | 166 if __name__ == '__main__': |
160 main() | 167 main() |
OLD | NEW |