summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Script
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine/SCons/Script')
-rw-r--r--src/engine/SCons/Script/Main.py1
-rw-r--r--src/engine/SCons/Script/__init__.py19
2 files changed, 19 insertions, 1 deletions
diff --git a/src/engine/SCons/Script/Main.py b/src/engine/SCons/Script/Main.py
index f39375a..71f6d61 100644
--- a/src/engine/SCons/Script/Main.py
+++ b/src/engine/SCons/Script/Main.py
@@ -434,7 +434,6 @@ def _set_globals(options):
if "includes" in debug_values:
print_includes = 1
if "memoizer" in debug_values:
- SCons.Memoize.EnableCounting()
print_memoizer = 1
if "memory" in debug_values:
memory_stats = []
diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py
index d94fee2..7368c8c 100644
--- a/src/engine/SCons/Script/__init__.py
+++ b/src/engine/SCons/Script/__init__.py
@@ -39,9 +39,28 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import time
start_time = time.time()
+import os
import string
+import sys
import UserList
+# Special chicken-and-egg handling of the "--debug=memoizer" flags:
+# SCons.Memoize contains a metaclass implementation that affects how
+# the other classes are instantiated. The Memoizer handles optional
+# counting of the hits and misses by using a different, parallel set of
+# functions, so we don't slow down normal operation any more than we
+# have to. But if we wait to enable the counting until we've parsed
+# the command line options normally, it will be too late, because the
+# Memoizer will have already analyzed the classes that it's Memoizing
+# and bound the non-counting versions of the functions. So we have to
+# use a special-case, up-front check for the "--debug=memoizer" flag
+# and turn on Memoizer counting, if desired, before we import any of
+# the other modules that use it.
+sconsflags = string.split(os.environ.get('SCONSFLAGS', ''))
+if "--debug=memoizer" in sys.argv + sconsflags:
+ import SCons.Memoize
+ SCons.Memoize.EnableCounting()
+
import SCons.Action
import SCons.Builder
import SCons.Environment