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

Side by Side Diff: tools/cc-frame-viewer/ccfv.py

Issue 15736032: Remove old cc-frame-viewer now that it is upstreamed into trace_viewer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | « tools/cc-frame-viewer/ccfv ('k') | tools/cc-frame-viewer/run_dev_server.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4 import optparse
5 import os
6 import sys
7
8 def Init():
9 chromeapp_path = os.path.abspath(
10 os.path.join(os.path.dirname(__file__),
11 'third_party', 'py-chrome-app'))
12 assert os.path.isdir(chromeapp_path)
13 sys.path.append(chromeapp_path)
14 Init()
15
16 import chromeapp
17 from build import parse_deps
18
19 srcdir = os.path.abspath(os.path.join(os.path.dirname(__file__), "src"))
20
21 js_warning_message = """/**
22 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
23 // Use of this source code is governed by a BSD-style license that can be
24 // found in the LICENSE file.
25
26 /* WARNING: This file is generated by ccfv.py
27 *
28 * Do not edit directly.
29 */
30 """
31
32 css_warning_message = """/**
33 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
34 * Use of this source code is governed by a BSD-style license that can be
35 * found in the LICENSE file. */
36
37 /* WARNING: This file is generated by ccfv.py
38 *
39 * Do not edit directly.
40 */
41 """
42
43 py_warning_message = """#!/usr/bin/env python
44 #
45 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
46 # Use of this source code is governed by a BSD-style license that can be
47 # found in the LICENSE file. */
48 #
49 # WARNING: This file is generated by ccfv.py
50 #
51 # Do not edit directly.
52 #
53 """
54
55 def _sopen(filename, mode):
56 if filename != '-':
57 return open(filename, mode)
58 return os.fdopen(os.dup(sys.stdout.fileno()), 'w')
59
60 def generate_css(input_filenames):
61 load_sequence = parse_deps.calc_load_sequence(input_filenames, srcdir)
62
63 style_sheet_chunks = [css_warning_message, '\n']
64 for module in load_sequence:
65 for style_sheet in module.style_sheets:
66 style_sheet_chunks.append("""%s\n""" % style_sheet.contents)
67
68 return ''.join(style_sheet_chunks)
69
70 def generate_js(input_filenames):
71 load_sequence = parse_deps.calc_load_sequence(input_filenames, srcdir)
72
73 js_chunks = [js_warning_message, '\n']
74 js_chunks.append("window.FLATTENED = {};\n")
75 js_chunks.append("window.FLATTENED_RAW_SCRIPTS = {};\n")
76
77 for module in load_sequence:
78 js_chunks.append("window.FLATTENED['%s'] = true;\n" % module.name)
79 for raw_script in module.dependent_raw_scripts:
80 js_chunks.append("window.FLATTENED_RAW_SCRIPTS['%s'] = true;\n" %
81 raw_script.name)
82
83 raw_scripts_that_have_been_written = set()
84 for module in load_sequence:
85 for raw_script in module.dependent_raw_scripts:
86 if raw_script.name in raw_scripts_that_have_been_written:
87 continue
88 js_chunks.append(raw_script.contents)
89 js_chunks.append("\n")
90 raw_scripts_that_have_been_written.add(raw_script.name)
91 js_chunks.append(module.contents)
92 js_chunks.append("\n")
93
94 return ''.join(js_chunks)
95
96 def Main(args):
97 parser = optparse.OptionParser('%prog <filename>')
98 parser.add_option('--debug', dest='debug_mode', action='store_true',
99 default=False, help='Enables debugging features')
100 options, args = parser.parse_args(args)
101 if len(args) != 1:
102 parser.error("argument required")
103 if not os.path.exists(args[0]):
104 parser.error("%s does not exist" % args[0])
105
106 manifest_file = os.path.join(os.path.dirname(__file__),
107 'app', 'manifest.json')
108 app = chromeapp.App('cc-frame-viewer',
109 manifest_file,
110 debug_mode=options.debug_mode)
111
112 def OnLoad(req):
113 with open(args[0], 'r') as f:
114 return f.read()
115
116 input_filenames = [os.path.join(srcdir, f)
117 for f in ['base.js', 'model_view.js']]
118 view_js_file = os.path.join(os.path.dirname(__file__),
119 'app', 'model_view.js')
120 view_css_file = os.path.join(os.path.dirname(__file__),
121 'app', 'model_view.css')
122 with open(view_js_file, 'w') as f:
123 f.write(generate_js(input_filenames))
124 with open(view_css_file, 'w') as f:
125 f.write(generate_css(input_filenames))
126
127 with chromeapp.AppInstance(app, []) as app_instance:
128 app_instance.AddListener('load', OnLoad)
129 try:
130 return app_instance.Run()
131 finally:
132 if os.path.exists(view_js_file):
133 os.unlink(view_js_file)
134 if os.path.exists(view_css_file):
135 os.unlink(view_css_file)
136
137
138 if __name__ == "__main__":
139 sys.exit(Main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « tools/cc-frame-viewer/ccfv ('k') | tools/cc-frame-viewer/run_dev_server.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698