summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@10gen.com>2012-01-04 11:30:29 -0800
committerAndy Schwerin <schwerin@10gen.com>2012-01-17 14:58:51 -0800
commit30668e1c79cf6e8dac45a61b64694c045e1a59f5 (patch)
treeda617cbf9d6c85c62564e48e2639d516e746a836
parent8a002c30c6d6749f87c618b61d3f58d54696bb7a (diff)
downloadmongo-30668e1c79cf6e8dac45a61b64694c045e1a59f5.tar.gz
SCons updates to support variant directories.
This patch is a reorganization of our build files, which brings them slightly closer in line with standard SCons organization. In particular, the SConstruct file sets up the various "build environment" objects, by examining the local system and command line parameters. Then, it delegates to some SConscript files, which describe build rules, like how to compile "mongod" from source. Typically, you would create several SConscript files for a project this large, after breaking the project into logical sub projects, such as "platform abstraction", "data manager", "query optimizer", etc. That will be future work. For now, we only separate out the special rules for executing smoke tests into SConscript.smoke. Pretty much all other build rules are in src/mongo/SConscript. "tools" are placed in site_scons/site_tools. This patch also includes better support for building and tracking dependencies among static libraries ("libdeps" and "MergeLibrary"), and some incumbent, minor restructuring. This patch introduces a "warning" message from SCons about framework.o having two rules that generate it. It is harmless, for now, and will be removed in future work. Future work also includes eliminating use of the SCons "Glob" utility, and restructuring the source code into sensible components.
-rw-r--r--.gitignore82
-rw-r--r--SConscript.smoke117
-rw-r--r--SConstruct750
-rw-r--r--site_scons/libdeps.py189
-rw-r--r--site_scons/site_tools/gch.py (renamed from gch.py)11
-rw-r--r--site_scons/site_tools/jsheader.py53
-rw-r--r--site_scons/site_tools/mergelib.py24
-rw-r--r--site_scons/site_tools/mergelibposix.py42
-rw-r--r--site_scons/site_tools/mergelibwin.py34
-rw-r--r--src/SConscript7
-rw-r--r--src/mongo/SConscript563
-rw-r--r--src/mongo/client/clientAndShell.cpp96
-rw-r--r--src/mongo/client/clientOnly.cpp76
-rw-r--r--src/third_party/SConscript14
-rw-r--r--src/third_party/mongo_pcrecpp.cc3
-rw-r--r--src/third_party/pcre-7.4/SConscript33
-rw-r--r--src/third_party/pcre.py42
-rw-r--r--src/third_party/sm.py2
-rw-r--r--src/third_party/snappy.py5
19 files changed, 1333 insertions, 810 deletions
diff --git a/.gitignore b/.gitignore
index 82a9d95186e..71b9f9a6e68 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,9 +1,10 @@
-.jsdbshell
-.dbshell
-.sconsign.dblite
-.sconf_temp
-perf.data
-massif.out.*
+/build
+/.jsdbshell
+/.dbshell
+/.sconsign.dblite
+/.sconf_temp
+/perf.data
+/massif.out.*
*~
*.swp
@@ -17,7 +18,6 @@ massif.out.*
*.ncb
*.idb
*.obj
-*/*.obj
*.opt
*.pch
*.jsh
@@ -36,8 +36,6 @@ massif.out.*
*.psess
*#
.#*
-/src/mongo/shell/mongo.cpp
-/src/mongo/shell/mongo-server.cpp
/src/mongo/*/*Debug/
/src/mongo/*/*/*Debug/
@@ -50,7 +48,6 @@ massif.out.*
/src/mongo/db/_ReSharper.db
config.log
settings.py
-buildinfo.cpp
tags
TAGS
failfile.smoke
@@ -67,50 +64,47 @@ scratch
# binaries
/mongo
-mongod
-mongogrid
-mongos
+/mongod
+/mongogrid
+/mongos
-mongodump
-mongorestore
+/mongodump
+/mongorestore
-mongofiles
-mongoexport
+/mongofiles
+/mongoexport
-mongoimport
-mongosniff
-mongobridge
-mongostat
-mongotop
-mongooplog
-mongoperf
-bsondump
+/mongoimport
+/mongosniff
+/mongobridge
+/mongostat
+/mongotop
+/mongooplog
+/mongoperf
+/bsondump
*.tgz
*.zip
*.tar.gz
-mongodb-*
-mongo-cxx-driver-*
-
#libs
-libmongoclient.*
-libmongotestfiles.*
-libmongoshellfiles.*
+/libmongoclient.*
+/libmongotestfiles.*
+/libmongoshellfiles.*
# examples
-firstExample
-secondExample
-whereExample
-bsondemo
-rsExample
+/firstExample
+/secondExample
+/whereExample
+/bsondemo
+/rsExample
#tests
-test
-authTest
-perftest
-clientTest
-httpClientTest
+/test
+/authTest
+/perftest
+/clientTest
+/httpClientTest
#debian
build-stamp
@@ -122,12 +116,6 @@ debian/mongodb
#osx
.DS_Store
-#third party
-src/third_party/js-1.7/jsautocfg.h
-src/third_party/js-1.7/jsautokw.h
-src/third_party/js-1.7/jskwgen
-src/third_party/js-1.7/jscpucfg
-
# QtCreator
*.config
*.creator
diff --git a/SConscript.smoke b/SConscript.smoke
new file mode 100644
index 00000000000..1a7f6196cde
--- /dev/null
+++ b/SConscript.smoke
@@ -0,0 +1,117 @@
+# -*- mode: python -*-
+#
+# This SConscript file describes the build rules for smoke tests (scons smoke,
+# e.g.)
+
+import os
+
+Import( "has_option env shellEnv testEnv" )
+
+def add_exe( v ):
+ return "${PROGPREFIX}%s${PROGSUFFIX}" % v
+
+smokeEnv = testEnv.Clone()
+smokeEnv['ENV']['PATH']=os.environ['PATH']
+smokeEnv.Alias( "dummySmokeSideEffect", [], [] )
+
+smokeFlags = []
+
+# Ugh. Frobbing the smokeFlags must precede using them to construct
+# actions, I think.
+if has_option( 'smokedbprefix'):
+ smokeFlags += ['--smoke-db-prefix', GetOption( 'smokedbprefix')]
+
+if 'startMongodSmallOplog' in COMMAND_LINE_TARGETS:
+ smokeFlags += ["--small-oplog"]
+
+def addTest(name, deps, actions):
+ smokeEnv.Alias( name, deps, actions )
+ smokeEnv.AlwaysBuild( name )
+ # Prevent smoke tests from running in parallel
+ smokeEnv.SideEffect( "dummySmokeSideEffect", name )
+
+def addSmoketest( name, deps ):
+ # Convert from smoke to test, smokeJs to js, and foo to foo
+ target = name
+ if name.startswith("smoke"):
+ if name == "smoke":
+ target = File("test").path
+ else:
+ target = name[5].lower() + name[6:]
+
+ addTest(name, deps, [ "python buildscripts/smoke.py " + " ".join(smokeFlags) + ' ' + target ])
+
+addSmoketest( "smoke", [ add_exe( "test" ), add_exe( "mongod" ), add_exe( "mongo" ) ] )
+addSmoketest( "smokePerf", [ add_exe("perftest") ] )
+addSmoketest( "smokeClient", [
+ add_exe('firstExample'),
+ add_exe('rsExample'),
+ add_exe('secondExample'),
+ add_exe('whereExample'),
+ add_exe('authTest'),
+ add_exe('httpClientTest'),
+ add_exe('bsondemo'),
+ add_exe('clientTest'),
+ ] )
+addSmoketest( "mongosTest", [ add_exe( 'mongos' ) ])
+
+# These tests require the mongo shell
+if shellEnv is not None:
+ addSmoketest( "smokeJs", [add_exe("mongo")] )
+ addSmoketest( "smokeClone", [ add_exe("mongo"), add_exe("mongod") ] )
+ addSmoketest( "smokeRepl", [ add_exe("mongo"), add_exe("mongod"), add_exe("mongobridge") ] )
+ addSmoketest( "smokeReplSets", [ add_exe("mongo"), add_exe("mongod"), add_exe("mongobridge") ] )
+ addSmoketest( "smokeDur", [ add_exe( "mongo" ), add_exe( "mongod" ), add_exe('mongorestore') ] )
+ addSmoketest( "smokeDisk", [ add_exe( "mongo" ), add_exe( "mongod" ), add_exe( "mongodump" ), add_exe( "mongorestore" ) ] )
+ addSmoketest( "smokeAuth", [ add_exe( "mongo" ), add_exe( "mongod" ) ] )
+ addSmoketest( "smokeParallel", [ add_exe( "mongo" ), add_exe( "mongod" ) ] )
+ addSmoketest( "smokeSharding", [ add_exe("mongo"), add_exe("mongod"), add_exe("mongos") ] )
+ addSmoketest( "smokeJsPerf", [ add_exe("mongo") ] )
+ addSmoketest( "smokeJsSlowNightly", [add_exe("mongo")])
+ addSmoketest( "smokeJsSlowWeekly", [add_exe("mongo")])
+ addSmoketest( "smokeQuota", [ add_exe("mongo") ] )
+ addSmoketest( "smokeTool", [ add_exe( "mongo" ), add_exe("mongod"), add_exe("mongos"), "tools" ] )
+
+# Note: although the test running logic has been moved to
+# buildscripts/smoke.py, the interface to running the tests has been
+# something like 'scons startMongod <suite>'; startMongod is now a
+# no-op, and should go away eventually.
+smokeEnv.Alias( "startMongod", [add_exe("mongod")]);
+smokeEnv.AlwaysBuild( "startMongod" );
+smokeEnv.SideEffect( "dummySmokeSideEffect", "startMongod" )
+
+smokeEnv.Alias( "startMongodSmallOplog", [add_exe("mongod")], [] );
+smokeEnv.AlwaysBuild( "startMongodSmallOplog" );
+smokeEnv.SideEffect( "dummySmokeSideEffect", "startMongodSmallOplog" )
+
+def addMongodReqTargets( env, target, source ):
+ mongodReqTargets = [ "smokeClient", "smokeJs" ]
+ for target in mongodReqTargets:
+ smokeEnv.Depends( target, "startMongod" )
+ smokeEnv.Depends( "smokeAll", target )
+
+smokeEnv.Alias( "addMongodReqTargets", [], [addMongodReqTargets] )
+smokeEnv.AlwaysBuild( "addMongodReqTargets" )
+
+smokeEnv.Alias( "smokeAll", [ "smoke", "mongosTest", "smokeClone", "smokeRepl", "addMongodReqTargets", "smokeDisk", "smokeAuth", "smokeSharding", "smokeTool" ] )
+smokeEnv.AlwaysBuild( "smokeAll" )
+
+def addMongodReqNoJsTargets( env, target, source ):
+ mongodReqTargets = [ "smokeClient" ]
+ for target in mongodReqTargets:
+ smokeEnv.Depends( target, "startMongod" )
+ smokeEnv.Depends( "smokeAllNoJs", target )
+
+smokeEnv.Alias( "addMongodReqNoJsTargets", [], [addMongodReqNoJsTargets] )
+smokeEnv.AlwaysBuild( "addMongodReqNoJsTargets" )
+
+smokeEnv.Alias( "smokeAllNoJs", [ "smoke", "mongosTest", "addMongodReqNoJsTargets" ] )
+smokeEnv.AlwaysBuild( "smokeAllNoJs" )
+
+def run_shell_tests(env, target, source):
+ from buildscripts import test_shell
+ test_shell.mongo_path = windows and "mongo.exe" or "mongo"
+ test_shell.run_tests()
+
+env.Alias("test_shell", [], [run_shell_tests])
+env.AlwaysBuild("test_shell")
diff --git a/SConstruct b/SConstruct
index b8dbf61bc80..a8a494cb9a9 100644
--- a/SConstruct
+++ b/SConstruct
@@ -10,6 +10,9 @@
# scons --distname=0.8 s3dist
# all s3 pushes require settings.py and simples3
+# This file, SConstruct, configures the build environment, and then delegates to
+# several, subordinate SConscript files, which describe specific build rules.
+
EnsureSConsVersion(0, 98, 4) # this is a common version known to work
import os
@@ -25,6 +28,8 @@ import buildscripts.bb
import stat
from buildscripts import utils
+import libdeps
+
buildscripts.bb.checkOk()
def findSettingsSetup():
@@ -37,7 +42,7 @@ def getThirdPartyShortNames():
for x in os.listdir( "src/third_party" ):
if not x.endswith( ".py" ) or x.find( "#" ) >= 0:
continue
-
+
lst.append( x.rpartition( "." )[0] )
return lst
@@ -107,7 +112,7 @@ def get_variant_dir():
else:
a.append( name + "-" + get_option( name ) )
- s = "build/"
+ s = "#build/${PYSYSPLATFORM}/"
if len(a) > 0:
a.sort()
@@ -166,7 +171,7 @@ add_option( "win2008plus", "use newer operating system API features" , 0 , False
# dev options
add_option( "d", "debug build no optimization, etc..." , 0 , True , "debugBuild" )
-add_option( "dd", "debug build no optimization, additional debug logging, etc..." , 0 , False , "debugBuildAndLogging" )
+add_option( "dd", "debug build no optimization, additional debug logging, etc..." , 0 , True , "debugBuildAndLogging" )
add_option( "durableDefaultOn" , "have durable default to on" , 0 , True )
add_option( "durableDefaultOff" , "have durable default to off" , 0 , True )
@@ -176,9 +181,6 @@ add_option( "clang" , "use clang++ rather than g++ (experimental)" , 0 , True )
# debugging/profiling help
-# to use CPUPROFILE=/tmp/profile
-# to view pprof -gv mongod /tmp/profile
-add_option( "pg", "link against profiler" , 0 , False , "profile" )
add_option( "tcmalloc" , "link against tcmalloc" , 0 , False )
add_option( "gdbserver" , "build in gdb server support" , 0 , True )
add_option( "heapcheck", "link to heap-checking malloc-lib and look for memory leaks during tests" , 0 , False )
@@ -188,7 +190,9 @@ 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 " , 0 , True )
+add_option( "use-system-pcre", "use system version of pcre library", 0, True )
+
+add_option( "use-system-all" , "use all system libraries", 0 , True )
add_option( "use-cpu-profiler",
"Link against the google-perftools profiler library",
@@ -200,6 +204,8 @@ if GetOption('help'):
# --- environment setup ---
+variantDir = get_variant_dir()
+
def removeIfInList( lst , thing ):
if thing in lst:
lst.remove( thing )
@@ -247,7 +253,25 @@ usePCH = has_option( "usePCH" )
justClientLib = (COMMAND_LINE_TARGETS == ['mongoclient'])
-env = Environment( MSVS_ARCH=msarch , tools = ["default", "gch"], toolpath = '.' )
+env = Environment( BUILD_DIR=variantDir,
+ MSVS_ARCH=msarch ,
+ tools=["default", "gch", "jsheader", "mergelib" ],
+ PYSYSPLATFORM=os.sys.platform,
+
+ PCRE_VERSION='7.4',
+ )
+
+
+libdeps.setup_environment( env )
+
+if env['PYSYSPLATFORM'] == 'linux3':
+ env['PYSYSPLATFORM'] = 'linux2'
+
+if os.sys.platform == 'win32':
+ env['OS_FAMILY'] = 'win'
+else:
+ env['OS_FAMILY'] = 'posix'
+
if has_option( "cxx" ):
env["CC"] = get_option( "cxx" )
env["CXX"] = get_option( "cxx" )
@@ -258,6 +282,19 @@ elif has_option("clang"):
if has_option( "cc" ):
env["CC"] = get_option( "cc" )
+if env['PYSYSPLATFORM'] == 'linux2':
+ env['LINK_LIBGROUP_START'] = '-Wl,--start-group'
+ env['LINK_LIBGROUP_END'] = '-Wl,--end-group'
+ env['RELOBJ_LIBDEPS_START'] = '--whole-archive'
+ env['RELOBJ_LIBDEPS_END'] = '--no-whole-archive'
+ env['RELOBJ_LIBDEPS_ITEM'] = ''
+elif env['PYSYSPLATFORM'] == 'darwin':
+ env['LINK_LIBGROUP_START'] = ''
+ env['LINK_LIBGROUP_END'] = ''
+ env['RELOBJ_LIBDEPS_START'] = ''
+ env['RELOBJ_LIBDEPS_END'] = ''
+ env['RELOBJ_LIBDEPS_ITEM'] = '-force_load'
+
env["LIBPATH"] = []
if has_option( "libpath" ):
@@ -266,9 +303,9 @@ if has_option( "libpath" ):
if has_option( "cpppath" ):
env["CPPPATH"] = [get_option( "cpppath" )]
-env.Append( CPPDEFINES=[ "_SCONS" , "MONGO_EXPOSE_MACROS" ] )
-env.Append( CPPPATH=[ "./src/mongo" ] )
-env.Append( CPPPATH=[ "./src/" ] )
+env.Append( CPPDEFINES=[ "_SCONS" , "MONGO_EXPOSE_MACROS" ],
+ CPPPATH=[ '$BUILD_DIR', "$BUILD_DIR/mongo" ] )
+#env.Append( CPPPATH=[ "src/mongo", "src" ] )
if has_option( "safeshell" ):
env.Append( CPPDEFINES=[ "MONGO_SAFE_SHELL" ] )
@@ -353,162 +390,6 @@ if has_option( "full" ):
installSetup.headers = True
installSetup.libraries = True
-
-#env.VariantDir( get_variant_dir() , "src" , duplicate=0 )
-
-# ------ SOURCE FILE SETUP -----------
-
-commonFiles = [ "src/mongo/pch.cpp" , "src/mongo/buildinfo.cpp" , "src/mongo/db/indexkey.cpp" , "src/mongo/db/jsobj.cpp" , "src/mongo/bson/oid.cpp" , "src/mongo/db/json.cpp" , "src/mongo/db/lasterror.cpp" , "src/mongo/db/nonce.cpp" , "src/mongo/db/queryutil.cpp" , "src/mongo/db/querypattern.cpp" , "src/mongo/db/projection.cpp" , "src/mongo/shell/mongo.cpp" ]
-commonFiles += [ "src/mongo/util/background.cpp" , "src/mongo/util/intrusive_counter.cpp",
- "src/mongo/util/util.cpp" , "src/mongo/util/file_allocator.cpp" ,
- "src/mongo/util/assert_util.cpp" , "src/mongo/util/log.cpp" , "src/mongo/util/ramlog.cpp" , "src/mongo/util/md5main.cpp" , "src/mongo/util/base64.cpp", "src/mongo/util/concurrency/vars.cpp", "src/mongo/util/concurrency/task.cpp", "src/mongo/util/debug_util.cpp",
- "src/mongo/util/concurrency/thread_pool.cpp", "src/mongo/util/password.cpp", "src/mongo/util/version.cpp", "src/mongo/util/signal_handlers.cpp",
- "src/mongo/util/concurrency/rwlockimpl.cpp", "src/mongo/util/histogram.cpp", "src/mongo/util/concurrency/spin_lock.cpp", "src/mongo/util/text.cpp" , "src/mongo/util/stringutils.cpp" ,
- "src/mongo/util/concurrency/synchronization.cpp" ]
-commonFiles += [ "src/mongo/util/net/sock.cpp" , "src/mongo/util/net/httpclient.cpp" , "src/mongo/util/net/message.cpp" , "src/mongo/util/net/message_port.cpp" , "src/mongo/util/net/listen.cpp" ]
-commonFiles += Glob( "src/mongo/util/*.c" )
-commonFiles += [ "src/mongo/client/connpool.cpp" , "src/mongo/client/dbclient.cpp" , "src/mongo/client/dbclient_rs.cpp" , "src/mongo/client/dbclientcursor.cpp" , "src/mongo/client/model.cpp" , "src/mongo/client/syncclusterconnection.cpp" , "src/mongo/client/distlock.cpp" , "src/mongo/s/shardconnection.cpp" ]
-
-#mmap stuff
-
-coreDbFiles = [ "src/mongo/db/commands.cpp" ]
-coreServerFiles = [ "src/mongo/util/net/message_server_port.cpp" ,
- "src/mongo/client/parallel.cpp" , "src/mongo/db/common.cpp",
- "src/mongo/util/net/miniwebserver.cpp" , "src/mongo/db/dbwebserver.cpp" ,
- "src/mongo/db/matcher.cpp" , "src/mongo/db/dbcommands_generic.cpp" , "src/mongo/db/commands/cloud.cpp", "src/mongo/db/dbmessage.cpp" ]
-
-mmapFiles = [ "src/mongo/util/mmap.cpp" ]
-
-if has_option( "mm" ):
- mmapFiles += [ "src/mongo/util/mmap_mm.cpp" ]
-elif os.sys.platform == "win32":
- mmapFiles += [ "src/mongo/util/mmap_win.cpp" ]
-else:
- mmapFiles += [ "src/mongo/util/mmap_posix.cpp" ]
-
-#coreServerFiles += mmapFiles
-
-# handle processinfo*
-processInfoFiles = [ "src/mongo/util/processinfo.cpp" ]
-
-if os.path.exists( "src/mongo/util/processinfo_" + os.sys.platform + ".cpp" ):
- processInfoFiles += [ "src/mongo/util/processinfo_" + os.sys.platform + ".cpp" ]
-elif os.sys.platform == "linux3":
- processInfoFiles += [ "src/mongo/util/processinfo_linux2.cpp" ]
-else:
- processInfoFiles += [ "src/mongo/util/processinfo_none.cpp" ]
-
-coreServerFiles += processInfoFiles
-
-# handle systeminfo*
-systemInfoFiles = [ ]
-if os.path.exists( "src/mongo/util/systeminfo_" + os.sys.platform + ".cpp" ):
- systemInfoFiles += [ "src/mongo/util/systeminfo_" + os.sys.platform + ".cpp" ]
-elif os.sys.platform == "linux3":
- systemInfoFiles += [ "src/mongo/util/systeminfo_linux2.cpp" ]
-else:
- systemInfoFiles += [ "src/mongo/util/systeminfo_none.cpp" ]
-
-coreServerFiles += systemInfoFiles
-
-
-if has_option( "asio" ):
- coreServerFiles += [ "src/mongo/util/net/message_server_asio.cpp" ]
-
-# mongod files - also files used in tools. present in dbtests, but not in mongos and not in client libs.
-serverOnlyFiles = [ "src/mongo/db/memconcept.cpp", "src/mongo/db/curop.cpp" , "src/mongo/db/d_globals.cpp" , "src/mongo/db/pagefault.cpp" , "src/mongo/util/compress.cpp" , "src/mongo/db/d_concurrency.cpp" , "src/mongo/db/key.cpp" , "src/mongo/db/btreebuilder.cpp" , "src/mongo/util/logfile.cpp" , "src/mongo/util/alignedbuilder.cpp" , "src/mongo/db/mongommf.cpp" , "src/mongo/db/dur.cpp" , "src/mongo/db/durop.cpp" , "src/mongo/db/dur_writetodatafiles.cpp" , "src/mongo/db/dur_preplogbuffer.cpp" , "src/mongo/db/dur_commitjob.cpp" , "src/mongo/db/dur_recover.cpp" , "src/mongo/db/dur_journal.cpp" , "src/mongo/db/introspect.cpp" , "src/mongo/db/btree.cpp" , "src/mongo/db/clientcursor.cpp" , "src/mongo/db/tests.cpp" , "src/mongo/db/repl.cpp" , "src/mongo/db/repl/rs.cpp" , "src/mongo/db/repl/consensus.cpp" , "src/mongo/db/repl/rs_initiate.cpp" , "src/mongo/db/repl/replset_commands.cpp" , "src/mongo/db/repl/manager.cpp" , "src/mongo/db/repl/health.cpp" , "src/mongo/db/repl/heartbeat.cpp" , "src/mongo/db/repl/rs_config.cpp" , "src/mongo/db/repl/rs_rollback.cpp" , "src/mongo/db/repl/rs_sync.cpp" , "src/mongo/db/repl/rs_initialsync.cpp" , "src/mongo/db/oplog.cpp" , "src/mongo/db/repl_block.cpp" , "src/mongo/db/btreecursor.cpp" , "src/mongo/db/cloner.cpp" , "src/mongo/db/namespace.cpp" , "src/mongo/db/cap.cpp" , "src/mongo/db/matcher_covered.cpp" , "src/mongo/db/dbeval.cpp" , "src/mongo/db/restapi.cpp" , "src/mongo/db/dbhelpers.cpp" , "src/mongo/db/instance.cpp" , "src/mongo/db/client.cpp" , "src/mongo/db/database.cpp" , "src/mongo/db/pdfile.cpp" , "src/mongo/db/record.cpp" , "src/mongo/db/cursor.cpp" , "src/mongo/db/security.cpp" , "src/mongo/db/queryoptimizer.cpp" , "src/mongo/db/queryoptimizercursor.cpp" , "src/mongo/db/extsort.cpp" , "src/mongo/db/cmdline.cpp" ]
-
-serverOnlyFiles += [ "src/mongo/db/index.cpp" , "src/mongo/db/scanandorder.cpp" ] + Glob( "src/mongo/db/geo/*.cpp" ) + Glob( "src/mongo/db/ops/*.cpp" )
-
-serverOnlyFiles += [ "src/mongo/db/dbcommands.cpp" , "src/mongo/db/dbcommands_admin.cpp" ]
-
-# most commands are only for mongod
-serverOnlyFiles += [
- "src/mongo/db/commands/distinct.cpp",
- "src/mongo/db/commands/find_and_modify.cpp",
- "src/mongo/db/commands/group.cpp",
- "src/mongo/db/commands/mr.cpp",
- "src/mongo/db/commands/pipeline_command.cpp",
- "src/mongo/db/commands/pipeline_d.cpp",
- "src/mongo/db/commands/document_source_cursor.cpp" ]
-# "src/mongo/db/commands/isself.cpp",
-#serverOnlyFiles += [ "src/mongo/db/commands/%s.cpp" % x for x in ["distinct","find_and_modify","group","mr"] ]
-
-serverOnlyFiles += [ "src/mongo/db/driverHelpers.cpp" ]
-
-serverOnlyFiles += mmapFiles
-
-# but the pipeline command works everywhere
-coreServerFiles += [ "src/mongo/db/commands/pipeline.cpp" ]
-coreServerFiles += Glob("src/mongo/db/pipeline/*.cpp")
-
-serverOnlyFiles += [ "src/mongo/db/stats/snapshots.cpp" ]
-############coreServerFiles += "src/mongo/db/stats/snapshots.cpp"
-coreServerFiles += [ "src/mongo/db/stats/counters.cpp", "src/mongo/db/stats/service_stats.cpp", "src/mongo/db/stats/top.cpp" ]
-#coreServerFiles += Glob( "src/mongo/db/stats/*.cpp" )
-coreServerFiles += [ "src/mongo/db/commands/isself.cpp", "src/mongo/db/security_common.cpp", "src/mongo/db/security_commands.cpp" ]
-
-scriptingFiles = [ "src/mongo/scripting/engine.cpp" , "src/mongo/scripting/utils.cpp" , "src/mongo/scripting/bench.cpp" ]
-
-if usesm:
- scriptingFiles += [ "src/mongo/scripting/engine_spidermonkey.cpp" ]
-elif usev8:
- scriptingFiles += [ Glob( "src/mongo/scripting/*v8*.cpp" ) ]
-else:
- scriptingFiles += [ "src/mongo/scripting/engine_none.cpp" ]
-
-coreShardFiles = [ "src/mongo/s/config.cpp" , "src/mongo/s/grid.cpp" , "src/mongo/s/chunk.cpp" , "src/mongo/s/shard.cpp" , "src/mongo/s/shardkey.cpp" ]
-shardServerFiles = coreShardFiles + Glob( "src/mongo/s/strategy*.cpp" ) + [ "src/mongo/s/commands_admin.cpp" , "src/mongo/s/commands_public.cpp" , "src/mongo/s/request.cpp" , "src/mongo/s/client.cpp" , "src/mongo/s/cursors.cpp" , "src/mongo/s/server.cpp" , "src/mongo/s/config_migrate.cpp" , "src/mongo/s/s_only.cpp" , "src/mongo/s/stats.cpp" , "src/mongo/s/balance.cpp" , "src/mongo/s/balancer_policy.cpp" , "src/mongo/db/cmdline.cpp" , "src/mongo/s/writeback_listener.cpp" , "src/mongo/s/shard_version.cpp", "src/mongo/s/mr_shard.cpp", "src/mongo/s/security.cpp" ]
-serverOnlyFiles += coreShardFiles + [ "src/mongo/s/d_logic.cpp" , "src/mongo/s/d_writeback.cpp" , "src/mongo/s/d_migrate.cpp" , "src/mongo/s/d_state.cpp" , "src/mongo/s/d_split.cpp" , "src/mongo/client/distlock_test.cpp" , "src/mongo/s/d_chunk_manager.cpp", "src/mongo/s/default_version.cpp" ]
-
-serverOnlyFiles += [ "src/mongo/db/module.cpp" ] + Glob( "src/mongo/db/modules/*.cpp" )
-
-modules = []
-moduleNames = []
-
-for x in os.listdir( "src/mongo/db/modules/" ):
- if x.find( "." ) >= 0:
- continue
- print( "adding module: " + x )
- moduleNames.append( x )
- modRoot = "src/mongo/db/modules/" + x + "/"
-
- modBuildFile = modRoot + "build.py"
- myModule = None
- 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:
- serverOnlyFiles += Glob( modRoot + "src/*.cpp" )
-
-mongodOnlyFiles = [ "src/mongo/db/db.cpp", "src/mongo/db/compact.cpp" ]
-if "win32" == os.sys.platform:
- mongodOnlyFiles.append( "src/mongo/util/ntservice.cpp" )
-
-def fixBuildDir( lst ):
- for i in xrange(0,len(lst)):
- x = str(lst[i])
- if not x.startswith( "src/" ):
- continue
- #x = get_variant_dir() + "/" + x.partition( "src/" )[2]
- #x = x.replace( "//" , "/" )
- #lst[i] = x
-
-
-
-allClientFiles = commonFiles + coreDbFiles + [ "src/mongo/client/clientOnly.cpp" , "src/mongo/client/gridfs.cpp" ];
-
-fixBuildDir( commonFiles )
-fixBuildDir( coreDbFiles )
-fixBuildDir( allClientFiles )
-fixBuildDir( coreServerFiles )
-fixBuildDir( serverOnlyFiles )
-fixBuildDir( mongodOnlyFiles )
-fixBuildDir( shardServerFiles )
-
# ---- other build setup -----
platform = os.sys.platform
@@ -583,6 +464,8 @@ elif os.sys.platform.startswith("linux"):
linux = True
platform = "linux"
+ env.Append( LIBS=['m'] )
+
if os.uname()[4] == "x86_64" and not force32:
linux64 = True
nixLibPrefix = "lib64"
@@ -748,7 +631,7 @@ elif "win32" == os.sys.platform:
winLibString = "ws2_32.lib kernel32.lib advapi32.lib Psapi.lib"
if force64:
-
+
winLibString += ""
#winLibString += " LIBCMT LIBCPMT "
@@ -756,8 +639,8 @@ elif "win32" == os.sys.platform:
winLibString += " user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib ole32.lib oleaut32.lib "
winLibString += " odbc32.lib odbccp32.lib uuid.lib "
- # v8 calls timeGetTime()
- if usev8:
+ # v8 calls timeGetTime()
+ if usev8:
winLibString += " winmm.lib "
env.Append( LIBS=Split(winLibString) )
@@ -774,6 +657,7 @@ elif "win32" == os.sys.platform:
else:
print( "No special config for [" + os.sys.platform + "] which probably means it won't work" )
+env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
if nix:
if has_option( "distcc" ):
@@ -823,9 +707,6 @@ if nix:
env.Append( CXXFLAGS="-m32" )
env.Append( LINKFLAGS="-m32" )
- if has_option( "profile" ):
- env.Append( LIBS=[ "profiler" ] )
-
if has_option( "gdbserver" ):
env.Append( CPPDEFINES=["USE_GDBSERVER"] )
@@ -837,11 +718,12 @@ if nix:
#env.Prepend( CXXFLAGS=' -include pch.h ' ) # clang++ only uses pch from command line
print( "ERROR: clang pch is broken for now" )
Exit(1)
- env['Gch'] = env.Gch( [ "src/mongo/pch.h" ] )[0]
- env['GchSh'] = env.GchSh( [ "src/mongo/pch.h" ] )[0]
- elif os.path.exists( "src/mongo/pch.h.gch" ):
+ env['Gch'] = env.Gch( "$BUILD_DIR/mongo/pch.h$GCHSUFFIX",
+ "src/mongo/pch.h" )[0]
+ env['GchSh'] = env[ 'Gch' ]
+ elif os.path.exists( env.File("$BUILD_DIR/mongo/pch.h$GCHSUFFIX").abspath ):
print( "removing precompiled headers" )
- os.unlink( "src/mongo/pch.h.gch" ) # gcc uses the file if it exists
+ os.unlink( env.File("$BUILD_DIR/mongo/pch.h.$GCHSUFFIX").abspath ) # gcc uses the file if it exists
if usev8:
env.Prepend( CPPPATH=["../v8/include/"] )
@@ -869,23 +751,30 @@ if not windows:
os.chmod( keyfile , stat.S_IWUSR|stat.S_IRUSR )
moduleFiles = {}
-for shortName in getThirdPartyShortNames():
+commonFiles = []
+serverOnlyFiles = []
+scriptingFiles = []
+for shortName in getThirdPartyShortNames():
path = "src/third_party/%s.py" % shortName
myModule = imp.load_module( "src/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
-
+
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 )
-fixBuildDir( scriptingFiles )
-coreServerFiles += scriptingFiles
+if not has_option("use-system-all") and not has_option("use-system-pcre"):
+ env.Append(CPPPATH=[ '$BUILD_DIR/third_party/pcre-${PCRE_VERSION}' ])
+env['MONGO_COMMON_FILES'] = commonFiles
+env['MONGO_SERVER_ONLY_FILES' ] = serverOnlyFiles
+env['MONGO_SCRIPTING_FILES'] = scriptingFiles
+env['MONGO_MODULE_FILES'] = moduleFiles
# --- check system ---
@@ -895,44 +784,6 @@ def getSysInfo():
else:
return " ".join( os.uname() )
-def add_exe(target):
- if windows:
- return target + ".exe"
- return target
-
-def setupBuildInfoFile( outFile ):
- version = utils.getGitVersion()
- if len(moduleNames) > 0:
- version = version + " modules: " + ','.join( moduleNames )
- sysInfo = getSysInfo()
- contents = '\n'.join([
- '#include "pch.h"',
- '#include <iostream>',
- '#include <boost/version.hpp>',
- 'namespace mongo { const char * gitVersion(){ return "' + version + '"; } }',
- 'namespace mongo { string sysInfo(){ return "' + sysInfo + ' BOOST_LIB_VERSION=" BOOST_LIB_VERSION ; } }',
- ])
-
- contents += '\n';
-
- if os.path.exists( outFile ) and open( outFile ).read().strip() == contents.strip():
- return
-
- contents += '\n';
-
- out = open( outFile , 'w' )
- out.write( contents )
- out.close()
-
-setupBuildInfoFile( "src/mongo/buildinfo.cpp" )
-
-def bigLibString( myenv ):
- s = str( myenv["LIBS"] )
- if 'SLIBS' in myenv._dict:
- s += str( myenv["SLIBS"] )
- return s
-
-
def doConfigure( myenv , shell=False ):
conf = Configure(myenv)
myenv["LINKFLAGS_CLEAN"] = list( myenv["LINKFLAGS"] )
@@ -964,11 +815,10 @@ def doConfigure( myenv , shell=False ):
for loc in allPlaces:
fullPath = loc + "/lib" + p + ".a"
if os.path.exists( fullPath ):
- myenv['_LIBFLAGS']='${_stripixes(LIBLINKPREFIX, LIBS, LIBLINKSUFFIX, LIBPREFIXES, LIBSUFFIXES, __env__)} $SLIBS'
- myenv.Append( SLIBS=" " + fullPath + " " )
+ myenv.Append( _LIBFLAGS='${SLIBS}',
+ SLIBS=" " + fullPath + " " )
return True
-
if release and not windows and failIfNotFound:
print( "ERROR: can't find static version of: " + str( poss ) + " in: " + str( allPlaces ) )
Exit(1)
@@ -1016,12 +866,6 @@ def doConfigure( myenv , shell=False ):
removeIfInList( myenv["LIBS"] , "pcap" )
removeIfInList( myenv["LIBS"] , "wpcap" )
- for m in modules:
- if "customIncludes" in dir(m) and m.customIncludes:
- m.configure( conf , myenv , serverOnlyFiles )
- else:
- m.configure( conf , myenv )
-
if solaris:
conf.CheckLib( "nsl" )
@@ -1095,295 +939,32 @@ def doConfigure( myenv , shell=False ):
env = doConfigure( env )
-
-# --- jsh ---
-
-def jsToH(target, source, env):
-
- outFile = str( target[0] )
-
- h = ['#include "bson/stringdata.h"'
- ,'namespace mongo {'
- ,'struct JSFile{ const char* name; const StringData& source; };'
- ,'namespace JSFiles{'
- ]
-
- def cppEscape(s):
- s = s.strip()
- s = s.replace( '\\' , '\\\\' )
- s = s.replace( '"' , r'\"' )
- return s
-
- for s in source:
- filename = str(s)
- objname = os.path.split(filename)[1].split('.')[0]
- stringname = '_jscode_raw_' + objname
-
- h.append('const StringData ' + stringname + " = ")
-
- for l in open( filename , 'r' ):
- h.append( '"' + cppEscape(l) + r'\n" ' )
-
- h.append(";")
- h.append('extern const JSFile %s;'%objname) #symbols aren't exported w/o this
- h.append('const JSFile %s = { "%s" , %s };'%(objname, filename.replace('\\', '/'), stringname))
-
- h.append("} // namespace JSFiles")
- h.append("} // namespace mongo")
- h.append("")
-
- text = '\n'.join(h);
-
- out = open( outFile , 'wb' )
- out.write( text )
- out.close()
-
- return None
-
-jshBuilder = Builder(action = jsToH )
-# suffix = '.cpp',
-# src_suffix = '.js')
-
-env.Append( BUILDERS={'JSHeader' : jshBuilder})
-
-
-# --- targets ----
-
-# profile guided
-#if windows:
-# if release:
-# env.Append( LINKFLAGS="/PGD:test.pgd" )
-# env.Append( LINKFLAGS="/LTCG:PGINSTRUMENT" )
-# env.Append( LINKFLAGS="/LTCG:PGOPTIMIZE" )
-
testEnv = env.Clone()
testEnv.Append( CPPPATH=["../"] )
-testEnv.Prepend( LIBS=[ "mongotestfiles" ] )
-testEnv.Prepend( LIBPATH=["."] )
-
-# ----- TARGETS ------
-
-def checkErrorCodes():
- import buildscripts.errorcodes as x
- if x.checkErrorCodes() == False:
- print( "next id to use:" + str( x.getNextCode() ) )
- Exit(-1)
-
-checkErrorCodes()
-
-if has_option( 'use-cpu-profiler' ):
- coreServerFiles.append( 'src/mongo/db/commands/cpuprofile.cpp' )
- env.Append( LIBS=['profiler'] )
-
-# main db target
-mongod = env.Program( "mongod" , commonFiles + coreDbFiles + coreServerFiles + serverOnlyFiles + mongodOnlyFiles )
-Default( mongod )
-
-# tools
-allToolFiles = commonFiles + coreDbFiles + coreServerFiles + serverOnlyFiles + [ "src/mongo/client/gridfs.cpp", "src/mongo/tools/tool.cpp" , "src/mongo/tools/stat_util.cpp" ]
-normalTools = [ "dump" , "restore" , "export" , "import" , "files" , "stat" , "top" , "oplog" ]
-env.Alias( "tools" , [ add_exe( "mongo" + x ) for x in normalTools ] )
-for x in normalTools:
- env.Program( "mongo" + x , allToolFiles + [ "src/mongo/tools/" + x + ".cpp" ] )
-
-#some special tools
-env.Program( "bsondump" , allToolFiles + [ "src/mongo/tools/bsondump.cpp" ] )
-env.Program( "mongobridge" , allToolFiles + [ "src/mongo/tools/bridge.cpp" ] )
-env.Program( "mongoperf" , allToolFiles + [ "src/mongo/client/examples/mongoperf.cpp" ] )
-
-# mongos
-mongos = env.Program( "mongos" , commonFiles + coreDbFiles + coreServerFiles + shardServerFiles )
-
-# c++ library
-clientLib = env.Library( "mongoclient" , allClientFiles )
-clientLibName = str( clientLib[0] )
-if has_option( "sharedclient" ):
- sharedClientLibName = str( env.SharedLibrary( "mongoclient" , allClientFiles )[0] )
-env.Library( "mongotestfiles" , commonFiles + coreDbFiles + coreServerFiles + serverOnlyFiles + ["src/mongo/client/gridfs.cpp"])
-env.Library( "mongoshellfiles" , allClientFiles + coreServerFiles )
-
-clientEnv = env.Clone();
-clientEnv.Append( CPPPATH=["../"] )
-clientEnv.Prepend( LIBS=[ clientLib ] )
-clientEnv.Prepend( LIBPATH=["."] )
-clientEnv["CPPDEFINES"].remove( "MONGO_EXPOSE_MACROS" )
-l = clientEnv[ "LIBS" ]
-
-clientTests = []
-
-# examples
-clientTests += [ clientEnv.Program( "firstExample" , [ "src/mongo/client/examples/first.cpp" ] ) ]
-clientTests += [ clientEnv.Program( "rsExample" , [ "src/mongo/client/examples/rs.cpp" ] ) ]
-clientTests += [ clientEnv.Program( "secondExample" , [ "src/mongo/client/examples/second.cpp" ] ) ]
-clientTests += [ clientEnv.Program( "whereExample" , [ "src/mongo/client/examples/whereExample.cpp" ] ) ]
-clientTests += [ clientEnv.Program( "authTest" , [ "src/mongo/client/examples/authTest.cpp" ] ) ]
-clientTests += [ clientEnv.Program( "httpClientTest" , [ "src/mongo/client/examples/httpClientTest.cpp" ] ) ]
-clientTests += [ clientEnv.Program( "bsondemo" , [ "src/mongo/bson/bsondemo/bsondemo.cpp" ] ) ]
-
-# dbtests test binary
-test = testEnv.Program( "test" , Glob( "src/mongo/dbtests/*.cpp" ) )
-if windows:
- testEnv.Alias( "test" , "test.exe" )
-perftest = testEnv.Program( "perftest", [ "src/mongo/dbtests/framework.cpp" , "src/mongo/dbtests/perf/perftest.cpp" ] )
-clientTests += [ clientEnv.Program( "clientTest" , [ "src/mongo/client/examples/clientTest.cpp" ] ) ]
-
-# --- sniffer ---
-mongosniff_built = False
-if darwin or clientEnv["_HAVEPCAP"]:
- mongosniff_built = True
- sniffEnv = env.Clone()
- sniffEnv.Append( CPPDEFINES="MONGO_EXPOSE_MACROS" )
-
- if not windows:
- sniffEnv.Append( LIBS=[ "pcap" ] )
- else:
- sniffEnv.Append( LIBS=[ "wpcap" ] )
-
- sniffEnv.Prepend( LIBPATH=["."] )
- sniffEnv.Prepend( LIBS=[ "mongotestfiles" ] )
-
- sniffEnv.Program( "mongosniff" , "src/mongo/tools/sniffer.cpp" )
-
-# --- shell ---
-
-# note, if you add a file here, you need to add it in scripting/engine.cpp and shell/msvc/createCPPfromJavaScriptFiles.js as well
-env.Depends( "src/mongo/shell/dbshell.cpp" ,
- env.JSHeader( "src/mongo/shell/mongo.cpp" ,
- Glob( "src/mongo/shell/utils*.js" ) +
- [ "src/mongo/shell/db.js","src/mongo/shell/mongo.js","src/mongo/shell/mr.js","src/mongo/shell/query.js","src/mongo/shell/collection.js"] ) )
-
-env.JSHeader( "src/mongo/shell/mongo-server.cpp" , [ "src/mongo/shell/servers.js"] )
-
-shellEnv = env.Clone();
-
-if release and ( ( darwin and force64 ) or linux64 ):
- shellEnv["LINKFLAGS"] = env["LINKFLAGS_CLEAN"]
- shellEnv["LIBS"] = env["LIBS_CLEAN"]
- shellEnv["SLIBS"] = ""
+shellEnv = None
if noshell:
print( "not building shell" )
elif not onlyServer:
- l = shellEnv["LIBS"]
+ shellEnv = env.Clone();
+
+ if release and ( ( darwin and force64 ) or linux64 ):
+ shellEnv["LINKFLAGS"] = env["LINKFLAGS_CLEAN"]
+ shellEnv["LIBS"] = env["LIBS_CLEAN"]
+ shellEnv["SLIBS"] = ""
if windows:
shellEnv.Append( LIBS=["winmm.lib"] )
- coreShellFiles = [ "src/mongo/shell/dbshell.cpp" , "src/mongo/shell/shell_utils.cpp" , "src/mongo/shell/mongo-server.cpp" ]
-
- coreShellFiles.append( "src/third_party/linenoise/linenoise.cpp" )
-
- shellEnv.Prepend( LIBPATH=[ "." ] )
-
shellEnv = doConfigure( shellEnv , shell=True )
- shellEnv.Prepend( LIBS=[ "mongoshellfiles"] )
-
- shellFilesToUse = coreShellFiles
- if "pcre" in moduleFiles:
- shellFilesToUse += moduleFiles["pcre"]
-
- mongo = shellEnv.Program( "mongo" , shellFilesToUse )
-
-
-# ---- RUNNING TESTS ----
-
-smokeEnv = testEnv.Clone()
-smokeEnv['ENV']['PATH']=os.environ['PATH']
-smokeEnv.Alias( "dummySmokeSideEffect", [], [] )
-
-smokeFlags = []
-
-# Ugh. Frobbing the smokeFlags must precede using them to construct
-# actions, I think.
-if has_option( 'smokedbprefix'):
- smokeFlags += ['--smoke-db-prefix', GetOption( 'smokedbprefix')]
-
-if 'startMongodSmallOplog' in COMMAND_LINE_TARGETS:
- smokeFlags += ["--small-oplog"]
-
-def addTest(name, deps, actions):
- smokeEnv.Alias( name, deps, actions )
- smokeEnv.AlwaysBuild( name )
- # Prevent smoke tests from running in parallel
- smokeEnv.SideEffect( "dummySmokeSideEffect", name )
+def checkErrorCodes():
+ import buildscripts.errorcodes as x
+ if x.checkErrorCodes() == False:
+ print( "next id to use:" + str( x.getNextCode() ) )
+ Exit(-1)
-def addSmoketest( name, deps ):
- # Convert from smoke to test, smokeJs to js, and foo to foo
- target = name
- if name.startswith("smoke"):
- if name == "smoke":
- target = "test"
- else:
- target = name[5].lower() + name[6:]
-
- addTest(name, deps, [ "python buildscripts/smoke.py " + " ".join(smokeFlags) + ' ' + target ])
-
-addSmoketest( "smoke", [ add_exe( "test" ) ] )
-addSmoketest( "smokePerf", [ "perftest" ] )
-addSmoketest( "smokeClient" , clientTests )
-addSmoketest( "mongosTest" , [ mongos[0].abspath ] )
-
-# These tests require the mongo shell
-if not onlyServer and not noshell:
- addSmoketest( "smokeJs", [add_exe("mongo")] )
- addSmoketest( "smokeClone", [ add_exe( "mongo" ), add_exe( "mongod" ) ] )
- addSmoketest( "smokeRepl", [ add_exe( "mongo" ), add_exe( "mongod" ), add_exe( "mongobridge" ) ] )
- addSmoketest( "smokeReplSets", [ add_exe( "mongo" ), add_exe( "mongod" ), add_exe( "mongobridge" ) ] )
- addSmoketest( "smokeDur", [ add_exe( "mongo" ) , add_exe( "mongod" ) , add_exe( 'mongorestore' ) ] )
- addSmoketest( "smokeDisk", [ add_exe( "mongo" ), add_exe( "mongod" ), add_exe( "mongodump" ), add_exe( "mongorestore" ) ] )
- addSmoketest( "smokeAuth", [ add_exe( "mongo" ), add_exe( "mongod" ) ] )
- addSmoketest( "smokeParallel", [ add_exe( "mongo" ), add_exe( "mongod" ) ] )
- addSmoketest( "smokeSharding", [ add_exe( "mongo" ), add_exe( "mongod" ), add_exe( "mongos" ) ] )
- addSmoketest( "smokeJsPerf", [ "mongo" ] )
- addSmoketest( "smokeJsSlowNightly", [add_exe("mongo")])
- addSmoketest( "smokeJsSlowWeekly", [add_exe("mongo")])
- addSmoketest( "smokeQuota", [ "mongo" ] )
- addSmoketest( "smokeTool", [ add_exe( "mongo" ), add_exe("mongod"), "tools" ] )
-
-# Note: although the test running logic has been moved to
-# buildscripts/smoke.py, the interface to running the tests has been
-# something like 'scons startMongod <suite>'; startMongod is now a
-# no-op, and should go away eventually.
-smokeEnv.Alias( "startMongod", [add_exe("mongod")]);
-smokeEnv.AlwaysBuild( "startMongod" );
-smokeEnv.SideEffect( "dummySmokeSideEffect", "startMongod" )
-
-smokeEnv.Alias( "startMongodSmallOplog", [add_exe("mongod")], [] );
-smokeEnv.AlwaysBuild( "startMongodSmallOplog" );
-smokeEnv.SideEffect( "dummySmokeSideEffect", "startMongodSmallOplog" )
-
-def addMongodReqTargets( env, target, source ):
- mongodReqTargets = [ "smokeClient", "smokeJs" ]
- for target in mongodReqTargets:
- smokeEnv.Depends( target, "startMongod" )
- smokeEnv.Depends( "smokeAll", target )
-
-smokeEnv.Alias( "addMongodReqTargets", [], [addMongodReqTargets] )
-smokeEnv.AlwaysBuild( "addMongodReqTargets" )
-
-smokeEnv.Alias( "smokeAll", [ "smoke", "mongosTest", "smokeClone", "smokeRepl", "addMongodReqTargets", "smokeDisk", "smokeAuth", "smokeSharding", "smokeTool" ] )
-smokeEnv.AlwaysBuild( "smokeAll" )
-
-def addMongodReqNoJsTargets( env, target, source ):
- mongodReqTargets = [ "smokeClient" ]
- for target in mongodReqTargets:
- smokeEnv.Depends( target, "startMongod" )
- smokeEnv.Depends( "smokeAllNoJs", target )
-
-smokeEnv.Alias( "addMongodReqNoJsTargets", [], [addMongodReqNoJsTargets] )
-smokeEnv.AlwaysBuild( "addMongodReqNoJsTargets" )
-
-smokeEnv.Alias( "smokeAllNoJs", [ "smoke", "mongosTest", "addMongodReqNoJsTargets" ] )
-smokeEnv.AlwaysBuild( "smokeAllNoJs" )
-
-def run_shell_tests(env, target, source):
- from buildscripts import test_shell
- test_shell.mongo_path = windows and "mongo.exe" or "mongo"
- test_shell.run_tests()
-
-env.Alias("test_shell", [], [run_shell_tests])
-env.AlwaysBuild("test_shell")
+checkErrorCodes()
# ---- Docs ----
def build_docs(env, target, source):
@@ -1396,7 +977,7 @@ env.AlwaysBuild("docs")
# ---- astyle ----
def doStyling( env , target , source ):
-
+
res = utils.execsys( "astyle --version" )
res = " ".join(res)
if res.count( "2." ) == 0:
@@ -1427,9 +1008,6 @@ def getSystemInstallName():
n += "-debugsymbols"
if nix and os.uname()[2].startswith( "8." ):
n += "-tiger"
-
- if len(moduleNames) > 0:
- n += "-" + "-".join( moduleNames )
try:
findSettingsSetup()
@@ -1439,7 +1017,7 @@ def getSystemInstallName():
except:
pass
-
+
dn = GetOption( "distmod" )
if dn and len(dn) > 0:
n = n + "-" + dn
@@ -1486,101 +1064,12 @@ if distBuild:
installDir += getDistName( installDir )
print "going to make dist: " + installDir
-# binaries
-
-def checkGlibc(target,source,env):
- import subprocess
- stringProcess = subprocess.Popen( [ "strings" , str( target[0] ) ] , stdout=subprocess.PIPE )
- stringResult = stringProcess.communicate()[0]
- if stringResult.count( "GLIBC_2.4" ) > 0:
- print( "************* " + str( target[0] ) + " has GLIBC_2.4 dependencies!" )
- Exit(-3)
-
-allBinaries = []
-
-def installBinary( e , name ):
- if not installSetup.binaries:
- return
-
- global allBinaries
-
- if windows:
- e.Alias( name , name + ".exe" )
- name += ".exe"
-
- inst = e.Install( installDir + "/bin" , name )
-
- fullInstallName = installDir + "/bin/" + name
-
- allBinaries += [ name ]
- if (solaris or linux) and (not has_option("nostrip")):
- e.AddPostAction( inst, e.Action( 'strip ' + fullInstallName ) )
-
- if not has_option( "no-glibc-check" ) and linux and len( COMMAND_LINE_TARGETS ) == 1 and str( COMMAND_LINE_TARGETS[0] ) == "s3dist":
- e.AddPostAction( inst , checkGlibc )
-
- if nix:
- e.AddPostAction( inst , e.Action( 'chmod 755 ' + fullInstallName ) )
-
-for x in normalTools:
- installBinary( env , "mongo" + x )
-installBinary( env , "bsondump" )
-installBinary( env , "mongoperf" )
-
-if mongosniff_built:
- installBinary(env, "mongosniff")
-
-installBinary( env , "mongod" )
-installBinary( env , "mongos" )
-
-if not noshell:
- installBinary( env , "mongo" )
-
-env.Alias( "all" , allBinaries )
-env.Alias( "core" , [ add_exe( "mongo" ) , add_exe( "mongod" ) , add_exe( "mongos" ) ] )
-
-#headers
-if installSetup.headers:
- for id in [ "mongo/" , "mongo/util/", "mongo/util/net/", "mongo/util/mongoutils/", "mongo/util/concurrency/", "mongo/db/" , "mongo/db/stats/" , "mongo/db/repl/" , "mongo/db/ops/" , "mongo/client/" , "mongo/bson/", "mongo/bson/util/" , "mongo/s/" , "mongo/scripting/" ]:
- env.Install( installDir + "/" + installSetup.headerRoot + "/" + id , Glob( "src/" + id + "*.h" ) )
- env.Install( installDir + "/" + installSetup.headerRoot + "/" + id , Glob( "src/" + id + "*.hpp" ) )
-
-if installSetup.clientSrc:
- for x in allClientFiles:
- x = str(x)
- env.Install( installDir + "/mongo/" + x.rpartition( "/" )[0] , x )
-
-#lib
-if installSetup.libraries:
- env.Install( installDir + "/" + nixLibPrefix, clientLibName )
- if has_option( "sharedclient" ):
- env.Install( installDir + "/" + nixLibPrefix, sharedClientLibName )
-
-
-#textfiles
-if installSetup.bannerDir:
- for x in os.listdir( installSetup.bannerDir ):
- full = installSetup.bannerDir + "/" + x
- if os.path.isdir( full ):
- continue
- if x.find( "~" ) >= 0:
- continue
- env.Install( installDir , full )
-
-if installSetup.clientTestsDir:
- for x in os.listdir( installSetup.clientTestsDir ):
- full = installSetup.clientTestsDir + "/" + x
- if os.path.isdir( full ):
- continue
- if x.find( "~" ) >= 0:
- continue
- env.Install( installDir + '/' + installSetup.clientTestsDir , full )
-
-#final alias
-env.Alias( "install" , installDir )
-
-# aliases
-env.Alias( "mongoclient" , has_option( "sharedclient" ) and sharedClientLibName or clientLibName )
+env['NIX_LIB_DIR'] = nixLibPrefix
+env['INSTALL_DIR'] = installDir
+if testEnv is not None:
+ testEnv['INSTALL_DIR'] = installDir
+if shellEnv is not None:
+ shellEnv['INSTALL_DIR'] = installDir
# ---- CONVENIENCE ----
@@ -1672,38 +1161,6 @@ if installDir[-1] != "/":
env.Alias( "s3dist" , [ "install" , distFile ] , [ s3dist ] )
env.AlwaysBuild( "s3dist" )
-
-# client dist
-def build_and_test_client(env, target, source):
- from subprocess import call
-
- if GetOption("extrapath") is not None:
- scons_command = ["scons", "--extrapath=" + GetOption("extrapath")]
- else:
- scons_command = ["scons"]
-
- call(scons_command + ["libmongoclient.a", "clientTests"], cwd=installDir)
-
- return bool(call(["python", "buildscripts/smoke.py",
- "--test-path", installDir, "client"]))
-env.Alias("clientBuild", [mongod, installDir], [build_and_test_client])
-env.AlwaysBuild("clientBuild")
-
-def clean_old_dist_builds(env, target, source):
- prefix = "mongodb-%s-%s" % (platform, processor)
- filenames = sorted(os.listdir("."))
- filenames = [x for x in filenames if x.startswith(prefix)]
- to_keep = [x for x in filenames if x.endswith(".tgz") or x.endswith(".zip")][-2:]
- for filename in [x for x in filenames if x not in to_keep]:
- print "removing %s" % filename
- try:
- shutil.rmtree(filename)
- except:
- os.remove(filename)
-
-env.Alias("dist_clean", [], [clean_old_dist_builds])
-env.AlwaysBuild("dist_clean")
-
# --- an uninstall target ---
if len(COMMAND_LINE_TARGETS) > 0 and 'uninstall' in COMMAND_LINE_TARGETS:
SetOption("clean", 1)
@@ -1711,3 +1168,22 @@ if len(COMMAND_LINE_TARGETS) > 0 and 'uninstall' in COMMAND_LINE_TARGETS:
# what we want, but changing BUILD_TARGETS does.
BUILD_TARGETS.remove("uninstall")
BUILD_TARGETS.append("install")
+
+# The following symbols are exported for use in subordinate SConscript files.
+# Ideally, the SConscript files would be purely declarative. They would only
+# import build environment objects, and would contain few or no conditional
+# statements or branches.
+#
+# Currently, however, the SConscript files do need some predicates for
+# conditional decision making that hasn't been moved up to this SConstruct file,
+# and they are exported here, as well.
+Export("env")
+Export("shellEnv")
+Export("testEnv")
+Export("has_option")
+Export("installSetup getSysInfo")
+Export("usesm usev8")
+Export("darwin windows solaris linux nix")
+
+env.SConscript( 'src/SConscript', variant_dir=variantDir, duplicate=False )
+env.SConscript( 'SConscript.smoke' )
diff --git a/site_scons/libdeps.py b/site_scons/libdeps.py
new file mode 100644
index 00000000000..24b857c16e8
--- /dev/null
+++ b/site_scons/libdeps.py
@@ -0,0 +1,189 @@
+"""Extension to SCons providing advanced static library dependency tracking.
+
+These modifications to a build environment, which can be attached to
+StaticLibrary and Program builders via a call to setup_environment(env),
+cause the build system to track library dependencies through static libraries,
+and to add them to the link command executed when building programs.
+
+For example, consider a program 'try' that depends on a lib 'tc', which in
+turn uses a symbol from a lib 'tb' which in turn uses a library from 'ta'.
+Without this package, the Program declaration for "try" looks like this:
+
+Program('try', ['try.c', 'path/to/${LIBPREFIX}tc${LIBSUFFIX}',
+ 'path/to/${LIBPREFIX}tc${LIBSUFFIX}',
+ 'path/to/${LIBPREFIX}tc${LIBSUFFIX}',])
+
+With this library, we can instead write the following
+
+Program('try', ['try.c'], LIBDEPS=['path/to/tc'])
+StaticLibrary('tc', ['c.c'], LIBDEPS=['path/to/tb'])
+StaticLibrary('tb', ['b.c'], LIBDEPS=['path/to/ta'])
+StaticLibrary('ta', ['a.c'])
+
+And the build system will figure out that it needs to link libta.a and libtb.a
+when building 'try'.
+"""
+
+# Copyright (c) 2010, Corensic Inc., All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+import os
+
+import SCons.Errors
+import SCons.Scanner
+import SCons.Util
+
+class DependencyCycleError(SCons.Errors.UserError):
+ """Exception representing a cycle discovered in library dependencies."""
+
+ def __init__(self, first_node ):
+ super(DependencyCycleError, self).__init__()
+ self.cycle_nodes = [first_node]
+
+ def __str__(self):
+ return " => ".join(str(n) for n in self.cycle_nodes)
+
+def __get_libdeps(node, env_var):
+ """Given a SCons Node, return its library dependencies.
+
+ Computes the dependencies if they're not already cached.
+ """
+
+ cached_var_name = env_var + '_cached'
+
+ if not hasattr(node.attributes, cached_var_name):
+ setattr(node.attributes, cached_var_name, __compute_libdeps(node, env_var))
+ return getattr(node.attributes, cached_var_name)
+
+def __compute_libdeps(node, env_var):
+ """Recursively identify all library dependencies for a node."""
+
+ if getattr(node.attributes, 'libdeps_exploring', False):
+ raise DependencyCycleError(node)
+
+ env = node.get_env()
+ deps = set()
+ node.attributes.libdeps_exploring = True
+ try:
+ try:
+ for child in env.Flatten(env.get(env_var, [])):
+ if not child:
+ continue
+ deps.add(child)
+ deps.update(__get_libdeps(child, env_var))
+
+ except DependencyCycleError, e:
+ if len(e.cycle_nodes) == 1 or e.cycle_nodes[0] != e.cycle_nodes[-1]:
+ e.cycle_nodes.append(node)
+ raise
+ finally:
+ node.attributes.libdeps_exploring = False
+
+ return deps
+
+def update_scanner(builder):
+ """Update the scanner for "builder" to also scan library dependencies."""
+
+ old_scanner = builder.target_scanner
+
+ if old_scanner:
+ path_function = old_scanner.path_function
+ def new_scanner(node, env, path=()):
+ result = set(old_scanner.function(node, env, path))
+ result.update(__get_libdeps(node, 'LIBDEPS'))
+ result.update(__get_libdeps(node, 'SYSLIBDEPS'))
+ return sorted(result)
+ else:
+ path_function = None
+ def new_scanner(node, env, path=()):
+ result = set(__get_libdeps(node, 'LIBDEPS'))
+ result.update(__get_libdeps(node, 'SYSLIBDEPS'))
+ return sorted(result)
+
+ builder.target_scanner = SCons.Scanner.Scanner(function=new_scanner,
+ path_function=path_function)
+
+def get_libdeps(source, target, env, for_signature):
+ """Implementation of the special _LIBDEPS environment variable.
+
+ Expands to the library dependencies for a target.
+ """
+
+ if for_signature:
+ return []
+ return list(__get_libdeps(target[0], 'LIBDEPS'))
+
+def get_syslibdeps(source, target, env, for_signature):
+ if for_signature:
+ return[]
+ deps = list(__get_libdeps(target[0], 'SYSLIBDEPS'))
+ return deps
+
+def libdeps_emitter(target, source, env):
+ """SCons emitter that takes values from the LIBDEPS environment variable and
+ converts them to File node objects, binding correct path information into
+ those File objects.
+
+ Emitters run on a particular "target" node during the initial execution of
+ the SConscript file, rather than during the later build phase. When they
+ run, the "env" environment's working directory information is what you
+ expect it to be -- that is, the working directory is considered to be the
+ one that contains the SConscript file. This allows specification of
+ relative paths to LIBDEPS elements.
+
+ This emitter also adds LIBSUFFIX and LIBPREFIX appropriately.
+ """
+
+ libdep_files = []
+ lib_suffix = env.subst('$LIBSUFFIX', target=target, source=source)
+ lib_prefix = env.subst('$LIBPREFIX', target=target, source=source)
+ for dep in env.Flatten([env.get('LIBDEPS', [])]):
+ full_path = env.subst(str(dep), target=target, source=source)
+ dir_name = os.path.dirname(full_path)
+ file_name = os.path.basename(full_path)
+ if not file_name.startswith(lib_prefix):
+ file_name = '${LIBPREFIX}' + file_name
+ if not file_name.endswith(lib_suffix):
+ file_name += '${LIBSUFFIX}'
+ libdep_files.append(env.File(os.path.join(dir_name, file_name)))
+
+ env['LIBDEPS'] = libdep_files
+
+ return target, source
+
+def setup_environment(env):
+ """Set up the given build environment to do LIBDEPS tracking."""
+
+ env['_LIBDEPS'] = get_libdeps
+ env['_SYSLIBDEPS'] = ' ${_stripixes(LIBLINKPREFIX, SYSLIBDEPS, LIBLINKSUFFIX, LIBPREFIXES, LIBSUFFIXES, __env__)} '
+ env['_SHLIBDEPS'] = '$SHLIBDEP_GROUP_START ${_concat(SHLIBDEPPREFIX, __env__.subst(_LIBDEPS, target=TARGET, source=SOURCE), SHLIBDEPSUFFIX, __env__, target=TARGET, source=SOURCE)} $SHLIBDEP_GROUP_END'
+
+ env['LIBDEPS'] = SCons.Util.CLVar()
+ env['SYSLIBDEPS'] = SCons.Util.CLVar()
+ env.Append(LIBEMITTER=libdeps_emitter,
+ PROGEMITTER=libdeps_emitter,
+ SHLIBEMITTER=libdeps_emitter)
+ env.Prepend(_LIBFLAGS=' $LINK_LIBGROUP_START $_LIBDEPS $LINK_LIBGROUP_END $_SYSLIBDEPS ')
+ for builder_name in ('Program', 'SharedLibrary', 'LoadableModule'):
+ try:
+ update_scanner(env['BUILDERS'][builder_name])
+ except KeyError:
+ pass
diff --git a/gch.py b/site_scons/site_tools/gch.py
index 61060c688b6..8db5403ffcc 100644
--- a/gch.py
+++ b/site_scons/site_tools/gch.py
@@ -37,9 +37,10 @@ GchShAction = SCons.Action.Action('$GCHSHCOM', '$GCHSHCOMSTR')
def gen_suffix(env, sources):
return sources[0].get_suffix() + env['GCHSUFFIX']
-def header_path(node):
- path = node.path
- return path[:-4] # strip final '.gch'
+def header_path(env, node):
+ assert len(node.sources) == 1
+ path = node.sources[0].path
+ return path
GchShBuilder = SCons.Builder.Builder(action = GchShAction,
source_scanner = SCons.Scanner.C.CScanner(),
@@ -57,7 +58,7 @@ def static_pch_emitter(target,source,env):
deps = scanner(source[0], env, path)
if env.has_key('Gch') and env['Gch']:
- if header_path(env['Gch']) in [x.path for x in deps]:
+ if header_path(env, env['Gch']) in [x.path for x in deps]:
env.Depends(target, env['Gch'])
return (target, source)
@@ -70,7 +71,7 @@ def shared_pch_emitter(target,source,env):
deps = scanner(source[0], env, path)
if env.has_key('GchSh') and env['GchSh']:
- if header_path(env['GchSh']) in [x.path for x in deps]:
+ if header_path(env, env['GchSh']) in [x.path for x in deps]:
env.Depends(target, env['GchSh'])
return (target, source)
diff --git a/site_scons/site_tools/jsheader.py b/site_scons/site_tools/jsheader.py
new file mode 100644
index 00000000000..c271948599b
--- /dev/null
+++ b/site_scons/site_tools/jsheader.py
@@ -0,0 +1,53 @@
+import os
+
+from SCons.Builder import Builder
+
+def jsToH(target, source, env):
+
+ outFile = str( target[0] )
+
+ h = ['#include "bson/stringdata.h"'
+ ,'namespace mongo {'
+ ,'struct JSFile{ const char* name; const StringData& source; };'
+ ,'namespace JSFiles{'
+ ]
+
+ def cppEscape(s):
+ s = s.strip()
+ s = s.replace( '\\', '\\\\' )
+ s = s.replace( '"', r'\"' )
+ return s
+
+ for s in source:
+ filename = str(s)
+ objname = os.path.split(filename)[1].split('.')[0]
+ stringname = '_jscode_raw_' + objname
+
+ h.append('const StringData ' + stringname + " = ")
+
+ for l in open( filename, 'r' ):
+ h.append( '"' + cppEscape(l) + r'\n" ' )
+
+ h.append(";")
+ h.append('extern const JSFile %s;'%objname) #symbols aren't exported w/o this
+ h.append('const JSFile %s = { "%s", %s };'%(objname, filename.replace('\\', '/'), stringname))
+
+ h.append("} // namespace JSFiles")
+ h.append("} // namespace mongo")
+ h.append("")
+
+ text = '\n'.join(h);
+
+ out = open( outFile, 'wb' )
+ try:
+ out.write( text )
+ finally:
+ out.close()
+
+jshBuilder = Builder( action=jsToH )
+
+def generate(env, **kw):
+ env.Append( BUILDERS=dict( JSHeader=jshBuilder ) )
+
+def exists(env):
+ return True
diff --git a/site_scons/site_tools/mergelib.py b/site_scons/site_tools/mergelib.py
new file mode 100644
index 00000000000..8c63d3aacce
--- /dev/null
+++ b/site_scons/site_tools/mergelib.py
@@ -0,0 +1,24 @@
+"""Builder for static libraries composed of the contents of other static libraries.
+
+The following rule creates a library "mylib" whose contents are the contents of
+"firstlib", "secondlib", and all LIBDEPS dependencies of "firstlib" and
+"secondlib". This creates self-contained static and shared libraries that can
+be distributed to customers.
+
+MergeLibrary('mylib', ['firstlib', 'secondlib'])
+MergeSharedLibrary('mylib', ['firstlib', 'secondlib'])
+
+This file provides the platform-independent tool, which just selects and imports
+the platform-specific tool providing MergeLibrary and MergeSharedLibrary.
+"""
+
+import sys
+
+def exists( env ):
+ return True
+
+def generate( env ):
+ if sys.platform == 'win32':
+ env.Tool( 'mergelibwin' )
+ else:
+ env.Tool( 'mergelibposix' )
diff --git a/site_scons/site_tools/mergelibposix.py b/site_scons/site_tools/mergelibposix.py
new file mode 100644
index 00000000000..82807ed6b4f
--- /dev/null
+++ b/site_scons/site_tools/mergelibposix.py
@@ -0,0 +1,42 @@
+"""Builder for static libraries composed of the contents of other static libraries.
+
+The following rule creates a library "mylib" whose contents are the contents of
+"firstlib", "secondlib", and all LIBDEPS dependencies of "firstlib" and
+"secondlib". This creates self-contained static and shared libraries that can
+be distributed to customers.
+
+MergeLibrary('mylib', ['firstlib', 'secondlib'])
+MergeSharedLibrary('mylib', ['firstlib', 'secondlib'])
+
+This implementation is for posix systems whose linkers can generate "relocatable
+objects" (usually with the -r option).
+"""
+
+import libdeps
+from SCons.Action import Action
+from SCons.Builder import Builder
+
+def merge_library_method( env, target, source, LIBDEPS=None, **kwargs ):
+ robj_name = env.subst( '${TARGET}-mergelib', target=target, source=source )
+ robj = env.RelocatableObject( robj_name, [], LIBDEPS=source, **kwargs )
+ return env.Library( target, robj, LIBDEPS=LIBDEPS or [], **kwargs )
+
+def merge_shared_library_method( env, target, source, LIBDEPS=None, **kwargs ):
+ robj_name = env.subst( '${TARGET}-mergeshlib', target=target, source=source )
+ robj = env.RelocatableObject( robj_name, [], LIBDEPS=source, **kwargs )
+ return env.SharedLibrary( target, robj, LIBDEPS=LIBDEPS or [], **kwargs )
+
+def exists( env ):
+ return True
+
+def generate( env ):
+ env['_RELOBJDEPSFLAGS'] = '$RELOBJ_LIBDEPS_START ${_concat("$RELOBJ_LIBDEPS_ITEM ", __env__.subst(_LIBDEPS, target=TARGET, source=SOURCE), "", __env__, target=TARGET, source=SOURCE)} $RELOBJ_LIBDEPS_END'
+ env['RELOBJCOM'] = 'ld -o $TARGET -r $SOURCES $_RELOBJDEPSFLAGS'
+ relobj_builder = Builder( action='$RELOBJCOM',
+ prefix="$OBJPREFIX",
+ suffix="$OBJSUFFIX",
+ emitter=libdeps.libdeps_emitter )
+ libdeps.update_scanner( relobj_builder )
+ env['BUILDERS']['RelocatableObject'] = relobj_builder
+ env.AddMethod( merge_library_method, 'MergeLibrary' )
+ env.AddMethod( merge_shared_library_method, 'MergeSharedLibrary' )
diff --git a/site_scons/site_tools/mergelibwin.py b/site_scons/site_tools/mergelibwin.py
new file mode 100644
index 00000000000..680ccdd5b9a
--- /dev/null
+++ b/site_scons/site_tools/mergelibwin.py
@@ -0,0 +1,34 @@
+"""Builder for static libraries composed of the contents of other static libraries.
+
+The following rule creates a library "mylib" whose contents are the contents of
+"firstlib", "secondlib", and all LIBDEPS dependencies of "firstlib" and
+"secondlib". This creates self-contained static and shared libraries that can
+be distributed to customers.
+
+MergeLibrary('mylib', ['firstlib', 'secondlib'])
+MergeSharedLibrary('mylib', ['firstlib', 'secondlib'])
+
+This implementation is for win32 systems using msvc.
+"""
+
+import libdeps
+from SCons.Action import Action
+from SCons.Builder import Builder
+
+def merge_library_method( env, target, source, LIBDEPS=None, **kwargs ):
+ return env._MergeLibrary( target, [], LIBDEPS=source, **kwargs )
+
+def exists( env ):
+ return True
+
+def generate( env ):
+ merge_library = Builder(
+ action='${TEMPFILE("$AR $ARFLAGS /OUT:$TARGET $_LIBDEPS")}',
+ src_prefix='$LIBPREFIX',
+ src_suffix='$LIBSUFFIX',
+ prefix='$LIBPREFIX',
+ suffix='$LIBSUFFIX',
+ emitter=libdeps.libdeps_emitter )
+ libdeps.update_scanner( merge_library )
+ env['BUILDERS']['_MergeLibrary'] = merge_library
+ env.AddMethod( merge_library_method, 'MergeLibrary' )
diff --git a/src/SConscript b/src/SConscript
new file mode 100644
index 00000000000..c4e96a5fddc
--- /dev/null
+++ b/src/SConscript
@@ -0,0 +1,7 @@
+# -*- mode: python; -*-
+#
+# This is the principle SConscript file, invoked by the SConstruct. Its job is
+# to delegate to any and all per-module SConscript files.
+
+SConscript( [ 'mongo/SConscript',
+ 'third_party/SConscript' ] )
diff --git a/src/mongo/SConscript b/src/mongo/SConscript
new file mode 100644
index 00000000000..cdb74e00cc7
--- /dev/null
+++ b/src/mongo/SConscript
@@ -0,0 +1,563 @@
+# -*- mode: python; -*-
+
+# This SConscript describes build rules for the "mongo" project.
+
+import os
+import buildscripts.utils as utils
+
+Import("env")
+Import("shellEnv")
+Import("testEnv")
+Import("has_option")
+Import("usesm usev8")
+Import("installSetup getSysInfo")
+Import("darwin windows solaris linux nix")
+
+def add_exe( v ):
+ return "${PROGPREFIX}%s${PROGSUFFIX}" % v
+
+def setupBuildInfoFile( env, target, source, **kw ):
+ version = utils.getGitVersion()
+ sysInfo = getSysInfo()
+ contents = '\n'.join([
+ '#include "pch.h"',
+ '#include <iostream>',
+ '#include <boost/version.hpp>',
+ 'namespace mongo { const char * gitVersion(){ return "' + version + '"; } }',
+ 'namespace mongo { string sysInfo(){ return "' + sysInfo + ' BOOST_LIB_VERSION=" BOOST_LIB_VERSION ; } }',
+ ])
+
+ contents += '\n\n';
+
+ out = open( str( target[0] ) , 'wb' )
+ try:
+ out.write( contents )
+ finally:
+ out.close()
+
+env.AlwaysBuild( env.Command( 'buildinfo.cpp', [], setupBuildInfoFile ) )
+
+# ------ SOURCE FILE SETUP -----------
+
+commonFiles = [ "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",
+ "util/background.cpp",
+ "util/intrusive_counter.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/rwlockimpl.cpp",
+ "util/histogram.cpp",
+ "util/concurrency/spin_lock.cpp",
+ "util/text.cpp",
+ "util/stringutils.cpp",
+ "util/concurrency/synchronization.cpp",
+ "util/net/sock.cpp",
+ "util/net/httpclient.cpp",
+ "util/net/message.cpp",
+ "util/net/message_port.cpp",
+ "util/net/listen.cpp",
+ "util/md5.c",
+ "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" ]
+
+commonFiles += env['MONGO_COMMON_FILES']
+
+env.StaticLibrary('mongocommon', commonFiles,
+ LIBDEPS=['$BUILD_DIR/third_party/pcrecpp'])
+
+#mmap stuff
+
+env.StaticLibrary("coredb", [ "db/commands.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/commands/cloud.cpp",
+ "db/dbmessage.cpp",
+ "db/commands/pipeline.cpp",
+ "db/pipeline/accumulator.cpp",
+ "db/pipeline/accumulator_add_to_set.cpp",
+ "db/pipeline/accumulator_avg.cpp",
+ "db/pipeline/accumulator_first.cpp",
+ "db/pipeline/accumulator_last.cpp",
+ "db/pipeline/accumulator_min_max.cpp",
+ "db/pipeline/accumulator_push.cpp",
+ "db/pipeline/accumulator_single_value.cpp",
+ "db/pipeline/accumulator_sum.cpp",
+ "db/pipeline/builder.cpp",
+ "db/pipeline/doc_mem_monitor.cpp",
+ "db/pipeline/document.cpp",
+ "db/pipeline/document_source.cpp",
+ "db/pipeline/document_source_bson_array.cpp",
+ "db/pipeline/document_source_command_futures.cpp",
+ "db/pipeline/document_source_filter.cpp",
+ "db/pipeline/document_source_filter_base.cpp",
+ "db/pipeline/document_source_group.cpp",
+ "db/pipeline/document_source_limit.cpp",
+ "db/pipeline/document_source_match.cpp",
+ "db/pipeline/document_source_out.cpp",
+ "db/pipeline/document_source_project.cpp",
+ "db/pipeline/document_source_skip.cpp",
+ "db/pipeline/document_source_sort.cpp",
+ "db/pipeline/document_source_unwind.cpp",
+ "db/pipeline/expression.cpp",
+ "db/pipeline/expression_context.cpp",
+ "db/pipeline/field_path.cpp",
+ "db/pipeline/value.cpp",
+ "db/stats/counters.cpp",
+ "db/stats/service_stats.cpp",
+ "db/stats/top.cpp",
+ "db/commands/isself.cpp",
+ "db/security_common.cpp",
+ "db/security_commands.cpp",
+ "scripting/engine.cpp",
+ "scripting/utils.cpp",
+ "scripting/bench.cpp",
+ ] + env['MONGO_SCRIPTING_FILES']
+
+if usesm:
+ coreServerFiles.append( "scripting/engine_spidermonkey.cpp" )
+elif usev8:
+ coreServerFiles.append( Glob( "scripting/*v8*.cpp" ) )
+else:
+ coreServerFiles.append( "scripting/engine_none.cpp" )
+
+mmapFiles = [ "util/mmap.cpp" ]
+
+if has_option( "mm" ):
+ mmapFiles += [ "util/mmap_mm.cpp" ]
+else:
+ mmapFiles += [ "util/mmap_${OS_FAMILY}.cpp" ]
+
+# handle processinfo*
+processInfoFiles = [ "util/processinfo.cpp" ]
+
+processInfoPlatformFile = env.File( "util/processinfo_${PYSYSPLATFORM}.cpp" )
+# NOTE( schwerin ): This is a very un-scons-y way to make this decision, and prevents one from using
+# code generation to produce util/processinfo_$PYSYSPLATFORM.cpp.
+if not os.path.exists( str( processInfoPlatformFile ) ):
+ processInfoPlatformFile = env.File( "util/processinfo_none.cpp" )
+
+processInfoFiles.append( processInfoPlatformFile )
+
+coreServerFiles += processInfoFiles
+
+# handle systeminfo*
+systemInfoPlatformFile = env.File( "util/systeminfo_${PYSYSPLATFORM}.cpp" )
+# NOTE( schwerin ): This is a very un-scons-y way to make this decision, and prevents one from using
+# code generation to produce util/systeminfo_$PYSYSPLATFORM.cpp.
+if not os.path.exists( str( systemInfoPlatformFile ) ):
+ systemInfoPlatformFile = env.File( "util/systeminfo_none.cpp" )
+
+coreServerFiles.append( systemInfoPlatformFile )
+
+if has_option( "asio" ):
+ coreServerFiles += [ "util/net/message_server_asio.cpp" ]
+
+# mongod files - also files used in tools. present in dbtests, but not in mongos and not in client libs.
+serverOnlyFiles = [ "db/curop.cpp",
+ "db/d_globals.cpp",
+ "db/pagefault.cpp",
+ "util/compress.cpp",
+ "db/d_concurrency.cpp",
+ "db/key.cpp",
+ "db/btreebuilder.cpp",
+ "util/logfile.cpp",
+ "util/alignedbuilder.cpp",
+ "db/mongommf.cpp",
+ "db/dur.cpp",
+ "db/durop.cpp",
+ "db/dur_writetodatafiles.cpp",
+ "db/dur_preplogbuffer.cpp",
+ "db/dur_commitjob.cpp",
+ "db/dur_recover.cpp",
+ "db/dur_journal.cpp",
+ "db/introspect.cpp",
+ "db/btree.cpp",
+ "db/clientcursor.cpp",
+ "db/tests.cpp",
+ "db/repl.cpp",
+ "db/repl/rs.cpp",
+ "db/repl/consensus.cpp",
+ "db/repl/rs_initiate.cpp",
+ "db/repl/replset_commands.cpp",
+ "db/repl/manager.cpp",
+ "db/repl/health.cpp",
+ "db/repl/heartbeat.cpp",
+ "db/repl/rs_config.cpp",
+ "db/repl/rs_rollback.cpp",
+ "db/repl/rs_sync.cpp",
+ "db/repl/rs_initialsync.cpp",
+ "db/oplog.cpp",
+ "db/repl_block.cpp",
+ "db/btreecursor.cpp",
+ "db/cloner.cpp",
+ "db/namespace.cpp",
+ "db/cap.cpp",
+ "db/matcher_covered.cpp",
+ "db/dbeval.cpp",
+ "db/restapi.cpp",
+ "db/dbhelpers.cpp",
+ "db/instance.cpp",
+ "db/client.cpp",
+ "db/database.cpp",
+ "db/pdfile.cpp",
+ "db/record.cpp",
+ "db/cursor.cpp",
+ "db/security.cpp",
+ "db/queryoptimizer.cpp",
+ "db/queryoptimizercursor.cpp",
+ "db/extsort.cpp",
+ "db/index.cpp",
+ "db/scanandorder.cpp",
+ "db/geo/2d.cpp",
+ "db/geo/haystack.cpp",
+ "db/ops/count.cpp",
+ "db/ops/delete.cpp",
+ "db/ops/query.cpp",
+ "db/ops/update.cpp",
+ "db/dbcommands.cpp",
+ "db/dbcommands_admin.cpp",
+
+ # most commands are only for mongod
+ "db/commands/distinct.cpp",
+ "db/commands/find_and_modify.cpp",
+ "db/commands/group.cpp",
+ "db/commands/mr.cpp",
+ "db/commands/pipeline_command.cpp",
+ "db/commands/pipeline_d.cpp",
+ "db/commands/document_source_cursor.cpp",
+ "db/driverHelpers.cpp" ] + env['MONGO_SERVER_ONLY_FILES']
+
+env.Library( "dbcmdline", "db/cmdline.cpp" )
+
+serverOnlyFiles += mmapFiles
+
+serverOnlyFiles += [ "db/stats/snapshots.cpp" ]
+
+env.Library( "coreshard", [ "s/config.cpp",
+ "s/grid.cpp",
+ "s/chunk.cpp",
+ "s/shard.cpp",
+ "s/shardkey.cpp"] )
+
+shardServerFiles = [
+ "s/strategy.cpp",
+ "s/strategy_shard.cpp",
+ "s/strategy_single.cpp",
+ "s/commands_admin.cpp",
+ "s/commands_public.cpp",
+ "s/request.cpp",
+ "s/client.cpp",
+ "s/cursors.cpp",
+ "s/server.cpp",
+ "s/config_migrate.cpp",
+ "s/s_only.cpp",
+ "s/stats.cpp",
+ "s/balance.cpp",
+ "s/balancer_policy.cpp",
+ "s/writeback_listener.cpp",
+ "s/shard_version.cpp",
+ "s/mr_shard.cpp",
+ "s/security.cpp",
+ ]
+
+serverOnlyFiles += [ "s/d_logic.cpp",
+ "s/d_writeback.cpp",
+ "s/d_migrate.cpp",
+ "s/d_state.cpp",
+ "s/d_split.cpp",
+ "client/distlock_test.cpp",
+ "s/d_chunk_manager.cpp",
+ "db/module.cpp",
+ "db/modules/mms.cpp", ]
+
+env.StaticLibrary("defaultversion", "s/default_version.cpp")
+
+env.StaticLibrary("serveronly", serverOnlyFiles, LIBDEPS=["coreshard", "dbcmdline", "defaultversion"])
+
+modules = []
+moduleNames = []
+
+mongodOnlyFiles = [ "db/db.cpp", "db/compact.cpp" ]
+if "win32" == os.sys.platform:
+ mongodOnlyFiles.append( "util/ntservice.cpp" )
+
+# ----- TARGETS ------
+
+env.StaticLibrary("gridfs", "client/gridfs.cpp")
+
+if has_option( 'use-cpu-profiler' ):
+ coreServerFiles.append( 'db/commands/cpuprofile.cpp' )
+ env.Append( LIBS=['profiler'] )
+
+env.StaticLibrary("coreserver", coreServerFiles, LIBDEPS=["mongocommon"])
+
+# main db target
+mongod = env.Install( '#/', env.Program( "mongod", mongodOnlyFiles,
+ LIBDEPS=["coreserver", "serveronly", "coredb"] ) )
+Default( mongod )
+
+# tools
+allToolFiles = [ "tools/tool.cpp", "tools/stat_util.cpp" ]
+env.StaticLibrary("alltools", allToolFiles, LIBDEPS=["serveronly", "coreserver", "coredb"])
+
+normalTools = [ "dump", "restore", "export", "import", "stat", "top", "oplog" ]
+env.Alias( "tools", [ "#/${PROGPREFIX}mongo" + x + "${PROGSUFFIX}" for x in normalTools ] )
+for x in normalTools:
+ env.Install( '#/', env.Program( "mongo" + x, [ "tools/" + x + ".cpp" ],
+ LIBDEPS=["alltools"]) )
+
+#some special tools
+env.Install( '#/', [
+ env.Program( "mongofiles", "tools/files.cpp", LIBDEPS=["alltools", "gridfs"] ),
+ env.Program( "bsondump", "tools/bsondump.cpp", LIBDEPS=["alltools"]),
+ env.Program( "mongobridge", "tools/bridge.cpp", LIBDEPS=["alltools"]),
+ env.Program( "mongoperf", "client/examples/mongoperf.cpp", LIBDEPS=["alltools"] ),
+ ] )
+
+# mongos
+mongos = env.Program( "mongos", shardServerFiles,
+ LIBDEPS=["coreserver", "coredb", "mongocommon", "coreshard", "dbcmdline"])
+env.Install( '#/', mongos )
+
+env.Library("clientandshell", "client/clientAndShell.cpp", LIBDEPS=["mongocommon", "coredb", "defaultversion", "gridfs"])
+env.Library("allclient", "client/clientOnly.cpp", LIBDEPS=["clientandshell"])
+# c++ library
+clientLib = env.MergeLibrary( "mongoclient", ["allclient"] )
+env.Install( '#/', clientLib )
+clientLibName = str( clientLib[0] )
+if has_option( "sharedclient" ):
+ sharedClientLibName = str( env.MergeSharedLibrary( "mongoclient", ["allclient"] )[0] )
+
+clientEnv = env.Clone();
+clientEnv.Append( CPPPATH=["../"] )
+clientEnv.Prepend( LIBS=[ clientLib ] )
+clientEnv.Prepend( LIBPATH=["."] )
+clientEnv["CPPDEFINES"].remove( "MONGO_EXPOSE_MACROS" )
+l = clientEnv[ "LIBS" ]
+
+# examples
+clientTests = [
+ clientEnv.Program( "firstExample", [ "client/examples/first.cpp" ] ),
+ clientEnv.Program( "rsExample", [ "client/examples/rs.cpp" ] ),
+ clientEnv.Program( "secondExample", [ "client/examples/second.cpp" ] ),
+ clientEnv.Program( "whereExample", [ "client/examples/whereExample.cpp" ] ),
+ clientEnv.Program( "authTest", [ "client/examples/authTest.cpp" ] ),
+ clientEnv.Program( "httpClientTest", [ "client/examples/httpClientTest.cpp" ] ),
+ clientEnv.Program( "bsondemo", [ "bson/bsondemo/bsondemo.cpp" ] ),
+ ]
+
+# dbtests test binary
+test = testEnv.Install(
+ '#/',
+ testEnv.Program( "test", Glob( "dbtests/*.cpp" ),
+ LIBDEPS=["mongocommon", "serveronly", "coreserver", "coredb" ] ) )
+
+if len(testEnv.subst('$PROGSUFFIX')):
+ testEnv.Alias( "test", "#/${PROGPREFIX}test${PROGSUFFIX}" )
+
+env.Install( '#/', testEnv.Program( "perftest", [ "dbtests/framework.cpp", "dbtests/perf/perftest.cpp" ], LIBDEPS=["serveronly", "coreserver", "coredb"] ) )
+clientTests += [ clientEnv.Program( "clientTest", [ "client/examples/clientTest.cpp" ] ) ]
+
+env.Install( '#/', clientTests )
+
+# --- sniffer ---
+mongosniff_built = False
+if darwin or clientEnv["_HAVEPCAP"]:
+ mongosniff_built = True
+ sniffEnv = env.Clone()
+ sniffEnv.Append( CPPDEFINES="MONGO_EXPOSE_MACROS" )
+
+ if not windows:
+ sniffEnv.Append( LIBS=[ "pcap" ] )
+ else:
+ sniffEnv.Append( LIBS=[ "wpcap" ] )
+
+ sniffEnv.Install( '#/', sniffEnv.Program( "mongosniff", "tools/sniffer.cpp",
+ LIBDEPS=["gridfs", "serveronly", "coreserver", "coredb"] ) )
+
+# --- shell ---
+
+# note, if you add a file here, you need to add it in scripting/engine.cpp and shell/msvc/createCPPfromJavaScriptFiles.js as well
+env.Depends( "shell/dbshell.cpp",
+ env.JSHeader( "shell/mongo.cpp" ,
+ Glob( "shell/utils*.js" ) +
+ [ "shell/db.js","shell/mongo.js","shell/mr.js","shell/query.js","shell/collection.js"] ) )
+
+env.JSHeader( "shell/mongo-server.cpp" , [ "shell/servers.js"] )
+
+coreShellFiles = [ "shell/dbshell.cpp",
+ "shell/shell_utils.cpp",
+ "shell/mongo-server.cpp",
+ "../third_party/linenoise/linenoise.cpp"]
+
+shellFilesToUse = coreShellFiles
+
+if shellEnv is not None:
+ mongo_shell = shellEnv.Program(
+ "mongo",
+ [ "shell/dbshell.cpp",
+ "shell/shell_utils.cpp",
+ "shell/mongo-server.cpp",
+ "../third_party/linenoise/linenoise.cpp" ],
+ LIBDEPS=["coreserver", "clientandshell",
+ "$BUILD_DIR/third_party/pcrecpp"] )
+
+ shellEnv.Install( '#/', mongo_shell )
+
+# ---- INSTALL -------
+
+# binaries
+
+def checkGlibc(target,source,env):
+ import subprocess
+ stringProcess = subprocess.Popen( [ "strings", str( target[0] ) ], stdout=subprocess.PIPE )
+ stringResult = stringProcess.communicate()[0]
+ if stringResult.count( "GLIBC_2.4" ) > 0:
+ print( "************* " + str( target[0] ) + " has GLIBC_2.4 dependencies!" )
+ Exit(-3)
+
+allBinaries = []
+
+def installBinary( e, name ):
+ if not installSetup.binaries:
+ return
+
+ global allBinaries
+
+ name = add_exe( name )
+
+ inst = e.Install( "$INSTALL_DIR/bin", name )[0]
+
+ allBinaries += [ name ]
+ if (solaris or linux) and (not has_option("nostrip")):
+ e.AddPostAction( inst, e.Action( 'strip $TARGET' ) )
+
+ if not has_option( "no-glibc-check" ) and linux and len( COMMAND_LINE_TARGETS ) == 1 and str( COMMAND_LINE_TARGETS[0] ) == "s3dist":
+ e.AddPostAction( inst, checkGlibc )
+
+ if nix:
+ e.AddPostAction( inst, e.Action( 'chmod 755 %s' % inst) )
+
+for x in normalTools:
+ installBinary( env, "mongo" + x )
+installBinary( env, "bsondump" )
+installBinary( env, "mongoperf" )
+
+if mongosniff_built:
+ installBinary(env, "mongosniff")
+
+installBinary( env, "mongod" )
+installBinary( env, "mongos" )
+
+if shellEnv is not None:
+ installBinary( env, "mongo" )
+
+env.Alias( "all", ['#/%s' % b for b in allBinaries ] )
+env.Alias( "core", [ '#/%s' % b for b in [ add_exe( "mongo" ), add_exe( "mongod" ), add_exe( "mongos" ) ] ] )
+
+#headers
+if installSetup.headers:
+ for id in [ "", "util/", "util/net/", "util/mongoutils/", "util/concurrency/", "db/", "db/stats/", "db/repl/", "db/ops/", "client/", "bson/", "bson/util/", "s/", "scripting/" ]:
+ env.Install( "$INSTALL_DIR/" + installSetup.headerRoot + "/" + id, Glob( id + "*.h" ) )
+ env.Install( "$INSTALL_DIR/" + installSetup.headerRoot + "/" + id, Glob( id + "*.hpp" ) )
+
+if installSetup.clientSrc:
+ print "ERROR! NOT IMPLEMENTED: client source installation"
+ Exit(1)
+
+#lib
+if installSetup.libraries:
+ env.Install( "$INSTALL_DIR/$NIX_LIB_DIR", clientLibName )
+ if has_option( "sharedclient" ):
+ env.Install( "$INSTALL_DIR/$NIX_LIB_DIR", sharedClientLibName )
+
+#textfiles
+if installSetup.bannerDir:
+ for x in os.listdir( installSetup.bannerDir ):
+ full = installSetup.bannerDir + "/" + x
+ if os.path.isdir( full ):
+ continue
+ if x.find( "~" ) >= 0:
+ continue
+ env.Install( "$INSTALL_DIR", full )
+
+if installSetup.clientTestsDir:
+ for x in os.listdir( installSetup.clientTestsDir ):
+ full = installSetup.clientTestsDir + "/" + x
+ if os.path.isdir( full ):
+ continue
+ if x.find( "~" ) >= 0:
+ continue
+ env.Install( '$INSTALL_DIR/' + installSetup.clientTestsDir, full )
+
+#final alias
+env.Alias( "install", "$INSTALL_DIR" )
+
+# aliases
+env.Alias( "mongoclient", '#/%s' % ( has_option( "sharedclient" ) and sharedClientLibName or clientLibName ) )
+
+def clean_old_dist_builds(env, target, source):
+ prefix = "mongodb-%s-%s" % (platform, processor)
+ filenames = sorted(os.listdir("."))
+ filenames = [x for x in filenames if x.startswith(prefix)]
+ to_keep = [x for x in filenames if x.endswith(".tgz") or x.endswith(".zip")][-2:]
+ for filename in [x for x in filenames if x not in to_keep]:
+ print "removing %s" % filename
+ try:
+ shutil.rmtree(filename)
+ except:
+ os.remove(filename)
+
+env.Alias("dist_clean", [], [clean_old_dist_builds])
+env.AlwaysBuild("dist_clean")
+
+# client dist
+def build_and_test_client(env, target, source):
+ from subprocess import call
+
+ installDir = env.subst('$INSTALL_DIR', target=target, source=source)
+ if GetOption("extrapath") is not None:
+ scons_command = ["scons", "--extrapath=" + GetOption("extrapath")]
+ else:
+ scons_command = ["scons"]
+
+ call(scons_command + ["libmongoclient.a", "clientTests"], cwd=installDir)
+
+ return bool(call(["python", "buildscripts/smoke.py",
+ "--test-path", installDir, "client"]))
+env.Alias("clientBuild", [mongod, '$INSTALL_DIR'], [build_and_test_client])
+env.AlwaysBuild("clientBuild")
diff --git a/src/mongo/client/clientAndShell.cpp b/src/mongo/client/clientAndShell.cpp
new file mode 100644
index 00000000000..401c8c9eb63
--- /dev/null
+++ b/src/mongo/client/clientAndShell.cpp
@@ -0,0 +1,96 @@
+// clientAndShell.cpp
+
+/* Copyright 2009 10gen Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "pch.h"
+#include "../client/dbclient.h"
+#include "../db/cmdline.h"
+#include "../db/client_common.h"
+#include "../s/shard.h"
+#include "../util/timer.h"
+#include "clientOnly-private.h"
+
+namespace mongo {
+
+ CmdLine cmdLine;
+
+ const char * curNs = "in client mode";
+
+ bool dbexitCalled = false;
+ // This mutex helps the shell serialize output on exit,
+ // to avoid deadlocks at shutdown. So it also protects
+ // the global dbexitCalled.
+ namespace shellUtils {
+ mongo::mutex &mongoProgramOutputMutex(*(new mongo::mutex("mongoProgramOutputMutex")));
+ }
+
+ void exitCleanly( ExitCode code ) {
+ dbexit( code );
+ }
+
+ void dbexit( ExitCode returnCode, const char *whyMsg , bool tryToGetLock ) {
+ {
+ mongo::mutex::scoped_lock lk( shellUtils::mongoProgramOutputMutex );
+ dbexitCalled = true;
+ }
+ out() << "dbexit called" << endl;
+ if ( whyMsg )
+ out() << " b/c " << whyMsg << endl;
+ out() << "exiting" << endl;
+ ::exit( returnCode );
+ }
+
+ bool inShutdown() {
+ return dbexitCalled;
+ }
+
+ void setupSignals() {
+ // maybe should do SIGPIPE here, not sure
+ }
+
+ string getDbContext() {
+ return "in client only mode";
+ }
+
+ bool haveLocalShardingInfo( const string& ns ) {
+ return false;
+ }
+
+ DBClientBase * createDirectClient() {
+ uassert( 10256 , "no createDirectClient in clientOnly" , 0 );
+ return 0;
+ }
+
+ void Shard::getAllShards( vector<Shard>& all ) {
+ assert(0);
+ }
+
+ bool Shard::isAShardNode( const string& ident ) {
+ assert(0);
+ return false;
+ }
+
+ string prettyHostName() {
+ assert(0);
+ return "";
+ }
+
+ ClientBasic* ClientBasic::getCurrent() {
+ return 0;
+ }
+
+
+}
diff --git a/src/mongo/client/clientOnly.cpp b/src/mongo/client/clientOnly.cpp
index 649f3bf53b0..a4f2f3a044a 100644
--- a/src/mongo/client/clientOnly.cpp
+++ b/src/mongo/client/clientOnly.cpp
@@ -15,88 +15,14 @@
* limitations under the License.
*/
-#include "pch.h"
-#include "../client/dbclient.h"
-#include "../db/cmdline.h"
-#include "../db/client_common.h"
-#include "../s/shard.h"
-#include "../util/timer.h"
-#include "clientOnly-private.h"
+#include "mongo/util/net/hostandport.h"
namespace mongo {
- CmdLine cmdLine;
-
- const char * curNs = "in client mode";
-
- bool dbexitCalled = false;
- // This mutex helps the shell serialize output on exit,
- // to avoid deadlocks at shutdown. So it also protects
- // the global dbexitCalled.
- namespace shellUtils {
- mongo::mutex &mongoProgramOutputMutex(*(new mongo::mutex("mongoProgramOutputMutex")));
- }
-
string dynHostMyName() { return ""; }
void dynHostResolve(string& name, int& port) {
assert(false);
}
- void exitCleanly( ExitCode code ) {
- dbexit( code );
- }
-
- void dbexit( ExitCode returnCode, const char *whyMsg , bool tryToGetLock ) {
- {
- mongo::mutex::scoped_lock lk( shellUtils::mongoProgramOutputMutex );
- dbexitCalled = true;
- }
- out() << "dbexit called" << endl;
- if ( whyMsg )
- out() << " b/c " << whyMsg << endl;
- out() << "exiting" << endl;
- ::exit( returnCode );
- }
-
- bool inShutdown() {
- return dbexitCalled;
- }
-
- void setupSignals() {
- // maybe should do SIGPIPE here, not sure
- }
-
- string getDbContext() {
- return "in client only mode";
- }
-
- bool haveLocalShardingInfo( const string& ns ) {
- return false;
- }
-
- DBClientBase * createDirectClient() {
- uassert( 10256 , "no createDirectClient in clientOnly" , 0 );
- return 0;
- }
-
- void Shard::getAllShards( vector<Shard>& all ) {
- assert(0);
- }
-
- bool Shard::isAShardNode( const string& ident ) {
- assert(0);
- return false;
- }
-
- string prettyHostName() {
- assert(0);
- return "";
- }
-
- ClientBasic* ClientBasic::getCurrent() {
- return 0;
- }
-
-
}
diff --git a/src/third_party/SConscript b/src/third_party/SConscript
new file mode 100644
index 00000000000..82797c63480
--- /dev/null
+++ b/src/third_party/SConscript
@@ -0,0 +1,14 @@
+# -*- mode: python -*-
+
+Import( "env has_option" )
+
+env.SConscript( [
+ "pcre-${PCRE_VERSION}/SConscript",
+ ] )
+
+if has_option( "use-system-pcre" ) or has_option( "use-system-all" ):
+ env.StaticLibrary( "pcrecpp", ['mongo_pcrecpp.cc'],
+ SYSLIBDEPS=[ 'pcrecpp' ] )
+else:
+ env.StaticLibrary( "pcrecpp", ['mongo_pcrecpp.cc'],
+ LIBDEPS=[ 'pcre-${PCRE_VERSION}/pcrecpp' ] )
diff --git a/src/third_party/mongo_pcrecpp.cc b/src/third_party/mongo_pcrecpp.cc
new file mode 100644
index 00000000000..362d603a22c
--- /dev/null
+++ b/src/third_party/mongo_pcrecpp.cc
@@ -0,0 +1,3 @@
+// This file intentionally blank. mongo_pcrecpp.cc is part of the
+// third_party/pcrecpp library, which is just a placeholder for forwarding
+// library dependencies.
diff --git a/src/third_party/pcre-7.4/SConscript b/src/third_party/pcre-7.4/SConscript
new file mode 100644
index 00000000000..d444454f541
--- /dev/null
+++ b/src/third_party/pcre-7.4/SConscript
@@ -0,0 +1,33 @@
+# -*- mode: python -*-
+
+Import( "env" )
+
+env = env.Clone()
+env.Append( CPPDEFINES=[ "HAVE_CONFIG_H" ] )
+
+env.StaticLibrary( "pcrecpp", [
+ "pcre_chartables.c",
+ "pcre_compile.c",
+ "pcre_config.c",
+ "pcre_dfa_exec.c",
+ "pcre_exec.c",
+ "pcre_fullinfo.c",
+ "pcre_get.c",
+ "pcre_globals.c",
+ "pcre_info.c",
+ "pcre_maketables.c",
+ "pcre_newline.c",
+ "pcre_ord2utf8.c",
+ "pcre_refcount.c",
+ "pcre_scanner.cc",
+ "pcre_stringpiece.cc",
+ "pcre_study.c",
+ "pcre_tables.c",
+ "pcre_try_flipped.c",
+ "pcre_ucp_searchfuncs.c",
+ "pcre_valid_utf8.c",
+ "pcre_version.c",
+ "pcre_xclass.c",
+ "pcrecpp.cc",
+ "pcreposix.c",
+ ] )
diff --git a/src/third_party/pcre.py b/src/third_party/pcre.py
deleted file mode 100644
index f33a71fe726..00000000000
--- a/src/third_party/pcre.py
+++ /dev/null
@@ -1,42 +0,0 @@
-
-import os
-
-root = "src/third_party/pcre-7.4"
-
-def getFiles():
-
- def pcreFilter(x):
- if x.endswith( "dftables.c" ):
- return False
- if x.endswith( "pcredemo.c" ):
- return False
- if x.endswith( "pcretest.c" ):
- return False
- if x.endswith( "unittest.cc" ):
- return False
- if x.endswith( "pcregrep.c" ):
- return False
- return x.endswith( ".c" ) or x.endswith( ".cc" )
-
- files = [ root + "/" + x for x in filter( pcreFilter , os.listdir( root ) ) ]
-
- return files
-
-def configure( env , fileLists , options ):
- #fileLists = { "serverOnlyFiles" : [] }
-
- env.Prepend( CPPPATH=["./" + root + "/"] )
-
- myenv = env.Clone()
- myenv.Append( CPPDEFINES=["HAVE_CONFIG_H"] )
- 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__":
- for x in getFiles():
- print( x )
diff --git a/src/third_party/sm.py b/src/third_party/sm.py
index 19a4dcbdae0..8a757ab2e47 100644
--- a/src/third_party/sm.py
+++ b/src/third_party/sm.py
@@ -37,7 +37,7 @@ basicFiles = [ "jsapi.c" ,
"jsxml.c" ,
"prmjtime.c" ]
-root = "src/third_party/js-1.7"
+root = "$BUILD_DIR/third_party/js-1.7"
def r(x):
return "%s/%s" % ( root , x )
diff --git a/src/third_party/snappy.py b/src/third_party/snappy.py
index 7949bbd555f..97b30df0279 100644
--- a/src/third_party/snappy.py
+++ b/src/third_party/snappy.py
@@ -1,12 +1,11 @@
def configure( env , fileLists , options ):
- #fileLists = { "serverOnlyFiles" : [] }
myenv = env.Clone()
if not options["windows"]:
myenv.Append(CPPFLAGS=" -Wno-sign-compare -Wno-unused-function ") #snappy doesn't compile cleanly
-
- files = ["src/third_party/snappy/snappy.cc", "src/third_party/snappy/snappy-sinksource.cc"]
+
+ files = ["$BUILD_DIR/third_party/snappy/snappy.cc", "$BUILD_DIR/third_party/snappy/snappy-sinksource.cc"]
fileLists["serverOnlyFiles"] += [ myenv.Object(f) for f in files ]