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

Side by Side Diff: tools/cc-frame-viewer/build/calcdeps.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/build/__init__.py ('k') | tools/cc-frame-viewer/build/parse_deps.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 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5 import optparse
6 import parse_deps
7 import sys
8 import os
9
10 srcdir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../src"))
11
12 js_warning_message = (
13 """// Copyright (c) 2012 The Chromium Authors. All rights reserved.
14 // Use of this source code is governed by a BSD-style license that can be
15 // found in the LICENSE file.
16
17 /**
18 * WARNING: This file is generated by calcdeps.py
19 *
20 * Do not edit directly.
21 */
22 """)
23
24 def generate_deps_js():
25 all_filenames = []
26 for dirpath, dirnames, filenames in os.walk(srcdir):
27 for f in filenames:
28 all_filenames.append(os.path.join(dirpath, f))
29 filenames = [x for x in all_filenames if
30 os.path.splitext(x)[1] == ".js"]
31
32 filenames = [os.path.relpath(x) for x in filenames]
33 def ignored(x):
34 if os.path.basename(x).startswith('.'):
35 return True
36 return False
37 filenames = [x for x in filenames if not ignored(x)]
38
39 if "deps.js" in filenames:
40 filenames.remove("deps.js")
41
42 load_sequence = parse_deps.calc_load_sequence(filenames, srcdir)
43
44 chunks = [js_warning_message]
45 for module in load_sequence:
46 for dependent_module_name in module.dependent_module_names:
47 chunks.append("base.addModuleDependency(\n '%s',\n '%s');\n" % (
48 module.name, dependent_module_name));
49
50 for dependent_raw_script_name in module.dependent_raw_script_names:
51 chunks.append(
52 "base.addModuleRawScriptDependency(\n '%s',\n '%s');\n" % (
53 module.name, dependent_raw_script_name));
54
55 for style_sheet in module.style_sheets:
56 chunks.append("base.addModuleStylesheet(\n '%s',\n '%s');\n" % (
57 module.name, style_sheet.name));
58
59 result = "".join(chunks)
60 return result
61
62 def is_out_of_date():
63 olddir = os.getcwd()
64 try:
65 os.chdir(srcdir)
66
67 o = open(os.path.join(srcdir, "base", "deps.js"), 'r')
68 existing_deps_js = o.read()
69 o.close()
70
71 result_js = generate_deps_js()
72
73 if result_js != existing_deps_js:
74 return True
75
76 finally:
77 os.chdir(olddir)
78 return False
79
80 def regenerate_deps():
81 olddir = os.getcwd()
82 try:
83 os.chdir(srcdir)
84
85 try:
86 deps_js = generate_deps_js()
87 except parse_deps.DepsException, ex:
88 sys.stderr.write("Error: %s\n\n" % str(ex))
89 return 255
90
91 o = open(os.path.join(srcdir, "base", "deps.js"), 'w')
92 o.write(deps_js)
93 o.close()
94
95 finally:
96 os.chdir(olddir)
97
98 def main(args):
99 parser = optparse.OptionParser()
100 options, args = parser.parse_args(args)
101
102 regenerate_deps()
103
104 return 0
105
106 if __name__ == "__main__":
107 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « tools/cc-frame-viewer/build/__init__.py ('k') | tools/cc-frame-viewer/build/parse_deps.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698