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 _CreateLocalePaksAssetJavaList(assets): | 220 def _CreateJavaAssetList(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 names_only = (a.split(':')[1][:-4] for a in assets if a.endswith('.pak')) | 222 return '{%s}' % ','.join(sorted(['"%s"' % a.split(':')[1] for a in assets])) |
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)) | |
225 | 223 |
226 | 224 |
227 def main(argv): | 225 def main(argv): |
228 parser = optparse.OptionParser() | 226 parser = optparse.OptionParser() |
229 build_utils.AddDepfileOption(parser) | 227 build_utils.AddDepfileOption(parser) |
230 parser.add_option('--build-config', help='Path to build_config output.') | 228 parser.add_option('--build-config', help='Path to build_config output.') |
231 parser.add_option( | 229 parser.add_option( |
232 '--type', | 230 '--type', |
233 help='Type of this target (e.g. android_library).') | 231 help='Type of this target (e.g. android_library).') |
234 parser.add_option( | 232 parser.add_option( |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 | 637 |
640 all_inputs.extend(runtime_deps_files) | 638 all_inputs.extend(runtime_deps_files) |
641 config['native'] = { | 639 config['native'] = { |
642 'libraries': library_paths, | 640 'libraries': library_paths, |
643 'secondary_abi_libraries': secondary_abi_library_paths, | 641 'secondary_abi_libraries': secondary_abi_library_paths, |
644 'java_libraries_list': java_libraries_list, | 642 'java_libraries_list': java_libraries_list, |
645 'secondary_abi_java_libraries_list': secondary_abi_java_libraries_list, | 643 'secondary_abi_java_libraries_list': secondary_abi_java_libraries_list, |
646 } | 644 } |
647 config['assets'], config['uncompressed_assets'] = ( | 645 config['assets'], config['uncompressed_assets'] = ( |
648 _MergeAssets(deps.All('android_assets'))) | 646 _MergeAssets(deps.All('android_assets'))) |
649 config['compressed_locales_java_list'] = ( | 647 config['compressed_assets_java_list'] = ( |
650 _CreateLocalePaksAssetJavaList(config['assets'])) | 648 _CreateJavaAssetList(config['assets'])) |
651 config['uncompressed_locales_java_list'] = ( | 649 config['uncompressed_assets_java_list'] = ( |
652 _CreateLocalePaksAssetJavaList(config['uncompressed_assets'])) | 650 _CreateJavaAssetList(config['uncompressed_assets'])) |
653 | 651 |
654 build_utils.WriteJson(config, options.build_config, only_if_changed=True) | 652 build_utils.WriteJson(config, options.build_config, only_if_changed=True) |
655 | 653 |
656 if options.depfile: | 654 if options.depfile: |
657 build_utils.WriteDepfile(options.depfile, options.build_config, all_inputs) | 655 build_utils.WriteDepfile(options.depfile, options.build_config, all_inputs) |
658 | 656 |
659 | 657 |
660 if __name__ == '__main__': | 658 if __name__ == '__main__': |
661 sys.exit(main(sys.argv[1:])) | 659 sys.exit(main(sys.argv[1:])) |
OLD | NEW |