summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Reams <jbreams@mongodb.com>2015-03-30 12:14:42 -0400
committerJonathan Reams <jbreams@mongodb.com>2015-03-30 12:14:42 -0400
commit06785ef692bae4beb4df859c3d4da2e0517ba0d5 (patch)
tree0e54cb8720569d302042c80dde66580420e203a1
parentc7ad4563a086eb9e9aeaf5f71e7e70b3b33a178a (diff)
downloadmongo-06785ef692bae4beb4df859c3d4da2e0517ba0d5.tar.gz
SERVER-9555 Better OS detection in scons
-rw-r--r--SConstruct238
-rw-r--r--etc/evergreen.yml2
-rw-r--r--src/mongo/SConscript39
-rw-r--r--src/mongo/db/storage/SConscript2
-rw-r--r--src/mongo/db/storage/storage_engine_lock_file_windows.cpp (renamed from src/mongo/db/storage/storage_engine_lock_file_win.cpp)0
-rw-r--r--src/mongo/installer/msi/SConscript1
-rw-r--r--src/mongo/util/mmap_windows.cpp (renamed from src/mongo/util/mmap_win.cpp)0
-rw-r--r--src/mongo/util/processinfo_linux.cpp (renamed from src/mongo/util/processinfo_linux2.cpp)0
-rw-r--r--src/mongo/util/processinfo_openbsd.cpp (renamed from src/mongo/util/processinfo_openbsd5.cpp)0
-rw-r--r--src/mongo/util/processinfo_osx.cpp (renamed from src/mongo/util/processinfo_darwin.cpp)0
-rw-r--r--src/mongo/util/processinfo_solaris.cpp (renamed from src/mongo/util/processinfo_sunos5.cpp)0
-rw-r--r--src/mongo/util/processinfo_unknown.cpp (renamed from src/mongo/util/processinfo_none.cpp)0
-rw-r--r--src/mongo/util/processinfo_windows.cpp (renamed from src/mongo/util/processinfo_win32.cpp)0
-rw-r--r--src/mongo/util/stacktrace_windows.cpp (renamed from src/mongo/util/stacktrace_win.cpp)0
-rw-r--r--src/third_party/SConscript6
-rw-r--r--src/third_party/boost-1.56.0/SConscript6
-rw-r--r--src/third_party/gperftools-2.2/SConscript1
-rw-r--r--src/third_party/pcre-8.36/SConscript6
-rw-r--r--src/third_party/s2/SConscript2
-rwxr-xr-xsrc/third_party/s2/base/SConscript2
-rwxr-xr-xsrc/third_party/s2/strings/SConscript2
-rwxr-xr-xsrc/third_party/s2/util/coding/SConscript2
-rwxr-xr-xsrc/third_party/s2/util/math/SConscript4
-rw-r--r--src/third_party/snappy-1.1.2/SConscript4
-rw-r--r--src/third_party/v8-3.25/SConscript22
-rw-r--r--src/third_party/v8/SConscript16
-rw-r--r--src/third_party/wiredtiger/SConscript19
-rw-r--r--src/third_party/zlib-1.2.8/SConscript4
28 files changed, 199 insertions, 179 deletions
diff --git a/SConstruct b/SConstruct
index f05ce32f9d1..541f675fa86 100644
--- a/SConstruct
+++ b/SConstruct
@@ -43,38 +43,58 @@ def findSettingsSetup():
def versiontuple(v):
return tuple(map(int, (v.split("."))))
-# --- platform identification ---
+# --- OS identification ---
#
# This needs to precede the options section so that we can only offer some options on certain
-# platforms.
-
-platform = os.sys.platform
-nix = False
-linux = False
-darwin = False
-windows = False
-freebsd = False
-openbsd = False
-solaris = False
-
-if "darwin" == platform:
- darwin = True
- platform = "osx" # prettier than darwin
-elif platform.startswith("linux"):
- linux = True
- platform = "linux"
-elif "sunos5" == platform:
- solaris = True
-elif platform.startswith( "freebsd" ):
- freebsd = True
-elif platform.startswith( "openbsd" ):
- openbsd = True
-elif "win32" == platform:
- windows = True
-else:
- print( "No special config for [" + platform + "] which probably means it won't work" )
+# operating systems.
+
+# This function gets the running OS as identified by Python
+# It should only be used to set up defaults for options/variables, because
+# its value could potentially be overridden by setting TARGET_OS on the
+# command-line. Treat this output as the value of HOST_OS
+def get_running_os_name():
+ running_os = os.sys.platform
+ if running_os.startswith('linux'):
+ running_os = 'linux'
+ elif running_os.startswith('freebsd'):
+ running_os = 'freebsd'
+ elif running_os.startswith('openbsd'):
+ running_os = 'openbsd'
+ elif running_os == 'sunos5':
+ running_os = 'solaris'
+ elif running_os == 'win32':
+ running_os = 'windows'
+ elif running_os == 'darwin':
+ running_os = 'osx'
+ else:
+ running_os = 'unknown'
+ return running_os
+
+def env_get_os_name_wrapper(self):
+ return env['TARGET_OS']
-nix = not windows
+def is_os_raw(target_os, os_list_to_check):
+ okay = False
+ posix_os_list = [ 'linux', 'openbsd', 'freebsd', 'osx', 'solaris' ]
+
+ for p in os_list_to_check:
+ if p == 'posix' and target_os in posix_os_list:
+ okay = True
+ break
+ elif p == target_os:
+ okay = True
+ break
+ return okay
+
+# This function tests the running OS as identified by Python
+# It should only be used to set up defaults for options/variables, because
+# its value could potentially be overridden by setting TARGET_OS on the
+# command-line. Treat this output as the value of HOST_OS
+def is_running_os(*os_list):
+ return is_os_raw(get_running_os_name(), os_list)
+
+def env_os_is_wrapper(self, *os_list):
+ return is_os_raw(self['TARGET_OS'], os_list)
# --- options ----
options = {}
@@ -168,7 +188,7 @@ def get_variant_dir():
s = "cached"
s += "/".join(extras) + "/"
else:
- s = "${PYSYSPLATFORM}/${TARGET_ARCH}/"
+ s = "${TARGET_ARCH}/"
a += extras
if len(a) > 0:
@@ -195,7 +215,7 @@ add_option( "variant-dir", "override variant subdirectory", 1, False )
# linking options
add_option( "release" , "release build" , 0 , True )
-add_option( "static-libstdc++" , "statically link libstdc++" , 0 , False )
+
add_option( "lto", "enable link time optimizations (experimental, except with MSVC)" , 0 , True )
add_option( "dynamic-windows", "dynamically link on Windows", 0, True)
@@ -245,7 +265,7 @@ add_option( "durableDefaultOn" , "have durable default to on" , 0 , True )
add_option( "durableDefaultOff" , "have durable default to off" , 0 , True )
# debugging/profiling help
-if os.sys.platform.startswith("linux"):
+if is_running_os('linux'):
defaultAllocator = 'tcmalloc'
else:
defaultAllocator = 'system'
@@ -307,22 +327,20 @@ add_option('propagate-shell-environment',
add_option('variables-help',
"Print the help text for SCons variables", 0, False)
-if darwin:
- add_option("osx-version-min", "minimum OS X version to support", 1, True)
-
-elif windows:
- win_version_min_choices = {
- 'xpsp3' : ('0501', '0300'),
- 'ws03sp2' : ('0502', '0200'),
- 'vista' : ('0600', '0000'),
- 'ws08r2' : ('0601', '0000'),
- 'win7' : ('0601', '0000'),
- 'win8' : ('0602', '0000'),
- }
+add_option("osx-version-min", "minimum OS X version to support", 1, True)
+
+win_version_min_choices = {
+ 'xpsp3' : ('0501', '0300'),
+ 'ws03sp2' : ('0502', '0200'),
+ 'vista' : ('0600', '0000'),
+ 'ws08r2' : ('0601', '0000'),
+ 'win7' : ('0601', '0000'),
+ 'win8' : ('0602', '0000'),
+}
- add_option("win-version-min", "minimum Windows version to support", 1, True,
- type = 'choice', default = None,
- choices = win_version_min_choices.keys())
+add_option("win-version-min", "minimum Windows version to support", 1, True,
+ type = 'choice', default = None,
+ choices = win_version_min_choices.keys())
add_option('cache',
"Use an object cache rather than a per-build variant directory (experimental)",
@@ -343,7 +361,7 @@ add_option('variable-parse-mode',
def variable_shlex_converter(val):
parse_mode = get_option('variable-parse-mode')
if parse_mode == 'auto':
- parse_mode = 'other' if windows else 'posix'
+ parse_mode = 'other' if is_running_os('windows') else 'posix'
return shlex.split(val, posix=(parse_mode == 'posix'))
def variable_arch_converter(val):
@@ -373,14 +391,12 @@ def variable_arch_converter(val):
# If we aren't on a platform where we know the minimal set of tools, we fall back to loading
# the 'default' tool.
def decide_platform_tools():
- if windows:
+ if is_running_os('windows'):
# we only support MS toolchain on windows
return ['msvc', 'mslink', 'mslib']
- elif linux:
- return ['gcc', 'g++', 'gnulink', 'ar']
- elif solaris:
+ elif is_running_os('linux', 'solaris'):
return ['gcc', 'g++', 'gnulink', 'ar']
- elif darwin:
+ elif is_running_os('osx'):
return ['gcc', 'g++', 'applelink', 'ar']
else:
return ["default"]
@@ -464,6 +480,11 @@ env_vars.Add('TARGET_ARCH',
converter=variable_arch_converter,
default=None)
+env_vars.Add('TARGET_OS',
+ help='Sets the target OS to build for',
+ default=get_running_os_name()
+)
+
env_vars.Add('TOOLS',
help='Sets the list of SCons tools to add to the environment',
converter=variable_tools_converter,
@@ -574,7 +595,6 @@ envDict = dict(BUILD_ROOT=buildDir,
# TODO: Move unittests.txt to $BUILD_DIR, but that requires
# changes to MCI.
UNITTEST_LIST='$BUILD_ROOT/unittests.txt',
- PYSYSPLATFORM=os.sys.platform,
PCRE_VERSION='8.36',
CONFIGUREDIR=sconsDataDir.Dir('sconf_temp'),
CONFIGURELOG=sconsDataDir.File('config.log'),
@@ -587,6 +607,9 @@ envDict = dict(BUILD_ROOT=buildDir,
env = Environment(variables=env_vars, **envDict)
del envDict
+env.AddMethod(env_os_is_wrapper, 'TargetOSIs')
+env.AddMethod(env_get_os_name_wrapper, 'GetTargetOSName')
+
if has_option('variables-help'):
print env_vars.GenerateHelpText(env)
Exit(0)
@@ -624,6 +647,7 @@ if has_option( "cc" ):
env["CC"] = get_option( "cc" )
detectEnv = env.Clone()
+
# Identify the toolchain in use. We currently support the following:
# These macros came from
# http://nadeausoftware.com/articles/2012/10/c_c_tip_how_detect_compiler_name_and_version_using_compiler_predefined_macros
@@ -692,9 +716,33 @@ def CheckForProcessor(context, which_arch):
context.Result('Could not detect processor model/architecture')
return False
+# Taken from http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system
+os_macros = {
+ "windows": "_WIN32",
+ "solaris": "__sun",
+ "freebsd": "__FreeBSD__",
+ "openbsd": "__OpenBSD__",
+ "osx": "__APPLE__",
+ "linux": "__linux__",
+}
+
+def CheckForOS(context, which_os):
+ test_body = """
+ #if defined({0})
+ /* detected {1} */
+ #else
+ #error
+ #endif
+ """.format(os_macros[which_os], which_os)
+ context.Message('Checking if target OS {0} is supported by the toolchain '.format(which_os))
+ ret = context.TryCompile(textwrap.dedent(test_body), ".c")
+ context.Result(ret)
+ return ret
+
detectConf = Configure(detectEnv, help=False, custom_tests = {
'CheckForToolchain' : CheckForToolchain,
'CheckForProcessor': CheckForProcessor,
+ 'CheckForOS': CheckForOS,
})
if not detectConf.CheckCXX():
@@ -705,8 +753,7 @@ if not detectConf.CheckCC():
Exit(1)
toolchain_search_sequence = [ "GCC", "clang" ]
-detected_toolchain = None
-if detectEnv['PYSYSPLATFORM'] == 'win32':
+if is_running_os('windows'):
toolchain_search_sequence = [ 'MSVC', 'clang', 'GCC' ]
for candidate_toolchain in toolchain_search_sequence:
if detectConf.CheckForToolchain(candidate_toolchain, "C++", "CXX", ".cpp"):
@@ -746,11 +793,22 @@ else:
Exit(1)
env['TARGET_ARCH'] = detected_processor
+if env['TARGET_OS'] not in os_macros:
+ print "No special config for [{0}] which probably means it won't work".format(env['TARGET_OS'])
+elif not detectConf.CheckForOS(env['TARGET_OS']):
+ print "TARGET_OS is not supported by compiler"
+ Exit(1)
+
detectConf.Finish()
if not env['HOST_ARCH']:
env['HOST_ARCH'] = env['TARGET_ARCH']
+# In some places we have POSIX vs Windows cpp files, and so there's an additional
+# env variable to interpolate their names in child sconscripts
+
+env['TARGET_OS_FAMILY'] = 'posix' if env.TargetOSIs('posix') else env.GetTargetOSName()
+
if has_option("cache"):
if has_option("release"):
print("Using the experimental --cache option is not permitted for --release builds")
@@ -811,23 +869,13 @@ if env['_LIBDEPS'] == '$_LIBDEPS_OBJS':
libdeps.setup_environment( env )
-if env['PYSYSPLATFORM'] == 'linux3':
- env['PYSYSPLATFORM'] = 'linux2'
-if 'freebsd' in env['PYSYSPLATFORM']:
- env['PYSYSPLATFORM'] = 'freebsd'
-
-if os.sys.platform == 'win32':
- env['OS_FAMILY'] = 'win'
-else:
- env['OS_FAMILY'] = 'posix'
-
-if env['PYSYSPLATFORM'] in ('linux2', 'freebsd'):
+if env.TargetOSIs('linux', 'freebsd'):
env['LINK_LIBGROUP_START'] = '-Wl,--start-group'
env['LINK_LIBGROUP_END'] = '-Wl,--end-group'
-elif env['PYSYSPLATFORM'] == 'darwin':
+elif env.TargetOSIs('osx'):
env['LINK_LIBGROUP_START'] = ''
env['LINK_LIBGROUP_END'] = ''
-elif env['PYSYSPLATFORM'].startswith('sunos'):
+elif env.TargetOSIs('solaris'):
env['LINK_LIBGROUP_START'] = '-z rescan'
env['LINK_LIBGROUP_END'] = ''
@@ -847,22 +895,20 @@ def filterExists(paths):
if debugBuild:
env.SetConfigHeaderDefine("MONGO_CONFIG_DEBUG_BUILD")
-if darwin:
- pass
-elif linux:
+if env.TargetOSIs('linux'):
env.Append( LIBS=['m'] )
-elif solaris:
+elif env.TargetOSIs('solaris'):
env.Append( LIBS=["socket","resolv","lgrp"] )
-elif freebsd:
+elif env.TargetOSIs('freebsd'):
env.Append( LIBS=[ "kvm" ] )
env.Append( CCFLAGS=[ "-fno-omit-frame-pointer" ] )
-elif openbsd:
+elif env.TargetOSIs('openbsd'):
env.Append( LIBS=[ "kvm" ] )
-elif windows:
+elif env.TargetOSIs('windows'):
dynamicCRT = has_option("dynamic-windows")
env['DIST_ARCHIVE_SUFFIX'] = '.zip'
@@ -1002,10 +1048,7 @@ elif windows:
env.Append(LIBS=['winmm.lib'])
env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
-if nix:
-
- if has_option( "static-libstdc++" ):
- env.Append( LINKFLAGS=["-static-libstdc++", "-static-libgcc"] )
+if env.TargetOSIs('posix'):
# -Winvalid-pch Warn if a precompiled header (see Precompiled Headers) is found in the search path but can't be used.
env.Append( CCFLAGS=["-fPIC",
@@ -1017,8 +1060,7 @@ if nix:
"-Wno-unknown-pragmas",
"-Winvalid-pch"] )
# env.Append( " -Wconversion" ) TODO: this doesn't really work yet
- if linux or darwin:
- env.Append( CCFLAGS=["-pipe"] )
+ if env.TargetOSIs('linux', 'osx'):
if not has_option("disable-warnings-as-errors"):
env.Append( CCFLAGS=["-Werror"] )
@@ -1030,14 +1072,12 @@ if nix:
#
# TODO: Is it necessary to add to both linkflags and shlinkflags, or are LINKFLAGS
# propagated to SHLINKFLAGS?
- if darwin:
+ if env.TargetOSIs('osx'):
env.Append( LINKFLAGS=["-Wl,-bind_at_load"] )
env.Append( SHLINKFLAGS=["-Wl,-bind_at_load"] )
else:
env.Append( LINKFLAGS=["-Wl,-z,now"] )
env.Append( SHLINKFLAGS=["-Wl,-z,now"] )
-
- if not darwin:
env.Append( LINKFLAGS=["-rdynamic"] )
env.Append( LIBS=[] )
@@ -1049,12 +1089,12 @@ if nix:
except KeyError:
pass
- if linux and has_option( "gcov" ):
+ if env.TargetOSIs('linux') and has_option( "gcov" ):
env.Append( CXXFLAGS=" -fprofile-arcs -ftest-coverage " )
env.Append( LINKFLAGS=" -fprofile-arcs -ftest-coverage " )
if optBuild:
- env.Append( CCFLAGS=["-O3"] )
+ env.Append( CCFLAGS=["-O2"] )
else:
env.Append( CCFLAGS=["-O0"] )
@@ -1063,12 +1103,11 @@ if nix:
env.Append( CCFLAGS=["-fstack-protector"] )
env.Append( LINKFLAGS=["-fstack-protector"] )
env.Append( SHLINKFLAGS=["-fstack-protector"] )
- env['ENV']['GLIBCXX_FORCE_NEW'] = 1; # play nice with valgrind
if has_option( "ssl" ):
env.SetConfigHeaderDefine("MONGO_CONFIG_SSL")
env.Append( MONGO_CRYPTO=["openssl"] )
- if windows:
+ if env.TargetOSIs('windows'):
env.Append( LIBS=["libeay32"] )
env.Append( LIBS=["ssleay32"] )
else:
@@ -1110,7 +1149,7 @@ try:
except OSError:
pass
-if not windows:
+if not env.TargetOSIs('windows'):
for keysuffix in [ "1" , "2" ]:
keyfile = "jstests/libs/key%s" % keysuffix
os.chmod( keyfile , stat.S_IWUSR|stat.S_IRUSR )
@@ -1241,7 +1280,7 @@ def doConfigure(myenv):
# Vista respectively. Finally, if they haven't done either of these, try invoking the
# compiler to figure out whether we are doing a 32 or 64 bit build and select as
# appropriate.
- if windows:
+ if env.TargetOSIs('windows'):
win_version_min = None
if has_option('win-version-min'):
win_version_min = get_option('win-version-min')
@@ -1375,7 +1414,7 @@ def doConfigure(myenv):
conf.Finish()
# This needs to happen before we check for libc++, since it affects whether libc++ is available.
- if darwin and has_option('osx-version-min'):
+ if env.TargetOSIs('osx') and has_option('osx-version-min'):
min_version = get_option('osx-version-min')
min_version_flag = '-mmacosx-version-min=%s' % (min_version)
if not AddToCCFLAGSIfSupported(myenv, min_version_flag):
@@ -1388,7 +1427,7 @@ def doConfigure(myenv):
if not myenv.ToolchainIs('clang'):
print( 'libc++ is currently only supported for clang')
Exit(1)
- if darwin and has_option('osx-version-min') and versiontuple(min_version) < versiontuple('10.7'):
+ if env.TargetOSIs('osx') and has_option('osx-version-min') and versiontuple(min_version) < versiontuple('10.7'):
print("Warning: You passed option 'libc++'. You probably want to also pass 'osx-version-min=10.7' or higher for libc++ support.")
if AddToCXXFLAGSIfSupported(myenv, '-stdlib=libc++'):
myenv.Append(LINKFLAGS=['-stdlib=libc++'])
@@ -1704,8 +1743,8 @@ def doConfigure(myenv):
printf("Don't know how to enable --lto on current toolchain")
Exit(1)
- # glibc's memcmp is faster than gcc's
- if linux:
+ # We set this to work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43052
+ if not myenv.ToolchainIs('msvc'):
AddToCCFLAGSIfSupported(myenv, "-fno-builtin-memcmp")
# When using msvc, check for support for __declspec(thread), unless we have been asked
@@ -1899,7 +1938,7 @@ def doConfigure(myenv):
conf.env["_HAVEPCAP"] = conf.CheckLib( ["pcap", "wpcap"], autoadd=False )
- if solaris:
+ if env.TargetOSIs('solaris'):
conf.CheckLib( "nsl" )
if usev8 and use_system_version_of_library("v8"):
@@ -1919,7 +1958,7 @@ def doConfigure(myenv):
Exit(1)
# requires ports devel/libexecinfo to be installed
- if freebsd or openbsd:
+ if env.TargetOSIs('freebsd', 'openbsd'):
if not conf.CheckLib("execinfo"):
print("Cannot find libexecinfo, please install devel/libexecinfo.")
Exit(1)
@@ -1992,10 +2031,10 @@ env.AlwaysBuild( "lint" )
def getSystemInstallName():
dist_arch = GetOption("distarch")
arch_name = env['TARGET_ARCH'] if not dist_arch else dist_arch
- n = platform + "-" + arch_name
+ n = env.GetTargetOSName() + "-" + arch_name
if has_option("nostrip"):
n += "-debugsymbols"
- if nix and os.uname()[2].startswith("8."):
+ if env.TargetOSIs('posix') and os.uname()[2].startswith("8."):
n += "-tiger"
if len(mongo_modules):
@@ -2129,7 +2168,6 @@ Export("serverJs")
Export("usev8")
Export("v8version v8suffix")
Export("boostSuffix")
-Export("darwin windows solaris linux freebsd nix openbsd")
Export('module_sconscripts')
Export("debugBuild optBuild")
Export("s3push")
diff --git a/etc/evergreen.yml b/etc/evergreen.yml
index 272d14578ec..77be70993c9 100644
--- a/etc/evergreen.yml
+++ b/etc/evergreen.yml
@@ -3359,7 +3359,7 @@ buildvariants:
push_bucket: downloads.mongodb.org
push_name: sunos5
push_arch: x86_64
- compile_flags: --cc=/opt/mongodbtoolchain/bin/gcc --cxx=/opt/mongodbtoolchain/bin/g++ --static-libstdc++ -j$(kstat cpu | sort -u | grep -c "^module") --release CCFLAGS="-m64" LINKFLAGS="-m64"
+ compile_flags: --cc=/opt/mongodbtoolchain/bin/gcc --cxx=/opt/mongodbtoolchain/bin/g++ -j$(kstat cpu | sort -u | grep -c "^module") --release CCFLAGS="-m64" LINKFLAGS="-m64 -static-libstdc++ -static-libgcc"
test_flags: --continue-on-failure
has_debugsymbols: true
tasks:
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
index 6826423bced..c26fe00f600 100644
--- a/src/mongo/SConscript
+++ b/src/mongo/SConscript
@@ -13,7 +13,6 @@ Import("get_option")
Import("serverJs")
Import("usev8")
Import("v8suffix")
-Import("darwin windows solaris linux nix")
Import("wiredtiger")
# Boost we need everywhere. 's2' is spammed in all over the place by
@@ -349,7 +348,7 @@ env.Library('lasterror', [
])
def getSysInfo():
- if windows:
+ if env.TargetOSIs("windows"):
return "windows " + str( sys.getwindowsversion() )
else:
return " ".join( os.uname() )
@@ -428,7 +427,7 @@ extraCommonLibdeps = []
if env['MONGO_BUILD_SASL_CLIENT']:
saslLibs = ['sasl2']
- if env['PYSYSPLATFORM'] == "win32":
+ if env.TargetOSIs('windows'):
saslLibs.extend(["secur32"])
env.Library('cyrus_sasl_client_session',
@@ -443,18 +442,8 @@ if env['MONGO_BUILD_SASL_CLIENT']:
extraCommonLibdeps.append('cyrus_sasl_client_session')
# handle processinfo*
-processInfoFiles = [ "util/processinfo.cpp" ]
-
-processInfoPlatformFile = env.File( "util/processinfo_${PYSYSPLATFORM}.cpp" )
-# NOTE( schwerin ): This is a very un-scons-y way to make this decision, and prevents one from using
-# code generation to produce util/processinfo_$PYSYSPLATFORM.cpp.
-if not os.path.exists( str( processInfoPlatformFile ) ):
- processInfoPlatformFile = env.File( "util/processinfo_none.cpp" )
-
-processInfoFiles.append( processInfoPlatformFile )
-
env.Library("processinfo",
- processInfoFiles,
+ [ "util/processinfo.cpp", "util/processinfo_${TARGET_OS}.cpp" ],
LIBDEPS=["foundation", "bson"])
env.CppUnitTest("processinfo_test",
@@ -605,7 +594,7 @@ coredbEnv.Library("coredb", [
env.Library('ntservice', ['util/ntservice.cpp'],
LIBDEPS=['foundation',
'$BUILD_DIR/mongo/util/options_parser/options_parser'])
-if windows:
+if env.TargetOSIs('windows'):
env.CppUnitTest('ntservice_test', 'util/ntservice_test.cpp',
LIBDEPS=['ntservice'],
LIBS=['shell32', env['LIBS']],
@@ -691,7 +680,7 @@ env.Library('global_environment_experiment',
'db/global_environment_noop.cpp' ])
# Memory-mapped files support. Used by mongod and some tools.
-env.Library('mmap', ['util/mmap.cpp', 'util/mmap_${OS_FAMILY}.cpp'], LIBDEPS=['foundation'])
+env.Library('mmap', ['util/mmap.cpp', 'util/mmap_${TARGET_OS_FAMILY}.cpp'], LIBDEPS=['foundation'])
env.Library('elapsed_tracker',
['util/elapsed_tracker.cpp'],
@@ -850,7 +839,7 @@ env.CppUnitTest('server_options_test', 'db/server_options_test.cpp',
env.CppUnitTest('v8_deadline_monitor_test', 'scripting/v8_deadline_monitor_test.cpp', LIBDEPS=[])
env.Library('stacktrace',
- 'util/stacktrace_${OS_FAMILY}.cpp',
+ 'util/stacktrace_${TARGET_OS_FAMILY}.cpp',
LIBDEPS=['bson',
'stringutils',
'version',
@@ -1263,12 +1252,12 @@ env.Alias('file_allocator_bench', "$BUILD_ROOT/" + add_exe("file_allocator_bench
# --- sniffer ---
mongosniff_built = False
-if darwin or env["_HAVEPCAP"]:
+if env.TargetOSIs('osx') or env["_HAVEPCAP"]:
mongosniff_built = True
sniffEnv = env.Clone()
sniffEnv.Append( CPPDEFINES="MONGO_EXPOSE_MACROS" )
- if not windows:
+ if not env.TargetOSIs('windows'):
sniffEnv.Append( LIBS=[ "pcap" ] )
else:
sniffEnv.Append( LIBS=[ "wpcap" ] )
@@ -1345,8 +1334,8 @@ if not has_option('noshell') and usev8:
LIBDEPS=['$BUILD_DIR/mongo/util/options_parser/options_parser_init'])
shellEnv = env.Clone()
- if windows:
- shellEnv.Append(LIBS=["winmm.lib"])
+ if env.TargetOSIs('windows'):
+ shellEnv.Append(LIBS=["winmm.lib"])
mongo_shell = shellEnv.Program(
"mongo",
@@ -1366,20 +1355,20 @@ else:
distBinaries = []
-if windows:
+if env.TargetOSIs('windows'):
distBinaries.extend(['mongod.pdb', 'mongos.pdb'])
def installBinary( e, name ):
name = add_exe( name )
- if (solaris or linux) and (not has_option("nostrip")):
+ if env.TargetOSIs('solaris', 'linux') and (not has_option("nostrip")):
name = e.Command('stripped/%s' % name, name, Copy('$TARGET', '$SOURCE'))[0]
e.AddPostAction(name, 'strip $TARGET')
distBinaries.append(name)
inst = e.Install( "$INSTALL_DIR/bin", name )
- if nix:
+ if env.TargetOSIs('posix'):
e.AddPostAction( inst, 'chmod 755 $TARGET' )
def installExternalBinary( e, name_str ):
@@ -1391,7 +1380,7 @@ def installExternalBinary( e, name_str ):
distBinaries.append(name)
inst = e.Install( "$INSTALL_DIR/bin", name )
- if nix:
+ if env.TargetOSIs('posix'):
e.AddPostAction( inst, 'chmod 755 $TARGET' )
diff --git a/src/mongo/db/storage/SConscript b/src/mongo/db/storage/SConscript
index 650942070c5..cefbcf752f5 100644
--- a/src/mongo/db/storage/SConscript
+++ b/src/mongo/db/storage/SConscript
@@ -82,7 +82,7 @@ env.Library(
env.Library(
target='storage_engine_lock_file',
source=[
- 'storage_engine_lock_file_${OS_FAMILY}.cpp',
+ 'storage_engine_lock_file_${TARGET_OS_FAMILY}.cpp',
],
LIBDEPS=[
]
diff --git a/src/mongo/db/storage/storage_engine_lock_file_win.cpp b/src/mongo/db/storage/storage_engine_lock_file_windows.cpp
index 41fc74ea736..41fc74ea736 100644
--- a/src/mongo/db/storage/storage_engine_lock_file_win.cpp
+++ b/src/mongo/db/storage/storage_engine_lock_file_windows.cpp
diff --git a/src/mongo/installer/msi/SConscript b/src/mongo/installer/msi/SConscript
index 984a709178e..fd3124d4a8b 100644
--- a/src/mongo/installer/msi/SConscript
+++ b/src/mongo/installer/msi/SConscript
@@ -3,7 +3,6 @@
import os
Import("env")
-Import("windows")
Import("s3push")
Import("has_option")
diff --git a/src/mongo/util/mmap_win.cpp b/src/mongo/util/mmap_windows.cpp
index 86e6c1e6b6b..86e6c1e6b6b 100644
--- a/src/mongo/util/mmap_win.cpp
+++ b/src/mongo/util/mmap_windows.cpp
diff --git a/src/mongo/util/processinfo_linux2.cpp b/src/mongo/util/processinfo_linux.cpp
index 2691fb7f054..2691fb7f054 100644
--- a/src/mongo/util/processinfo_linux2.cpp
+++ b/src/mongo/util/processinfo_linux.cpp
diff --git a/src/mongo/util/processinfo_openbsd5.cpp b/src/mongo/util/processinfo_openbsd.cpp
index f36bc0cab54..f36bc0cab54 100644
--- a/src/mongo/util/processinfo_openbsd5.cpp
+++ b/src/mongo/util/processinfo_openbsd.cpp
diff --git a/src/mongo/util/processinfo_darwin.cpp b/src/mongo/util/processinfo_osx.cpp
index a88aadbbd34..a88aadbbd34 100644
--- a/src/mongo/util/processinfo_darwin.cpp
+++ b/src/mongo/util/processinfo_osx.cpp
diff --git a/src/mongo/util/processinfo_sunos5.cpp b/src/mongo/util/processinfo_solaris.cpp
index 1a71f26bafb..1a71f26bafb 100644
--- a/src/mongo/util/processinfo_sunos5.cpp
+++ b/src/mongo/util/processinfo_solaris.cpp
diff --git a/src/mongo/util/processinfo_none.cpp b/src/mongo/util/processinfo_unknown.cpp
index 8d4216971a3..8d4216971a3 100644
--- a/src/mongo/util/processinfo_none.cpp
+++ b/src/mongo/util/processinfo_unknown.cpp
diff --git a/src/mongo/util/processinfo_win32.cpp b/src/mongo/util/processinfo_windows.cpp
index 1747b980225..1747b980225 100644
--- a/src/mongo/util/processinfo_win32.cpp
+++ b/src/mongo/util/processinfo_windows.cpp
diff --git a/src/mongo/util/stacktrace_win.cpp b/src/mongo/util/stacktrace_windows.cpp
index 4abc27e3c97..4abc27e3c97 100644
--- a/src/mongo/util/stacktrace_win.cpp
+++ b/src/mongo/util/stacktrace_windows.cpp
diff --git a/src/third_party/SConscript b/src/third_party/SConscript
index 8fa3a270c5f..6c3393c1021 100644
--- a/src/third_party/SConscript
+++ b/src/third_party/SConscript
@@ -1,6 +1,6 @@
# -*- mode: python -*-
-Import("env use_system_version_of_library windows darwin usev8 v8suffix solaris boostSuffix")
+Import("env use_system_version_of_library usev8 v8suffix boostSuffix")
Import("wiredtiger")
snappySuffix = '-1.1.2'
@@ -97,7 +97,7 @@ boostEnv = env
if use_system_version_of_library("boost"):
# On windows, we don't need the syslibdeps because autolib will select the right libraries
# for us automatically.
- if not windows:
+ if not env.TargetOSIs('windows'):
boostEnv = env.Clone(
SYSLIBDEPS=[
env['LIBDEPS_BOOST_PROGRAM_OPTIONS_SYSLIBDEP'],
@@ -258,7 +258,7 @@ yamlEnv.Library(
tzEnv = env.Clone()
-if solaris:
+if env.TargetOSIs('solaris'):
tzEnv.InjectThirdPartyIncludePaths(libraries=['tz'])
tzEnv.SConscript('tz/SConscript', exports={ 'env' : tzEnv })
tzEnv = tzEnv.Clone(
diff --git a/src/third_party/boost-1.56.0/SConscript b/src/third_party/boost-1.56.0/SConscript
index 2bd0e3ddd86..4a6dbe0b573 100644
--- a/src/third_party/boost-1.56.0/SConscript
+++ b/src/third_party/boost-1.56.0/SConscript
@@ -7,9 +7,9 @@ env.Library('boost_system', ['libs/system/src/error_code.cpp'])
boost_thread_source = dict(
posix=['libs/thread/src/pthread/once.cpp',
'libs/thread/src/pthread/thread.cpp'],
- win=['libs/thread/src/win32/thread.cpp',
- 'libs/thread/src/win32/tss_pe.cpp']
- ).get(env['OS_FAMILY'], 'UNKNOWN_OS_FAMILY_FOR_BOOST_THREADS__%s' % env['OS_FAMILY'])
+ windows=['libs/thread/src/win32/thread.cpp',
+ 'libs/thread/src/win32/tss_pe.cpp']
+ ).get(env['TARGET_OS_FAMILY'], 'UNKNOWN_OS_FAMILY_FOR_BOOST_THREADS__%s' % env['TARGET_OS_FAMILY'])
threadlib_env = env.Clone()
threadlib_env.Append(CPPDEFINES=['BOOST_THREAD_BUILD_LIB'])
diff --git a/src/third_party/gperftools-2.2/SConscript b/src/third_party/gperftools-2.2/SConscript
index 898061fe10d..58b72cff724 100644
--- a/src/third_party/gperftools-2.2/SConscript
+++ b/src/third_party/gperftools-2.2/SConscript
@@ -3,7 +3,6 @@
Import("env")
Import("has_option")
Import("debugBuild")
-Import("darwin")
files = [
'src/base/dynamic_annotations.c',
diff --git a/src/third_party/pcre-8.36/SConscript b/src/third_party/pcre-8.36/SConscript
index 8497d139d4b..46f049aa71b 100644
--- a/src/third_party/pcre-8.36/SConscript
+++ b/src/third_party/pcre-8.36/SConscript
@@ -1,6 +1,6 @@
# -*- mode: python -*-
-Import("env windows solaris")
+Import("env")
env = env.Clone()
env.Append( CPPDEFINES=[ "HAVE_CONFIG_H", "SUPPORT_UTF8" ] )
@@ -28,9 +28,9 @@ for to_remove in ['-Werror', '-Wall', '-W']:
# -DPCRE_MATCH_LIMIT:STRING="200000" -DPCRE_PARENS_NEST_LIMIT:STRING="250"
# -DPCRE_SUPPORT_UTF:BOOL="1"
#
-if windows:
+if env.TargetOSIs('windows'):
env.Append(CPPPATH=["build_windows"])
-elif solaris:
+elif env.TargetOSIs('solaris'):
env.Append(CPPPATH=["build_solaris"])
else:
env.Append(CPPPATH=["build_posix"])
diff --git a/src/third_party/s2/SConscript b/src/third_party/s2/SConscript
index fb1137f12d4..830dd65cedc 100644
--- a/src/third_party/s2/SConscript
+++ b/src/third_party/s2/SConscript
@@ -1,6 +1,6 @@
# -*- mode: python -*-
-Import("env windows linux darwin solaris")
+Import("env")
env = env.Clone()
diff --git a/src/third_party/s2/base/SConscript b/src/third_party/s2/base/SConscript
index a1f4a4720e5..ddeffd6273d 100755
--- a/src/third_party/s2/base/SConscript
+++ b/src/third_party/s2/base/SConscript
@@ -1,6 +1,6 @@
# -*- mode: python -*-
-Import("env windows linux darwin solaris")
+Import("env")
env = env.Clone()
diff --git a/src/third_party/s2/strings/SConscript b/src/third_party/s2/strings/SConscript
index 8ba95770af7..93eb6321c47 100755
--- a/src/third_party/s2/strings/SConscript
+++ b/src/third_party/s2/strings/SConscript
@@ -1,6 +1,6 @@
# -*- mode: python -*-
-Import("env windows linux darwin solaris")
+Import("env")
env = env.Clone()
diff --git a/src/third_party/s2/util/coding/SConscript b/src/third_party/s2/util/coding/SConscript
index 9dbc03b4818..91874e068a2 100755
--- a/src/third_party/s2/util/coding/SConscript
+++ b/src/third_party/s2/util/coding/SConscript
@@ -1,6 +1,6 @@
# -*- mode: python -*-
-Import("env windows linux darwin solaris")
+Import("env")
env = env.Clone()
diff --git a/src/third_party/s2/util/math/SConscript b/src/third_party/s2/util/math/SConscript
index e88c4898b60..865806049b9 100755
--- a/src/third_party/s2/util/math/SConscript
+++ b/src/third_party/s2/util/math/SConscript
@@ -1,13 +1,13 @@
# -*- mode: python -*-
-Import("env windows linux darwin solaris")
+Import("env")
env = env.Clone()
env.Append(CCFLAGS=['-Isrc/third_party/s2'])
env.Append(CCFLAGS=['-Isrc/third_party/gflags-2.0/src'])
-if solaris:
+if env.TargetOSIs('solaris'):
# Enables declaration of isinf() on Solaris
env.Append(CPPDEFINES=['__C99FEATURES__'])
diff --git a/src/third_party/snappy-1.1.2/SConscript b/src/third_party/snappy-1.1.2/SConscript
index d29622b3cb4..5b405d1d141 100644
--- a/src/third_party/snappy-1.1.2/SConscript
+++ b/src/third_party/snappy-1.1.2/SConscript
@@ -1,8 +1,8 @@
# -*- mode: python -*-
-Import("env windows")
+Import("env")
-if not windows:
+if env.ToolchainIs('clang', 'GCC'):
env = env.Clone()
env.Append(CCFLAGS=['-Wno-sign-compare', '-Wno-unused-function'])
diff --git a/src/third_party/v8-3.25/SConscript b/src/third_party/v8-3.25/SConscript
index b2918d9fecd..18872a394bb 100644
--- a/src/third_party/v8-3.25/SConscript
+++ b/src/third_party/v8-3.25/SConscript
@@ -32,7 +32,7 @@ root_dir = dirname(File('SConscript').rfile().abspath)
sys.path.insert(0, join(root_dir, 'tools'))
import js2c
-Import("env windows linux darwin solaris freebsd debugBuild openbsd")
+Import("env debugBuild")
# pared-down copies of the equivalent structures in v8's SConstruct/SConscript:
LIBRARY_FLAGS = {
@@ -361,17 +361,17 @@ def get_options():
else:
assert False, "Unsupported architecture: " + processor
- if linux:
+ if env.TargetOSIs('linux'):
os_string = 'os:linux'
- elif darwin:
+ elif env.TargetOSIs('osx'):
os_string = 'os:macos'
- elif windows:
+ elif env.TargetOSIs('windows'):
os_string = 'os:win32'
- elif freebsd:
+ elif env.TargetOSIs('freebsd'):
os_string = 'os:freebsd'
- elif solaris:
+ elif env.TargetOSIs('solaris'):
os_string = 'os:solaris'
- elif openbsd:
+ elif env.TargetOSIs('openbsd'):
os_string = 'os:openbsd'
else:
os_string = 'os:nullos'
@@ -399,14 +399,8 @@ def get_sources(options):
return sources
-def get_toolchain():
- if windows:
- return 'msvc'
- else:
- return 'gcc'
-
# convert our SConstruct variables to their v8 equivalents:
-toolchain = get_toolchain()
+toolchain = 'msvc' if env.ToolchainIs('MSVC') else 'gcc'
options = get_options()
sources = get_sources(options)
diff --git a/src/third_party/v8/SConscript b/src/third_party/v8/SConscript
index 6da6c9d915f..173fff9cecd 100644
--- a/src/third_party/v8/SConscript
+++ b/src/third_party/v8/SConscript
@@ -32,7 +32,7 @@ root_dir = dirname(File('SConscript').rfile().abspath)
sys.path.insert(0, join(root_dir, 'tools'))
import js2c
-Import("env windows linux darwin solaris freebsd debugBuild openbsd")
+Import("env debugBuild")
# pared-down copies of the equivalent structures in v8's SConstruct/SConscript:
LIBRARY_FLAGS = {
@@ -291,17 +291,17 @@ def get_options():
else:
assert False, "Unsupported architecture: " + processor
- if linux:
+ if env.TargetOSIs('linux'):
os_string = 'os:linux'
- elif darwin:
+ elif env.TargetOSIs('osx'):
os_string = 'os:macos'
- elif windows:
+ elif env.TargetOSIs('windows'):
os_string = 'os:win32'
- elif freebsd:
+ elif env.TargetOSIs('freebsd'):
os_string = 'os:freebsd'
- elif solaris:
+ elif env.TargetOSIs('solaris'):
os_string = 'os:solaris'
- elif openbsd:
+ elif env.TargetOSIs('openbsd'):
os_string = 'os:openbsd'
else:
os_string = 'os:nullos'
@@ -330,7 +330,7 @@ def get_sources(options):
return sources
def get_toolchain():
- if windows:
+ if env.ToolchainIs('MSVC'):
return 'msvc'
else:
return 'gcc'
diff --git a/src/third_party/wiredtiger/SConscript b/src/third_party/wiredtiger/SConscript
index 9f66c290d65..b39874abf61 100644
--- a/src/third_party/wiredtiger/SConscript
+++ b/src/third_party/wiredtiger/SConscript
@@ -2,7 +2,7 @@
import re
import textwrap
-Import("env windows darwin solaris linux freebsd openbsd debugBuild")
+Import("env debugBuild")
env = env.Clone()
env.InjectThirdPartyIncludePaths(libraries=['snappy', 'zlib'])
@@ -18,17 +18,17 @@ if debugBuild:
"HAVE_VERBOSE",
])
-if windows:
+if env.TargetOSIs('windows'):
env.Append(CPPPATH=["build_win"])
-elif darwin:
+elif env.TargetOSIs('osx'):
env.Append(CPPPATH=["build_darwin"])
-elif solaris:
+elif env.TargetOSIs('solaris'):
env.Append(CPPPATH=["build_solaris"])
-elif freebsd:
+elif env.TargetOSIs('freebsd'):
env.Append(CPPPATH=["build_freebsd"])
-elif openbsd:
+elif env.TargetOSIs('openbsd'):
env.Append(CPPPATH=["build_openbsd"])
-elif linux:
+elif env.TargetOSIs('linux'):
env.Append(CPPPATH=["build_linux"])
env.Append(CPPDEFINES=["_GNU_SOURCE"])
else:
@@ -75,7 +75,8 @@ replacements = {
'@VERSION_STRING@' : VERSION_STRING,
'@uintmax_t_decl@': "",
'@uintptr_t_decl@': "",
- '@off_t_decl@' : 'typedef int64_t wt_off_t;' if windows else "typedef off_t wt_off_t;",
+ '@off_t_decl@' : 'typedef int64_t wt_off_t;' if env.TargetOSIs('windows')
+ else "typedef off_t wt_off_t;",
'@wiredtiger_includes_decl@': wiredtiger_includes
}
@@ -89,7 +90,7 @@ env.Substfile(
#
# WiredTiger library
#
-filelistfile = "build_win/filelist.win" if windows else 'dist/filelist'
+filelistfile = "build_win/filelist.win" if env.TargetOSIs('windows') else 'dist/filelist'
wtsources = []
diff --git a/src/third_party/zlib-1.2.8/SConscript b/src/third_party/zlib-1.2.8/SConscript
index 656c6df7e0f..8bdc06a2bb4 100644
--- a/src/third_party/zlib-1.2.8/SConscript
+++ b/src/third_party/zlib-1.2.8/SConscript
@@ -1,9 +1,9 @@
# -*- mode: python; -*-
-Import("env windows")
+Import("env")
env = env.Clone()
env.Append(CPPDEFINES=["HAVE_STDARG_H"])
-if not windows:
+if not env.TargetOSIs('windows'):
env.Append(CPPDEFINES=["HAVE_UNISTD_H"])
env.Library(