mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
SERVER-40782 Allow specifying explicit ICECC_VERSION on command line
This commit is contained in:
parent
f24d55df48
commit
2392f37fec
@ -757,6 +757,12 @@ env_vars.Add('ICECC_CREATE_ENV',
|
|||||||
env_vars.Add('ICECC_SCHEDULER',
|
env_vars.Add('ICECC_SCHEDULER',
|
||||||
help='Tell ICECC where the sceduler daemon is running')
|
help='Tell ICECC where the sceduler daemon is running')
|
||||||
|
|
||||||
|
env_vars.Add('ICECC_VERSION',
|
||||||
|
help='Tell ICECC where the compiler package is')
|
||||||
|
|
||||||
|
env_vars.Add('ICECC_VERSION_ARCH',
|
||||||
|
help='Tell ICECC the target archicture for the compiler package, if non-native')
|
||||||
|
|
||||||
env_vars.Add('LIBPATH',
|
env_vars.Add('LIBPATH',
|
||||||
help='Adds paths to the linker search path',
|
help='Adds paths to the linker search path',
|
||||||
converter=variable_shlex_converter)
|
converter=variable_shlex_converter)
|
||||||
|
@ -48,71 +48,115 @@ def generate(env):
|
|||||||
env['CC'] = env.WhereIs('$CC')
|
env['CC'] = env.WhereIs('$CC')
|
||||||
env['CXX'] = env.WhereIs('$CXX')
|
env['CXX'] = env.WhereIs('$CXX')
|
||||||
|
|
||||||
# Make a predictable name for the toolchain
|
if 'ICECC_VERSION' in env:
|
||||||
icecc_version_target_filename = env.subst('$CC$CXX').replace('/', '_')
|
# TODO:
|
||||||
icecc_version = env.Dir('$BUILD_ROOT/scons/icecc').File(icecc_version_target_filename)
|
#
|
||||||
|
# If ICECC_VERSION is a file, we are done. If it is a file
|
||||||
|
# URL, resolve it to a filesystem path. If it is a remote UTL,
|
||||||
|
# then fetch it to somewhere under $BUILD_ROOT/scons/icecc
|
||||||
|
# with its "correct" name (i.e. the md5 hash), and symlink it
|
||||||
|
# to some other deterministic name to use as icecc_version.
|
||||||
|
|
||||||
# Make an isolated environment so that our setting of ICECC_VERSION in the environment
|
pass
|
||||||
# doesn't appear when executing icecc_create_env
|
else:
|
||||||
toolchain_env = env.Clone()
|
# Make a predictable name for the toolchain
|
||||||
if toolchain_env.ToolchainIs('clang'):
|
icecc_version_target_filename = env.subst('$CC$CXX').replace('/', '_')
|
||||||
toolchain = env.Command(
|
icecc_version = env.Dir('$BUILD_ROOT/scons/icecc').File(icecc_version_target_filename)
|
||||||
target=icecc_version,
|
|
||||||
source=['$ICECC_CREATE_ENV', '$CC', '$CXX'],
|
# Make an isolated environment so that our setting of ICECC_VERSION in the environment
|
||||||
action=[
|
# doesn't appear when executing icecc_create_env
|
||||||
"${SOURCES[0]} --clang ${SOURCES[1].abspath} /bin/true $TARGET",
|
toolchain_env = env.Clone()
|
||||||
],
|
if toolchain_env.ToolchainIs('clang'):
|
||||||
)
|
toolchain = env.Command(
|
||||||
|
target=icecc_version,
|
||||||
|
source=[
|
||||||
|
'$ICECC_CREATE_ENV',
|
||||||
|
'$CC',
|
||||||
|
'$CXX'
|
||||||
|
],
|
||||||
|
action=[
|
||||||
|
"${SOURCES[0]} --clang ${SOURCES[1].abspath} /bin/true $TARGET",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
toolchain = toolchain_env.Command(
|
||||||
|
target=icecc_version,
|
||||||
|
source=[
|
||||||
|
'$ICECC_CREATE_ENV',
|
||||||
|
'$CC',
|
||||||
|
'$CXX'
|
||||||
|
],
|
||||||
|
action=[
|
||||||
|
"${SOURCES[0]} --gcc ${SOURCES[1].abspath} ${SOURCES[2].abspath} $TARGET",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create an emitter that makes all of the targets depend on the
|
||||||
|
# icecc_version_target (ensuring that we have read the link), which in turn
|
||||||
|
# depends on the toolchain (ensuring that we have packaged it).
|
||||||
|
def icecc_toolchain_dependency_emitter(target, source, env):
|
||||||
|
env.Requires(target, toolchain)
|
||||||
|
return target, source
|
||||||
|
|
||||||
|
# Cribbed from Tool/cc.py and Tool/c++.py. It would be better if
|
||||||
|
# we could obtain this from SCons.
|
||||||
|
_CSuffixes = ['.c']
|
||||||
|
if not SCons.Util.case_sensitive_suffixes('.c', '.C'):
|
||||||
|
_CSuffixes.append('.C')
|
||||||
|
|
||||||
|
_CXXSuffixes = ['.cpp', '.cc', '.cxx', '.c++', '.C++']
|
||||||
|
if SCons.Util.case_sensitive_suffixes('.c', '.C'):
|
||||||
|
_CXXSuffixes.append('.C')
|
||||||
|
|
||||||
|
suffixes = _CSuffixes + _CXXSuffixes
|
||||||
|
for object_builder in SCons.Tool.createObjBuilders(env):
|
||||||
|
emitterdict = object_builder.builder.emitter
|
||||||
|
for suffix in emitterdict.keys():
|
||||||
|
if not suffix in suffixes:
|
||||||
|
continue
|
||||||
|
base = emitterdict[suffix]
|
||||||
|
emitterdict[suffix] = SCons.Builder.ListEmitter([
|
||||||
|
base,
|
||||||
|
icecc_toolchain_dependency_emitter
|
||||||
|
])
|
||||||
|
|
||||||
|
# Add ICECC_VERSION to the environment, pointed at the generated
|
||||||
|
# file so that we can expand it in the realpath expressions for
|
||||||
|
# CXXCOM and friends below.
|
||||||
|
env['ICECC_VERSION'] = icecc_version
|
||||||
|
|
||||||
|
if env.ToolchainIs('clang'):
|
||||||
env['ENV']['ICECC_CLANG_REMOTE_CPP'] = 1
|
env['ENV']['ICECC_CLANG_REMOTE_CPP'] = 1
|
||||||
else:
|
else:
|
||||||
toolchain = toolchain_env.Command(
|
env.AppendUnique(
|
||||||
target=icecc_version, source=['$ICECC_CREATE_ENV', '$CC', '$CXX'], action=[
|
CCFLAGS=[
|
||||||
"${SOURCES[0]} --gcc ${SOURCES[1].abspath} ${SOURCES[2].abspath} $TARGET",
|
'-fdirectives-only'
|
||||||
])
|
]
|
||||||
env.AppendUnique(CCFLAGS=['-fdirectives-only'])
|
)
|
||||||
|
|
||||||
# Add ICECC_VERSION to the environment, pointed at the generated
|
|
||||||
# file so that we can expand it in the realpath expressions for
|
|
||||||
# CXXCOM and friends below.
|
|
||||||
env['ICECC_VERSION'] = icecc_version
|
|
||||||
|
|
||||||
if 'ICECC_SCHEDULER' in env:
|
if 'ICECC_SCHEDULER' in env:
|
||||||
env['ENV']['USE_SCHEDULER'] = env['ICECC_SCHEDULER']
|
env['ENV']['USE_SCHEDULER'] = env['ICECC_SCHEDULER']
|
||||||
|
|
||||||
# Create an emitter that makes all of the targets depend on the
|
# Not all platforms have the readlink utility, so create our own
|
||||||
# icecc_version_target (ensuring that we have read the link), which in turn
|
# generator for that.
|
||||||
# depends on the toolchain (ensuring that we have packaged it).
|
def icecc_version_gen(target, source, env, for_signature):
|
||||||
def icecc_toolchain_dependency_emitter(target, source, env):
|
f = env.File('$ICECC_VERSION')
|
||||||
env.Requires(target, toolchain)
|
if not f.islink():
|
||||||
return target, source
|
return f
|
||||||
|
return env.File(os.path.realpath(f.abspath))
|
||||||
|
env['ICECC_VERSION_GEN'] = icecc_version_gen
|
||||||
|
|
||||||
# Cribbed from Tool/cc.py and Tool/c++.py. It would be better if
|
def icecc_version_arch_gen(target, source, env, for_signature):
|
||||||
# we could obtain this from SCons.
|
if 'ICECC_VERSION_ARCH' in env:
|
||||||
_CSuffixes = ['.c']
|
return "${ICECC_VERSION_ARCH}:"
|
||||||
if not SCons.Util.case_sensitive_suffixes('.c', '.C'):
|
return str()
|
||||||
_CSuffixes.append('.C')
|
env['ICECC_VERSION_ARCH_GEN'] = icecc_version_arch_gen
|
||||||
|
|
||||||
_CXXSuffixes = ['.cpp', '.cc', '.cxx', '.c++', '.C++']
|
|
||||||
if SCons.Util.case_sensitive_suffixes('.c', '.C'):
|
|
||||||
_CXXSuffixes.append('.C')
|
|
||||||
|
|
||||||
suffixes = _CSuffixes + _CXXSuffixes
|
|
||||||
for object_builder in SCons.Tool.createObjBuilders(env):
|
|
||||||
emitterdict = object_builder.builder.emitter
|
|
||||||
for suffix in emitterdict.keys():
|
|
||||||
if not suffix in suffixes:
|
|
||||||
continue
|
|
||||||
base = emitterdict[suffix]
|
|
||||||
emitterdict[suffix] = SCons.Builder.ListEmitter([
|
|
||||||
base,
|
|
||||||
icecc_toolchain_dependency_emitter
|
|
||||||
])
|
|
||||||
|
|
||||||
# Make compile jobs flow through icecc
|
# Make compile jobs flow through icecc
|
||||||
env['CCCOM'] = '$( ICECC_VERSION=$$(realpath $ICECC_VERSION) $ICECC $) ' + env['CCCOM']
|
env['CCCOM'] = '$( ICECC_VERSION=${ICECC_VERSION_ARCH_GEN}${ICECC_VERSION_GEN} $ICECC $) ' + env['CCCOM']
|
||||||
env['CXXCOM'] = '$( ICECC_VERSION=$$(realpath $ICECC_VERSION) $ICECC $) ' + env['CXXCOM']
|
env['CXXCOM'] = '$( ICECC_VERSION=${ICECC_VERSION_ARCH_GEN}${ICECC_VERSION_GEN} $ICECC $) ' + env['CXXCOM']
|
||||||
env['SHCCCOM'] = '$( ICECC_VERSION=$$(realpath $ICECC_VERSION) $ICECC $) ' + env['SHCCCOM']
|
env['SHCCCOM'] = '$( ICECC_VERSION=${ICECC_VERSION_ARCH_GEN}${ICECC_VERSION_GEN} $ICECC $) ' + env['SHCCCOM']
|
||||||
env['SHCXXCOM'] = '$( ICECC_VERSION=$$(realpath $ICECC_VERSION) $ICECC $) ' + env['SHCXXCOM']
|
env['SHCXXCOM'] = '$( ICECC_VERSION=${ICECC_VERSION_ARCH_GEN}${ICECC_VERSION_GEN} $ICECC $) ' + env['SHCXXCOM']
|
||||||
|
|
||||||
# Make link like jobs flow through icerun so we don't kill the
|
# Make link like jobs flow through icerun so we don't kill the
|
||||||
# local machine.
|
# local machine.
|
||||||
|
Loading…
Reference in New Issue
Block a user