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 """Writes a build_config file. | 7 """Writes a build_config file. |
8 | 8 |
9 The build_config file for a target is a json file containing information about | 9 The build_config file for a target is a json file containing information about |
10 how to build that target based on the target's dependencies. This includes | 10 how to build that target based on the target's dependencies. This includes |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 parser.add_option('--bypass-platform-checks', action='store_true', | 81 parser.add_option('--bypass-platform-checks', action='store_true', |
82 help='Bypass checks for support/require Android platform.') | 82 help='Bypass checks for support/require Android platform.') |
83 | 83 |
84 # android library options | 84 # android library options |
85 parser.add_option('--dex-path', help='Path to target\'s dex output.') | 85 parser.add_option('--dex-path', help='Path to target\'s dex output.') |
86 | 86 |
87 # native library options | 87 # native library options |
88 parser.add_option('--native-libs', help='List of top-level native libs.') | 88 parser.add_option('--native-libs', help='List of top-level native libs.') |
89 parser.add_option('--readelf-path', help='Path to toolchain\'s readelf.') | 89 parser.add_option('--readelf-path', help='Path to toolchain\'s readelf.') |
90 | 90 |
| 91 parser.add_option('--tested-apk-config', |
| 92 help='Path to the build config of the tested apk (for an instrumentation ' |
| 93 'test apk).') |
| 94 |
91 options, args = parser.parse_args(argv) | 95 options, args = parser.parse_args(argv) |
92 | 96 |
93 if args: | 97 if args: |
94 parser.error('No positional arguments should be given.') | 98 parser.error('No positional arguments should be given.') |
95 | 99 |
96 | 100 |
97 if not options.type in [ | 101 if not options.type in [ |
98 'java_library', 'android_resources', 'android_apk', 'deps_dex']: | 102 'java_library', 'android_resources', 'android_apk', 'deps_dex']: |
99 raise Exception('Unknown type: <%s>' % options.type) | 103 raise Exception('Unknown type: <%s>' % options.type) |
100 | 104 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 config['resources'] = {} | 214 config['resources'] = {} |
211 config['resources']['dependency_zips'] = [ | 215 config['resources']['dependency_zips'] = [ |
212 c['resources_zip'] for c in all_resources_deps] | 216 c['resources_zip'] for c in all_resources_deps] |
213 config['resources']['extra_package_names'] = [] | 217 config['resources']['extra_package_names'] = [] |
214 | 218 |
215 if options.type == 'android_apk': | 219 if options.type == 'android_apk': |
216 config['resources']['extra_package_names'] = [ | 220 config['resources']['extra_package_names'] = [ |
217 c['package_name'] for c in all_resources_deps if 'package_name' in c] | 221 c['package_name'] for c in all_resources_deps if 'package_name' in c] |
218 | 222 |
219 | 223 |
| 224 deps_dex_files = [c['dex_path'] for c in all_library_deps] |
| 225 # An instrumentation test apk should exclude the dex files that are in the apk |
| 226 # under test. |
| 227 if options.type == 'android_apk' and options.tested_apk_config: |
| 228 tested_apk_config_paths = GetAllDepsConfigsInOrder( |
| 229 [options.tested_apk_config]) |
| 230 tested_apk_configs = [GetDepConfig(p) for p in tested_apk_config_paths] |
| 231 tested_apk_library_deps = DepsOfType('java_library', tested_apk_configs) |
| 232 tested_apk_deps_dex_files = [c['dex_path'] for c in tested_apk_library_deps] |
| 233 deps_dex_files = [ |
| 234 p for p in deps_dex_files if not p in tested_apk_deps_dex_files] |
| 235 |
| 236 |
220 # Dependencies for the final dex file of an apk or a 'deps_dex'. | 237 # Dependencies for the final dex file of an apk or a 'deps_dex'. |
221 if options.type in ['android_apk', 'deps_dex']: | 238 if options.type in ['android_apk', 'deps_dex']: |
222 config['final_dex'] = {} | 239 config['final_dex'] = {} |
223 dex_config = config['final_dex'] | 240 dex_config = config['final_dex'] |
224 # TODO(cjhopman): proguard version | 241 # TODO(cjhopman): proguard version |
225 dex_deps_files = [c['dex_path'] for c in all_library_deps] | 242 dex_config['dependency_dex_files'] = deps_dex_files |
226 dex_config['dependency_dex_files'] = dex_deps_files | 243 |
227 | 244 |
228 if options.type == 'android_apk': | 245 if options.type == 'android_apk': |
229 config['dist_jar'] = { | 246 config['dist_jar'] = { |
230 'dependency_jars': [ | 247 'dependency_jars': [ |
231 c['jar_path'] for c in all_library_deps | 248 c['jar_path'] for c in all_library_deps |
232 ] | 249 ] |
233 } | 250 } |
234 | 251 |
235 library_paths = [] | 252 library_paths = [] |
236 java_libraries_list = [] | 253 java_libraries_list = [] |
(...skipping 21 matching lines...) Expand all Loading... |
258 build_utils.WriteJson(config, options.build_config, only_if_changed=True) | 275 build_utils.WriteJson(config, options.build_config, only_if_changed=True) |
259 | 276 |
260 if options.depfile: | 277 if options.depfile: |
261 build_utils.WriteDepfile( | 278 build_utils.WriteDepfile( |
262 options.depfile, | 279 options.depfile, |
263 all_deps_config_paths + build_utils.GetPythonDependencies()) | 280 all_deps_config_paths + build_utils.GetPythonDependencies()) |
264 | 281 |
265 | 282 |
266 if __name__ == '__main__': | 283 if __name__ == '__main__': |
267 sys.exit(main(sys.argv[1:])) | 284 sys.exit(main(sys.argv[1:])) |
OLD | NEW |