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

Side by Side Diff: tools/BUILD_simulator.py

Issue 1290833003: Add a simple script to simulate BUILD file glob() expansion. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: spelling 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 | « tools/BUILD.public.expected ('k') | 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
(Empty)
1 #!/usr/bin/env python
2 #
3 # Copyright 2015 Google Inc.
4 #
5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file.
7
8 # This script does a very rough simulation of BUILD file expansion,
9 # mostly to see the effects of glob().
10
11 # We start by adding some symbols to our namespace that BUILD.public calls.
12
13 # We don't really care about this, so just no-op it.
14 def exports_files(files):
15 pass
16
17 # Simulates BUILD file glob().
18 def glob(include, exclude=()):
19 from glob import glob as python_glob
20
21 files = set()
22 for pattern in include:
23 files.update(python_glob(pattern))
24 for pattern in exclude:
25 files.difference_update(python_glob(pattern))
26 return list(sorted(files))
27
28 # 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 # into our local namespace.
31 execfile('BUILD.public')
32
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:
37 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."
39 for name, value in sorted(locals().items()):
40 if name.isupper():
41 print >>out, name, '= ',
42 pprint(value, out)
OLDNEW
« no previous file with comments | « tools/BUILD.public.expected ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698