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

Side by Side Diff: build/secondary/tools/grit/stamp_grit_sources.py

Issue 2350583002: Starting work on full GN build (Closed)
Patch Set: Fixes for Fuchsia and Flutter. Cleanup. Created 4 years, 3 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
« no previous file with comments | « build/secondary/tools/grit/repack.gni ('k') | build/toolchain/fnl/BUILD.gn » ('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 2014 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
5 # This script enumerates the files in the given directory, writing an empty
6 # stamp file and a .d file listing the inputs required to make the stamp. This
7 # allows us to dynamically depend on the grit sources without enumerating the
8 # grit directory for every invocation of grit (which is what adding the source
9 # files to every .grd file's .d file would entail) or shelling out to grit
10 # synchronously during GN execution to get the list (which would be slow).
11 #
12 # Usage:
13 # stamp_grit_sources.py <directory> <stamp-file> <.d-file>
14
15 import os
16 import sys
17
18 def GritSourceFiles(grit_root_dir):
19 files = []
20 for root, _, filenames in os.walk(grit_root_dir):
21 grit_src = [os.path.join(root, f) for f in filenames
22 if f.endswith('.py') and not f.endswith('_unittest.py')]
23 files.extend(grit_src)
24 files = [f.replace('\\', '/') for f in files]
25 return sorted(files)
26
27
28 def WriteDepFile(dep_file, stamp_file, source_files):
29 with open(dep_file, "w") as f:
30 f.write(stamp_file)
31 f.write(": ")
32 f.write(' '.join(source_files))
33
34
35 def WriteStampFile(stamp_file):
36 with open(stamp_file, "w"):
37 pass
38
39
40 def main(argv):
41 if len(argv) != 4:
42 print "Error: expecting 3 args."
43 return 1
44
45 grit_root_dir = sys.argv[1]
46 stamp_file = sys.argv[2]
47 dep_file = sys.argv[3]
48
49 WriteStampFile(stamp_file)
50 WriteDepFile(dep_file, stamp_file, GritSourceFiles(grit_root_dir))
51 return 0
52
53
54 if __name__ == '__main__':
55 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « build/secondary/tools/grit/repack.gni ('k') | build/toolchain/fnl/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698