Permalink
Browse files

Pull all the code for defining and printing the version of executable…

…s to one place.
  • Loading branch information...
1 parent 5924044 commit 1798ea2d855505d2a02cf8a9b1936487caa1b568 alerner committed May 28, 2010
Showing with 124 additions and 71 deletions.
  1. +2 −2 SConstruct
  2. +1 −24 db/db.cpp
  3. +1 −0 db/dbcommands.cpp
  4. +1 −0 db/dbcommands_generic.cpp
  5. +1 −0 db/dbwebserver.cpp
  6. +1 −0 dbtests/framework.cpp
  7. +0 −6 pch.cpp
  8. +2 −11 pch.h
  9. +1 −0 s/server.cpp
  10. +1 −0 scripting/utils.cpp
  11. +1 −0 shell/dbshell.cpp
  12. +0 −28 util/util.cpp
  13. +88 −0 util/version.cpp
  14. +24 −0 util/version.h
View
@@ -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" )
View
@@ -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) {
View
@@ -39,6 +39,7 @@
#include "../scripting/engine.h"
#include "stats/counters.h"
#include "background.h"
+#include "../util/version.h"
namespace mongo {
@@ -43,6 +43,7 @@
#include "../scripting/engine.h"
#include "stats/counters.h"
#include "background.h"
+#include "../util/version.h"
namespace mongo {
View
@@ -31,6 +31,7 @@
#include "stats/snapshots.h"
#include "background.h"
#include "commands.h"
+#include "../util/version.h"
#include <pcrecpp.h>
#include <boost/date_time/posix_time/posix_time.hpp>
#undef assert
View
@@ -17,6 +17,7 @@
*/
#include "pch.h"
+#include "../util/version.h"
#include <boost/program_options.hpp>
#undef assert
View
@@ -28,9 +28,3 @@
#else
// unknown compiler
#endif
-
-namespace mongo {
-
- const char versionString[] = "1.5.3-pre-";
-
-} // namespace mongo
View
13 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
View
@@ -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"
View
@@ -19,6 +19,7 @@
#include "pch.h"
#include "engine.h"
#include "../util/md5.hpp"
+#include "../util/version.h"
namespace mongo {
View
@@ -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;
View
@@ -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;
View
@@ -0,0 +1,88 @@
+#include <cstdlib>
+#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <string>
+
+#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;
+ }
+
+}
View
@@ -0,0 +1,24 @@
+#ifndef UTIL_VERSION_HEADER
+#define UTIL_VERSION_HEADER
+
+#include <string>
+
+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

0 comments on commit 1798ea2

Please sign in to comment.