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

Unified Diff: build/secondary/tools/grit/stamp_grit_sources.py

Issue 407653003: Hook up .d files and outputs to grit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | « build/secondary/tools/grit/grit_rule.gni ('k') | chrome/browser/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/secondary/tools/grit/stamp_grit_sources.py
diff --git a/build/secondary/tools/grit/stamp_grit_sources.py b/build/secondary/tools/grit/stamp_grit_sources.py
new file mode 100644
index 0000000000000000000000000000000000000000..59eef88f83b1ab5dfe7ac0784e7621520d82208b
--- /dev/null
+++ b/build/secondary/tools/grit/stamp_grit_sources.py
@@ -0,0 +1,46 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
viettrungluu 2014/07/21 19:43:17 Please run pylint on this script.
brettw 2014/07/21 20:11:19 Done.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This script enumerates the files in the given directory, writing an empty
+# stamp file and a .d file listing the inputs required to make the stamp. This
+# allows us to dynamically depend on the grit sources without enumerating the
+# grit directory for every invocation of grit (which is what adding the source
+# files to every .grd file's .d file would entail) or shelling out to grit
+# synchronously during GN execution to get the list (which would be slow).
+#
+# Usage:
+# stamp_grit_sources.py <directory> <stamp-file> <.d-file>
viettrungluu 2014/07/21 19:43:17 It seems to me that this isn't very grit-specific
brettw 2014/07/21 20:11:19 Yes, I'm going to keep that in mind, but I don't w
+
+import os
+import sys
+
+def GritSourceFiles(grit_root_dir):
+ files = []
+ for root, dirs, filenames in os.walk(grit_root_dir):
viettrungluu 2014/07/21 19:43:17 It's conventional to use _ for any variable you're
brettw 2014/07/21 20:11:19 Done.
+ grit_src = [os.path.join(root, f) for f in filenames
+ if f.endswith('.py') and not f.endswith('_unittest.py')]
+ files.extend(grit_src)
+ files = [f.replace('\\', '/') for f in files]
+ return sorted(files)
+
+def WriteDepFile(dep_file, stamp_file, source_files):
+ with open(dep_file, "w") as f:
+ f.write(stamp_file)
+ f.write(": ")
+ f.write(' '.join(source_files))
+
+def WriteStampFile(stamp_file):
+ with open(stamp_file, "w"):
+ pass
+
+if len(sys.argv) != 4:
viettrungluu 2014/07/21 19:43:17 Please put all of this in a main() function (or Ma
brettw 2014/07/21 20:11:19 Done.
+ print "Error: expecting 3 args."
+ sys.exit(1)
+
+grit_root_dir = sys.argv[1]
+stamp_file = sys.argv[2]
+dep_file = sys.argv[3]
+
+WriteStampFile(stamp_file)
+WriteDepFile(dep_file, stamp_file, GritSourceFiles(grit_root_dir))
« no previous file with comments | « build/secondary/tools/grit/grit_rule.gni ('k') | chrome/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698