| OLD | NEW |
| 1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 189 |
| 190 | 190 |
| 191 ################################################################################ | 191 ################################################################################ |
| 192 | 192 |
| 193 def main(argv): | 193 def main(argv): |
| 194 # If file itself executed, cache templates | 194 # If file itself executed, cache templates |
| 195 try: | 195 try: |
| 196 cache_dir = argv[1] | 196 cache_dir = argv[1] |
| 197 dummy_filename = argv[2] | 197 dummy_filename = argv[2] |
| 198 except IndexError as err: | 198 except IndexError as err: |
| 199 print 'Usage: %s OUTPUT_DIR DUMMY_FILENAME' % argv[0] | 199 print 'Usage: %s CACHE_DIR DUMMY_FILENAME' % argv[0] |
| 200 return 1 | 200 return 1 |
| 201 | 201 |
| 202 # Cache templates | 202 # Cache templates |
| 203 jinja_env = initialize_jinja_env(cache_dir) | 203 jinja_env = initialize_jinja_env(cache_dir) |
| 204 template_filenames = [filename for filename in os.listdir(templates_dir) | 204 template_filenames = [filename for filename in os.listdir(templates_dir) |
| 205 # Skip .svn, directories, etc. | 205 # Skip .svn, directories, etc. |
| 206 if filename.endswith(('.cpp', '.h'))] | 206 if filename.endswith(('.cpp', '.h'))] |
| 207 for template_filename in template_filenames: | 207 for template_filename in template_filenames: |
| 208 jinja_env.get_template(template_filename) | 208 jinja_env.get_template(template_filename) |
| 209 | 209 |
| 210 # Create a dummy file as output for the build system, | 210 # Create a dummy file as output for the build system, |
| 211 # since filenames of individual cache files are unpredictable and opaque | 211 # since filenames of individual cache files are unpredictable and opaque |
| 212 # (they are hashes of the template path, which varies based on environment) | 212 # (they are hashes of the template path, which varies based on environment) |
| 213 with open(dummy_filename, 'w') as dummy_file: | 213 with open(dummy_filename, 'w') as dummy_file: |
| 214 pass # |open| creates or touches the file | 214 pass # |open| creates or touches the file |
| 215 | 215 |
| 216 | 216 |
| 217 if __name__ == '__main__': | 217 if __name__ == '__main__': |
| 218 sys.exit(main(sys.argv)) | 218 sys.exit(main(sys.argv)) |
| OLD | NEW |