| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 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 ''' Generates a deps.js file based on an input list of javascript files using | 7 ''' Generates a deps.js file based on an input list of javascript files using |
| 8 Closure style provide/require calls. | 8 Closure style provide/require calls. |
| 9 ''' | 9 ''' |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 'The resulting path is used in the deps mapping ' + | 35 'The resulting path is used in the deps mapping ' + |
| 36 'file path to a list of provided and required ' + | 36 'file path to a list of provided and required ' + |
| 37 'namespaces.')) | 37 'namespaces.')) |
| 38 parser.add_option('-o', '--output_file', action='store', default=[], | 38 parser.add_option('-o', '--output_file', action='store', default=[], |
| 39 metavar='SPEC', | 39 metavar='SPEC', |
| 40 help=('Where to output the generated deps file.')) | 40 help=('Where to output the generated deps file.')) |
| 41 options, args = parser.parse_args() | 41 options, args = parser.parse_args() |
| 42 | 42 |
| 43 path_rewriter = PathRewriter(options.prefix_map) | 43 path_rewriter = PathRewriter(options.prefix_map) |
| 44 | 44 |
| 45 # Create the generated deps file's parent directory. |
| 46 output_dir = os.path.dirname(os.path.abspath(options.output_file)) |
| 47 if not os.path.exists(output_dir): |
| 48 os.makedirs(output_dir) |
| 49 |
| 45 # Write the generated deps file. | 50 # Write the generated deps file. |
| 46 with open(options.output_file, 'w') as output: | 51 with open(options.output_file, 'w') as output: |
| 47 for path in args: | 52 for path in args: |
| 48 js_deps = source.Source(source.GetFileContents(path)) | 53 js_deps = source.Source(source.GetFileContents(path)) |
| 49 path = path_rewriter.RewritePath(path) | 54 path = path_rewriter.RewritePath(path) |
| 50 line = 'goog.addDependency(\'%s\', %s, %s);\n' % ( | 55 line = 'goog.addDependency(\'%s\', %s, %s);\n' % ( |
| 51 path, sorted(js_deps.provides), sorted(js_deps.requires)) | 56 path, sorted(js_deps.provides), sorted(js_deps.requires)) |
| 52 output.write(line) | 57 output.write(line) |
| 53 | 58 |
| 54 | 59 |
| 55 if __name__ == '__main__': | 60 if __name__ == '__main__': |
| 56 main() | 61 main() |
| OLD | NEW |