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

Unified Diff: tools/BUILD_simulator.py

Issue 1298813002: Clean up BUILD_simulator.py (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-18 (Tuesday) 11:26:46 EDT 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/BUILD.public.expected ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/BUILD_simulator.py
diff --git a/tools/BUILD_simulator.py b/tools/BUILD_simulator.py
old mode 100644
new mode 100755
index 65e6b7d11ed769ce5369baffb3dfee644a7390ba..46d3cd79e7008511d4b322b4153ef488565c5da4
--- a/tools/BUILD_simulator.py
+++ b/tools/BUILD_simulator.py
@@ -10,33 +10,34 @@
# We start by adding some symbols to our namespace that BUILD.public calls.
-# We don't really care about this, so just no-op it.
-def exports_files(files):
+import glob
+import pprint
+
+def noop(*args, **kwargs):
pass
# Simulates BUILD file glob().
-def glob(include, exclude=()):
- from glob import glob as python_glob
-
+def BUILD_glob(include, exclude=()):
files = set()
for pattern in include:
- files.update(python_glob(pattern))
+ files.update(glob.glob(pattern))
for pattern in exclude:
- files.difference_update(python_glob(pattern))
+ files.difference_update(glob.glob(pattern))
return list(sorted(files))
-# We've put enough into our environment now to treat BUILD.public as if it were
-# Python code. This pulls its variable definitions (SRCS, HDRS, DEFINES, etc.)
-# into our local namespace.
-execfile('BUILD.public')
+# With these namespaces, we can treat BUILD.public as if it were
+# Python code. This pulls its variable definitions (SRCS, HDRS,
+# DEFINES, etc.) into local_names.
+global_names = {
+ 'exports_files': noop,
+ 'glob': BUILD_glob,
+}
+local_names = {}
+execfile('BUILD.public', global_names, local_names)
-# Pretty-print every variable whose name is COMPLETELY_UPPERCASE,
-# i.e. every variable from BUILD.public. This is obviously quite heuristic.
-from pprint import pprint
with open('tools/BUILD.public.expected', 'w') as out:
print >>out, "This file is auto-generated by tools/BUILD_simulator.py."
print >>out, "It expands BUILD.public to make it easy to see changes."
- for name, value in sorted(locals().items()):
- if name.isupper():
- print >>out, name, '= ',
- pprint(value, out)
+ for name, value in sorted(local_names.items()):
+ print >>out, name, '= ',
+ pprint.pprint(value, out)
« 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