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

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

Issue 472903003: DevTools: Get rid of module initializers in the source tree (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add missing worker module.json's to gypi 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
OLDNEW
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 """Inlines all module.json files into modules.js.""" 7 """Inlines all module.json files into "var allDescriptors" in Runtime.js."""
8 8
9 from os import path 9 from os import path
10 import errno 10 import errno
11 import os
12 import re
11 import shutil 13 import shutil
12 import sys 14 import sys
13 try: 15 try:
14 import simplejson as json 16 import simplejson as json
15 except ImportError: 17 except ImportError:
16 import json 18 import json
17 19
18 20
19 def read_file(filename): 21 def read_file(filename):
20 with open(filename, 'rt') as file: 22 with open(filename, 'rt') as file:
(...skipping 17 matching lines...) Expand all
38 module_json['scripts'] = [] 40 module_json['scripts'] = []
39 result.append(module_json) 41 result.append(module_json)
40 return json.dumps(result) 42 return json.dumps(result)
41 43
42 44
43 def main(argv): 45 def main(argv):
44 input_filename = argv[1] 46 input_filename = argv[1]
45 output_filename = argv[2] 47 output_filename = argv[2]
46 module_jsons = argv[3:] 48 module_jsons = argv[3:]
47 49
50 output_contents = re.sub('var allDescriptors = \[\];', 'var allDescriptors = %s;' % build_modules(module_jsons).replace("\\", "\\\\"), read_file(input_filen ame), 1)
51 if (path.exists(output_filename)):
52 os.remove(output_filename)
48 with open(output_filename, 'w') as output_file: 53 with open(output_filename, 'w') as output_file:
49 output_file.write('var allDescriptors=%s;' % build_modules(module_jsons) ) 54 output_file.write(output_contents)
50
51 55
52 if __name__ == '__main__': 56 if __name__ == '__main__':
53 sys.exit(main(sys.argv)) 57 sys.exit(main(sys.argv))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698