summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSye van der Veen <svanderveen@blackberry.com>2014-01-30 15:43:41 (GMT)
committerSye van der Veen <svanderveen@blackberry.com>2014-01-30 15:43:41 (GMT)
commitbf075e2a9c29b35fe8908d1b91c470c4b2c823a8 (patch)
treefb4c07034a066d1873246114d5832186f3290712 /src
parentcb44210566c28d16c1e2c91d898306ad539fa9f5 (diff)
downloadSCons-bf075e2a9c29b35fe8908d1b91c470c4b2c823a8.zip
SCons-bf075e2a9c29b35fe8908d1b91c470c4b2c823a8.tar.gz
SCons-bf075e2a9c29b35fe8908d1b91c470c4b2c823a8.tar.bz2
Add caching to MSCommon.script_env for builds that initialize the same MSVS/MSVC tool multiple times (in multiple environments, perhaps)
Diffstat (limited to 'src')
-rw-r--r--src/engine/SCons/Tool/MSCommon/vc.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py
index c970118..b5491b1 100644
--- a/src/engine/SCons/Tool/MSCommon/vc.py
+++ b/src/engine/SCons/Tool/MSCommon/vc.py
@@ -298,8 +298,18 @@ def reset_installed_vcs():
"""Make it try again to find VC. This is just for the tests."""
__INSTALLED_VCS_RUN = None
+# Running these batch files isn't cheap: most of the time spent in
+# msvs.generate() is due to vcvars*.bat. In a build that keeps separate
+# environments for debug and release, or perhaps builds against multiple
+# MSVS versions at once, we can save a lot of time by caching the output.
+script_env_stdout_cache = {}
def script_env(script, args=None):
- stdout = common.get_output(script, args)
+ cache_key = (script, args)
+ stdout = script_env_stdout_cache.get(cache_key, None)
+ if stdout is None:
+ stdout = common.get_output(script, args)
+ script_env_stdout_cache[cache_key] = stdout
+
# Stupid batch files do not set return code: we take a look at the
# beginning of the output for an error message instead
olines = stdout.splitlines()
@@ -416,7 +426,7 @@ def msvc_find_valid_batch_script(env,version):
if not vc_script and sdk_script:
debug('vc.py:msvc_find_valid_batch_script() use_script 4: trying sdk script: %s'%(sdk_script))
try:
- d = script_env(sdk_script,args=[])
+ d = script_env(sdk_script)
except BatchFileExecutionError,e:
debug('vc.py:msvc_find_valid_batch_script() use_script 5: failed running SDK script %s: Error:%s'%(repr(sdk_script),e))
continue