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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 # If file itself executed, cache templates | 190 # If file itself executed, cache templates |
191 try: | 191 try: |
192 cache_dir = argv[1] | 192 cache_dir = argv[1] |
193 dummy_filename = argv[2] | 193 dummy_filename = argv[2] |
194 except IndexError as err: | 194 except IndexError as err: |
195 print 'Usage: %s OUTPUT_DIR DUMMY_FILENAME' % argv[0] | 195 print 'Usage: %s OUTPUT_DIR DUMMY_FILENAME' % argv[0] |
196 return 1 | 196 return 1 |
197 | 197 |
198 # Cache templates | 198 # Cache templates |
199 jinja_env = initialize_jinja_env(cache_dir) | 199 jinja_env = initialize_jinja_env(cache_dir) |
200 for template_filename in os.listdir(templates_dir): | 200 template_filenames = [filename for filename in os.listdir(templates_dir) |
| 201 # Skip .svn, directories, etc. |
| 202 if filename.endswith(('.cpp', '.h'))] |
| 203 for template_filename in template_filenames: |
201 jinja_env.get_template(template_filename) | 204 jinja_env.get_template(template_filename) |
202 | 205 |
203 # Create a dummy file as output for the build system, | 206 # Create a dummy file as output for the build system, |
204 # since filenames of individual cache files are unpredictable and opaque | 207 # since filenames of individual cache files are unpredictable and opaque |
205 # (they are hashes of the template path, which varies based on environment) | 208 # (they are hashes of the template path, which varies based on environment) |
206 with open(dummy_filename, 'w') as dummy_file: | 209 with open(dummy_filename, 'w') as dummy_file: |
207 pass # |open| creates or touches the file | 210 pass # |open| creates or touches the file |
208 | 211 |
209 | 212 |
210 if __name__ == '__main__': | 213 if __name__ == '__main__': |
211 sys.exit(main(sys.argv)) | 214 sys.exit(main(sys.argv)) |
OLD | NEW |