summaryrefslogtreecommitdiff
path: root/site_scons
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2017-04-05 18:10:19 -0400
committerAndrew Morrow <acm@mongodb.com>2017-04-06 14:31:32 -0400
commit7237623f2d067161b03d9489d052a33a5b2e059f (patch)
tree185ef009c29928ec937c6f1e881692ff74206301 /site_scons
parent865b400e4a74c3acb529d7bbba9d782e9db9fb11 (diff)
downloadmongo-7237623f2d067161b03d9489d052a33a5b2e059f.tar.gz
SERVER-28583 Split up mongo_scons_utils.py into site_scons/mongo
Diffstat (limited to 'site_scons')
-rw-r--r--site_scons/mongo/generators.py (renamed from site_scons/mongo_scons_utils.py)94
-rw-r--r--site_scons/mongo/toolchain.py41
2 files changed, 72 insertions, 63 deletions
diff --git a/site_scons/mongo_scons_utils.py b/site_scons/mongo/generators.py
index 69b81f751dd..c07e86a4d14 100644
--- a/site_scons/mongo_scons_utils.py
+++ b/site_scons/mongo/generators.py
@@ -1,6 +1,35 @@
+# -*- mode: python; -*-
+
import md5
-import subprocess
-import SCons.Action
+
+# Default and alternative generator definitions go here.
+
+# This is the tuple that will be returned by the buildInfo command and
+# printed by the --version command-line option to mongod.
+# Each tuple consists of:
+# key (string)
+# value (string)
+# should be included in buildInfo output (bool)
+# should be included in --version output (bool)
+# The values will be passed through env.subst, so you can use any SCons variables you
+# want to define them.
+def default_buildinfo_environment_data():
+ return (
+ ('distmod', '$MONGO_DISTMOD', True, True,),
+ ('distarch', '$MONGO_DISTARCH', True, True,),
+ ('cc', '$CC_VERSION', True, False,),
+ ('ccflags', '$CCFLAGS', True, False,),
+ ('cxx', '$CXX_VERSION', True, False,),
+ ('cxxflags', '$CXXFLAGS', True, False,),
+ ('linkflags', '$LINKFLAGS', True, False,),
+ ('target_arch', '$TARGET_ARCH', True, True,),
+ ('target_os', '$TARGET_OS', True, False,),
+ )
+
+# If you want buildInfo and --version to be relatively empty, set
+# MONGO_BUILDINFO_ENVIRONMENT_DATA = empty_buildinfo_environment_data()
+def empty_buildinfo_environment_data():
+ return ()
def default_variant_dir_generator(target, source, env, for_signature):
@@ -37,64 +66,3 @@ def os_specific_variant_dir_generator(target, source, env, for_signature):
return '-'.join([
env['TARGET_OS'],
default_variant_dir_generator(target, source, env, for_signature)])
-
-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))
-
-# This is the tuple that will be returned by the buildInfo command and
-# printed by the --version command-line option to mongod.
-# Each tuple consists of:
-# key (string)
-# value (string)
-# should be included in buildInfo output (bool)
-# should be included in --version output (bool)
-# The values will be passed through env.subst, so you can use any SCons variables you
-# want to define them.
-def default_buildinfo_environment_data():
- return (
- ('distmod', '$MONGO_DISTMOD', True, True,),
- ('distarch', '$MONGO_DISTARCH', True, True,),
- ('cc', '$CC_VERSION', True, False,),
- ('ccflags', '$CCFLAGS', True, False,),
- ('cxx', '$CXX_VERSION', True, False,),
- ('cxxflags', '$CXXFLAGS', True, False,),
- ('linkflags', '$LINKFLAGS', True, False,),
- ('target_arch', '$TARGET_ARCH', True, True,),
- ('target_os', '$TARGET_OS', True, False,),
- )
-
-# If you want buildInfo and --version to be relatively empty, set
-# env['MONGO_BUILDINFO_ENVIRONMENT_DATA'] = empty_buildinfo_environment_data()
-def empty_buildinfo_environment_data():
- return ()
diff --git a/site_scons/mongo/toolchain.py b/site_scons/mongo/toolchain.py
new file mode 100644
index 00000000000..ffa74f56f6f
--- /dev/null
+++ b/site_scons/mongo/toolchain.py
@@ -0,0 +1,41 @@
+# -*- 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))