From: Antonin Kral Date: Thu, 15 Dec 2011 11:22:43 +0100 Subject: use system-wide pcre --- SConstruct | 98 ++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 53 insertions(+), 45 deletions(-) diff --git a/SConstruct b/SConstruct index 9d52617..418cb4c 100644 --- a/SConstruct +++ b/SConstruct @@ -48,7 +48,11 @@ def getThirdPartyShortNames(): for x in os.listdir( "third_party" ): if not x.endswith( ".py" ) or x.find( "#" ) >= 0: continue - + + #use system-wide pcre + if x.find('pcre') >= 0: + continue + lst.append( _rpartition( x, "." )[0] ) return lst @@ -64,7 +68,7 @@ def add_option( name, help , nargs , contibutesToVariantDir , dest=None ): if dest is None: dest = name - AddOption( "--" + name , + AddOption( "--" + name , dest=dest, type="string", nargs=nargs, @@ -72,9 +76,9 @@ def add_option( name, help , nargs , contibutesToVariantDir , dest=None ): help=help ) options[name] = { "help" : help , - "nargs" : nargs , + "nargs" : nargs , "contibutesToVariantDir" : contibutesToVariantDir , - "dest" : dest } + "dest" : dest } def get_option( name ): return GetOption( name ) @@ -99,16 +103,16 @@ def has_option( name ): def get_variant_dir(): - + a = [] - + for name in options: o = options[name] if not has_option( o["dest"] ): continue if not o["contibutesToVariantDir"]: continue - + if o["nargs"] == 0: a.append( name ) else: @@ -119,9 +123,9 @@ def get_variant_dir(): if len(a) > 0: a.sort() s += "/".join( a ) + "/" - + return s - + # installation/packaging @@ -230,16 +234,16 @@ msarch = None if force64: msarch = "amd64" -force32 = has_option( "force32" ) +force32 = has_option( "force32" ) release = has_option( "release" ) static = has_option( "static" ) -debugBuild = has_option( "debugBuild" ) or has_option( "debugBuildAndLogging" ) +debugBuild = has_option( "debugBuild" ) or has_option( "debugBuildAndLogging" ) debugLogging = has_option( "debugBuildAndLogging" ) -noshell = has_option( "noshell" ) +noshell = has_option( "noshell" ) usesm = has_option( "usesm" ) -usev8 = has_option( "usev8" ) +usev8 = has_option( "usev8" ) asio = has_option( "asio" ) @@ -325,7 +329,7 @@ class InstallSetup: def __init__(self): self.default() - + def default(self): self.binaries = True self.libraries = False @@ -343,7 +347,7 @@ class InstallSetup: self.bannerDir = "distsrc/client/" self.headerRoot = "" self.clientTestsDir = "client/examples/" - + installSetup = InstallSetup() env["installSetup"] = installSetup if distBuild: @@ -359,19 +363,19 @@ if has_option( "full" ): commonFiles = Split( "pch.cpp buildinfo.cpp db/indexkey.cpp db/jsobj.cpp bson/oid.cpp db/json.cpp db/lasterror.cpp db/nonce.cpp db/queryutil.cpp db/querypattern.cpp db/projection.cpp shell/mongo.cpp" ) commonFiles += [ "util/background.cpp" , "util/util.cpp" , "util/file_allocator.cpp" , "util/assert_util.cpp" , "util/log.cpp" , "util/ramlog.cpp" , "util/md5main.cpp" , "util/base64.cpp", "util/concurrency/vars.cpp", "util/concurrency/task.cpp", "util/debug_util.cpp", - "util/concurrency/thread_pool.cpp", "util/password.cpp", "util/version.cpp", "util/signal_handlers.cpp", + "util/concurrency/thread_pool.cpp", "util/password.cpp", "util/version.cpp", "util/signal_handlers.cpp", "util/histogram.cpp", "util/concurrency/spin_lock.cpp", "util/text.cpp" , "util/stringutils.cpp" , "util/concurrency/synchronization.cpp" ] commonFiles += [ "util/net/sock.cpp" , "util/net/httpclient.cpp" , "util/net/message.cpp" , "util/net/message_port.cpp" , "util/net/listen.cpp" ] -commonFiles += Glob( "util/*.c" ) +commonFiles += Glob( "util/*.c" ) commonFiles += Split( "client/connpool.cpp client/dbclient.cpp client/dbclient_rs.cpp client/dbclientcursor.cpp client/model.cpp client/syncclusterconnection.cpp client/distlock.cpp s/shardconnection.cpp" ) #mmap stuff coreDbFiles = [ "db/commands.cpp" ] -coreServerFiles = [ "util/net/message_server_port.cpp" , - "client/parallel.cpp" , "db/common.cpp", - "util/net/miniwebserver.cpp" , "db/dbwebserver.cpp" , +coreServerFiles = [ "util/net/message_server_port.cpp" , + "client/parallel.cpp" , "db/common.cpp", + "util/net/miniwebserver.cpp" , "db/dbwebserver.cpp" , "db/matcher.cpp" , "db/dbcommands_generic.cpp" , "db/dbmessage.cpp", "db/security_common.cpp", "db/security_commands.cpp", ] @@ -440,7 +444,7 @@ for x in os.listdir( "db/modules/" ): if os.path.exists( modBuildFile ): myModule = imp.load_module( "module_" + x , open( modBuildFile , "r" ) , modBuildFile , ( ".py" , "r" , imp.PY_SOURCE ) ) modules.append( myModule ) - + if myModule and "customIncludes" in dir(myModule) and myModule.customIncludes: pass else: @@ -523,6 +527,10 @@ elif "linux2" == os.sys.platform or "linux3" == os.sys.platform: linux = True platform = "linux" + # use system-wide pcre + env.Append( CPPPATH=["/usr/include"] ) + env.Append( LIBS=["pcrecpp", "pcre"] ) + if os.uname()[4] == "x86_64" and not force32: linux64 = True nixLibPrefix = "lib" @@ -576,7 +584,7 @@ elif "win32" == os.sys.platform: env['ENV'] = dict(os.environ) def find_boost(): - for x in ('', ' (x86)'): + for x in ('', ' (x86)'): boostDir = "C:/Program Files" + x + "/boost/latest" if os.path.exists( boostDir ): return boostDir @@ -617,12 +625,12 @@ elif "win32" == os.sys.platform: # some warnings we don't like: env.Append( CPPFLAGS=" /wd4355 /wd4800 /wd4267 /wd4244 " ) - + # PSAPI_VERSION relates to process api dll Psapi.dll. env.Append( CPPDEFINES=["_CONSOLE","_CRT_SECURE_NO_WARNINGS","PSAPI_VERSION=1" ] ) - # this would be for pre-compiled headers, could play with it later - #env.Append( CPPFLAGS=' /Yu"pch.h" ' ) + # this would be for pre-compiled headers, could play with it later + #env.Append( CPPFLAGS=' /Yu"pch.h" ' ) # docs say don't use /FD from command line (minimal rebuild) # /Gy function level linking @@ -634,11 +642,11 @@ elif "win32" == os.sys.platform: # TODO: this has caused some linking problems : # /GL whole program optimization # /LTCG link time code generation - env.Append( CPPFLAGS= " /GL " ) + env.Append( CPPFLAGS= " /GL " ) env.Append( LINKFLAGS=" /LTCG " ) else: # /Od disable optimization - # /ZI debug info w/edit & continue + # /ZI debug info w/edit & continue # /TP it's a c++ file # RTC1 /GZ (Enable Stack Frame Run-Time Error Checking) env.Append( CPPFLAGS=" /RTC1 /MDd /Z7 /TP /errorReport:none " ) @@ -647,7 +655,7 @@ elif "win32" == os.sys.platform: if debugBuild: env.Append( LINKFLAGS=" /debug " ) env.Append( CPPFLAGS=" /Od " ) - + if debugLogging: env.Append( CPPDEFINES=[ "_DEBUG" ] ) @@ -672,7 +680,7 @@ elif "win32" == os.sys.platform: winLibString = "ws2_32.lib kernel32.lib advapi32.lib Psapi.lib" if force64: - + winLibString += "" #winLibString += " LIBCMT LIBCPMT " @@ -698,8 +706,8 @@ if nix: if has_option( "distcc" ): env["CXX"] = "distcc " + env["CXX"] - - # -Winvalid-pch Warn if a precompiled header (see Precompiled Headers) is found in the search path but can't be used. + + # -Winvalid-pch Warn if a precompiled header (see Precompiled Headers) is found in the search path but can't be used. env.Append( CPPFLAGS="-fPIC -fno-strict-aliasing -ggdb -pthread -Wall -Wsign-compare -Wno-unknown-pragmas -Winvalid-pch" ) # env.Append( " -Wconversion" ) TODO: this doesn't really work yet if linux: @@ -732,7 +740,7 @@ if nix: #env.Append( LINKFLAGS=" -fprofile-generate" ) # then: #env.Append( CPPFLAGS=" -fprofile-use" ) - #env.Append( LINKFLAGS=" -fprofile-use" ) + #env.Append( LINKFLAGS=" -fprofile-use" ) if debugLogging: env.Append( CPPFLAGS=" -D_DEBUG" ); @@ -792,14 +800,14 @@ if not windows: os.chmod( keyfile , stat.S_IWUSR|stat.S_IRUSR ) moduleFiles = {} -for shortName in getThirdPartyShortNames(): +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 } - + options_topass["windows"] = windows options_topass["nix"] = nix - + if has_option( "use-system-" + shortName ) or has_option( "use-system-all" ): print( "using system version of: " + shortName ) myModule.configureSystem( env , fileLists , options_topass ) @@ -983,7 +991,7 @@ def doConfigure( myenv , shell=False ): if not found: raise "can't find a static %s" % l - # 'tcmalloc' needs to be the last library linked. Please, add new libraries before this + # 'tcmalloc' needs to be the last library linked. Please, add new libraries before this # point. if has_option( "heapcheck" ) and not shell: if ( not debugBuild ) and ( not debugLogging ): @@ -998,7 +1006,7 @@ def doConfigure( myenv , shell=False ): myenv.Append( CPPDEFINES=[ "HEAP_CHECKING" ] ) myenv.Append( CPPFLAGS="-fno-omit-frame-pointer" ) - # FIXME doConfigure() is being called twice, in the case of the shell. So if it is called + # FIXME doConfigure() is being called twice, in the case of the shell. So if it is called # with shell==True, it'd be on its second call and it would need to rearrange the libraries' # order. The following removes tcmalloc from the LIB's list and reinserts it at the end. if has_option( "heapcheck" ) and shell: @@ -1108,7 +1116,7 @@ checkErrorCodes() # main db target mongodOnlyFiles = [ "db/db.cpp", "db/compact.cpp" ] if windows: - mongodOnlyFiles.append( "util/ntservice.cpp" ) + mongodOnlyFiles.append( "util/ntservice.cpp" ) mongod = env.Program( "mongod" , commonFiles + coreDbFiles + coreServerFiles + serverOnlyFiles + mongodOnlyFiles ) Default( mongod ) @@ -1195,7 +1203,7 @@ elif not onlyServer: coreShellFiles.append( "third_party/linenoise/linenoise.cpp" ) shellEnv.Prepend( LIBPATH=[ "." ] ) - + shellEnv = doConfigure( shellEnv , shell=True ) shellEnv.Prepend( LIBS=[ "mongoshellfiles"] ) @@ -1344,14 +1352,14 @@ env.AlwaysBuild("docs") # ---- astyle ---- def doStyling( env , target , source ): - + res = utils.execsys( "astyle --version" ) res = " ".join(res) if res.count( "2." ) == 0: print( "astyle 2.x needed, found:" + res ) Exit(-1) - files = utils.getAllSourceFiles() + files = utils.getAllSourceFiles() files = filter( lambda x: not x.endswith( ".c" ) , files ) files.remove( "./shell/mongo_vstudio.cpp" ) @@ -1376,7 +1384,7 @@ def getSystemInstallName(): n += "-debugsymbols" if nix and os.uname()[2].startswith( "8." ): n += "-tiger" - + if len(moduleNames) > 0: n += "-" + "-".join( moduleNames ) @@ -1388,7 +1396,7 @@ def getSystemInstallName(): except: pass - + dn = GetOption( "distmod" ) if dn and len(dn) > 0: n = n + "-" + dn @@ -1501,7 +1509,7 @@ if installSetup.clientSrc: #lib if installSetup.libraries: env.Install( installDir + "/" + nixLibPrefix, clientLibName ) - if has_option( "sharedclient" ): + if has_option( "sharedclient" ): env.Install( installDir + "/" + nixLibPrefix, sharedClientLibName ) @@ -1583,7 +1591,7 @@ def s3push( localName , remoteName=None , remotePrefix=None , fixName=True , pla name = name.lower() else: name = remoteName - + if isDriverBuild(): name = "cxx-driver/" + name elif platformDir: