| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 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 .h files for NativeLibraries.template | 7 """Writes .h files for NativeLibraries.template |
| 8 | 8 |
| 9 The native library list header should contain the list of native libraries to | 9 The native library list header should contain the list of native libraries to |
| 10 load in the form: | 10 load in the form: |
| 11 = { "lib1", "lib2" } | 11 = { "lib1", "lib2" } |
| 12 The version header should contain a version name string of the form | 12 The version header should contain a version name string of the form |
| 13 = "version_name" | 13 = "version_name" |
| 14 """ | 14 """ |
| 15 | 15 |
| 16 import json | 16 import json |
| 17 import optparse | 17 import optparse |
| 18 import os | 18 import os |
| 19 import sys | 19 import sys |
| 20 | 20 |
| 21 from util import build_utils # pylint: disable=F0401 | 21 from util import build_utils |
| 22 | 22 |
| 23 | 23 |
| 24 def main(): | 24 def main(argv): |
| 25 parser = optparse.OptionParser() | 25 parser = optparse.OptionParser() |
| 26 | 26 |
| 27 parser.add_option('--native-library-list', | 27 parser.add_option('--native-library-list', |
| 28 help='Path to generated .java file containing library list') | 28 help='Path to generated .java file containing library list') |
| 29 parser.add_option('--version-output', | 29 parser.add_option('--version-output', |
| 30 help='Path to generated .java file containing version name') | 30 help='Path to generated .java file containing version name') |
| 31 parser.add_option('--ordered-libraries', | 31 parser.add_option('--ordered-libraries', |
| 32 help='Path to json file containing list of ordered libraries') | 32 help='Path to json file containing list of ordered libraries') |
| 33 parser.add_option('--version-name', | 33 parser.add_option('--version-name', |
| 34 help='expected version name of native library') | 34 help='expected version name of native library') |
| 35 | 35 |
| 36 # args should be the list of libraries in dependency order. | 36 # args should be the list of libraries in dependency order. |
| 37 options, _ = parser.parse_args() | 37 options, _ = parser.parse_args() |
| 38 | 38 |
| 39 build_utils.MakeDirectory(os.path.dirname(options.native_library_list)) | 39 build_utils.MakeDirectory(os.path.dirname(options.native_library_list)) |
| 40 | 40 |
| 41 with open(options.ordered_libraries, 'r') as libfile: | 41 with open(options.ordered_libraries, 'r') as libfile: |
| 42 libraries = json.load(libfile) | 42 libraries = json.load(libfile) |
| 43 # Generates string of the form '= { "base", "net", | 43 # Generates string of the form '= { "base", "net", |
| 44 # "content_shell_content_view" }' from a list of the form ["libbase.so", | 44 # "content_shell_content_view" }' from a list of the form ["libbase.so", |
| 45 # libnet.so", "libcontent_shell_content_view.so"] | 45 # libnet.so", "libcontent_shell_content_view.so"] |
| 46 libraries = ['"' + lib[3:-3] + '"' for lib in libraries] | 46 libraries = ['"' + lib[3:-3] + '"' for lib in libraries] |
| 47 array = '= { ' + ', '.join(libraries) + '}' | 47 array = '= { ' + ', '.join(libraries) + '}'; |
| 48 | 48 |
| 49 with open(options.native_library_list, 'w') as header: | 49 with open(options.native_library_list, 'w') as header: |
| 50 header.write(array) | 50 header.write(array) |
| 51 | 51 |
| 52 with open(options.version_output, 'w') as header: | 52 with open(options.version_output, 'w') as header: |
| 53 header.write('= "%s"' % options.version_name) | 53 header.write('= "%s"' % options.version_name) |
| 54 | 54 |
| 55 if __name__ == '__main__': | 55 if __name__ == '__main__': |
| 56 sys.exit(main()) | 56 sys.exit(main(sys.argv)) |
| OLD | NEW |