| 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 """Renders one or more template files using the Jinja template engine.""" | 7 """Renders one or more template files using the Jinja template engine.""" |
| 8 | 8 |
| 9 import codecs | 9 import codecs |
| 10 import optparse | 10 import optparse |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 | 45 |
| 46 def ProcessFiles(env, input_filenames, loader_base_dir, inputs_base_dir, | 46 def ProcessFiles(env, input_filenames, loader_base_dir, inputs_base_dir, |
| 47 outputs_zip, variables): | 47 outputs_zip, variables): |
| 48 with build_utils.TempDir() as temp_dir: | 48 with build_utils.TempDir() as temp_dir: |
| 49 for input_filename in input_filenames: | 49 for input_filename in input_filenames: |
| 50 relpath = os.path.relpath(os.path.abspath(input_filename), | 50 relpath = os.path.relpath(os.path.abspath(input_filename), |
| 51 os.path.abspath(inputs_base_dir)) | 51 os.path.abspath(inputs_base_dir)) |
| 52 if relpath.startswith(os.pardir): | 52 if relpath.startswith(os.pardir): |
| 53 raise Exception('input file %s is not contained in inputs base dir %s' | 53 raise Exception('input file %s is not contained in inputs base dir %s' |
| 54 % input_filename, inputs_base_dir) | 54 % (input_filename, inputs_base_dir)) |
| 55 | 55 |
| 56 output_filename = os.path.join(temp_dir, relpath) | 56 output_filename = os.path.join(temp_dir, relpath) |
| 57 parent_dir = os.path.dirname(output_filename) | 57 parent_dir = os.path.dirname(output_filename) |
| 58 build_utils.MakeDirectory(parent_dir) | 58 build_utils.MakeDirectory(parent_dir) |
| 59 ProcessFile(env, input_filename, loader_base_dir, output_filename, | 59 ProcessFile(env, input_filename, loader_base_dir, output_filename, |
| 60 variables) | 60 variables) |
| 61 | 61 |
| 62 build_utils.ZipDir(outputs_zip, temp_dir) | 62 build_utils.ZipDir(outputs_zip, temp_dir) |
| 63 | 63 |
| 64 | 64 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 ProcessFiles(env, inputs, options.loader_base_dir, options.inputs_base_dir, | 112 ProcessFiles(env, inputs, options.loader_base_dir, options.inputs_base_dir, |
| 113 options.outputs_zip, variables) | 113 options.outputs_zip, variables) |
| 114 | 114 |
| 115 if options.depfile: | 115 if options.depfile: |
| 116 deps = loader.get_loaded_templates() + build_utils.GetPythonDependencies() | 116 deps = loader.get_loaded_templates() + build_utils.GetPythonDependencies() |
| 117 build_utils.WriteDepfile(options.depfile, deps) | 117 build_utils.WriteDepfile(options.depfile, deps) |
| 118 | 118 |
| 119 | 119 |
| 120 if __name__ == '__main__': | 120 if __name__ == '__main__': |
| 121 main() | 121 main() |
| OLD | NEW |