@@ -6,6 +6,7 @@ import imp
6
6
import os
7
7
import platform as py_platform
8
8
import re
9
+ import shlex
9
10
import shutil
10
11
import stat
11
12
import sys
@@ -217,6 +218,10 @@ add_option("use-sasl-client", "Support SASL authentication in the client library
217
218
218
219
add_option ('build-fast-and-loose' , "NEVER for production builds" , 0 , False )
219
220
221
+ add_option ( "boost-lib-search-suffixes" ,
222
+ "Comma delimited sequence of boost library suffixes to search" ,
223
+ 1 , False )
224
+
220
225
add_option ('disable-warnings-as-errors' , "Don't add -Werror to compiler command line" , 0 , False )
221
226
222
227
add_option ('propagate-shell-environment' ,
@@ -236,6 +241,10 @@ add_option('mongo-orchestration-host',
236
241
add_option ('mongo-orchestration-port' ,
237
242
"Host mongo-orchestration is running on" ,
238
243
1 , False , default = '8889' )
244
+
245
+ add_option ('variables-help' ,
246
+ "Print the help text for SCons variables" , 0 , False )
247
+
239
248
if darwin :
240
249
osx_version_choices = ['10.6' , '10.7' , '10.8' , '10.9' , '10.10' ]
241
250
@@ -281,6 +290,64 @@ add_option('cache-dir',
281
290
"Specify the directory to use for caching objects if --cache is in use" ,
282
291
1 , False , default = "$BUILD_DIR/scons/cache" )
283
292
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
+
284
351
# don't run configure if user calls --help
285
352
if GetOption ('help' ):
286
353
Return ()
@@ -433,9 +500,36 @@ if windows:
433
500
msvc_script = None
434
501
envDict ['MSVC_USE_SCRIPT' ] = msvc_script
435
502
436
- env = Environment (** envDict )
503
+ env = Environment (variables = env_vars , ** envDict )
437
504
del envDict
438
505
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
+
439
533
if has_option ("cache" ):
440
534
EnsureSConsVersion ( 2 , 3 , 0 )
441
535
if has_option ("release" ):
@@ -524,8 +618,6 @@ if has_option( "cc" ):
524
618
exit (1 )
525
619
env ["CC" ] = get_option ( "cc" )
526
620
527
- env ["LIBPATH" ] = []
528
-
529
621
if has_option ( "libpath" ):
530
622
env ["LIBPATH" ] = [get_option ( "libpath" )]
531
623
@@ -843,6 +935,14 @@ except OSError:
843
935
844
936
env .Prepend (CPPPATH = ['$VARIANT_DIR/third_party/gtest-1.7.0/include' ])
845
937
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
+
846
946
env .Append ( CPPPATH = ['$EXTRACPPPATH' ],
847
947
LIBPATH = ['$EXTRALIBPATH' ] )
848
948
@@ -1643,10 +1743,10 @@ def doConfigure(myenv):
1643
1743
print ( "Could not find boost headers in include search path" )
1644
1744
Exit (1 )
1645
1745
1646
- if not windows :
1746
+ if ( not windows ) and boostSuffixList :
1647
1747
# We don't do this for windows because we rely on autolib.
1648
1748
for b in boostLibs :
1649
- boostCandidates = ["boost_" + b + "-mt" , "boost_" + b ]
1749
+ boostCandidates = ["boost_" + b + suffix for suffix in boostSuffixList ]
1650
1750
if not conf .CheckLib (boostCandidates , language = "C++" ):
1651
1751
print ( "can't find boost" )
1652
1752
Exit (1 )
0 commit comments