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