summaryrefslogtreecommitdiff
path: root/site_scons/site_tools/ccache.py
diff options
context:
space:
mode:
authorMathew Robinson <mathew.robinson@mongodb.com>2020-01-07 18:48:42 +0000
committerevergreen <evergreen@mongodb.com>2020-01-07 18:48:42 +0000
commit16207c4fa75a8045f24126d768b0ba2e1ce32b1f (patch)
tree6df377ef6da81df1637ccaf95f40354f19af53d4 /site_scons/site_tools/ccache.py
parent71658c0e2edb8c900ced5098f3f5a146a2d649ea (diff)
downloadmongo-16207c4fa75a8045f24126d768b0ba2e1ce32b1f.tar.gz
SERVER-44947 Allow test execution selection by test source file name
Diffstat (limited to 'site_scons/site_tools/ccache.py')
-rw-r--r--site_scons/site_tools/ccache.py38
1 files changed, 22 insertions, 16 deletions
diff --git a/site_scons/site_tools/ccache.py b/site_scons/site_tools/ccache.py
index d5ff49c06cf..cabb2d316b5 100644
--- a/site_scons/site_tools/ccache.py
+++ b/site_scons/site_tools/ccache.py
@@ -21,17 +21,18 @@ import SCons
from pkg_resources import parse_version
# This is the oldest version of ccache that offers support for -gsplit-dwarf
-_ccache_version_min = parse_version('3.2.3')
+_ccache_version_min = parse_version("3.2.3")
_ccache_version_found = None
+
def exists(env):
"""Look for a viable ccache implementation that meets our version requirements."""
# If we already generated, we definitely exist
- if 'CCACHE_VERSION' in env:
+ if "CCACHE_VERSION" in env:
return True
- ccache = env.get('CCACHE', False)
+ ccache = env.get("CCACHE", False)
if not ccache:
return False
@@ -39,22 +40,26 @@ def exists(env):
if not ccache:
return False
- pipe = SCons.Action._subproc(env,
- SCons.Util.CLVar(ccache) + ['--version'], stdin='devnull',
- stderr='devnull', stdout=subprocess.PIPE)
+ pipe = SCons.Action._subproc(
+ env,
+ SCons.Util.CLVar(ccache) + ["--version"],
+ stdin="devnull",
+ stderr="devnull",
+ stdout=subprocess.PIPE,
+ )
if pipe.wait() != 0:
return False
validated = False
for line in pipe.stdout:
- line = line.decode('utf-8')
+ line = line.decode("utf-8")
if validated:
continue # consume all data
- version_banner = re.search(r'^ccache version', line)
+ version_banner = re.search(r"^ccache version", line)
if not version_banner:
continue
- ccache_version = re.split('ccache version (.+)', line)
+ ccache_version = re.split("ccache version (.+)", line)
if len(ccache_version) < 2:
continue
global _ccache_version_found
@@ -64,11 +69,12 @@ def exists(env):
return validated
+
def generate(env):
"""Add ccache support."""
# If we have already generated the tool, don't generate it again.
- if 'CCACHE_VERSION' in env:
+ if "CCACHE_VERSION" in env:
return
# If we can't find ccache, or it is too old a version, don't
@@ -81,18 +87,18 @@ def generate(env):
# if ccache is active. Looking at the CCACHE variable in the
# environment is not sufficient, since the user may have set it,
# but it doesn't work or is out of date.
- env['CCACHE_VERSION'] = _ccache_version_found
+ env["CCACHE_VERSION"] = _ccache_version_found
# ccache does not support response files so force scons to always
# use the full command
#
# Note: This only works for Python versions >= 3.5
- env['MAXLINELENGTH'] = math.inf
+ env["MAXLINELENGTH"] = math.inf
# Add ccache to the relevant command lines. Wrap the reference to
# ccache in the $( $) pattern so that turning ccache on or off
# doesn't invalidate your build.
- env['CCCOM'] = '$( $CCACHE $)' + env['CCCOM']
- env['CXXCOM'] = '$( $CCACHE $)' + env['CXXCOM']
- env['SHCCCOM'] = '$( $CCACHE $)' + env['SHCCCOM']
- env['SHCXXCOM'] = '$( $CCACHE $)' + env['SHCXXCOM']
+ env["CCCOM"] = "$( $CCACHE $)" + env["CCCOM"]
+ env["CXXCOM"] = "$( $CCACHE $)" + env["CXXCOM"]
+ env["SHCCCOM"] = "$( $CCACHE $)" + env["SHCCCOM"]
+ env["SHCXXCOM"] = "$( $CCACHE $)" + env["SHCXXCOM"]