@@ -510,14 +510,26 @@ if windows:
510510env = Environment (variables = env_vars , ** envDict )
511511del envDict
512512
513+ def fatal_error (env , msg , * args ):
514+ print msg .format (* args )
515+ Exit (1 )
516+
517+ def conf_error (env , msg , * args ):
518+ print msg .format (* args )
519+ print "See {0} for details" .format (env ['CONFIGURELOG' ].abspath )
520+
521+ Exit (1 )
522+
523+ env .AddMethod (fatal_error , 'FatalError' )
524+ env .AddMethod (conf_error , 'ConfError' )
525+
513526if has_option ('variables-help' ):
514527 print env_vars .GenerateHelpText (env )
515528 Exit (0 )
516529
517530unknown_vars = env_vars .UnknownVariables ()
518531if unknown_vars :
519- print "Unknown variables specified: {0}" .format (", " .join (unknown_vars .keys ()))
520- Exit (1 )
532+ env .FatalError ("Unknown variables specified: {0}" , ", " .join (unknown_vars .keys ()))
521533
522534
523535# Add any scons options that conflict with scons variables here.
@@ -533,18 +545,15 @@ variable_conflicts = [
533545
534546for (opt_name , var_name ) in variable_conflicts :
535547 if has_option (opt_name ) and var_name in env :
536- print ("Both option \" --{0}\" and variable {1} were specified" .
537- format (opt_name , var_name ))
538- Exit (1 )
548+ env .FatalError ("Both option \" --{0}\" and variable {1} were specified" , opt_name , var_name )
539549
540550if has_option ("cache" ):
541551 EnsureSConsVersion ( 2 , 3 , 0 )
542552 if has_option ("release" ):
543- print ( "Using the experimental --cache option is not permitted for --release builds" )
544- Exit ( 1 )
553+ env . FatalError (
554+ "Using the experimental --cache option is not permitted for --release builds" )
545555 if has_option ("gcov" ):
546- print ("Mixing --cache and --gcov doesn't work correctly yet. See SERVER-11084" )
547- Exit (1 )
556+ env .FatalError ("Mixing --cache and --gcov doesn't work correctly yet. See SERVER-11084" )
548557 env .CacheDir (str (env .Dir (cacheDir )))
549558
550559if has_option ("propagate-shell-environment" ):
@@ -599,11 +608,9 @@ else:
599608 env ['OS_FAMILY' ] = 'posix'
600609
601610if has_option ( "cc-use-shell-environment" ) and has_option ( "cc" ):
602- print ("Cannot specify both --cc-use-shell-environment and --cc" )
603- Exit (1 )
611+ env .FatalError ("Cannot specify both --cc-use-shell-environment and --cc" )
604612elif has_option ( "cxx-use-shell-environment" ) and has_option ( "cxx" ):
605- print ("Cannot specify both --cxx-use-shell-environment and --cxx" )
606- Exit (1 )
613+ env .FatalError ("Cannot specify both --cxx-use-shell-environment and --cxx" )
607614
608615
609616if has_option ( "gtest-filter" ):
@@ -617,13 +624,11 @@ if has_option( "cc-use-shell-environment" ):
617624
618625if has_option ( "cxx" ):
619626 if not has_option ( "cc" ):
620- print "Must specify C compiler when specifying C++ compiler"
621- exit (1 )
627+ env .FatalError ("Must specify C compiler when specifying C++ compiler" )
622628 env ["CXX" ] = get_option ( "cxx" )
623629if has_option ( "cc" ):
624630 if not has_option ( "cxx" ):
625- print "Must specify C++ compiler when specifying C compiler"
626- exit (1 )
631+ env .FatalError ("Must specify C++ compiler when specifying C compiler" )
627632 env ["CC" ] = get_option ( "cc" )
628633
629634if has_option ( "libpath" ):
@@ -720,8 +725,7 @@ elif windows:
720725 env .Append ( CPPDEFINES = [ "BOOST_ALL_DYN_LINK" ] )
721726
722727 if has_option ("sharedclient" ) and not dynamicCRT :
723- print ("The shared client must be built with the dynamic runtime library" )
724- Exit (1 )
728+ env .FatalError ("The shared client must be built with the dynamic runtime library" )
725729
726730 # If tools configuration fails to set up 'cl' in the path, fall back to importing the whole
727731 # shell environment and hope for the best. This will work, for instance, if you have loaded
@@ -954,16 +958,14 @@ def doConfigure(myenv):
954958
955959 if 'CheckCXX' in dir ( conf ):
956960 if not conf .CheckCXX ():
957- print ("C++ compiler %s does not work" % (conf .env ["CXX" ]))
958- Exit (1 )
961+ conf .env .FatalError ("C++ compiler {0} does not work" , conf .env ["CXX" ])
959962
960963 # Only do C checks if CC != CXX
961964 check_c = (myenv ["CC" ] != myenv ["CXX" ])
962965
963966 if check_c and 'CheckCC' in dir ( conf ):
964967 if not conf .CheckCC ():
965- print ("C compiler %s does not work" % (conf .env ["CC" ]))
966- Exit (1 )
968+ conf .env .FatalError ("C compiler {0} does not work" , conf .env ["CC" ])
967969 myenv = conf .Finish ()
968970
969971 # Identify the toolchain in use. We currently support the following:
@@ -1026,12 +1028,10 @@ def doConfigure(myenv):
10261028 break
10271029
10281030 if not have_toolchain ():
1029- print ("Couldn't identify the toolchain" )
1030- Exit (1 )
1031+ conf .env .FatalError ("Couldn't identify the toolchain" )
10311032
10321033 if check_c and not conf .CheckForToolchain (toolchain , "C" , "CC" , ".c" ):
1033- print ("C toolchain doesn't match identified C++ toolchain" )
1034- Exit (1 )
1034+ conf .env .FatalError ("C toolchain doesn't match identified C++ toolchain" )
10351035
10361036 myenv = conf .Finish ()
10371037
@@ -1094,8 +1094,7 @@ def doConfigure(myenv):
10941094 return ret
10951095
10961096 if using_msvc ():
1097- print ("AddFlagIfSupported is not currently supported with MSVC" )
1098- Exit (1 )
1097+ env .FatalError ("AddFlagIfSupported is not currently supported with MSVC" )
10991098
11001099 test_mutation = mutation
11011100 if using_gcc ():
@@ -1201,22 +1200,19 @@ def doConfigure(myenv):
12011200 min_version = get_option ('osx-version-min' )
12021201 min_version_flag = '-mmacosx-version-min=%s' % (min_version )
12031202 if not AddToCCFLAGSIfSupported (myenv , min_version_flag ):
1204- print ( "Can't set minimum OS X version with this compiler" )
1205- Exit (1 )
1203+ myenv .ConfError ("Can't set minimum OS X version with this compiler" )
12061204 myenv .AppendUnique (LINKFLAGS = [min_version_flag ])
12071205
12081206 usingLibStdCxx = False
12091207 if has_option ('libc++' ):
12101208 if not using_clang ():
1211- print ( 'libc++ is currently only supported for clang' )
1212- Exit (1 )
1209+ myenv .ConfError ('libc++ is currently only supported for clang' )
12131210 if darwin and has_option ('osx-version-min' ) and versiontuple (min_version ) < versiontuple ('10.7' ):
12141211 print ("Warning: You passed option 'libc++'. You probably want to also pass 'osx-version-min=10.7' or higher for libc++ support." )
12151212 if AddToCXXFLAGSIfSupported (myenv , '-stdlib=libc++' ):
12161213 myenv .Append (LINKFLAGS = ['-stdlib=libc++' ])
12171214 else :
1218- print ( 'libc++ requested, but compiler does not support -stdlib=libc++' )
1219- Exit (1 )
1215+ myenv .ConfError ('libc++ requested, but compiler does not support -stdlib=libc++' )
12201216 else :
12211217 def CheckLibStdCxx (context ):
12221218 test_body = """
@@ -1283,10 +1279,11 @@ def doConfigure(myenv):
12831279 if cxx11_mode == "auto" :
12841280 cxx11_mode = "off"
12851281 else :
1286- print ( 'Detected libstdc++ is too old to support C++11 mode' )
1282+ cxx11_error = 'Detected libstdc++ is too old to support C++11 mode'
12871283 if darwin :
1288- print ( 'Try building with --libc++ and --osx-version-min=10.7 or higher' )
1289- Exit (1 )
1284+ cxx11_error += \
1285+ '\n Try building with --libc++ and --osx-version-min=10.7 or higher'
1286+ myenv .ConfError (cxx11_error )
12901287
12911288 # We are going to be adding flags to the environment, but we don't want to persist
12921289 # those changes unless we pass all the below checks. Make a copy of the environment
@@ -1304,8 +1301,8 @@ def doConfigure(myenv):
13041301 if cxx11_mode == "auto" :
13051302 cxx11_mode = "off"
13061303 else :
1307- print ( 'C++11 mode requested, but cannot find a flag to enable it' )
1308- Exit ( 1 )
1304+ cxx11Env . ConfError (
1305+ 'C++11 mode requested, but cannot find a flag to enable it' )
13091306
13101307 # We appear to have C++11, or at least a flag to enable it, which is now set in the
13111308 # environment. If we are in auto mode, check if the compiler claims that it strictly
@@ -1342,8 +1339,8 @@ def doConfigure(myenv):
13421339 if cxx11_mode == "auto" :
13431340 cxx11_mode = "off"
13441341 else :
1345- print ( "C++11 mode selected for C++ files, but can't enable C99 for C files" )
1346- Exit ( 1 )
1342+ cxx11Env . ConfError (
1343+ "C++11 mode selected for C++ files, but can't enable C99 for C files" )
13471344
13481345 # If we got here and cxx11_mode hasn't become false, then its true, so swap in the
13491346 # modified environment.
@@ -1403,8 +1400,7 @@ def doConfigure(myenv):
14031400 if has_option ('sanitize' ):
14041401
14051402 if not (using_clang () or using_gcc ()):
1406- print ( 'sanitize is only supported with clang or gcc' )
1407- Exit (1 )
1403+ myenv .FatalError ('sanitize is only supported with clang or gcc' )
14081404
14091405 sanitizer_list = get_option ('sanitize' ).split (',' )
14101406
@@ -1432,8 +1428,7 @@ def doConfigure(myenv):
14321428 myenv .Append (LINKFLAGS = [sanitizer_option ])
14331429 myenv .Append (CCFLAGS = ['-fno-omit-frame-pointer' ])
14341430 else :
1435- print ( 'Failed to enable sanitizers with flag: ' + sanitizer_option )
1436- Exit (1 )
1431+ myenv .ConfError ('Failed to enable sanitizers with flag: {0}' , sanitizer_option )
14371432
14381433 blackfiles_map = {
14391434 "address" : myenv .File ("#etc/asan.blacklist" ),
@@ -1461,8 +1456,7 @@ def doConfigure(myenv):
14611456 myenv ['ENV' ]['ASAN_SYMBOLIZER_PATH' ] = llvm_symbolizer
14621457 myenv ['ENV' ]['LSAN_SYMBOLIZER_PATH' ] = llvm_symbolizer
14631458 elif using_lsan :
1464- print ("Using the leak sanitizer requires a valid symbolizer" )
1465- Exit (1 )
1459+ myenv .ConfError ("Using the leak sanitizer requires a valid symbolizer" )
14661460
14671461 # When using msvc, check for VS 2013 Update 2+ so we can use new compiler flags
14681462 if using_msvc ():
@@ -1541,18 +1535,15 @@ def doConfigure(myenv):
15411535 if not conf .LinkHelloWorld ():
15421536 conf .env .Append (LINKFLAGS = ["-fuse-ld=gold" ])
15431537 if not conf .LinkHelloWorld ("(with -fuse-ld=gold)" ):
1544- print ("Error: Couldn't link with LTO" )
1545- Exit (1 )
1538+ myenv .ConfError ("Error: Couldn't link with LTO" )
15461539
15471540 myenv = conf .Finish ()
15481541
15491542 else :
1550- print ( "Link time optimization requested, " +
1551- "but selected compiler does not honor -flto" )
1552- Exit (1 )
1543+ myenv .ConfError ("Link time optimization requested, " +
1544+ "but selected compiler does not honor -flto" )
15531545 else :
1554- printf ("Don't know how to enable --lto on current toolchain" )
1555- Exit (1 )
1546+ myenv .ConfError ("Don't know how to enable --lto on current toolchain" )
15561547
15571548 # When using msvc, check for support for __declspec(thread), unless we have been asked
15581549 # explicitly not to use it. For other compilers, see if __thread works.
@@ -1795,16 +1786,14 @@ def doConfigure(myenv):
17951786 conf .env .Append (CPPDEFINES = ["MONGO_HAVE_FIPS_MODE_SET" ])
17961787
17971788 if not conf .CheckCXXHeader ( "boost/version.hpp" ):
1798- print ( "Could not find boost headers in include search path" )
1799- Exit (1 )
1789+ conf .env .ConfError ("Could not find boost headers in include search path" )
18001790
18011791 if (not windows ) and boostSuffixList :
18021792 # We don't do this for windows because we rely on autolib.
18031793 for b in boostLibs :
18041794 boostCandidates = ["boost_" + b + suffix for suffix in boostSuffixList ]
18051795 if not conf .CheckLib (boostCandidates , language = "C++" ):
1806- print ( "can't find boost" )
1807- Exit (1 )
1796+ conf .env .ConfError ("can't find boost" )
18081797
18091798 # We need xtime internally no matter what the local boost thread version may be since we
18101799 # cannot require the existence of chrono. It is important that no uses of xtime become part
@@ -1828,21 +1817,20 @@ def doConfigure(myenv):
18281817 conf .env ['MONGO_SASL' ] = bool (has_option ("use-sasl-client" ))
18291818
18301819 if conf .env ['MONGO_SASL' ] and not conf .env ['MONGO_SSL' ]:
1831- print ("SASL support requires --ssl" )
1832- Exit (1 )
1820+ myenv .FatalError ("SASL support requires --ssl" )
18331821
18341822 if conf .env ['MONGO_SASL' ] and not conf .CheckLibWithHeader (
18351823 "sasl2" ,
18361824 ["stddef.h" ,"sasl/sasl.h" ],
18371825 "C" ,
18381826 "sasl_version_info(0, 0, 0, 0, 0, 0);" ,
18391827 autoadd = True ):
1840- Exit ( 1 )
1828+ myenv . ConfError ( "Couldn't find SASL header/libraries" )
18411829
18421830 # requires ports devel/libexecinfo to be installed
18431831 if freebsd or openbsd :
18441832 if not conf .CheckLib ("execinfo" ):
1845- Exit ( 1 )
1833+ myenv . ConfError ( "Cannot find libexecinfo, please install devel/libexecinfo" )
18461834
18471835 # check for presence of timegm(3) and polyfill if needed
18481836 conf .env ['MONGO_HAVE_TIMEGM' ] = conf .CheckDeclaration (
0 commit comments