@@ -6,6 +6,7 @@ import imp
66import os
77import platform as py_platform
88import re
9+ import shlex
910import shutil
1011import stat
1112import sys
@@ -217,6 +218,10 @@ add_option("use-sasl-client", "Support SASL authentication in the client library
217218
218219add_option ('build-fast-and-loose' , "NEVER for production builds" , 0 , False )
219220
221+ add_option ( "boost-lib-search-suffixes" ,
222+ "Comma delimited sequence of boost library suffixes to search" ,
223+ 1 , False )
224+
220225add_option ('disable-warnings-as-errors' , "Don't add -Werror to compiler command line" , 0 , False )
221226
222227add_option ('propagate-shell-environment' ,
@@ -236,6 +241,10 @@ add_option('mongo-orchestration-host',
236241add_option ('mongo-orchestration-port' ,
237242 "Host mongo-orchestration is running on" ,
238243 1 , False , default = '8889' )
244+
245+ add_option ('variables-help' ,
246+ "Print the help text for SCons variables" , 0 , False )
247+
239248if darwin :
240249 osx_version_choices = ['10.6' , '10.7' , '10.8' , '10.9' , '10.10' ]
241250
@@ -281,6 +290,64 @@ add_option('cache-dir',
281290 "Specify the directory to use for caching objects if --cache is in use" ,
282291 1 , False , default = "$BUILD_DIR/scons/cache" )
283292
293+ # Setup the command-line variables
294+ def variable_shlex_converter (val ):
295+ return shlex .split (val )
296+
297+ env_vars = Variables ()
298+
299+ env_vars .Add ('ARFLAGS' ,
300+ help = 'Sets flags for the archiver' ,
301+ converter = variable_shlex_converter )
302+
303+ env_vars .Add ('CCFLAGS' ,
304+ help = 'Sets flags for the C and C++ compiler' ,
305+ converter = variable_shlex_converter )
306+
307+ env_vars .Add ('CFLAGS' ,
308+ help = 'Sets flags for the C compiler' ,
309+ converter = variable_shlex_converter )
310+
311+ env_vars .Add ('CPPDEFINES' ,
312+ help = 'Sets pre-processor definitions for C and C++' ,
313+ converter = variable_shlex_converter )
314+
315+ env_vars .Add ('CPPPATH' ,
316+ help = 'Adds paths to the preprocessor search path' ,
317+ converter = variable_shlex_converter )
318+
319+ env_vars .Add ('CXXFLAGS' ,
320+ help = 'Sets flags for the C++ compiler' ,
321+ converter = variable_shlex_converter )
322+
323+ env_vars .Add ('LIBPATH' ,
324+ help = 'Adds paths to the linker search path' ,
325+ converter = variable_shlex_converter )
326+
327+ env_vars .Add ('LIBS' ,
328+ help = 'Adds extra libraries to link against' ,
329+ converter = variable_shlex_converter )
330+
331+ env_vars .Add ('LINKFLAGS' ,
332+ help = 'Sets flags for the linker' ,
333+ converter = variable_shlex_converter )
334+
335+ env_vars .Add ('SHCCFLAGS' ,
336+ help = 'Sets flags for the C and C++ compiler when building shared libraries' ,
337+ converter = variable_shlex_converter )
338+
339+ env_vars .Add ('SHCFLAGS' ,
340+ help = 'Sets flags for the C compiler when building shared libraries' ,
341+ converter = variable_shlex_converter )
342+
343+ env_vars .Add ('SHCXXFLAGS' ,
344+ help = 'Sets flags for the C++ compiler when building shared libraries' ,
345+ converter = variable_shlex_converter )
346+
347+ env_vars .Add ('SHLINKFLAGS' ,
348+ help = 'Sets flags for the linker when building shared libraries' ,
349+ converter = variable_shlex_converter )
350+
284351# don't run configure if user calls --help
285352if GetOption ('help' ):
286353 Return ()
@@ -433,9 +500,36 @@ if windows:
433500 msvc_script = None
434501 envDict ['MSVC_USE_SCRIPT' ] = msvc_script
435502
436- env = Environment (** envDict )
503+ env = Environment (variables = env_vars , ** envDict )
437504del envDict
438505
506+ if has_option ('variables-help' ):
507+ print env_vars .GenerateHelpText (env )
508+ Exit (0 )
509+
510+ unknown_vars = env_vars .UnknownVariables ()
511+ if unknown_vars :
512+ print "Unknown variables specified: {0}" .format (", " .join (unknown_vars .keys ()))
513+ Exit (1 )
514+
515+
516+ # Add any scons options that conflict with scons variables here.
517+ # The first item in each tuple is the option name and the second
518+ # is the variable name
519+ variable_conflicts = [
520+ ('libpath' , 'LIBPATH' ),
521+ ('cpppath' , 'CPPPATH' ),
522+ ('extrapath' , 'CPPPATH' ),
523+ ('extrapath' , 'LIBPATH' ),
524+ ('extralib' , 'LIBS' )
525+ ]
526+
527+ for (opt_name , var_name ) in variable_conflicts :
528+ if has_option (opt_name ) and var_name in env :
529+ print ("Both option \" --{0}\" and variable {1} were specified" .
530+ format (opt_name , var_name ))
531+ Exit (1 )
532+
439533if has_option ("cache" ):
440534 EnsureSConsVersion ( 2 , 3 , 0 )
441535 if has_option ("release" ):
@@ -524,8 +618,6 @@ if has_option( "cc" ):
524618 exit (1 )
525619 env ["CC" ] = get_option ( "cc" )
526620
527- env ["LIBPATH" ] = []
528-
529621if has_option ( "libpath" ):
530622 env ["LIBPATH" ] = [get_option ( "libpath" )]
531623
@@ -843,6 +935,14 @@ except OSError:
843935
844936env .Prepend (CPPPATH = ['$VARIANT_DIR/third_party/gtest-1.7.0/include' ])
845937
938+ boostSuffixList = ["-mt" , "" ]
939+ if get_option ("boost-lib-search-suffixes" ) is not None :
940+ boostSuffixList = get_option ("boost-lib-search-suffixes" )
941+ if boostSuffixList == "" :
942+ boostSuffixList = []
943+ else :
944+ boostSuffixList = boostSuffixList .split (',' )
945+
846946env .Append ( CPPPATH = ['$EXTRACPPPATH' ],
847947 LIBPATH = ['$EXTRALIBPATH' ] )
848948
@@ -1643,10 +1743,10 @@ def doConfigure(myenv):
16431743 print ( "Could not find boost headers in include search path" )
16441744 Exit (1 )
16451745
1646- if not windows :
1746+ if ( not windows ) and boostSuffixList :
16471747 # We don't do this for windows because we rely on autolib.
16481748 for b in boostLibs :
1649- boostCandidates = ["boost_" + b + "-mt" , "boost_" + b ]
1749+ boostCandidates = ["boost_" + b + suffix for suffix in boostSuffixList ]
16501750 if not conf .CheckLib (boostCandidates , language = "C++" ):
16511751 print ( "can't find boost" )
16521752 Exit (1 )
0 commit comments