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

Unified Diff: tools/cc-frame-viewer/build/calcdeps.py

Issue 12225131: [cc] Initial checkin of cc-frame-viewer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/cc-frame-viewer/build/calcdeps.py
diff --git a/tools/cc-frame-viewer/build/calcdeps.py b/tools/cc-frame-viewer/build/calcdeps.py
new file mode 100755
index 0000000000000000000000000000000000000000..b62a9129f84c9ad2d238117ca45688a88418c520
--- /dev/null
+++ b/tools/cc-frame-viewer/build/calcdeps.py
@@ -0,0 +1,107 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+import optparse
+import parse_deps
+import sys
+import os
+
+srcdir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../src"))
+
+js_warning_message = (
+"""// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * WARNING: This file is generated by calcdeps.py
+ *
+ * Do not edit directly.
+ */
+""")
+
+def generate_deps_js():
+ all_filenames = []
+ for dirpath, dirnames, filenames in os.walk(srcdir):
+ for f in filenames:
+ all_filenames.append(os.path.join(dirpath, f))
+ filenames = [x for x in all_filenames if
+ os.path.splitext(x)[1] == ".js"]
+
+ filenames = [os.path.relpath(x) for x in filenames]
+ def ignored(x):
+ if os.path.basename(x).startswith('.'):
+ return True
+ return False
+ filenames = [x for x in filenames if not ignored(x)]
+
+ if "deps.js" in filenames:
+ filenames.remove("deps.js")
+
+ load_sequence = parse_deps.calc_load_sequence(filenames, srcdir)
+
+ chunks = [js_warning_message]
+ for module in load_sequence:
+ for dependent_module_name in module.dependent_module_names:
+ chunks.append("base.addModuleDependency(\n '%s',\n '%s');\n" % (
+ module.name, dependent_module_name));
+
+ for dependent_raw_script_name in module.dependent_raw_script_names:
+ chunks.append(
+ "base.addModuleRawScriptDependency(\n '%s',\n '%s');\n" % (
+ module.name, dependent_raw_script_name));
+
+ for style_sheet in module.style_sheets:
+ chunks.append("base.addModuleStylesheet(\n '%s',\n '%s');\n" % (
+ module.name, style_sheet.name));
+
+ result = "".join(chunks)
+ return result
+
+def is_out_of_date():
+ olddir = os.getcwd()
+ try:
+ os.chdir(srcdir)
+
+ o = open(os.path.join(srcdir, "base", "deps.js"), 'r')
+ existing_deps_js = o.read()
+ o.close()
+
+ result_js = generate_deps_js()
+
+ if result_js != existing_deps_js:
+ return True
+
+ finally:
+ os.chdir(olddir)
+ return False
+
+def regenerate_deps():
+ olddir = os.getcwd()
+ try:
+ os.chdir(srcdir)
+
+ try:
+ deps_js = generate_deps_js()
+ except parse_deps.DepsException, ex:
+ sys.stderr.write("Error: %s\n\n" % str(ex))
+ return 255
+
+ o = open(os.path.join(srcdir, "base", "deps.js"), 'w')
+ o.write(deps_js)
+ o.close()
+
+ finally:
+ os.chdir(olddir)
+
+def main(args):
+ parser = optparse.OptionParser()
+ options, args = parser.parse_args(args)
+
+ regenerate_deps()
+
+ return 0
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv))
« 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