2009-01-06 00:19:56 +01:00
|
|
|
|
|
|
|
# build file for 10gen db
|
|
|
|
# this request scons
|
|
|
|
# you can get from http://www.scons.org
|
|
|
|
# then just type scons
|
|
|
|
|
|
|
|
import os
|
2009-01-27 19:08:44 +01:00
|
|
|
import sys
|
2009-01-28 23:27:12 +01:00
|
|
|
import types
|
2009-01-06 00:19:56 +01:00
|
|
|
|
2009-01-14 16:58:32 +01:00
|
|
|
# --- options ----
|
|
|
|
AddOption('--prefix',
|
|
|
|
dest='prefix',
|
|
|
|
type='string',
|
|
|
|
nargs=1,
|
|
|
|
action='store',
|
|
|
|
metavar='DIR',
|
|
|
|
help='installation prefix')
|
|
|
|
|
2009-01-20 16:22:09 +01:00
|
|
|
AddOption( "--64",
|
|
|
|
dest="force64",
|
|
|
|
type="string",
|
|
|
|
nargs=0,
|
|
|
|
action="store",
|
|
|
|
help="whether to force 64 bit" )
|
|
|
|
|
2009-01-14 16:58:32 +01:00
|
|
|
|
2009-01-22 15:12:58 +01:00
|
|
|
AddOption( "--32",
|
|
|
|
dest="force32",
|
|
|
|
type="string",
|
|
|
|
nargs=0,
|
|
|
|
action="store",
|
|
|
|
help="whether to force 32 bit" )
|
|
|
|
|
2009-01-30 04:31:13 +01:00
|
|
|
|
|
|
|
AddOption( "--mm",
|
|
|
|
dest="mm",
|
|
|
|
type="string",
|
|
|
|
nargs=0,
|
|
|
|
action="store",
|
|
|
|
help="use main memory instead of memory mapped files" )
|
|
|
|
|
|
|
|
|
2009-01-27 04:19:15 +01:00
|
|
|
AddOption( "--release",
|
|
|
|
dest="release",
|
|
|
|
type="string",
|
|
|
|
nargs=0,
|
|
|
|
action="store",
|
|
|
|
help="relase build")
|
2009-01-22 15:12:58 +01:00
|
|
|
|
2009-01-19 19:02:41 +01:00
|
|
|
AddOption('--java',
|
|
|
|
dest='javaHome',
|
|
|
|
type='string',
|
|
|
|
default="/opt/java/",
|
|
|
|
nargs=1,
|
|
|
|
action='store',
|
|
|
|
metavar='DIR',
|
|
|
|
help='java home')
|
|
|
|
|
2009-01-27 04:19:15 +01:00
|
|
|
AddOption( "--v8" ,
|
|
|
|
dest="v8home",
|
|
|
|
type="string",
|
2009-01-27 04:54:22 +01:00
|
|
|
default="../v8/",
|
2009-01-27 04:19:15 +01:00
|
|
|
nargs=1,
|
|
|
|
action="store",
|
|
|
|
metavar="dir",
|
|
|
|
help="v8 location")
|
2009-01-19 19:02:41 +01:00
|
|
|
|
2009-01-14 16:58:32 +01:00
|
|
|
# --- environment setup ---
|
|
|
|
|
2009-01-06 00:19:56 +01:00
|
|
|
env = Environment()
|
|
|
|
|
|
|
|
env.Append( CPPPATH=[ "." ] )
|
|
|
|
|
|
|
|
|
|
|
|
boostLibs = [ "thread" , "filesystem" , "program_options" ]
|
|
|
|
|
2009-01-23 17:28:29 +01:00
|
|
|
commonFiles = Split( "stdafx.cpp db/jsobj.cpp db/json.cpp db/commands.cpp db/lasterror.cpp db/nonce.cpp" )
|
2009-01-30 04:21:33 +01:00
|
|
|
commonFiles += [ "util/background.cpp" , "util/miniwebserver.cpp" , "util/mmap.cpp" , "util/sock.cpp" , "util/util.cpp" ]
|
|
|
|
commonFiles += Glob( "util/*.c" ) + Glob( "grid/*.cpp" )
|
2009-01-15 16:08:20 +01:00
|
|
|
commonFiles += Split( "client/connpool.cpp client/dbclient.cpp client/model.cpp" )
|
2009-01-06 00:19:56 +01:00
|
|
|
|
2009-01-30 04:21:33 +01:00
|
|
|
#mmap stuff
|
|
|
|
|
2009-01-30 04:31:13 +01:00
|
|
|
if GetOption( "mm" ) != None:
|
|
|
|
commonFiles += [ "util/mmap_mm.cpp" ]
|
|
|
|
elif os.sys.platform == "win32":
|
2009-01-30 04:21:33 +01:00
|
|
|
commonFiles += [ "util/mmap_win.cpp" ]
|
|
|
|
else:
|
|
|
|
commonFiles += [ "util/mmap_posix.cpp" ]
|
|
|
|
|
2009-01-15 16:08:20 +01:00
|
|
|
coreDbFiles = Split( "" )
|
|
|
|
|
2009-01-23 17:28:29 +01:00
|
|
|
serverOnlyFiles = Split( "db/query.cpp db/introspect.cpp db/btree.cpp db/clientcursor.cpp db/javajs.cpp db/tests.cpp db/repl.cpp db/btreecursor.cpp db/cloner.cpp db/namespace.cpp db/matcher.cpp db/dbcommands.cpp db/dbeval.cpp db/dbwebserver.cpp db/dbinfo.cpp db/dbhelpers.cpp db/instance.cpp db/pdfile.cpp db/cursor.cpp db/security_commands.cpp db/security.cpp" )
|
2009-01-15 16:08:20 +01:00
|
|
|
|
|
|
|
allClientFiles = commonFiles + coreDbFiles + [ "client/clientOnly.cpp" ];
|
2009-01-06 00:19:56 +01:00
|
|
|
|
2009-01-07 19:27:01 +01:00
|
|
|
nix = False
|
2009-01-27 17:27:34 +01:00
|
|
|
linux64 = False
|
2009-01-29 00:04:08 +01:00
|
|
|
darwin = False
|
2009-01-20 16:22:09 +01:00
|
|
|
force64 = not GetOption( "force64" ) is None
|
2009-01-22 15:12:58 +01:00
|
|
|
force32 = not GetOption( "force32" ) is None
|
2009-01-28 23:27:12 +01:00
|
|
|
release = not GetOption( "release" ) is None
|
2009-01-20 16:22:09 +01:00
|
|
|
|
2009-01-22 15:12:58 +01:00
|
|
|
installDir = "/usr/local"
|
|
|
|
nixLibPrefix = "lib"
|
2009-01-07 19:27:01 +01:00
|
|
|
|
2009-01-19 20:25:50 +01:00
|
|
|
javaHome = GetOption( "javaHome" )
|
2009-01-27 17:38:41 +01:00
|
|
|
javaLibs = []
|
2009-01-19 19:02:41 +01:00
|
|
|
|
2009-01-09 18:16:32 +01:00
|
|
|
def findVersion( root , choices ):
|
|
|
|
for c in choices:
|
|
|
|
if ( os.path.exists( root + c ) ):
|
|
|
|
return root + c
|
|
|
|
raise "can't find a version of [" + root + "] choices: " + choices
|
|
|
|
|
2009-01-06 00:19:56 +01:00
|
|
|
if "darwin" == os.sys.platform:
|
2009-01-28 23:27:12 +01:00
|
|
|
darwin = True
|
|
|
|
|
2009-01-25 16:01:43 +01:00
|
|
|
env.Append( CPPPATH=[ "-I/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Headers/" ] )
|
2009-01-06 00:19:56 +01:00
|
|
|
|
|
|
|
env.Append( CPPFLAGS=" -mmacosx-version-min=10.4 " )
|
|
|
|
env.Append( FRAMEWORKS=["JavaVM"] )
|
|
|
|
|
|
|
|
if os.path.exists( "/usr/bin/g++-4.2" ):
|
|
|
|
env["CXX"] = "g++-4.2"
|
2009-01-06 00:53:46 +01:00
|
|
|
|
2009-01-07 19:27:01 +01:00
|
|
|
nix = True
|
2009-01-20 16:22:09 +01:00
|
|
|
|
2009-01-25 16:01:43 +01:00
|
|
|
if force64:
|
2009-01-26 22:29:19 +01:00
|
|
|
env.Append( CPPPATH=["/usr/64/include"] )
|
|
|
|
env.Append( LIBPATH=["/usr/64/lib"] )
|
|
|
|
installDir = "/usr/64/"
|
2009-01-25 16:01:43 +01:00
|
|
|
else:
|
|
|
|
env.Append( CPPPATH=[ "/sw/include" , "/opt/local/include"] )
|
|
|
|
env.Append( LIBPATH=["/sw/lib/", "/opt/local/lib"] )
|
|
|
|
|
2009-01-06 00:53:46 +01:00
|
|
|
elif "linux2" == os.sys.platform:
|
2009-01-30 15:46:25 +01:00
|
|
|
|
2009-01-30 15:47:01 +01:00
|
|
|
if not os.path.exists( javaHome ):
|
2009-01-30 15:46:25 +01:00
|
|
|
#fedora standarm jvm location
|
|
|
|
javaHome = "/usr/lib/jvm/java/"
|
2009-01-06 00:53:46 +01:00
|
|
|
|
|
|
|
env.Append( CPPPATH=[ javaHome + "include" , javaHome + "include/linux"] )
|
2009-01-06 00:19:56 +01:00
|
|
|
|
2009-01-06 00:53:46 +01:00
|
|
|
javaVersion = "i386";
|
|
|
|
|
2009-01-22 16:14:03 +01:00
|
|
|
if os.uname()[4] == "x86_64" and not force32:
|
2009-01-27 17:27:34 +01:00
|
|
|
linux64 = True
|
2009-01-06 00:53:46 +01:00
|
|
|
javaVersion = "amd64"
|
2009-01-22 15:12:58 +01:00
|
|
|
nixLibPrefix = "lib64"
|
2009-01-19 17:59:42 +01:00
|
|
|
env.Append( LIBPATH=["/usr/lib64"] )
|
2009-01-06 00:53:46 +01:00
|
|
|
|
|
|
|
env.Append( LIBPATH=[ javaHome + "jre/lib/" + javaVersion + "/server" , javaHome + "jre/lib/" + javaVersion ] )
|
2009-01-27 17:38:41 +01:00
|
|
|
javaLibs += [ "java" , "jvm" ]
|
2009-01-06 00:53:46 +01:00
|
|
|
|
|
|
|
env.Append( LINKFLAGS="-Xlinker -rpath -Xlinker " + javaHome + "jre/lib/" + javaVersion + "/server" )
|
|
|
|
env.Append( LINKFLAGS="-Xlinker -rpath -Xlinker " + javaHome + "jre/lib/" + javaVersion )
|
|
|
|
|
2009-01-27 04:19:15 +01:00
|
|
|
if force32:
|
2009-01-27 14:57:15 +01:00
|
|
|
env.Append( LIBPATH=["/usr/lib32"] )
|
2009-01-27 04:19:15 +01:00
|
|
|
|
2009-01-29 22:55:10 +01:00
|
|
|
#if release:
|
|
|
|
# env.Append( LINKFLAGS=" -static " )
|
2009-01-28 23:27:12 +01:00
|
|
|
|
2009-01-07 19:27:01 +01:00
|
|
|
nix = True
|
|
|
|
|
2009-01-07 21:51:42 +01:00
|
|
|
elif "win32" == os.sys.platform:
|
|
|
|
boostDir = "C:/Program Files/Boost/boost_1_35_0"
|
2009-01-09 18:16:32 +01:00
|
|
|
javaHome = findVersion( "C:/Program Files/java/" ,
|
|
|
|
[ "jdk" , "jdk1.6.0_10" ] )
|
|
|
|
winSDKHome = findVersion( "C:/Program Files/Microsoft SDKs/Windows/" ,
|
|
|
|
[ "v6.0" , "v6.0a" , "v6.1" ] )
|
2009-01-07 21:51:42 +01:00
|
|
|
|
2009-01-09 18:16:32 +01:00
|
|
|
env.Append( CPPPATH=[ boostDir , javaHome + "/include" , javaHome + "/include/win32" , "pcre-7.4" , winSDKHome + "/Include" ] )
|
2009-01-07 21:51:42 +01:00
|
|
|
|
2009-01-08 00:05:22 +01:00
|
|
|
# /Fo"Debug\\" /Fd"Debug\vc90.pdb"
|
|
|
|
|
|
|
|
env.Append( CPPFLAGS=" /Od /EHsc /Gm /RTC1 /MDd /ZI /W3 " )
|
2009-01-07 21:51:42 +01:00
|
|
|
env.Append( CPPDEFINES=["WIN32","_DEBUG","_CONSOLE","_CRT_SECURE_NO_WARNINGS","HAVE_CONFIG_H","PCRE_STATIC","_UNICODE","UNICODE" ] )
|
|
|
|
|
2009-01-09 18:16:32 +01:00
|
|
|
env.Append( LIBPATH=[ boostDir + "/Lib" , javaHome + "/Lib" , winSDKHome + "/Lib" ] )
|
2009-01-27 17:38:41 +01:00
|
|
|
javaLibs += [ "jvm" ];
|
2009-01-08 15:53:46 +01:00
|
|
|
|
|
|
|
def pcreFilter(x):
|
|
|
|
name = x.name
|
|
|
|
if x.name.endswith( "dftables.c" ):
|
|
|
|
return False
|
|
|
|
if x.name.endswith( "pcredemo.c" ):
|
|
|
|
return False
|
|
|
|
if x.name.endswith( "pcretest.c" ):
|
|
|
|
return False
|
|
|
|
if x.name.endswith( "unittest.cc" ):
|
|
|
|
return False
|
|
|
|
if x.name.endswith( "pcregrep.c" ):
|
|
|
|
return False
|
|
|
|
return True
|
|
|
|
|
|
|
|
commonFiles += filter( pcreFilter , Glob( "pcre-7.4/*.c" ) )
|
|
|
|
commonFiles += filter( pcreFilter , Glob( "pcre-7.4/*.cc" ) )
|
|
|
|
|
|
|
|
env.Append( LIBS=Split("ws2_32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib" ) )
|
2009-01-08 00:05:22 +01:00
|
|
|
|
2009-01-06 00:53:46 +01:00
|
|
|
else:
|
|
|
|
print( "No special config for [" + os.sys.platform + "] which probably means it won't work" )
|
2009-01-06 00:19:56 +01:00
|
|
|
|
2009-01-07 19:27:01 +01:00
|
|
|
if nix:
|
|
|
|
env.Append( CPPFLAGS="-fPIC -fno-strict-aliasing -ggdb -pthread -O3 -Wall -Wsign-compare -Wno-non-virtual-dtor" )
|
2009-01-25 16:01:43 +01:00
|
|
|
env.Append( LINKFLAGS=" -fPIC " )
|
2009-01-28 23:27:12 +01:00
|
|
|
env.Append( LIBS=[ "stdc++" ] )
|
2009-01-08 00:05:22 +01:00
|
|
|
|
2009-01-20 16:22:09 +01:00
|
|
|
if force64:
|
2009-01-22 16:14:03 +01:00
|
|
|
env.Append( CFLAGS="-m64" )
|
2009-01-20 16:22:09 +01:00
|
|
|
env.Append( CXXFLAGS="-m64" )
|
2009-01-22 16:14:03 +01:00
|
|
|
env.Append( LINKFLAGS="-m64" )
|
2009-01-20 16:22:09 +01:00
|
|
|
|
2009-01-22 15:12:58 +01:00
|
|
|
if force32:
|
2009-01-22 16:14:03 +01:00
|
|
|
env.Append( CFLAGS="-m32" )
|
2009-01-22 15:12:58 +01:00
|
|
|
env.Append( CXXFLAGS="-m32" )
|
2009-01-22 16:14:03 +01:00
|
|
|
env.Append( LINKFLAGS="-m32" )
|
2009-01-20 16:22:09 +01:00
|
|
|
|
|
|
|
|
2009-01-18 21:32:00 +01:00
|
|
|
# --- check system ---
|
|
|
|
|
|
|
|
conf = Configure(env)
|
|
|
|
|
2009-01-28 23:27:12 +01:00
|
|
|
def myCheckLib( poss , failIfNotFound=False ):
|
|
|
|
|
|
|
|
if type( poss ) != types.ListType :
|
|
|
|
poss = [poss]
|
|
|
|
|
|
|
|
if darwin and release and not force64:
|
|
|
|
allPlaces = [];
|
|
|
|
allPlaces += env["LIBPATH"]
|
|
|
|
allPlaces += [ "/usr/lib" , "/usr/local/lib" ]
|
|
|
|
|
|
|
|
for p in poss:
|
|
|
|
for loc in allPlaces:
|
|
|
|
fullPath = loc + "/lib" + p + ".a"
|
|
|
|
if os.path.exists( fullPath ):
|
|
|
|
env.Append( LINKFLAGS=" " + fullPath + " " )
|
|
|
|
return True
|
|
|
|
|
|
|
|
res = conf.CheckLib( poss )
|
|
|
|
if not res and failIfNotFound:
|
|
|
|
print( "can't find " + poss )
|
|
|
|
Exit(1)
|
|
|
|
|
|
|
|
return res
|
|
|
|
|
2009-01-18 21:32:00 +01:00
|
|
|
if not conf.CheckCXXHeader( 'pcrecpp.h' ):
|
|
|
|
print( "can't find pcre" )
|
|
|
|
Exit(1)
|
|
|
|
|
|
|
|
if not conf.CheckCXXHeader( "boost/filesystem/operations.hpp" ):
|
|
|
|
print( "can't find boost headers" )
|
|
|
|
Exit(1)
|
|
|
|
|
2009-01-25 16:01:43 +01:00
|
|
|
for b in boostLibs:
|
|
|
|
l = "boost_" + b
|
2009-01-28 23:27:12 +01:00
|
|
|
if not myCheckLib( [ l + "-mt" , l ] ):
|
2009-01-27 15:37:33 +01:00
|
|
|
print "can't find a required boost library [" + l + "]";
|
|
|
|
Exit(1)
|
2009-01-25 16:01:43 +01:00
|
|
|
|
2009-01-27 17:38:41 +01:00
|
|
|
for j in javaLibs:
|
2009-01-28 23:27:12 +01:00
|
|
|
if not myCheckLib( j ):
|
2009-01-27 17:38:41 +01:00
|
|
|
print( "can't find java lib [" + j + "]" )
|
|
|
|
Exit(1)
|
|
|
|
|
2009-01-28 23:27:12 +01:00
|
|
|
if nix:
|
|
|
|
myCheckLib( "pcrecpp" , True )
|
|
|
|
myCheckLib( "pcre" , True )
|
|
|
|
|
|
|
|
|
2009-01-25 16:01:43 +01:00
|
|
|
# this will add it iff it exists and works
|
2009-01-28 23:27:12 +01:00
|
|
|
myCheckLib( "boost_system-mt" )
|
2009-01-18 21:32:00 +01:00
|
|
|
|
|
|
|
env = conf.Finish()
|
|
|
|
|
2009-01-27 04:19:15 +01:00
|
|
|
# --- v8 ---
|
|
|
|
|
|
|
|
v8Home = GetOption( "v8home" )
|
|
|
|
|
2009-01-27 05:30:22 +01:00
|
|
|
if not os.path.exists( v8Home ):
|
2009-01-27 04:19:15 +01:00
|
|
|
for poss in [ "../v8" , "../open-source/v8" ]:
|
|
|
|
if os.path.exists( poss ):
|
|
|
|
v8Home = poss
|
|
|
|
break
|
|
|
|
|
|
|
|
# --- js concat ---
|
|
|
|
|
|
|
|
def concatjs(target, source, env):
|
|
|
|
|
|
|
|
outFile = str( target[0] )
|
|
|
|
|
|
|
|
fullSource = ""
|
|
|
|
|
|
|
|
for s in source:
|
|
|
|
f = open( str(s) , 'r' )
|
|
|
|
for l in f:
|
|
|
|
fullSource += l
|
|
|
|
|
|
|
|
out = open( outFile , 'w' )
|
|
|
|
out.write( fullSource )
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
jsBuilder = Builder(action = concatjs,
|
|
|
|
suffix = '.jsall',
|
|
|
|
src_suffix = '.js')
|
|
|
|
|
|
|
|
env.Append( BUILDERS={'JSConcat' : jsBuilder})
|
|
|
|
|
|
|
|
# --- jsh ---
|
|
|
|
|
|
|
|
def jsToH(target, source, env):
|
|
|
|
|
|
|
|
outFile = str( target[0] )
|
|
|
|
if len( source ) != 1:
|
|
|
|
raise Exception( "wrong" )
|
|
|
|
|
|
|
|
h = "const char * jsconcatcode = \n"
|
|
|
|
|
|
|
|
for l in open( str(source[0]) , 'r' ):
|
|
|
|
l = l.strip()
|
|
|
|
l = l.partition( "//" )[0]
|
|
|
|
l = l.replace( '\\' , "\\\\" )
|
|
|
|
l = l.replace( '"' , "\\\"" )
|
|
|
|
|
|
|
|
|
|
|
|
h += '"' + l + "\\n\"\n "
|
|
|
|
|
|
|
|
h += ";\n\n"
|
|
|
|
|
|
|
|
out = open( outFile , 'w' )
|
|
|
|
out.write( h )
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
jshBuilder = Builder(action = jsToH,
|
|
|
|
suffix = '.jsh',
|
|
|
|
src_suffix = '.jsall')
|
|
|
|
|
|
|
|
env.Append( BUILDERS={'JSHeader' : jshBuilder})
|
|
|
|
|
|
|
|
|
2009-01-18 21:32:00 +01:00
|
|
|
# --- targets ----
|
2009-01-08 00:05:22 +01:00
|
|
|
|
2009-01-13 15:56:18 +01:00
|
|
|
clientEnv = env.Clone();
|
|
|
|
clientEnv.Append( CPPPATH=["../"] )
|
2009-01-15 16:08:20 +01:00
|
|
|
clientEnv.Append( LIBS=[ "libmongoclient.a"] )
|
2009-01-13 15:56:18 +01:00
|
|
|
clientEnv.Append( LIBPATH=["."] )
|
|
|
|
|
2009-01-15 16:08:20 +01:00
|
|
|
testEnv = env.Clone()
|
|
|
|
testEnv.Append( CPPPATH=["../"] )
|
|
|
|
testEnv.Append( LIBS=[ "unittest" , "libmongotestfiles.a" ] )
|
|
|
|
testEnv.Append( LIBPATH=["."] )
|
|
|
|
|
2009-01-12 21:27:55 +01:00
|
|
|
|
|
|
|
# ----- TARGETS ------
|
|
|
|
|
2009-01-06 00:19:56 +01:00
|
|
|
|
2009-01-12 16:34:12 +01:00
|
|
|
# main db target
|
2009-01-27 15:26:15 +01:00
|
|
|
Default( env.Program( "mongod" , commonFiles + coreDbFiles + serverOnlyFiles + [ "db/db.cpp" ] ) )
|
2009-01-12 16:34:12 +01:00
|
|
|
|
|
|
|
# tools
|
2009-01-27 21:16:09 +01:00
|
|
|
allToolFiles = allClientFiles + [ "tools/Tool.cpp" ]
|
|
|
|
env.Program( "mongodump" , allToolFiles + [ "tools/dump.cpp" ] )
|
|
|
|
env.Program( "mongoimport" , allToolFiles + [ "tools/import.cpp" ] )
|
2009-01-29 19:01:45 +01:00
|
|
|
env.Program( "mongoimportjson" , allToolFiles + [ "tools/importJSON.cpp" ] )
|
2009-01-06 00:19:56 +01:00
|
|
|
|
2009-01-12 16:34:12 +01:00
|
|
|
# dbgrid
|
2009-01-27 15:26:15 +01:00
|
|
|
env.Program( "mongogrid" , commonFiles + coreDbFiles + Glob( "dbgrid/*.cpp" ) )
|
2009-01-12 16:34:12 +01:00
|
|
|
|
|
|
|
# c++ library
|
2009-01-15 16:08:20 +01:00
|
|
|
env.Library( "mongoclient" , allClientFiles )
|
|
|
|
env.Library( "mongotestfiles" , commonFiles + coreDbFiles + serverOnlyFiles )
|
2009-01-12 21:27:55 +01:00
|
|
|
|
2009-01-29 15:19:51 +01:00
|
|
|
clientTests = []
|
|
|
|
|
2009-01-13 15:15:47 +01:00
|
|
|
# examples
|
2009-01-29 15:19:51 +01:00
|
|
|
clientTests += [ clientEnv.Program( "firstExample" , [ "client/examples/first.cpp" ] ) ]
|
|
|
|
clientTests += [ clientEnv.Program( "secondExample" , [ "client/examples/second.cpp" ] ) ]
|
2009-01-29 16:30:25 +01:00
|
|
|
clientTests += [ clientEnv.Program( "whereExample" , [ "client/examples/whereExample.cpp" ] ) ]
|
2009-01-29 15:19:51 +01:00
|
|
|
clientTests += [ clientEnv.Program( "authTest" , [ "client/examples/authTest.cpp" ] ) ]
|
2009-01-12 21:27:55 +01:00
|
|
|
|
2009-01-13 15:15:47 +01:00
|
|
|
# testing
|
2009-01-17 15:22:55 +01:00
|
|
|
test = testEnv.Program( "test" , Glob( "dbtests/*.cpp" ) )
|
2009-01-29 15:19:51 +01:00
|
|
|
clientTests += [ clientEnv.Program( "clientTest" , [ "client/examples/clientTest.cpp" ] ) ]
|
2009-01-12 21:27:55 +01:00
|
|
|
|
2009-01-27 17:27:34 +01:00
|
|
|
|
|
|
|
# --- shell ---
|
|
|
|
# shell is complicated by the fact that v8 doesn't work 64-bit yet
|
|
|
|
|
|
|
|
shellEnv = env.Clone();
|
|
|
|
shellEnv.Append( CPPPATH=[ "../" , v8Home + "/include/" ] )
|
2009-01-27 19:19:35 +01:00
|
|
|
shellEnv.Append( LIBS=[ "v8" , "readline" ] )
|
2009-01-27 17:27:34 +01:00
|
|
|
shellEnv.Append( LIBPATH=[ v8Home] )
|
|
|
|
|
2009-01-27 04:19:15 +01:00
|
|
|
shellEnv.JSConcat( "shell/mongo.jsall" , Glob( "shell/*.js" ) )
|
|
|
|
shellEnv.JSHeader( "shell/mongo.jsall" )
|
2009-01-27 17:27:34 +01:00
|
|
|
|
2009-01-27 19:19:35 +01:00
|
|
|
if linux64 or force64:
|
|
|
|
if linux64:
|
|
|
|
shellEnv.Append( CFLAGS="-m32" )
|
|
|
|
shellEnv.Append( CXXFLAGS="-m32" )
|
|
|
|
shellEnv.Append( LINKFLAGS="-m32" )
|
|
|
|
shellEnv.Append( LIBPATH=[ "/usr/lib32" ] )
|
|
|
|
else:
|
|
|
|
shellEnv["CFLAGS"].remove("-m64")
|
|
|
|
shellEnv["CXXFLAGS"].remove("-m64")
|
|
|
|
shellEnv["LINKFLAGS"].remove("-m64")
|
|
|
|
shellEnv["CPPPATH"].remove( "/usr/64/include" )
|
|
|
|
shellEnv["LIBPATH"].remove( "/usr/64/lib" )
|
|
|
|
shellEnv.Append( CPPPATH=[ "/sw/include" , "/opt/local/include"] )
|
2009-01-28 23:27:12 +01:00
|
|
|
shellEnv.Append( LIBPATH=[ "/sw/lib/", "/opt/local/lib"] )
|
2009-01-27 19:19:35 +01:00
|
|
|
|
2009-01-27 17:27:34 +01:00
|
|
|
l = shellEnv["LIBS"]
|
2009-01-27 19:19:35 +01:00
|
|
|
if linux64:
|
|
|
|
l.remove("java")
|
|
|
|
l.remove("jvm")
|
|
|
|
l.remove("pcre")
|
|
|
|
l.remove("pcrecpp")
|
2009-01-27 17:27:34 +01:00
|
|
|
|
|
|
|
shell32BitFiles = Glob( "shell/*.cpp" )
|
|
|
|
for f in allClientFiles:
|
|
|
|
shell32BitFiles.append( "32bit/" + str( f ) )
|
|
|
|
|
|
|
|
shellEnv.VariantDir( "32bit" , "." )
|
|
|
|
shellEnv.Program( "mongo" , shell32BitFiles )
|
|
|
|
else:
|
|
|
|
shellEnv.Append( LIBPATH=[ "." ] )
|
|
|
|
shellEnv.Append( LIBS=[ "mongoclient"] )
|
|
|
|
shellEnv.Program( "mongo" , Glob( "shell/*.cpp" ) );
|
|
|
|
|
2009-01-27 04:19:15 +01:00
|
|
|
|
2009-01-17 15:22:55 +01:00
|
|
|
# ---- RUNNING TESTS ----
|
|
|
|
|
2009-01-29 15:19:51 +01:00
|
|
|
def testSetup( env , target , source ):
|
|
|
|
Mkdir( "/tmp/unittest/" )
|
|
|
|
|
|
|
|
testEnv.Alias( "smoke", [ "test" ] , [ testSetup , test[ 0 ].abspath ] )
|
2009-01-17 15:22:55 +01:00
|
|
|
testEnv.AlwaysBuild( "smoke" )
|
|
|
|
|
2009-01-29 15:19:51 +01:00
|
|
|
testEnv.Alias( "smokeClient" , [] , [ x[0].abspath for x in clientTests ] );
|
|
|
|
testEnv.AlwaysBuild( "smokeClient" )
|
|
|
|
|
2009-01-12 21:27:55 +01:00
|
|
|
# ---- INSTALL -------
|
|
|
|
|
2009-01-14 16:58:32 +01:00
|
|
|
if GetOption( "prefix" ):
|
|
|
|
installDir = GetOption( "prefix" )
|
2009-01-12 21:27:55 +01:00
|
|
|
|
|
|
|
#binaries
|
|
|
|
env.Install( installDir + "/bin" , "mongodump" )
|
2009-01-29 19:01:45 +01:00
|
|
|
env.Install( installDir + "/bin" , "mongoimportjson" )
|
2009-01-27 15:26:15 +01:00
|
|
|
env.Install( installDir + "/bin" , "mongod" )
|
|
|
|
env.Install( installDir + "/bin" , "mongo" )
|
2009-01-12 21:27:55 +01:00
|
|
|
|
2009-01-27 19:19:35 +01:00
|
|
|
# NOTE: In some cases scons gets confused between installation targets and build
|
|
|
|
# dependencies. Here, we use InstallAs instead of Install to prevent such confusion
|
|
|
|
# on a case-by-case basis.
|
|
|
|
|
2009-01-12 21:27:55 +01:00
|
|
|
#headers
|
2009-01-27 19:19:35 +01:00
|
|
|
for id in [ "", "util/", "grid/", "db/" ]:
|
2009-01-12 21:27:55 +01:00
|
|
|
env.Install( installDir + "/include/mongo/" + id , Glob( id + "*.h" ) )
|
2009-01-27 19:19:35 +01:00
|
|
|
env.Install( installDir + "/include/mongo/client" , "client/connpool.h" )
|
|
|
|
env.Install( installDir + "/include/mongo/client" , "client/model.h" )
|
|
|
|
env.InstallAs( target=installDir + "/include/mongo/client" , source="client/dbclient.h" )
|
2009-01-12 21:27:55 +01:00
|
|
|
|
|
|
|
#lib
|
2009-01-29 03:19:27 +01:00
|
|
|
env.Install( installDir + "/" + nixLibPrefix, "libmongoclient.a" )
|
2009-01-22 17:15:51 +01:00
|
|
|
env.Install( installDir + "/" + nixLibPrefix + "/mongo/jars" , Glob( "jars/*" ) )
|
2009-01-12 21:27:55 +01:00
|
|
|
|
|
|
|
#final alias
|
|
|
|
env.Alias( "install" , installDir )
|
|
|
|
|
2009-01-17 15:22:55 +01:00
|
|
|
# ---- CONVENIENCE ----
|
|
|
|
|
|
|
|
def tabs( env, target, source ):
|
|
|
|
from subprocess import Popen, PIPE
|
|
|
|
from re import search, match
|
|
|
|
diff = Popen( [ "git", "diff", "-U0", "origin", "master" ], stdout=PIPE ).communicate()[ 0 ]
|
|
|
|
sourceFile = False
|
|
|
|
for line in diff.split( "\n" ):
|
|
|
|
if match( "diff --git", line ):
|
2009-01-18 16:23:57 +01:00
|
|
|
sourceFile = not not search( "\.(h|hpp|c|cpp)\s*$", line )
|
2009-01-17 16:33:43 +01:00
|
|
|
if sourceFile and match( "\+ *\t", line ):
|
2009-01-17 15:22:55 +01:00
|
|
|
return True
|
|
|
|
return False
|
|
|
|
env.Alias( "checkSource", [], [ tabs ] )
|
|
|
|
env.AlwaysBuild( "checkSource" )
|
|
|
|
|
|
|
|
def gitPush( env, target, source ):
|
|
|
|
import subprocess
|
|
|
|
return subprocess.call( [ "git", "push" ] )
|
2009-01-26 22:29:19 +01:00
|
|
|
env.Alias( "push", [ ".", "smoke", "checkSource" ], gitPush )
|
2009-01-17 15:22:55 +01:00
|
|
|
env.AlwaysBuild( "push" )
|
2009-01-27 19:08:44 +01:00
|
|
|
|
|
|
|
|
|
|
|
# ---- deploying ---
|
|
|
|
|
|
|
|
def s3push( localName , remoteName=None , remotePrefix="-latest" ):
|
|
|
|
sys.path.append( "." )
|
|
|
|
|
|
|
|
import simples3
|
|
|
|
import settings
|
|
|
|
|
|
|
|
s = simples3.S3Bucket( "mongodb" , settings.id , settings.key )
|
|
|
|
un = os.uname()
|
|
|
|
|
|
|
|
if remoteName is None:
|
|
|
|
remoteName = localName
|
|
|
|
|
|
|
|
name = remoteName + "-" + un[0] + "-" + un[4] + remotePrefix
|
|
|
|
name = name.lower()
|
|
|
|
|
|
|
|
s.put( name , open( localName ).read() , acl="public-read" );
|
|
|
|
print( "uploaded " + localName + " to http://s3.amazonaws.com/" + s.name + "/" + name )
|
|
|
|
|
|
|
|
def s3shellpush( env , target , source ):
|
|
|
|
s3push( "mongo" , "mongo-shell" )
|
|
|
|
|
|
|
|
env.Alias( "s3shell" , [ "mongo" ] , [ s3shellpush ] )
|
|
|
|
env.AlwaysBuild( "s3shell" )
|