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.
7 """Writes .h files for NativeLibraries.template
9 The native library list header should contain the list of native libraries to
12 The version header should contain a version name string of the form
21 from util import build_utils
25 parser = optparse.OptionParser()
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')
36 # args should be the list of libraries in dependency order.
37 options, _ = parser.parse_args()
39 build_utils.MakeDirectory(os.path.dirname(options.native_library_list))
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) + '}'
49 with open(options.native_library_list, 'w') as header:
52 with open(options.version_output, 'w') as header:
53 header.write('= "%s"' % options.version_name)
55 if __name__ == '__main__':