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

Side by Side Diff: tools/BUILD_simulator.py

Issue 1298813002: Clean up BUILD_simulator.py (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2015 Google Inc. 3 # Copyright 2015 Google Inc.
4 # 4 #
5 # Use of this source code is governed by a BSD-style license that can be 5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file. 6 # found in the LICENSE file.
7 7
8 # This script does a very rough simulation of BUILD file expansion, 8 # This script does a very rough simulation of BUILD file expansion,
9 # mostly to see the effects of glob(). 9 # mostly to see the effects of glob().
10 10
11 # We start by adding some symbols to our namespace that BUILD.public calls. 11 # We start by adding some symbols to our namespace that BUILD.public calls.
12 12
13 from pprint import pprint
14 from glob import glob as python_glob
15
13 # We don't really care about this, so just no-op it. 16 # We don't really care about this, so just no-op it.
14 def exports_files(files): 17 def exports_files(files):
15 pass 18 pass
16 19
17 # Simulates BUILD file glob(). 20 # Simulates BUILD file glob().
18 def glob(include, exclude=()): 21 def glob(include, exclude=()):
19 from glob import glob as python_glob
20
21 files = set() 22 files = set()
22 for pattern in include: 23 for pattern in include:
23 files.update(python_glob(pattern)) 24 files.update(python_glob(pattern))
24 for pattern in exclude: 25 for pattern in exclude:
25 files.difference_update(python_glob(pattern)) 26 files.difference_update(python_glob(pattern))
26 return list(sorted(files)) 27 return list(sorted(files))
27 28
28 # We've put enough into our environment now to treat BUILD.public as if it were 29 # We've put enough into our environment now to treat BUILD.public as if it were
29 # Python code. This pulls its variable definitions (SRCS, HDRS, DEFINES, etc.) 30 # Python code. This pulls its variable definitions (SRCS, HDRS, DEFINES, etc.)
mtklein 2015/08/17 22:40:34 Update all the comments when we're settled?
hal.canary 2015/08/18 15:14:23 Done.
30 # into our local namespace. 31 # into our local namespace.
31 execfile('BUILD.public') 32 local_namespace = {}
33 execfile('BUILD.public', globals(), local_namespace)
mtklein 2015/08/17 22:40:34 Let's do this: from pprint import pprint from glo
hal.canary 2015/08/18 15:14:23 global is a keyword. Otherwise, done.
32 34
33 # Pretty-print every variable whose name is COMPLETELY_UPPERCASE,
34 # i.e. every variable from BUILD.public. This is obviously quite heuristic.
35 from pprint import pprint
36 with open('tools/BUILD.public.expected', 'w') as out: 35 with open('tools/BUILD.public.expected', 'w') as out:
37 print >>out, "This file is auto-generated by tools/BUILD_simulator.py." 36 print >>out, "This file is auto-generated by tools/BUILD_simulator.py."
38 print >>out, "It expands BUILD.public to make it easy to see changes." 37 print >>out, "It expands BUILD.public to make it easy to see changes."
39 for name, value in sorted(locals().items()): 38 for name, value in sorted(local_namespace.items()):
40 if name.isupper(): 39 print >>out, name, '= ',
41 print >>out, name, '= ', 40 pprint(value, out)
42 pprint(value, out)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698