2017-04-06 00:10:19 +02:00
|
|
|
# -*- mode: python; -*-
|
|
|
|
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
import SCons
|
|
|
|
|
|
|
|
# Helper functions for generic toolchain things go here
|
|
|
|
|
2019-02-19 16:50:57 +01:00
|
|
|
|
2017-04-06 00:10:19 +02:00
|
|
|
def get_toolchain_ver(env, tool):
|
|
|
|
# By default we don't know the version of each tool, and only report what
|
|
|
|
# command gets executed (gcc vs /opt/mongodbtoolchain/bin/gcc).
|
|
|
|
verstr = "version unknown"
|
|
|
|
proc = None
|
|
|
|
if env.ToolchainIs('clang', 'gcc'):
|
2019-02-19 16:50:57 +01:00
|
|
|
proc = SCons.Action._subproc(env, env.subst("${%s} --version" % tool),
|
|
|
|
stdout=subprocess.PIPE, stderr='devnull', stdin='devnull',
|
|
|
|
universal_newlines=True, error='raise', shell=True)
|
2017-04-06 00:10:19 +02:00
|
|
|
verstr = proc.stdout.readline()
|
|
|
|
|
|
|
|
elif env.ToolchainIs('msvc') and env.TargetOSIs('windows'):
|
2019-02-19 16:50:57 +01:00
|
|
|
proc = SCons.Action._subproc(env, env.subst("${%s}" % tool), stdout='devnull',
|
|
|
|
stderr=subprocess.PIPE, stdin='devnull',
|
|
|
|
universal_newlines=True, error='raise', shell=True)
|
2017-04-06 00:10:19 +02:00
|
|
|
verstr = proc.stderr.readline()
|
|
|
|
|
|
|
|
# If we started a process, we should drain its stdout/stderr and wait for
|
|
|
|
# it to end.
|
|
|
|
if proc:
|
|
|
|
proc.communicate()
|
|
|
|
|
|
|
|
return env.subst('${%s}: %s' % (tool, verstr))
|