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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 parser.add_option('--bypass-platform-checks', action='store_true', | 182 parser.add_option('--bypass-platform-checks', action='store_true', |
183 help='Bypass checks for support/require Android platform.') | 183 help='Bypass checks for support/require Android platform.') |
184 | 184 |
185 # android library options | 185 # android library options |
186 parser.add_option('--dex-path', help='Path to target\'s dex output.') | 186 parser.add_option('--dex-path', help='Path to target\'s dex output.') |
187 | 187 |
188 # native library options | 188 # native library options |
189 parser.add_option('--native-libs', help='List of top-level native libs.') | 189 parser.add_option('--native-libs', help='List of top-level native libs.') |
190 parser.add_option('--readelf-path', help='Path to toolchain\'s readelf.') | 190 parser.add_option('--readelf-path', help='Path to toolchain\'s readelf.') |
191 | 191 |
| 192 # apk options |
| 193 parser.add_option('--apk-path', help='Path to the target\'s apk output.') |
| 194 |
192 parser.add_option('--tested-apk-config', | 195 parser.add_option('--tested-apk-config', |
193 help='Path to the build config of the tested apk (for an instrumentation ' | 196 help='Path to the build config of the tested apk (for an instrumentation ' |
194 'test apk).') | 197 'test apk).') |
195 parser.add_option('--proguard-enabled', action='store_true', | 198 parser.add_option('--proguard-enabled', action='store_true', |
196 help='Whether proguard is enabled for this apk.') | 199 help='Whether proguard is enabled for this apk.') |
197 parser.add_option('--proguard-info', | 200 parser.add_option('--proguard-info', |
198 help='Path to the proguard .info output for this apk.') | 201 help='Path to the proguard .info output for this apk.') |
199 | 202 |
200 options, args = parser.parse_args(argv) | 203 options, args = parser.parse_args(argv) |
201 | 204 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 raise Exception('Not all deps support the Android platform: ' + | 287 raise Exception('Not all deps support the Android platform: ' + |
285 str(deps_not_support_android)) | 288 str(deps_not_support_android)) |
286 | 289 |
287 if options.type in ['java_library', 'android_apk']: | 290 if options.type in ['java_library', 'android_apk']: |
288 javac_classpath = [c['jar_path'] for c in direct_library_deps] | 291 javac_classpath = [c['jar_path'] for c in direct_library_deps] |
289 java_full_classpath = [c['jar_path'] for c in all_library_deps] | 292 java_full_classpath = [c['jar_path'] for c in all_library_deps] |
290 deps_info['resources_deps'] = [c['path'] for c in all_resources_deps] | 293 deps_info['resources_deps'] = [c['path'] for c in all_resources_deps] |
291 deps_info['jar_path'] = options.jar_path | 294 deps_info['jar_path'] = options.jar_path |
292 if options.type == 'android_apk' or options.supports_android: | 295 if options.type == 'android_apk' or options.supports_android: |
293 deps_info['dex_path'] = options.dex_path | 296 deps_info['dex_path'] = options.dex_path |
| 297 if options.type == 'android_apk': |
| 298 deps_info['apk_path'] = options.apk_path |
294 config['javac'] = { | 299 config['javac'] = { |
295 'classpath': javac_classpath, | 300 'classpath': javac_classpath, |
296 } | 301 } |
297 config['java'] = { | 302 config['java'] = { |
298 'full_classpath': java_full_classpath | 303 'full_classpath': java_full_classpath |
299 } | 304 } |
300 | 305 |
301 if options.type == 'java_library': | 306 if options.type == 'java_library': |
302 # Only resources might have srcjars (normal srcjar targets are listed in | 307 # Only resources might have srcjars (normal srcjar targets are listed in |
303 # srcjar_deps). A resource's srcjar contains the R.java file for those | 308 # srcjar_deps). A resource's srcjar contains the R.java file for those |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 | 382 |
378 tested_apk_config = GetDepConfig(options.tested_apk_config) | 383 tested_apk_config = GetDepConfig(options.tested_apk_config) |
379 expected_tested_package = tested_apk_config['package_name'] | 384 expected_tested_package = tested_apk_config['package_name'] |
380 AndroidManifest(options.android_manifest).CheckInstrumentation( | 385 AndroidManifest(options.android_manifest).CheckInstrumentation( |
381 expected_tested_package) | 386 expected_tested_package) |
382 if tested_apk_config['proguard_enabled']: | 387 if tested_apk_config['proguard_enabled']: |
383 assert proguard_enabled, ('proguard must be enabled for instrumentation' | 388 assert proguard_enabled, ('proguard must be enabled for instrumentation' |
384 ' apks if it\'s enabled for the tested apk') | 389 ' apks if it\'s enabled for the tested apk') |
385 proguard_config['tested_apk_info'] = tested_apk_config['proguard_info'] | 390 proguard_config['tested_apk_info'] = tested_apk_config['proguard_info'] |
386 | 391 |
| 392 deps_info['tested_apk_path'] = tested_apk_config['apk_path'] |
| 393 |
387 # Dependencies for the final dex file of an apk or a 'deps_dex'. | 394 # Dependencies for the final dex file of an apk or a 'deps_dex'. |
388 if options.type in ['android_apk', 'deps_dex']: | 395 if options.type in ['android_apk', 'deps_dex']: |
389 config['final_dex'] = {} | 396 config['final_dex'] = {} |
390 dex_config = config['final_dex'] | 397 dex_config = config['final_dex'] |
391 if proguard_enabled: | 398 if proguard_enabled: |
392 # When proguard is enabled, the proguarded jar contains the code for all | 399 # When proguard is enabled, the proguarded jar contains the code for all |
393 # of the dependencies. | 400 # of the dependencies. |
394 deps_dex_files = [] | 401 deps_dex_files = [] |
395 dex_config['dependency_dex_files'] = deps_dex_files | 402 dex_config['dependency_dex_files'] = deps_dex_files |
396 | 403 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 build_utils.WriteJson(config, options.build_config, only_if_changed=True) | 454 build_utils.WriteJson(config, options.build_config, only_if_changed=True) |
448 | 455 |
449 if options.depfile: | 456 if options.depfile: |
450 build_utils.WriteDepfile( | 457 build_utils.WriteDepfile( |
451 options.depfile, | 458 options.depfile, |
452 deps.AllConfigPaths() + build_utils.GetPythonDependencies()) | 459 deps.AllConfigPaths() + build_utils.GetPythonDependencies()) |
453 | 460 |
454 | 461 |
455 if __name__ == '__main__': | 462 if __name__ == '__main__': |
456 sys.exit(main(sys.argv[1:])) | 463 sys.exit(main(sys.argv[1:])) |
OLD | NEW |