summaryrefslogtreecommitdiff
path: root/SConstruct
diff options
context:
space:
mode:
authorRyan Egesdahl <ryan.egesdahl@mongodb.com>2020-08-22 23:07:17 -0700
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-09 19:32:51 +0000
commit4853c612df5100278dc2f7f2c3d922bdb3c54b05 (patch)
tree5009b88740b9b2fc8d27ee6261d4465f605370e2 /SConstruct
parent59c563338ae7dc6106aff81071a3bfd7b7f0389c (diff)
downloadmongo-4853c612df5100278dc2f7f2c3d922bdb3c54b05.tar.gz
SERVER-47943 Make bad icecream and ccache paths fail hard
If CCACHE or ICECC are specified on the SCons command line but the paths given don't exist, the associated tool would simply be skipped. This caused confusion when users were expecting the tool to run and the compile would proceed without it. Now specifying an incorrect path to the tool will cause a configure failure. (cherry picked from commit ecc06d297844ec06d206d68e0759e2078cd272d2)
Diffstat (limited to 'SConstruct')
-rw-r--r--SConstruct50
1 files changed, 38 insertions, 12 deletions
diff --git a/SConstruct b/SConstruct
index f90ac61d791..604d67b43bb 100644
--- a/SConstruct
+++ b/SConstruct
@@ -801,6 +801,10 @@ env_vars.Add('ICECC_CREATE_ENV',
help='Tell SCons where icecc-create-env tool is',
default='icecc-create-env')
+env_vars.Add('ICECC_DEBUG',
+ help='Tell ICECC to create debug logs (auto, on/off true/false 1/0)',
+ default=False)
+
env_vars.Add('ICECC_SCHEDULER',
help='Tell ICECC where the sceduler daemon is running')
@@ -1166,18 +1170,32 @@ def conf_error(env, msg, *args):
env.AddMethod(fatal_error, 'FatalError')
env.AddMethod(conf_error, 'ConfError')
+def to_boolean(s):
+ if isinstance(s, bool):
+ return s
+ elif s.lower() in ('1', "on", "true", "yes"):
+ return True
+ elif s.lower() in ('0', "off", "false", "no"):
+ return False
+ raise ValueError(f'Invalid value {s}, must be a boolean-like string')
+
# Normalize the VERBOSE Option, and make its value available as a
# function.
if env['VERBOSE'] == "auto":
env['VERBOSE'] = not sys.stdout.isatty()
-elif env['VERBOSE'] in ('1', "ON", "on", "True", "true", True):
- env['VERBOSE'] = True
-elif env['VERBOSE'] in ('0', "OFF", "off", "False", "false", False):
- env['VERBOSE'] = False
else:
- env.FatalError("Invalid value {0} for VERBOSE Variable", env['VERBOSE'])
+ try:
+ env['VERBOSE'] = to_boolean(env['VERBOSE'])
+ except ValueError as e:
+ env.FatalError(f"Error setting VERBOSE variable: {e}")
env.AddMethod(lambda env: env['VERBOSE'], 'Verbose')
+# Normalize the ICECC_DEBUG option
+try:
+ env['ICECC_DEBUG'] = to_boolean(env['ICECC_DEBUG'])
+except ValueError as e:
+ env.FatalError("Error setting ICECC_DEBUG variable: {e}")
+
if has_option('variables-help'):
print(env_vars.GenerateHelpText(env))
Exit(0)
@@ -3851,20 +3869,28 @@ env = doConfigure( env )
env["NINJA_SYNTAX"] = "#site_scons/third_party/ninja_syntax.py"
-# Now that we are done with configure checks, enable ccache and
-# icecream if requested. If *both* icecream and ccache are requested,
-# ccache must be loaded first.
-env.Tool('ccache')
-
if env.ToolchainIs("clang"):
env["ICECC_COMPILER_TYPE"] = "clang"
elif env.ToolchainIs("gcc"):
env["ICECC_COMPILER_TYPE"] = "gcc"
+# Now that we are done with configure checks, enable ccache and
+# icecream if requested.
if get_option('build-tools') == 'next' or get_option('ninja') == 'next':
- env['ICECREAM_TARGET_DIR'] = '$BUILD_ROOT/scons/icecream'
- env.Tool('icecream', verbose=env.Verbose())
+ if 'CCACHE' in env and env['CCACHE']:
+ ccache = Tool('ccache')
+ if not ccache.exists(env):
+ env.FatalError(f"Failed to load ccache tool with CCACHE={env['CCACHE']}")
+ ccache(env)
+ if 'ICECC' in env and env['ICECC']:
+ env['ICECREAM_VERBOSE'] = env.Verbose()
+ env['ICECREAM_TARGET_DIR'] = '$BUILD_ROOT/scons/icecream'
+ icecream = Tool('icecream')
+ if not icecream.exists(env):
+ env.FatalError(f"Failed to load icecream tool with ICECC={env['ICECC']}")
+ icecream(env)
else:
+ env.Tool('ccache')
env.Tool('icecream')
# Defaults for SCons provided flags. SetOption only sets the option to our value