summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary Oberbrunner <garyo@oberbrunner.com>2014-04-19 13:35:40 -0400
committerGary Oberbrunner <garyo@oberbrunner.com>2014-04-19 13:35:40 -0400
commitb5c114714edc311f750bdc2730315e905b8f4fa9 (patch)
tree1210878a18fd9910ed974455b0eda8a6848625ab
parent85fdb430f393ac98e576a840201c24ceed791a5c (diff)
parent6f7255096462195be3ea812b4dcf9dbee6d08ef0 (diff)
downloadscons-git-b5c114714edc311f750bdc2730315e905b8f4fa9.tar.gz
Merged in Syeberman/scons/msvs-vcvars-caching (pull request #105)
Add caching to MSCommon.script_env
-rw-r--r--src/engine/SCons/Tool/MSCommon/vc.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/engine/SCons/Tool/MSCommon/vc.py b/src/engine/SCons/Tool/MSCommon/vc.py
index 68ebbd3a9..97cb34902 100644
--- a/src/engine/SCons/Tool/MSCommon/vc.py
+++ b/src/engine/SCons/Tool/MSCommon/vc.py
@@ -305,8 +305,21 @@ 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 uses "tools='msvs'"
+# in multiple environments, for example:
+# env1 = Environment(tools='msvs')
+# env2 = Environment(tools='msvs')
+# we can greatly improve the speed of the second and subsequent Environment
+# (or Clone) calls by memoizing the environment variables set by vcvars*.bat.
+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()
@@ -423,7 +436,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