summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SConstruct16
-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
3 files changed, 78 insertions, 73 deletions
diff --git a/SConstruct b/SConstruct
index ba567a001ca..dbe813eede4 100644
--- a/SConstruct
+++ b/SConstruct
@@ -24,6 +24,8 @@ DefaultEnvironment(tools=[])
# after calling DefaultEnvironment, for the sake of paranoia.
import mongo
import mongo.platform as mongo_platform
+import mongo.toolchain as mongo_toolchain
+import mongo.generators as mongo_generators
EnsurePythonVersion(2, 7)
EnsureSConsVersion(2, 5)
@@ -31,12 +33,6 @@ EnsureSConsVersion(2, 5)
from buildscripts import utils
from buildscripts import moduleconfig
-from mongo_scons_utils import (
- default_buildinfo_environment_data,
- default_variant_dir_generator,
- get_toolchain_ver,
-)
-
import libdeps
atexit.register(mongo.print_build_failures)
@@ -644,7 +640,7 @@ env_vars.Add('MAXLINELENGTH',
# default_buildinfo_environment_data() function for examples of how to use this.
env_vars.Add('MONGO_BUILDINFO_ENVIRONMENT_DATA',
help='Sets the info returned from the buildInfo command and --version command-line flag',
- default=default_buildinfo_environment_data())
+ default=mongo_generators.default_buildinfo_environment_data())
env_vars.Add('MONGO_DIST_SRC_PREFIX',
help='Sets the prefix for files in the source distribution archive',
@@ -727,7 +723,7 @@ env_vars.Add('TOOLS',
env_vars.Add('VARIANT_DIR',
help='Sets the name (or generator function) for the variant directory',
- default=default_variant_dir_generator,
+ default=mongo_generators.default_variant_dir_generator,
)
env_vars.Add('VERBOSE',
@@ -1115,8 +1111,8 @@ elif not detectConf.CheckForOS(env['TARGET_OS']):
detectConf.Finish()
-env['CC_VERSION'] = get_toolchain_ver(env, 'CC')
-env['CXX_VERSION'] = get_toolchain_ver(env, 'CXX')
+env['CC_VERSION'] = mongo_toolchain.get_toolchain_ver(env, 'CC')
+env['CXX_VERSION'] = mongo_toolchain.get_toolchain_ver(env, 'CXX')
if not env['HOST_ARCH']:
env['HOST_ARCH'] = env['TARGET_ARCH']
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))