OLD | NEW |
1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import codecs | 5 import codecs |
6 import argparse | 6 import argparse |
7 import os | 7 import os |
8 import sys | 8 import sys |
9 | 9 |
10 import tvcm | 10 import py_vulcanize |
11 | 11 |
12 import tracing_project | 12 import tracing_project |
13 | 13 |
14 | 14 |
15 def Main(args): | 15 def Main(args): |
16 parser = argparse.ArgumentParser(usage='%(prog)s --outdir=<directory>') | 16 parser = argparse.ArgumentParser(usage='%(prog)s --outdir=<directory>') |
17 parser.add_argument('--outdir', dest='out_dir', | 17 parser.add_argument('--outdir', dest='out_dir', |
18 help='Where to place generated content') | 18 help='Where to place generated content') |
19 parser.add_argument('--no-min', default=False, action='store_true', | 19 parser.add_argument('--no-min', default=False, action='store_true', |
20 help='Skip minification') | 20 help='Skip minification') |
(...skipping 10 matching lines...) Expand all Loading... |
31 vulcanizer = project.CreateVulcanizer() | 31 vulcanizer = project.CreateVulcanizer() |
32 load_sequence = vulcanizer.CalcLoadSequenceForModuleNames(names) | 32 load_sequence = vulcanizer.CalcLoadSequenceForModuleNames(names) |
33 | 33 |
34 olddir = os.getcwd() | 34 olddir = os.getcwd() |
35 try: | 35 try: |
36 if not os.path.exists(args.out_dir): | 36 if not os.path.exists(args.out_dir): |
37 os.makedirs(args.out_dir) | 37 os.makedirs(args.out_dir) |
38 o = codecs.open(os.path.join(args.out_dir, 'about_tracing.html'), 'w', | 38 o = codecs.open(os.path.join(args.out_dir, 'about_tracing.html'), 'w', |
39 encoding='utf-8') | 39 encoding='utf-8') |
40 try: | 40 try: |
41 tvcm.GenerateStandaloneHTMLToFile( | 41 py_vulcanize.GenerateStandaloneHTMLToFile( |
42 o, | 42 o, |
43 load_sequence, | 43 load_sequence, |
44 title='chrome://tracing', | 44 title='chrome://tracing', |
45 flattened_js_url='tracing.js', | 45 flattened_js_url='tracing.js', |
46 minify=not args.no_min) | 46 minify=not args.no_min) |
47 except tvcm.module.DepsException, ex: | 47 except py_vulcanize.module.DepsException, ex: |
48 sys.stderr.write('Error: %s\n\n' % str(ex)) | 48 sys.stderr.write('Error: %s\n\n' % str(ex)) |
49 return 255 | 49 return 255 |
50 o.close() | 50 o.close() |
51 | 51 |
52 o = codecs.open(os.path.join(args.out_dir, 'about_tracing.js'), 'w', | 52 o = codecs.open(os.path.join(args.out_dir, 'about_tracing.js'), 'w', |
53 encoding='utf-8') | 53 encoding='utf-8') |
54 assert o.encoding == 'utf-8' | 54 assert o.encoding == 'utf-8' |
55 tvcm.GenerateJSToFile( | 55 py_vulcanize.GenerateJSToFile( |
56 o, | 56 o, |
57 load_sequence, | 57 load_sequence, |
58 use_include_tags_for_scripts=False, | 58 use_include_tags_for_scripts=False, |
59 dir_for_include_tag_root=args.out_dir, | 59 dir_for_include_tag_root=args.out_dir, |
60 minify=not args.no_min) | 60 minify=not args.no_min) |
61 o.close() | 61 o.close() |
62 | 62 |
63 finally: | 63 finally: |
64 os.chdir(olddir) | 64 os.chdir(olddir) |
65 | 65 |
66 return 0 | 66 return 0 |
OLD | NEW |