Skip to content

Commit

Permalink
Pull all the code for defining and printing the version of executable…
Browse files Browse the repository at this point in the history
…s to one place.
  • Loading branch information
alerner committed May 28, 2010
1 parent 5924044 commit 1798ea2
Show file tree
Hide file tree
Showing 14 changed files with 124 additions and 71 deletions.
4 changes: 2 additions & 2 deletions SConstruct
Expand Up @@ -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" )

Expand Down Expand Up @@ -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" )
Expand Down
25 changes: 1 addition & 24 deletions db/db.cpp
Expand Up @@ -44,6 +44,7 @@
#include "cmdline.h"
#include "stats/snapshots.h"
#include "../util/concurrency/task.h"
#include "../util/version.h"

namespace mongo {

Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions db/dbcommands.cpp
Expand Up @@ -39,6 +39,7 @@
#include "../scripting/engine.h"
#include "stats/counters.h"
#include "background.h"
#include "../util/version.h"

namespace mongo {

Expand Down
1 change: 1 addition & 0 deletions db/dbcommands_generic.cpp
Expand Up @@ -43,6 +43,7 @@
#include "../scripting/engine.h"
#include "stats/counters.h"
#include "background.h"
#include "../util/version.h"

namespace mongo {

Expand Down
1 change: 1 addition & 0 deletions db/dbwebserver.cpp
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions dbtests/framework.cpp
Expand Up @@ -17,6 +17,7 @@
*/

#include "pch.h"
#include "../util/version.h"
#include <boost/program_options.hpp>

#undef assert
Expand Down
6 changes: 0 additions & 6 deletions pch.cpp
Expand Up @@ -28,9 +28,3 @@
#else
// unknown compiler
#endif

namespace mongo {

const char versionString[] = "1.5.3-pre-";

} // namespace mongo
13 changes: 2 additions & 11 deletions pch.h
Expand Up @@ -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 ,
Expand Down Expand Up @@ -138,12 +135,6 @@ namespace mongo {

namespace mongo {

const char * gitVersion();
string sysInfo();
string mongodVersion();

void printGitVersion();
void printSysInfo();

typedef char _TCHAR;

} // namespace mongo
1 change: 1 addition & 0 deletions s/server.cpp
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions scripting/utils.cpp
Expand Up @@ -19,6 +19,7 @@
#include "pch.h"
#include "engine.h"
#include "../util/md5.hpp"
#include "../util/version.h"

namespace mongo {

Expand Down
1 change: 1 addition & 0 deletions shell/dbshell.cpp
Expand Up @@ -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;
Expand Down
28 changes: 0 additions & 28 deletions util/util.cpp
Expand Up @@ -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;
Expand Down
88 changes: 88 additions & 0 deletions util/version.cpp
@@ -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;
}

}
24 changes: 24 additions & 0 deletions util/version.h
@@ -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.