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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 return ret | 210 return ret |
211 | 211 |
212 | 212 |
213 def _CreateJavaLibrariesList(library_paths): | 213 def _CreateJavaLibrariesList(library_paths): |
214 """Returns a java literal array with the "base" library names: | 214 """Returns a java literal array with the "base" library names: |
215 e.g. libfoo.so -> foo | 215 e.g. libfoo.so -> foo |
216 """ | 216 """ |
217 return ('{%s}' % ','.join(['"%s"' % s[3:-3] for s in library_paths])) | 217 return ('{%s}' % ','.join(['"%s"' % s[3:-3] for s in library_paths])) |
218 | 218 |
219 | 219 |
220 def _CreateJavaAssetList(assets): | 220 def _CreateLocalePaksAssetJavaList(assets): |
221 """Returns a java literal array from a list of assets in the form src:dst.""" | 221 """Returns a java literal array from a list of assets in the form src:dst.""" |
222 return '{%s}' % ','.join(sorted(['"%s"' % a.split(':')[1] for a in assets])) | 222 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) |
| 224 return '{%s}' % ','.join(sorted('"%s"' % a for a in locales_only)) |
223 | 225 |
224 | 226 |
225 def main(argv): | 227 def main(argv): |
226 parser = optparse.OptionParser() | 228 parser = optparse.OptionParser() |
227 build_utils.AddDepfileOption(parser) | 229 build_utils.AddDepfileOption(parser) |
228 parser.add_option('--build-config', help='Path to build_config output.') | 230 parser.add_option('--build-config', help='Path to build_config output.') |
229 parser.add_option( | 231 parser.add_option( |
230 '--type', | 232 '--type', |
231 help='Type of this target (e.g. android_library).') | 233 help='Type of this target (e.g. android_library).') |
232 parser.add_option( | 234 parser.add_option( |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 | 639 |
638 all_inputs.extend(runtime_deps_files) | 640 all_inputs.extend(runtime_deps_files) |
639 config['native'] = { | 641 config['native'] = { |
640 'libraries': library_paths, | 642 'libraries': library_paths, |
641 'secondary_abi_libraries': secondary_abi_library_paths, | 643 'secondary_abi_libraries': secondary_abi_library_paths, |
642 'java_libraries_list': java_libraries_list, | 644 'java_libraries_list': java_libraries_list, |
643 'secondary_abi_java_libraries_list': secondary_abi_java_libraries_list, | 645 'secondary_abi_java_libraries_list': secondary_abi_java_libraries_list, |
644 } | 646 } |
645 config['assets'], config['uncompressed_assets'] = ( | 647 config['assets'], config['uncompressed_assets'] = ( |
646 _MergeAssets(deps.All('android_assets'))) | 648 _MergeAssets(deps.All('android_assets'))) |
647 config['compressed_assets_java_list'] = ( | 649 config['compressed_locales_java_list'] = ( |
648 _CreateJavaAssetList(config['assets'])) | 650 _CreateLocalePaksAssetJavaList(config['assets'])) |
649 config['uncompressed_assets_java_list'] = ( | 651 config['uncompressed_locales_java_list'] = ( |
650 _CreateJavaAssetList(config['uncompressed_assets'])) | 652 _CreateLocalePaksAssetJavaList(config['uncompressed_assets'])) |
651 | 653 |
652 build_utils.WriteJson(config, options.build_config, only_if_changed=True) | 654 build_utils.WriteJson(config, options.build_config, only_if_changed=True) |
653 | 655 |
654 if options.depfile: | 656 if options.depfile: |
655 build_utils.WriteDepfile(options.depfile, options.build_config, all_inputs) | 657 build_utils.WriteDepfile(options.depfile, options.build_config, all_inputs) |
656 | 658 |
657 | 659 |
658 if __name__ == '__main__': | 660 if __name__ == '__main__': |
659 sys.exit(main(sys.argv[1:])) | 661 sys.exit(main(sys.argv[1:])) |
OLD | NEW |