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