0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-27 23:27:11 +01:00
mongodb/site_scons/mongo/toolchain.py
Steve McClure fedfb0e8e4 SERVER-90617: Enable python formatting checks for site_scons directory (#22301)
GitOrigin-RevId: 0cd9cfa93f7cbfee24b19f6795ae366d5fa94625
2024-05-19 00:00:43 +00:00

47 lines
1.3 KiB
Python

# -*- mode: python; -*-
import subprocess
import SCons
# Helper functions for generic toolchain things go here
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"):
proc = SCons.Action._subproc(
env,
env.subst("${%s} --version" % tool),
stdout=subprocess.PIPE,
stderr="devnull",
stdin="devnull",
universal_newlines=True,
error="raise",
shell=True,
)
verstr = proc.stdout.readline()
elif env.ToolchainIs("msvc") and env.TargetOSIs("windows"):
proc = SCons.Action._subproc(
env,
env.subst("${%s}" % tool),
stdout="devnull",
stderr=subprocess.PIPE,
stdin="devnull",
universal_newlines=True,
error="raise",
shell=True,
)
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))