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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 def AllConfigPaths(self): | 114 def AllConfigPaths(self): |
115 return self.all_deps_config_paths | 115 return self.all_deps_config_paths |
116 | 116 |
117 def RemoveNonDirectDep(self, path): | 117 def RemoveNonDirectDep(self, path): |
118 if path in self.direct_deps_config_paths: | 118 if path in self.direct_deps_config_paths: |
119 raise Exception('Cannot remove direct dep.') | 119 raise Exception('Cannot remove direct dep.') |
120 self.all_deps_config_paths.remove(path) | 120 self.all_deps_config_paths.remove(path) |
121 self.all_deps_configs.remove(GetDepConfig(path)) | 121 self.all_deps_configs.remove(GetDepConfig(path)) |
122 | 122 |
123 def PrebuiltJarPaths(self): | 123 def GradlePrebuiltJarPaths(self): |
124 ret = [] | 124 ret = [] |
125 for config in self.Direct('java_library'): | 125 |
126 if config['is_prebuilt']: | 126 def helper(cur): |
127 ret.append(config['jar_path']) | 127 for config in cur.Direct('java_library'): |
128 ret.extend(Deps(config['deps_configs']).PrebuiltJarPaths()) | 128 if config['is_prebuilt'] or config['gradle_treat_as_prebuilt']: |
| 129 if config['jar_path'] not in ret: |
| 130 ret.append(config['jar_path']) |
| 131 |
| 132 helper(self) |
| 133 return ret |
| 134 |
| 135 def GradleLibraryProjectDeps(self): |
| 136 ret = [] |
| 137 |
| 138 def helper(cur): |
| 139 for config in cur.Direct('java_library'): |
| 140 if config['is_prebuilt']: |
| 141 pass |
| 142 elif config['gradle_treat_as_prebuilt']: |
| 143 helper(Deps(config['deps_configs'])) |
| 144 elif config not in ret: |
| 145 ret.append(config) |
| 146 |
| 147 helper(self) |
129 return ret | 148 return ret |
130 | 149 |
131 | 150 |
132 def _MergeAssets(all_assets): | 151 def _MergeAssets(all_assets): |
133 """Merges all assets from the given deps. | 152 """Merges all assets from the given deps. |
134 | 153 |
135 Returns: | 154 Returns: |
136 A tuple of lists: (compressed, uncompressed) | 155 A tuple of lists: (compressed, uncompressed) |
137 Each tuple entry is a list of "srcPath:zipPath". srcPath is the path of the | 156 Each tuple entry is a list of "srcPath:zipPath". srcPath is the path of the |
138 asset to add, and zipPath is the location within the zip (excluding assets/ | 157 asset to add, and zipPath is the location within the zip (excluding assets/ |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 help='GYP-list of .srcjars that have been included in this java_library.') | 280 help='GYP-list of .srcjars that have been included in this java_library.') |
262 parser.add_option('--supports-android', action='store_true', | 281 parser.add_option('--supports-android', action='store_true', |
263 help='Whether this library supports running on the Android platform.') | 282 help='Whether this library supports running on the Android platform.') |
264 parser.add_option('--requires-android', action='store_true', | 283 parser.add_option('--requires-android', action='store_true', |
265 help='Whether this library requires running on the Android platform.') | 284 help='Whether this library requires running on the Android platform.') |
266 parser.add_option('--bypass-platform-checks', action='store_true', | 285 parser.add_option('--bypass-platform-checks', action='store_true', |
267 help='Bypass checks for support/require Android platform.') | 286 help='Bypass checks for support/require Android platform.') |
268 parser.add_option('--extra-classpath-jars', | 287 parser.add_option('--extra-classpath-jars', |
269 help='GYP-list of .jar files to include on the classpath when compiling, ' | 288 help='GYP-list of .jar files to include on the classpath when compiling, ' |
270 'but not to include in the final binary.') | 289 'but not to include in the final binary.') |
| 290 parser.add_option('--gradle-treat-as-prebuilt', action='store_true', |
| 291 help='Whether this library should be treated as a prebuilt library by ' |
| 292 'generate_gradle.py.') |
| 293 parser.add_option('--main-class', help='Java class for java_binary targets.') |
271 | 294 |
272 # android library options | 295 # android library options |
273 parser.add_option('--dex-path', help='Path to target\'s dex output.') | 296 parser.add_option('--dex-path', help='Path to target\'s dex output.') |
274 | 297 |
275 # native library options | 298 # native library options |
276 parser.add_option('--shared-libraries-runtime-deps', | 299 parser.add_option('--shared-libraries-runtime-deps', |
277 help='Path to file containing runtime deps for shared ' | 300 help='Path to file containing runtime deps for shared ' |
278 'libraries.') | 301 'libraries.') |
279 parser.add_option('--secondary-abi-shared-libraries-runtime-deps', | 302 parser.add_option('--secondary-abi-shared-libraries-runtime-deps', |
280 help='Path to file containing runtime deps for secondary ' | 303 help='Path to file containing runtime deps for secondary ' |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 }, | 392 }, |
370 # Info needed only by generate_gradle.py. | 393 # Info needed only by generate_gradle.py. |
371 'gradle': {} | 394 'gradle': {} |
372 } | 395 } |
373 deps_info = config['deps_info'] | 396 deps_info = config['deps_info'] |
374 gradle = config['gradle'] | 397 gradle = config['gradle'] |
375 | 398 |
376 # Required for generating gradle files. | 399 # Required for generating gradle files. |
377 if options.type == 'java_library': | 400 if options.type == 'java_library': |
378 deps_info['is_prebuilt'] = is_java_prebuilt | 401 deps_info['is_prebuilt'] = is_java_prebuilt |
| 402 deps_info['gradle_treat_as_prebuilt'] = options.gradle_treat_as_prebuilt |
379 | 403 |
380 if options.android_manifest: | 404 if options.android_manifest: |
381 gradle['android_manifest'] = options.android_manifest | 405 gradle['android_manifest'] = options.android_manifest |
382 if options.type in ('java_binary', 'java_library', 'android_apk'): | 406 if options.type in ('java_binary', 'java_library', 'android_apk'): |
383 if options.java_sources_file: | 407 if options.java_sources_file: |
384 gradle['java_sources_file'] = options.java_sources_file | 408 gradle['java_sources_file'] = options.java_sources_file |
385 if options.bundled_srcjars: | 409 if options.bundled_srcjars: |
386 gradle['bundled_srcjars'] = ( | 410 gradle['bundled_srcjars'] = ( |
387 build_utils.ParseGnList(options.bundled_srcjars)) | 411 build_utils.ParseGnList(options.bundled_srcjars)) |
388 | 412 |
389 gradle['dependent_prebuilt_jars'] = deps.PrebuiltJarPaths() | |
390 | |
391 gradle['dependent_android_projects'] = [] | 413 gradle['dependent_android_projects'] = [] |
392 gradle['dependent_java_projects'] = [] | 414 gradle['dependent_java_projects'] = [] |
393 for c in direct_library_deps: | 415 gradle['dependent_prebuilt_jars'] = deps.GradlePrebuiltJarPaths() |
394 if not c['is_prebuilt']: | 416 |
395 if c['requires_android']: | 417 if options.main_class: |
396 gradle['dependent_android_projects'].append(c['path']) | 418 gradle['main_class'] = options.main_class |
397 else: | 419 |
398 gradle['dependent_java_projects'].append(c['path']) | 420 for c in deps.GradleLibraryProjectDeps(): |
| 421 if c['requires_android']: |
| 422 gradle['dependent_android_projects'].append(c['path']) |
| 423 else: |
| 424 gradle['dependent_java_projects'].append(c['path']) |
399 | 425 |
400 | 426 |
401 if (options.type in ('java_binary', 'java_library') and | 427 if (options.type in ('java_binary', 'java_library') and |
402 not options.bypass_platform_checks): | 428 not options.bypass_platform_checks): |
403 deps_info['requires_android'] = options.requires_android | 429 deps_info['requires_android'] = options.requires_android |
404 deps_info['supports_android'] = options.supports_android | 430 deps_info['supports_android'] = options.supports_android |
405 | 431 |
406 deps_require_android = (all_resources_deps + | 432 deps_require_android = (all_resources_deps + |
407 [d['name'] for d in all_library_deps if d['requires_android']]) | 433 [d['name'] for d in all_library_deps if d['requires_android']]) |
408 deps_not_support_android = ( | 434 deps_not_support_android = ( |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 _CreateLocalePaksAssetJavaList(config['uncompressed_assets'])) | 678 _CreateLocalePaksAssetJavaList(config['uncompressed_assets'])) |
653 | 679 |
654 build_utils.WriteJson(config, options.build_config, only_if_changed=True) | 680 build_utils.WriteJson(config, options.build_config, only_if_changed=True) |
655 | 681 |
656 if options.depfile: | 682 if options.depfile: |
657 build_utils.WriteDepfile(options.depfile, options.build_config, all_inputs) | 683 build_utils.WriteDepfile(options.depfile, options.build_config, all_inputs) |
658 | 684 |
659 | 685 |
660 if __name__ == '__main__': | 686 if __name__ == '__main__': |
661 sys.exit(main(sys.argv[1:])) | 687 sys.exit(main(sys.argv[1:])) |
OLD | NEW |