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 file for NativeLibraries.template
9 This header should contain the list of native libraries to load in the form:
18 from util import build_utils
22 parser = optparse.OptionParser()
24 parser.add_option('--output', help='Path to generated .java file')
25 parser.add_option('--ordered-libraries',
26 help='Path to json file containing list of ordered libraries')
27 parser.add_option('--stamp', help='Path to touch on success')
29 # args should be the list of libraries in dependency order.
30 options, _ = parser.parse_args()
32 build_utils.MakeDirectory(os.path.dirname(options.output))
34 with open(options.ordered_libraries, 'r') as libfile:
35 libraries = json.load(libfile)
36 # Generates string of the form '= { "base", "net",
37 # "content_shell_content_view" }' from a list of the form ["libbase.so",
38 # libnet.so", "libcontent_shell_content_view.so"]
39 libraries = ['"' + lib[3:-3] + '"' for lib in libraries]
40 array = '= { ' + ', '.join(libraries) + '}';
42 with open(options.output, 'w') as header:
46 build_utils.Touch(options.stamp)
49 if __name__ == '__main__':
50 sys.exit(main(sys.argv))