OLD | NEW |
(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) |
OLD | NEW |