diff options
author | Ryan Egesdahl <ryan.egesdahl@mongodb.com> | 2020-08-22 23:07:17 -0700 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-09-03 19:38:16 +0000 |
commit | ecc06d297844ec06d206d68e0759e2078cd272d2 (patch) | |
tree | d04f17ce504779d1c0edff44bb178e184a2dfe21 /SConstruct | |
parent | b1920ea0a48a86bcd99eb5273ccbf12c008e4ed0 (diff) | |
download | mongo-ecc06d297844ec06d206d68e0759e2078cd272d2.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.
Diffstat (limited to 'SConstruct')
-rw-r--r-- | SConstruct | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/SConstruct b/SConstruct index b2e700ce664..91b8070f296 100644 --- a/SConstruct +++ b/SConstruct @@ -774,6 +774,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') @@ -1136,18 +1140,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) @@ -3937,20 +3955,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 |