Clean up BUILD_simulator.py
authorhalcanary <halcanary@google.com>
Tue, 18 Aug 2015 15:35:45 +0000 (08:35 -0700)
committerCommit bot <commit-bot@chromium.org>
Tue, 18 Aug 2015 15:35:45 +0000 (08:35 -0700)
Review URL: https://codereview.chromium.org/1298813002

tools/BUILD.public.expected
tools/BUILD_simulator.py [changed mode: 0644->0755]

index e7f3a098fcc4c8eae9900517bfc5a0997aa1c2da..18ee72f715e4ac3b26cf5ab4005b51a89857f839 100644 (file)
@@ -50,14 +50,11 @@ HDRS = ['include/animator/SkAnimator.h',
  'include/core/SkDrawFilter.h',
  'include/core/SkDrawLooper.h',
  'include/core/SkDrawable.h',
- 'include/core/SkEndian.h',
  'include/core/SkError.h',
  'include/core/SkFilterQuality.h',
  'include/core/SkFixed.h',
  'include/core/SkFlattenable.h',
  'include/core/SkFlattenableSerialization.h',
- 'include/core/SkFloatBits.h',
- 'include/core/SkFloatingPoint.h',
  'include/core/SkFont.h',
  'include/core/SkFontHost.h',
  'include/core/SkFontLCDConfig.h',
@@ -124,7 +121,6 @@ HDRS = ['include/animator/SkAnimator.h',
  'include/core/SkTypes.h',
  'include/core/SkUnPreMultiply.h',
  'include/core/SkUtils.h',
- 'include/core/SkWeakRefCnt.h',
  'include/core/SkWriteBuffer.h',
  'include/core/SkWriter32.h',
  'include/core/SkXfermode.h',
@@ -228,12 +224,15 @@ HDRS = ['include/animator/SkAnimator.h',
  'include/ports/SkTypeface_mac.h',
  'include/ports/SkTypeface_win.h',
  'include/private/SkChecksum.h',
+ 'include/private/SkFloatBits.h',
+ 'include/private/SkFloatingPoint.h',
  'include/private/SkFunction.h',
  'include/private/SkGpuFenceSync.h',
  'include/private/SkMiniRecorder.h',
  'include/private/SkRecords.h',
  'include/private/SkTHash.h',
  'include/private/SkTLogic.h',
+ 'include/private/SkWeakRefCnt.h',
  'include/svg/SkSVGCanvas.h',
  'include/utils/SkBoundaryPatch.h',
  'include/utils/SkCamera.h',
old mode 100644 (file)
new mode 100755 (executable)
index 65e6b7d..46d3cd7
 
 # 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)