summaryrefslogtreecommitdiff
path: root/src/mongo/util
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@10gen.com>2013-12-19 19:13:11 -0500
committerAndy Schwerin <schwerin@10gen.com>2013-12-23 12:55:55 -0500
commitb00647b114f7f7f36b37acb6217025ba1bd378c2 (patch)
treea109059510d49e0294ddc5b106202d848e68232a /src/mongo/util
parent88a82062a05b2a969219581d066afc3b9580c4bc (diff)
downloadmongo-b00647b114f7f7f36b37acb6217025ba1bd378c2.tar.gz
SERVER-12156 Split version.h/cpp into version and version_reporting.
Diffstat (limited to 'src/mongo/util')
-rw-r--r--src/mongo/util/version.cpp93
-rw-r--r--src/mongo/util/version.h18
-rw-r--r--src/mongo/util/version_reporting.cpp111
-rw-r--r--src/mongo/util/version_reporting.h56
4 files changed, 180 insertions, 98 deletions
diff --git a/src/mongo/util/version.cpp b/src/mongo/util/version.cpp
index 6c5f15be206..50ba5cc3fa1 100644
--- a/src/mongo/util/version.cpp
+++ b/src/mongo/util/version.cpp
@@ -15,25 +15,12 @@
* limitations under the License.
*/
+#include "mongo/platform/basic.h"
-#include <cstdlib>
-#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <string>
-#include <fstream>
+#include "mongo/util/version.h"
#include "mongo/base/parse_number.h"
#include "mongo/db/jsobj.h"
-#include "mongo/db/pdfile_version.h"
-#include "mongo/db/storage_options.h"
-#include "mongo/util/file.h"
-#include "mongo/util/net/ssl_manager.h"
-#include "mongo/util/processinfo.h"
-#include "mongo/util/ramlog.h"
-#include "mongo/util/stringutils.h"
-#include "mongo/util/version.h"
-
namespace mongo {
@@ -111,27 +98,16 @@ namespace mongo {
}
#ifndef _SCONS
- // only works in scons
+ //
+ // The following implementations are provided for use when buildinfo.cpp is not autogenerated.
+ //
+
const char * gitVersion() { return "not-scons"; }
const char * compiledJSEngine() { return ""; }
const char * allocator() { return ""; }
const char * loaderFlags() { return ""; }
const char * compilerFlags() { return ""; }
-#endif
-
- void printGitVersion() { log() << "git version: " << gitVersion() << endl; }
- const std::string openSSLVersion(const std::string &prefix, const std::string &suffix) {
- return getSSLVersion(prefix, suffix);
- }
-
- void printOpenSSLVersion() {
-#ifdef MONGO_SSL
- log() << openSSLVersion("OpenSSL version: ") << endl;
-#endif
- }
-
-#ifndef _SCONS
#if defined(_WIN32)
string sysInfo() {
stringstream ss;
@@ -140,61 +116,14 @@ namespace mongo {
ss << " boostver:" << BOOST_VERSION;
#if( !defined(_MT) )
#error _MT is not defined
-#endif
+#endif // !defined(_MT)
ss << (sizeof(char *) == 8 ? " 64bit" : " 32bit");
return ss.str();
}
-#else
+#else // defined(_WIN32)
string sysInfo() { return ""; }
-#endif
-#endif
-
-#if defined(_WIN32)
- std::string targetMinOS() {
- stringstream ss;
-#if (NTDDI_VERSION >= 0x06010000)
- ss << "Windows 7/Windows Server 2008 R2";
-#elif (NTDDI_VERSION >= 0x05020200)
- ss << "Windows Server 2003 SP2";
-#elif (NTDDI_VERSION >= 0x05010300)
- ss << "Windows XP SP3";
-#else
-#error This targetted Windows version is not supported
-#endif // NTDDI_VERSION
- return ss.str();
- }
+#endif // defined(_WIN32)
+#endif // !defined(_SCONS)
- void printTargetMinOS() {
- log() << "targetMinOS: " << targetMinOS();
- }
-#endif // _WIN32
-
- void printSysInfo() {
- log() << "build info: " << sysInfo() << endl;
- }
-
- void printAllocator() {
- log() << "allocator: " << allocator() << endl;
- }
-
- void appendBuildInfo(BSONObjBuilder& result) {
- result << "version" << versionString
- << "gitVersion" << gitVersion()
-#if defined(_WIN32)
- << "targetMinOS" << targetMinOS()
-#endif
- << "OpenSSLVersion" << openSSLVersion()
- << "sysInfo" << sysInfo()
- << "loaderFlags" << loaderFlags()
- << "compilerFlags" << compilerFlags()
- << "allocator" << allocator()
- << "versionArray" << versionArray
- << "javascriptEngine" << compiledJSEngine()
-/*TODO: add this back once the module system is in place -- maybe once we do something like serverstatus with callbacks*/
-// << "interpreterVersion" << globalScriptEngine->getInterpreterVersionString()
- << "bits" << ( sizeof( int* ) == 4 ? 32 : 64 );
- result.appendBool( "debug" , debug );
- result.appendNumber("maxBsonObjectSize", BSONObjMaxUserSize);
- }
-}
+} // namespace mongo
diff --git a/src/mongo/util/version.h b/src/mongo/util/version.h
index dcdb12c44d6..24a465285e5 100644
--- a/src/mongo/util/version.h
+++ b/src/mongo/util/version.h
@@ -31,8 +31,7 @@
#include <string>
-#include "mongo/base/string_data.h"
-#include "mongo/bson/bsonobjbuilder.h"
+#include "mongo/bson/bsonobj.h"
namespace mongo {
struct BSONArray;
@@ -44,29 +43,16 @@ namespace mongo {
// Convert a version string into a numeric array
BSONArray toVersionArray(const char* version);
-
+
// Checks whether another version is the same major version as us
bool isSameMajorVersion(const char* version);
- void appendBuildInfo(BSONObjBuilder& result);
-
const char * gitVersion();
const char * compiledJSEngine();
const char * allocator();
const char * loaderFlags();
const char * compilerFlags();
-
- void printGitVersion();
-
- const std::string openSSLVersion(const std::string &prefix = "", const std::string &suffix = "");
- void printOpenSSLVersion();
-
std::string sysInfo();
- void printSysInfo();
- void printTargetMinOS();
- void printAllocator();
-
- void show_warnings();
} // namespace mongo
diff --git a/src/mongo/util/version_reporting.cpp b/src/mongo/util/version_reporting.cpp
new file mode 100644
index 00000000000..32994231a40
--- /dev/null
+++ b/src/mongo/util/version_reporting.cpp
@@ -0,0 +1,111 @@
+// @file version.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 "mongo/platform/basic.h"
+
+#include "mongo/util/version_reporting.h"
+
+#include <sstream>
+#include <string>
+
+#include "mongo/bson/bsonobjbuilder.h"
+#include "mongo/db/jsobj.h"
+#include "mongo/util/net/ssl_manager.h"
+#include "mongo/util/version.h"
+
+
+namespace mongo {
+
+ void printGitVersion() { log() << "git version: " << gitVersion() << endl; }
+
+ const std::string openSSLVersion(const std::string &prefix, const std::string &suffix) {
+ return getSSLVersion(prefix, suffix);
+ }
+
+ void printOpenSSLVersion() {
+#ifdef MONGO_SSL
+ log() << openSSLVersion("OpenSSL version: ") << endl;
+#endif
+ }
+
+#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
+
+#if defined(_WIN32)
+ std::string targetMinOS() {
+ stringstream ss;
+#if (NTDDI_VERSION >= 0x06010000)
+ ss << "Windows 7/Windows Server 2008 R2";
+#elif (NTDDI_VERSION >= 0x05020200)
+ ss << "Windows Server 2003 SP2";
+#elif (NTDDI_VERSION >= 0x05010300)
+ ss << "Windows XP SP3";
+#else
+#error This targetted Windows version is not supported
+#endif // NTDDI_VERSION
+ return ss.str();
+ }
+
+ void printTargetMinOS() {
+ log() << "targetMinOS: " << targetMinOS();
+ }
+#endif // _WIN32
+
+ void printSysInfo() {
+ log() << "build info: " << sysInfo() << endl;
+ }
+
+ void printAllocator() {
+ log() << "allocator: " << allocator() << endl;
+ }
+
+ void appendBuildInfo(BSONObjBuilder& result) {
+ result << "version" << versionString
+ << "gitVersion" << gitVersion()
+#if defined(_WIN32)
+ << "targetMinOS" << targetMinOS()
+#endif
+ << "OpenSSLVersion" << openSSLVersion()
+ << "sysInfo" << sysInfo()
+ << "loaderFlags" << loaderFlags()
+ << "compilerFlags" << compilerFlags()
+ << "allocator" << allocator()
+ << "versionArray" << versionArray
+ << "javascriptEngine" << compiledJSEngine()
+/*TODO: add this back once the module system is in place -- maybe once we do something like serverstatus with callbacks*/
+// << "interpreterVersion" << globalScriptEngine->getInterpreterVersionString()
+ << "bits" << ( sizeof( int* ) == 4 ? 32 : 64 );
+ result.appendBool( "debug" , debug );
+ result.appendNumber("maxBsonObjectSize", BSONObjMaxUserSize);
+ }
+}
diff --git a/src/mongo/util/version_reporting.h b/src/mongo/util/version_reporting.h
new file mode 100644
index 00000000000..278a2ec0e69
--- /dev/null
+++ b/src/mongo/util/version_reporting.h
@@ -0,0 +1,56 @@
+/**
+* Copyright (C) 2012 10gen Inc.
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License, version 3,
+* as published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with this program. If not, see <http://www.gnu.org/licenses/>.
+*
+* As a special exception, the copyright holders give permission to link the
+* code of portions of this program with the OpenSSL library under certain
+* conditions as described in each individual source file and distribute
+* linked combinations including the program with the OpenSSL library. You
+* must comply with the GNU Affero General Public License in all respects
+* for all of the code used other than as permitted herein. If you modify
+* file(s) with this exception, you may extend this exception to your
+* version of the file(s), but you are not obligated to do so. If you do not
+* wish to do so, delete this exception statement from your version. If you
+* delete this exception statement from all source files in the program,
+* then also delete it in the license file.
+*/
+
+#pragma once
+
+#include <string>
+
+namespace mongo {
+ class BSONObjBuilder;
+
+ void appendBuildInfo(BSONObjBuilder& result);
+
+ const char * gitVersion();
+ const char * compiledJSEngine();
+ const char * allocator();
+ const char * loaderFlags();
+ const char * compilerFlags();
+
+ void printGitVersion();
+
+ const std::string openSSLVersion(const std::string &prefix = "", const std::string &suffix = "");
+ void printOpenSSLVersion();
+
+ std::string sysInfo();
+ void printSysInfo();
+ void printTargetMinOS();
+ void printAllocator();
+
+ void show_warnings();
+
+} // namespace mongo