From 4c2600d332d367084b8bcf9598aed5f131229c5d Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Mon, 14 Nov 2011 18:05:08 -0500 Subject: [PATCH] scons flag to use each library externally --use-system-(prcre|boost) SERVER-3829 currently supported: --use-system-all --use-system-pcre --use-system-sm --- SConstruct | 37 ++++++++++++++++++++++++++++--------- third_party/pcre.py | 3 +++ third_party/sm.py | 22 ++++++++++++++++++---- third_party/snappy.py | 3 +++ 4 files changed, 52 insertions(+), 13 deletions(-) diff --git a/SConstruct b/SConstruct index b9e8b9fb0f3..3ebae2a59ef 100644 --- a/SConstruct +++ b/SConstruct @@ -32,6 +32,16 @@ def findSettingsSetup(): sys.path.append( ".." ) sys.path.append( "../../" ) +def getThirdPartyShortNames(): + lst = [] + for x in os.listdir( "third_party" ): + if not x.endswith( ".py" ) or x.find( "#" ) >= 0: + continue + + lst.append( x.rpartition( "." )[0] ) + return lst + + # --- options ---- options = {} @@ -172,6 +182,11 @@ add_option( "heapcheck", "link to heap-checking malloc-lib and look for memory l add_option("smokedbprefix", "prefix to dbpath et al. for smoke tests", 1 , False ) +for shortName in getThirdPartyShortNames(): + add_option( "use-system-" + shortName , "use system version of library " + shortName , 0 , True ) + +add_option( "use-system-all" , "use all system libraries " + shortName , 0 , True ) + # --- environment setup --- def removeIfInList( lst , thing ): @@ -763,21 +778,20 @@ if not windows: os.chmod( keyfile , stat.S_IWUSR|stat.S_IRUSR ) moduleFiles = {} -for x in os.listdir( "third_party" ): - if not x.endswith( ".py" ) or x.find( "#" ) >= 0: - continue - - shortName = x.rpartition( "." )[0] - path = "third_party/%s" % x - +for shortName in getThirdPartyShortNames(): + path = "third_party/%s.py" % shortName myModule = imp.load_module( "third_party_%s" % shortName , open( path , "r" ) , path , ( ".py" , "r" , imp.PY_SOURCE ) ) fileLists = { "commonFiles" : commonFiles , "serverOnlyFiles" : serverOnlyFiles , "scriptingFiles" : scriptingFiles, "moduleFiles" : moduleFiles } options_topass["windows"] = windows options_topass["nix"] = nix - myModule.configure( env , fileLists , options_topass ) + if has_option( "use-system-" + shortName ) or has_option( "use-system-all" ): + print( "using system version of: " + shortName ) + myModule.configureSystem( env , fileLists , options_topass ) + else: + myModule.configure( env , fileLists , options_topass ) coreServerFiles += scriptingFiles @@ -1174,7 +1188,12 @@ elif not onlyServer: shellEnv = doConfigure( shellEnv , shell=True ) shellEnv.Prepend( LIBS=[ "mongoshellfiles"] ) - mongo = shellEnv.Program( "mongo" , moduleFiles["pcre"] + coreShellFiles ) + + shellFilesToUse = coreShellFiles + if "pcre" in moduleFiles: + shellFilesToUse += moduleFiles["pcre"] + + mongo = shellEnv.Program( "mongo" , shellFilesToUse ) # ---- RUNNING TESTS ---- diff --git a/third_party/pcre.py b/third_party/pcre.py index b0554416bb2..fdc761af8d1 100644 --- a/third_party/pcre.py +++ b/third_party/pcre.py @@ -32,6 +32,9 @@ def configure( env , fileLists , options ): fileLists["commonFiles"] += [ myenv.Object(f) for f in getFiles() ] fileLists["moduleFiles"]["pcre"] = [ myenv.Object(f) for f in getFiles() ] +def configureSystem( env , fileLists , options ): + + env.Append( LIBS=[ "pcrecpp" ] ) if __name__ == "__main__": diff --git a/third_party/sm.py b/third_party/sm.py index 53e7984b8ae..9927be88b78 100644 --- a/third_party/sm.py +++ b/third_party/sm.py @@ -42,15 +42,20 @@ root = "third_party/js-1.7" def r(x): return "%s/%s" % ( root , x ) -def configure( env , fileLists , options ): - if not options["usesm"]: - return - +def configureBasics( env , fileLists , options ): if options["windows"]: env.Append( CPPDEFINES=[ "XP_WIN" ] ) else: env.Append( CPPDEFINES=[ "XP_UNIX" ] ) + + +def configure( env , fileLists , options ): + if not options["usesm"]: + return + + configureBasics( env , fileLists , options ) + env.Prepend( CPPPATH=[root] ) myenv = env.Clone() @@ -98,3 +103,12 @@ def configure( env , fileLists , options ): myenv.Auto( r("jsautocfg.h") , [ jscpucfg ] ) myenv.Depends( r("jsscan.c") , r("jsautokw.h") ) + + +def configureSystem( env , fileLists , options ): + if not options["usesm"]: + return + + configureBasics( env , fileLists , options ) + + env.Append( LIBS=[ "js" ] ) diff --git a/third_party/snappy.py b/third_party/snappy.py index c70cb28c52e..e53ee632bbd 100644 --- a/third_party/snappy.py +++ b/third_party/snappy.py @@ -9,3 +9,6 @@ def configure( env , fileLists , options ): files = ["third_party/snappy/snappy.cc", "third_party/snappy/snappy-sinksource.cc"] fileLists["serverOnlyFiles"] += [ myenv.Object(f) for f in files ] + +def configureSystem( env , fileLists , options ): + configure( env , fileLists , options )