Chromium Code Reviews| 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 import json | |
| 8 import optparse | |
| 9 import os | |
| 10 import sys | |
| 11 | |
| 12 from pylib import build_utils | |
| 13 | |
| 14 | |
| 15 def main(argv): | |
| 16 parser = optparse.OptionParser() | |
| 17 | |
| 18 parser.add_option('--template', help='Path to the .java template file') | |
| 19 parser.add_option('--output', help='Path to generated .java file') | |
| 20 parser.add_option('--ordered-libraries', | |
| 21 help='Path to json file containing list of ordered libraries') | |
| 22 parser.add_option('--stamp', help='Path to touch on success') | |
|
bulach
2013/03/26 19:02:15
see below, I think we can simplify and make this a
| |
| 23 | |
| 24 # args should be the list of libraries in dependency order. | |
| 25 options, _ = parser.parse_args() | |
| 26 | |
| 27 build_utils.MakeDirectory(os.path.dirname(options.output)) | |
| 28 | |
| 29 with open(options.ordered_libraries, 'r') as libfile: | |
| 30 libraries = json.load(libfile) | |
| 31 # Generates string of the form '= { "base", "net", | |
| 32 # "content_shell_content_view" }' from a list of the form ["libbase.so", | |
| 33 # libnet.so", "libcontent_shell_content_view.so"] | |
| 34 libraries = ['"' + lib[3:-3] + '"' for lib in libraries] | |
| 35 array = '= { ' + ', '.join(libraries) + '}'; | |
| 36 | |
| 37 with open(options.template, 'r') as template: | |
| 38 with open(options.output, 'w') as output: | |
| 39 for line in template.readlines(): | |
| 40 # The template contains a line of the form: | |
| 41 # static String[] libraries /*****/; | |
| 42 output.write(line.replace('/*****/', array)) | |
| 43 | |
| 44 if options.stamp: | |
| 45 build_utils.Touch(options.stamp) | |
| 46 | |
| 47 | |
| 48 if __name__ == '__main__': | |
| 49 sys.exit(main(sys.argv)) | |
| 50 | |
| 51 | |
| OLD | NEW |