Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: Source/devtools/scripts/inline_js_imports.py

Issue 459833002: Revert of Revert of DevTools: Introduce module initializers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/devtools/scripts/concatenate_module_descriptors.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (C) 2011 Google Inc. All rights reserved. 3 # Copyright (C) 2011 Google Inc. All rights reserved.
4 # 4 #
5 # Redistribution and use in source and binary forms, with or without 5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are 6 # modification, are permitted provided that the following conditions are
7 # met: 7 # met:
8 # 8 #
9 # * Redistributions of source code must retain the above copyright 9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer. 10 # notice, this list of conditions and the following disclaimer.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 'check source tree for consistency' % 68 'check source tree for consistency' %
69 (import_file_name, input_file_name)) 69 (import_file_name, input_file_name))
70 import_file = open(full_path, 'r') 70 import_file = open(full_path, 'r')
71 import_script = import_file.read() 71 import_script = import_file.read()
72 import_file.close() 72 import_file.close()
73 return import_script 73 return import_script
74 74
75 output_script = re.sub(r'importScripts?\([\'"]([^\'"]+)[\'"]\)', replace, in put_script) 75 output_script = re.sub(r'importScripts?\([\'"]([^\'"]+)[\'"]\)', replace, in put_script)
76 if re.search("importScripts?\(\"", output_script): 76 if re.search("importScripts?\(\"", output_script):
77 raise Exception('Unresolved "importScript" statements found in "%s". ' 77 raise Exception('Unresolved "importScript" statements found in "%s". '
78 'Make sure you call "importScript" in module heads only. ' % 78 'Make sure you call "importScript" in module initializer s only.' %
79 (output_file_name)) 79 (output_file_name))
80 80
81 if os.path.exists(output_file_name): 81 if os.path.exists(output_file_name):
82 os.remove(output_file_name) 82 os.remove(output_file_name)
83 output_file = open(output_file_name, 'w') 83 output_file = open(output_file_name, 'w')
84 if not no_minify: 84 if not no_minify:
85 output_script = rjsmin.jsmin(output_script) 85 output_script = rjsmin.jsmin(output_script)
86 output_file.write(output_script) 86 output_file.write(output_script)
87 output_file.close() 87 output_file.close()
88 88
89 # Touch output file directory to make sure that Xcode will copy 89 # Touch output file directory to make sure that Xcode will copy
90 # modified resource files. 90 # modified resource files.
91 if sys.platform == 'darwin': 91 if sys.platform == 'darwin':
92 output_dir_name = os.path.dirname(output_file_name) 92 output_dir_name = os.path.dirname(output_file_name)
93 os.utime(output_dir_name, None) 93 os.utime(output_dir_name, None)
94 94
95 if __name__ == '__main__': 95 if __name__ == '__main__':
96 sys.exit(main(sys.argv)) 96 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « Source/devtools/scripts/concatenate_module_descriptors.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698