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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 if target_type in _RESOURCE_TYPES: | 191 if target_type in _RESOURCE_TYPES: |
192 configs = [c for c in configs if c['type'] in _RESOURCE_TYPES] | 192 configs = [c for c in configs if c['type'] in _RESOURCE_TYPES] |
193 return [c['path'] for c in configs] | 193 return [c['path'] for c in configs] |
194 | 194 |
195 | 195 |
196 def _AsInterfaceJar(jar_path): | 196 def _AsInterfaceJar(jar_path): |
197 return jar_path[:-3] + 'interface.jar' | 197 return jar_path[:-3] + 'interface.jar' |
198 | 198 |
199 | 199 |
200 def _ExtractSharedLibsFromRuntimeDeps(runtime_deps_files): | 200 def _ExtractSharedLibsFromRuntimeDeps(runtime_deps_files): |
201 ret = [] | 201 """Returns sorted direct and all deps. |
agrieve
2016/10/26 19:46:18
Not sure this makes sense. How about:
Returns a t
| |
202 """ | |
203 all_deps = set() | |
204 direct_deps = [] | |
202 for path in runtime_deps_files: | 205 for path in runtime_deps_files: |
203 with open(path) as f: | 206 with open(path) as f: |
207 first_line = True | |
204 for line in f: | 208 for line in f: |
205 line = line.rstrip() | 209 line = line.rstrip() |
206 if not line.endswith('.so'): | 210 if first_line: |
211 if not line.endswith('.so'): | |
212 raise Exception('Wrong runtime deps file %s' % path) | |
213 direct_deps.append(os.path.normpath(line)) | |
214 first_line = False | |
215 elif not line.endswith('.so'): | |
207 continue | 216 continue |
208 ret.append(os.path.normpath(line)) | 217 all_deps.add(os.path.normpath(line)) |
209 ret.reverse() | 218 return sorted(direct_deps), sorted(all_deps) |
210 return ret | |
211 | 219 |
212 | 220 |
213 def _CreateJavaLibrariesList(library_paths): | 221 def _CreateJavaLibrariesList(library_paths): |
214 """Returns a java literal array with the "base" library names: | 222 """Returns a java literal array with the "base" library names: |
215 e.g. libfoo.so -> foo | 223 e.g. libfoo.so -> foo |
216 """ | 224 """ |
217 return ('{%s}' % ','.join(['"%s"' % s[3:-3] for s in library_paths])) | 225 return ('{%s}' % ','.join(['"%s"' % os.path.basename(s)[3:-3] |
226 for s in library_paths])) | |
218 | 227 |
219 | 228 |
220 def _CreateLocalePaksAssetJavaList(assets): | 229 def _CreateLocalePaksAssetJavaList(assets): |
221 """Returns a java literal array from a list of assets in the form src:dst.""" | 230 """Returns a java literal array from a list of assets in the form src:dst.""" |
222 names_only = (a.split(':')[1][:-4] for a in assets if a.endswith('.pak')) | 231 names_only = (a.split(':')[1][:-4] for a in assets if a.endswith('.pak')) |
223 locales_only = (a for a in names_only if '-' in a or len(a) == 2) | 232 locales_only = (a for a in names_only if '-' in a or len(a) == 2) |
224 return '{%s}' % ','.join(sorted('"%s"' % a for a in locales_only)) | 233 return '{%s}' % ','.join(sorted('"%s"' % a for a in locales_only)) |
225 | 234 |
226 | 235 |
227 def main(argv): | 236 def main(argv): |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
617 deps_info['package_name'] = manifest.GetPackageName() | 626 deps_info['package_name'] = manifest.GetPackageName() |
618 if not options.tested_apk_config and manifest.GetInstrumentation(): | 627 if not options.tested_apk_config and manifest.GetInstrumentation(): |
619 # This must then have instrumentation only for itself. | 628 # This must then have instrumentation only for itself. |
620 manifest.CheckInstrumentation(manifest.GetPackageName()) | 629 manifest.CheckInstrumentation(manifest.GetPackageName()) |
621 | 630 |
622 library_paths = [] | 631 library_paths = [] |
623 java_libraries_list = None | 632 java_libraries_list = None |
624 runtime_deps_files = build_utils.ParseGnList( | 633 runtime_deps_files = build_utils.ParseGnList( |
625 options.shared_libraries_runtime_deps or '[]') | 634 options.shared_libraries_runtime_deps or '[]') |
626 if runtime_deps_files: | 635 if runtime_deps_files: |
627 library_paths = _ExtractSharedLibsFromRuntimeDeps(runtime_deps_files) | 636 direct_dep_libs, library_paths = _ExtractSharedLibsFromRuntimeDeps( |
628 java_libraries_list = _CreateJavaLibrariesList(library_paths) | 637 runtime_deps_files) |
638 java_libraries_list = _CreateJavaLibrariesList(direct_dep_libs) | |
629 | 639 |
630 secondary_abi_library_paths = [] | 640 secondary_abi_library_paths = [] |
631 secondary_abi_java_libraries_list = None | 641 secondary_abi_java_libraries_list = None |
632 secondary_abi_runtime_deps_files = build_utils.ParseGnList( | 642 secondary_abi_runtime_deps_files = build_utils.ParseGnList( |
633 options.secondary_abi_shared_libraries_runtime_deps or '[]') | 643 options.secondary_abi_shared_libraries_runtime_deps or '[]') |
634 if secondary_abi_runtime_deps_files: | 644 if secondary_abi_runtime_deps_files: |
635 secondary_abi_library_paths = _ExtractSharedLibsFromRuntimeDeps( | 645 (secondary_abi_direct_dep_libs, |
646 secondary_abi_library_paths) = _ExtractSharedLibsFromRuntimeDeps( | |
636 secondary_abi_runtime_deps_files) | 647 secondary_abi_runtime_deps_files) |
637 secondary_abi_java_libraries_list = _CreateJavaLibrariesList( | 648 secondary_abi_java_libraries_list = _CreateJavaLibrariesList( |
638 secondary_abi_library_paths) | 649 secondary_abi_direct_dep_libs) |
650 if java_libraries_list != secondary_abi_java_libraries_list: | |
651 raise Exception('Secondary abi library list should same as primary one.' | |
652 ' Secondary abi: %s, primary abi:%s' | |
653 % (secondary_abi_java_libraries_list, java_libraries_list)) | |
639 | 654 |
640 all_inputs.extend(runtime_deps_files) | 655 all_inputs.extend(runtime_deps_files) |
641 config['native'] = { | 656 config['native'] = { |
642 'libraries': library_paths, | 657 'libraries': library_paths, |
643 'secondary_abi_libraries': secondary_abi_library_paths, | 658 'secondary_abi_libraries': secondary_abi_library_paths, |
644 'java_libraries_list': java_libraries_list, | 659 'java_libraries_list': java_libraries_list, |
645 'secondary_abi_java_libraries_list': secondary_abi_java_libraries_list, | 660 'secondary_abi_java_libraries_list': secondary_abi_java_libraries_list, |
646 } | 661 } |
647 config['assets'], config['uncompressed_assets'] = ( | 662 config['assets'], config['uncompressed_assets'] = ( |
648 _MergeAssets(deps.All('android_assets'))) | 663 _MergeAssets(deps.All('android_assets'))) |
649 config['compressed_locales_java_list'] = ( | 664 config['compressed_locales_java_list'] = ( |
650 _CreateLocalePaksAssetJavaList(config['assets'])) | 665 _CreateLocalePaksAssetJavaList(config['assets'])) |
651 config['uncompressed_locales_java_list'] = ( | 666 config['uncompressed_locales_java_list'] = ( |
652 _CreateLocalePaksAssetJavaList(config['uncompressed_assets'])) | 667 _CreateLocalePaksAssetJavaList(config['uncompressed_assets'])) |
653 | 668 |
654 build_utils.WriteJson(config, options.build_config, only_if_changed=True) | 669 build_utils.WriteJson(config, options.build_config, only_if_changed=True) |
655 | 670 |
656 if options.depfile: | 671 if options.depfile: |
657 build_utils.WriteDepfile(options.depfile, options.build_config, all_inputs) | 672 build_utils.WriteDepfile(options.depfile, options.build_config, all_inputs) |
658 | 673 |
659 | 674 |
660 if __name__ == '__main__': | 675 if __name__ == '__main__': |
661 sys.exit(main(sys.argv[1:])) | 676 sys.exit(main(sys.argv[1:])) |
OLD | NEW |