diff --git a/SConstruct b/SConstruct index e10b67e7b4a..2ca8617f42e 100644 --- a/SConstruct +++ b/SConstruct @@ -387,7 +387,7 @@ if distBuild: commonFiles = Split( "pch.cpp buildinfo.cpp db/common.cpp db/jsobj.cpp db/json.cpp db/lasterror.cpp db/nonce.cpp db/queryutil.cpp shell/mongo.cpp" ) commonFiles += [ "util/background.cpp" , "util/mmap.cpp" , "util/ramstore.cpp", "util/sock.cpp" , "util/util.cpp" , "util/message.cpp" , "util/assert_util.cpp" , "util/httpclient.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/concurrency/thread_pool.cpp", "util/password.cpp", "util/version.cpp" ] commonFiles += Glob( "util/*.c" ) commonFiles += Split( "client/connpool.cpp client/dbclient.cpp client/dbclientcursor.cpp client/model.cpp client/syncclusterconnection.cpp s/shardconnection.cpp" ) @@ -1461,7 +1461,7 @@ def getSystemInstallName(): return n def getCodeVersion(): - fullSource = open( "pch.cpp" , "r" ).read() + fullSource = open( "util/version.cpp" , "r" ).read() allMatches = re.findall( r"versionString.. = \"(.*?)\"" , fullSource ); if len(allMatches) != 1: print( "can't find version # in code" ) diff --git a/db/db.cpp b/db/db.cpp index 60e491d2886..b5eeea16b73 100644 --- a/db/db.cpp +++ b/db/db.cpp @@ -44,6 +44,7 @@ #include "cmdline.h" #include "stats/snapshots.h" #include "../util/concurrency/task.h" +#include "../util/version.h" namespace mongo { @@ -438,30 +439,6 @@ namespace mongo { double _sleepsecs; // default value controlled by program options } dataFileSync; - void show_32_warning(){ -#if BOOST_VERSION < 103500 - cout << "\nwarning: built with boost version <= 1.34, limited concurrency" << endl; -#endif - - { - const char * foo = strchr( versionString , '.' ) + 1; - int bar = atoi( foo ); - if ( ( 2 * ( bar / 2 ) ) != bar ){ - log() << "****\n"; - log() << "WARNING: This is development a version (" << versionString << ") of MongoDB. Not recommended for production.\n"; - log() << "****" << endl; - } - - } - - if ( sizeof(int*) != 4 ) - return; - cout << endl; - cout << "** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data" << endl; - cout << "** see http://blog.mongodb.org/post/137788967/32-bit-limitations for more" << endl; - cout << endl; - } - Timer startupSrandTimer; void _initAndListen(int listenPort, const char *appserverLoc = NULL) { diff --git a/db/dbcommands.cpp b/db/dbcommands.cpp index bbb0f2f3cde..fe72bcf4c24 100644 --- a/db/dbcommands.cpp +++ b/db/dbcommands.cpp @@ -39,6 +39,7 @@ #include "../scripting/engine.h" #include "stats/counters.h" #include "background.h" +#include "../util/version.h" namespace mongo { diff --git a/db/dbcommands_generic.cpp b/db/dbcommands_generic.cpp index fb2e630607a..ff3e99af156 100644 --- a/db/dbcommands_generic.cpp +++ b/db/dbcommands_generic.cpp @@ -43,6 +43,7 @@ #include "../scripting/engine.h" #include "stats/counters.h" #include "background.h" +#include "../util/version.h" namespace mongo { diff --git a/db/dbwebserver.cpp b/db/dbwebserver.cpp index dff6b265a8a..7376af18e6d 100644 --- a/db/dbwebserver.cpp +++ b/db/dbwebserver.cpp @@ -31,6 +31,7 @@ #include "stats/snapshots.h" #include "background.h" #include "commands.h" +#include "../util/version.h" #include #include #undef assert diff --git a/dbtests/framework.cpp b/dbtests/framework.cpp index f85e2c0f783..f0b8bc2b72d 100644 --- a/dbtests/framework.cpp +++ b/dbtests/framework.cpp @@ -17,6 +17,7 @@ */ #include "pch.h" +#include "../util/version.h" #include #undef assert diff --git a/pch.cpp b/pch.cpp index b1887edcda7..7202a90bc44 100644 --- a/pch.cpp +++ b/pch.cpp @@ -28,9 +28,3 @@ #else // unknown compiler #endif - -namespace mongo { - - const char versionString[] = "1.5.3-pre-"; - -} // namespace mongo diff --git a/pch.h b/pch.h index 80528b4270c..08de1a2e764 100644 --- a/pch.h +++ b/pch.h @@ -81,10 +81,7 @@ namespace mongo { // pdfile versions const int VERSION = 4; const int VERSION_MINOR = 5; - - // mongo version - extern const char versionString[]; - + enum ExitCode { EXIT_CLEAN = 0 , EXIT_BADOPTIONS = 2 , @@ -138,12 +135,6 @@ namespace mongo { namespace mongo { - const char * gitVersion(); - string sysInfo(); - string mongodVersion(); - - void printGitVersion(); - void printSysInfo(); - typedef char _TCHAR; + } // namespace mongo diff --git a/s/server.cpp b/s/server.cpp index 59bca879f90..af387fb0348 100644 --- a/s/server.cpp +++ b/s/server.cpp @@ -21,6 +21,7 @@ #include "../util/unittest.h" #include "../client/connpool.h" #include "../util/message_server.h" +#include "../util/version.h" #include "server.h" #include "request.h" diff --git a/scripting/utils.cpp b/scripting/utils.cpp index 3bb4bc93a40..ee01bb28fa9 100644 --- a/scripting/utils.cpp +++ b/scripting/utils.cpp @@ -19,6 +19,7 @@ #include "pch.h" #include "engine.h" #include "../util/md5.hpp" +#include "../util/version.h" namespace mongo { diff --git a/shell/dbshell.cpp b/shell/dbshell.cpp index b91d517c17a..f7168c78fc7 100644 --- a/shell/dbshell.cpp +++ b/shell/dbshell.cpp @@ -31,6 +31,7 @@ jmp_buf jbuf; #include "../db/cmdline.h" #include "utils.h" #include "../util/password.h" +#include "../util/version.h" using namespace std; using namespace boost::filesystem; diff --git a/util/util.cpp b/util/util.cpp index cba3da4fdd1..922ca679fe4 100644 --- a/util/util.cpp +++ b/util/util.cpp @@ -151,34 +151,6 @@ void setThreadName(const char *name) #endif } -#ifndef _SCONS - // only works in scons - const char * gitVersion(){ return "not-scons"; } -#if defined(_WIN32) - string sysInfo(){ - stringstream ss; - ss << "not-scons win"; - ss << " mscver:" << _MSC_FULL_VER << " built:" << __DATE__; - ss << " boostver:" << BOOST_VERSION; -#if( !defined(_MT) ) -#error _MT is not defined -#endif - ss << (sizeof(char *) == 8) ? " 64bit" : " 32bit"; - return ss.str(); - } -#else - string sysInfo(){ return ""; } -#endif -#endif - - void printGitVersion() { log() << "git version: " << gitVersion() << endl; } - void printSysInfo() { log() << "sys info: " << sysInfo() << endl; } - string mongodVersion() { - stringstream ss; - ss << "db version v" << versionString << ", pdfile version " << VERSION << "." << VERSION_MINOR; - return ss.str(); - } - ostream& operator<<( ostream &s, const ThreadSafeString &o ){ s << (string)o; return s; diff --git a/util/version.cpp b/util/version.cpp new file mode 100644 index 00000000000..db9eefce951 --- /dev/null +++ b/util/version.cpp @@ -0,0 +1,88 @@ +#include +#include +#include +#include +#include + +#include "pch.h" + +#include "version.h" + +namespace mongo { + + // + // mongo processes version support + // + + const char versionString[] = "1.5.3-pre-"; + + string mongodVersion() { + stringstream ss; + ss << "db version v" << versionString << ", pdfile version " << VERSION << "." << VERSION_MINOR; + return ss.str(); + } + + // + // git version support + // + +#ifndef _SCONS + // only works in scons + const char * gitVersion(){ return "not-scons"; } +#endif + + void printGitVersion() { log() << "git version: " << gitVersion() << endl; } + + // + // sys info support + // + +#ifndef _SCONS +#if defined(_WIN32) + string sysInfo(){ + stringstream ss; + ss << "not-scons win"; + ss << " mscver:" << _MSC_FULL_VER << " built:" << __DATE__; + ss << " boostver:" << BOOST_VERSION; +#if( !defined(_MT) ) +#error _MT is not defined +#endif + ss << (sizeof(char *) == 8) ? " 64bit" : " 32bit"; + return ss.str(); + } +#else + string sysInfo(){ return ""; } +#endif +#endif + + void printSysInfo() { log() << "sys info: " << sysInfo() << endl; } + + // + // 32 bit systems warning + // + + void show_32_warning(){ +#if BOOST_VERSION < 103500 + cout << "\nwarning: built with boost version <= 1.34, limited concurrency" << endl; +#endif + + { + const char * foo = strchr( versionString , '.' ) + 1; + int bar = atoi( foo ); + if ( ( 2 * ( bar / 2 ) ) != bar ){ + log() << "****\n"; + log() << "WARNING: This is development a version (" << versionString << ") of MongoDB. Not recommended for production.\n"; + log() << "****" << endl; + } + + } + + if ( sizeof(int*) != 4 ) + return; + cout << endl; + cout << "** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data" << endl; + cout << "** see http://blog.mongodb.org/post/137788967/32-bit-limitations for more" << endl; + cout << endl; + } + +} diff --git a/util/version.h b/util/version.h new file mode 100644 index 00000000000..70ddeb87af7 --- /dev/null +++ b/util/version.h @@ -0,0 +1,24 @@ +#ifndef UTIL_VERSION_HEADER +#define UTIL_VERSION_HEADER + +#include + +namespace mongo { + + using std::string; + + // mongo version + extern const char versionString[]; + string mongodVersion(); + + const char * gitVersion(); + void printGitVersion(); + + string sysInfo(); + void printSysInfo(); + + void show_32_warning(); + +} // namespace mongo + +#endif // UTIL_VERSION_HEADER