| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 code + | 180 code + |
| 181 '#endif // %s\n' % conditional_string) | 181 '#endif // %s\n' % conditional_string) |
| 182 | 182 |
| 183 | 183 |
| 184 # [RuntimeEnabled] | 184 # [RuntimeEnabled] |
| 185 def runtime_enabled_if(code, runtime_enabled_function_name): | 185 def runtime_enabled_if(code, runtime_enabled_function_name): |
| 186 if not runtime_enabled_function_name: | 186 if not runtime_enabled_function_name: |
| 187 return code | 187 return code |
| 188 # Indent if statement to level of original code | 188 # Indent if statement to level of original code |
| 189 indent = re.match(' *', code).group(0) | 189 indent = re.match(' *', code).group(0) |
| 190 return ('%sif (%s())\n' % (indent, runtime_enabled_function_name) + | 190 return ('%sif (%s()) {\n' % (indent, runtime_enabled_function_name) + |
| 191 ' %s' % code) | 191 ' %s\n' % '\n '.join(code.splitlines()) + |
| 192 '%s}\n' % indent) |
| 192 | 193 |
| 193 | 194 |
| 194 ################################################################################ | 195 ################################################################################ |
| 195 | 196 |
| 196 def main(argv): | 197 def main(argv): |
| 197 # If file itself executed, cache templates | 198 # If file itself executed, cache templates |
| 198 try: | 199 try: |
| 199 cache_dir = argv[1] | 200 cache_dir = argv[1] |
| 200 dummy_filename = argv[2] | 201 dummy_filename = argv[2] |
| 201 except IndexError as err: | 202 except IndexError as err: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 212 | 213 |
| 213 # Create a dummy file as output for the build system, | 214 # Create a dummy file as output for the build system, |
| 214 # since filenames of individual cache files are unpredictable and opaque | 215 # since filenames of individual cache files are unpredictable and opaque |
| 215 # (they are hashes of the template path, which varies based on environment) | 216 # (they are hashes of the template path, which varies based on environment) |
| 216 with open(dummy_filename, 'w') as dummy_file: | 217 with open(dummy_filename, 'w') as dummy_file: |
| 217 pass # |open| creates or touches the file | 218 pass # |open| creates or touches the file |
| 218 | 219 |
| 219 | 220 |
| 220 if __name__ == '__main__': | 221 if __name__ == '__main__': |
| 221 sys.exit(main(sys.argv)) | 222 sys.exit(main(sys.argv)) |
| OLD | NEW |