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-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-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-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-15 16:08:20 +01:00
|
|
|
commonFiles += Glob( "util/*.cpp" ) + Glob( "util/*.c" ) + Glob( "grid/*.cpp" )
|
|
|
|
commonFiles += Split( "client/connpool.cpp client/dbclient.cpp client/model.cpp" )
|
2009-01-06 00:19:56 +01:00
|
|
|
|
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-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-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-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-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:
|
|
|
|
|
|
|
|
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-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 ] )
|
|
|
|
env.Append( LIBS=[ "java" , "jvm" ] )
|
|
|
|
|
|
|
|
env.Append( LINKFLAGS="-Xlinker -rpath -Xlinker " + javaHome + "jre/lib/" + javaVersion + "/server" )
|
|
|
|
env.Append( LINKFLAGS="-Xlinker -rpath -Xlinker " + javaHome + "jre/lib/" + javaVersion )
|
|
|
|
|
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-08 15:53:46 +01:00
|
|
|
env.Append( LIBS=[ "jvm" ] )
|
|
|
|
|
|
|
|
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-08 00:05:22 +01:00
|
|
|
env.Append( LIBS=[ "pcrecpp" , "pcre" , "stdc++" ] )
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
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
|
|
|
|
if not conf.CheckLib( l + "-mt" ):
|
|
|
|
if not conf.CheckLib( l ):
|
|
|
|
print "can't find a required boost library [" + l + "]";
|
|
|
|
Exit(1)
|
|
|
|
|
|
|
|
# this will add it iff it exists and works
|
2009-01-26 22:29:19 +01:00
|
|
|
conf.CheckLib( "boost_system-mt" )
|
2009-01-18 21:32:00 +01:00
|
|
|
|
|
|
|
env = conf.Finish()
|
|
|
|
|
|
|
|
# --- 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
|
|
|
# SYSTEM CHECKS
|
|
|
|
configure = env.Configure()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ----- TARGETS ------
|
|
|
|
|
2009-01-06 00:19:56 +01:00
|
|
|
|
2009-01-12 16:34:12 +01:00
|
|
|
# main db target
|
2009-01-15 16:08:20 +01:00
|
|
|
Default( env.Program( "db/db" , commonFiles + coreDbFiles + serverOnlyFiles + [ "db/db.cpp" ] ) )
|
2009-01-12 16:34:12 +01:00
|
|
|
|
|
|
|
# tools
|
2009-01-15 16:08:20 +01:00
|
|
|
env.Program( "mongodump" , allClientFiles + [ "tools/dump.cpp" ] )
|
|
|
|
env.Program( "mongoimport" , allClientFiles + [ "tools/import.cpp" ] )
|
2009-01-06 00:19:56 +01:00
|
|
|
|
2009-01-12 16:34:12 +01:00
|
|
|
# dbgrid
|
2009-01-15 16:08:20 +01:00
|
|
|
env.Program( "db/dbgrid" , 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-13 15:15:47 +01:00
|
|
|
# examples
|
2009-01-13 15:56:18 +01:00
|
|
|
clientEnv.Program( "firstExample" , [ "client/examples/first.cpp" ] )
|
2009-01-13 18:53:00 +01:00
|
|
|
clientEnv.Program( "secondExample" , [ "client/examples/second.cpp" ] )
|
2009-01-20 17:38:12 +01:00
|
|
|
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-13 21:45:49 +01:00
|
|
|
clientEnv.Program( "clientTest" , [ "client/examples/clientTest.cpp" ] )
|
2009-01-12 21:27:55 +01:00
|
|
|
|
2009-01-17 15:22:55 +01:00
|
|
|
# ---- RUNNING TESTS ----
|
|
|
|
|
|
|
|
testEnv.Alias( "smoke", "test", test[ 0 ].abspath )
|
|
|
|
testEnv.AlwaysBuild( "smoke" )
|
|
|
|
|
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" )
|
|
|
|
env.Install( installDir + "/bin" , "mongoimport" )
|
|
|
|
env.Install( installDir + "/bin" , "db/db" )
|
|
|
|
|
|
|
|
#headers
|
|
|
|
for id in [ "" , "client/" , "util/" , "grid/" , "db/" ]:
|
|
|
|
env.Install( installDir + "/include/mongo/" + id , Glob( id + "*.h" ) )
|
|
|
|
|
|
|
|
#lib
|
2009-01-26 22:29:19 +01:00
|
|
|
# (Using InstallAs syntax so scons doesn't treat the install location as a
|
|
|
|
# dependency for the client targets.)
|
|
|
|
env.InstallAs( target=installDir + "/" + nixLibPrefix, source="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" )
|