[icinga-checkins] icinga.org: icinga2/master: Include compiler name/ version and build host name in --version

git at icinga.org git at icinga.org
Wed Aug 10 08:09:43 CEST 2016


Module: icinga2
Branch: master
Commit: e8ae1dc4a66b810953b9610570734723f900a728
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=e8ae1dc4a66b810953b9610570734723f900a728

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Wed Aug 10 08:03:54 2016 +0200

Include compiler name/version and build host name in --version

fixes #12389

---

 CMakeLists.txt               |   10 ++++++++++
 config.h.cmake               |    4 ++++
 doc/18-language-reference.md |    3 +++
 icinga-app/icinga.cpp        |    4 ++++
 lib/base/application.cpp     |    5 +++++
 5 files changed, 26 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 09d6da8..9fd1f7a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,6 +55,16 @@ set(ICINGA2_GIT_VERSION_INFO ON CACHE BOOL "Whether to use git describe")
 set(ICINGA2_UNITY_BUILD ON CACHE BOOL "Whether to perform a unity build")
 set(ICINGA2_LTO_BUILD OFF CACHE BOOL "Whether to use LTO")
 
+site_name(ICINGA2_BUILD_HOST_NAME)
+set(ICINGA2_BUILD_COMPILER_NAME "${CMAKE_CXX_COMPILER_ID}")
+
+if(NOT CMAKE_CXX_COMPILER_VERSION)
+  execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
+    OUTPUT_VARIABLE CMAKE_CXX_COMPILER_VERSION)
+endif()
+
+set(ICINGA2_BUILD_COMPILER_VERSION "${CMAKE_CXX_COMPILER_VERSION}")
+
 file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING" ICINGA2_LICENSE_GPL)
 file(READ "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.Exceptions" ICINGA2_LICENSE_ADDITIONS)
 set(ICINGA2_LICENSE "${ICINGA2_LICENSE_GPL}\n\n---\n\n${ICINGA2_LICENSE_ADDITIONS}")
diff --git a/config.h.cmake b/config.h.cmake
index 521fcb9..7d67840 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -22,4 +22,8 @@
 #define ICINGA_USER "${ICINGA2_USER}"
 #define ICINGA_GROUP "${ICINGA2_GROUP}"
 
+#define ICINGA_BUILD_HOST_NAME "${ICINGA2_BUILD_HOST_NAME}"
+#define ICINGA_BUILD_COMPILER_NAME "${ICINGA2_BUILD_COMPILER_NAME}"
+#define ICINGA_BUILD_COMPILER_VERSION "${ICINGA2_BUILD_COMPILER_VERSION}"
+
 #endif /* CONFIG_H */
diff --git a/doc/18-language-reference.md b/doc/18-language-reference.md
index ec76cd6..8ce5b72 100644
--- a/doc/18-language-reference.md
+++ b/doc/18-language-reference.md
@@ -377,6 +377,9 @@ PlatformName        |**Read-only.** The name of the operating system, e.g. "Ubun
 PlatformVersion     |**Read-only.** The version of the operating system, e.g. "14.04.3 LTS".
 PlatformKernel      |**Read-only.** The name of the operating system kernel, e.g. "Linux".
 PlatformKernelVersion|**Read-only.** The version of the operating system kernel, e.g. "3.13.0-63-generic".
+BuildCompilerName   |**Read-only.** The name of the compiler Icinga was built with, e.g. "Clang".
+BuildCompilerVersion|**Read-only.** The version of the compiler Icinga was built with, e.g. "7.3.0.7030031".
+BuildHostName       |**Read-only.** The name of the host Icinga was built on, e.g. "acheron".
 
 ## <a id="apply"></a> Apply
 
diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp
index 75ef695..f504505 100644
--- a/icinga-app/icinga.cpp
+++ b/icinga-app/icinga.cpp
@@ -169,6 +169,10 @@ int Main(void)
 	ScriptGlobal::Set("PlatformVersion", Utility::GetPlatformVersion());
 	ScriptGlobal::Set("PlatformArchitecture", Utility::GetPlatformArchitecture());
 
+	ScriptGlobal::Set("BuildHostName", ICINGA_BUILD_HOST_NAME);
+	ScriptGlobal::Set("BuildCompilerName", ICINGA_BUILD_COMPILER_NAME);
+	ScriptGlobal::Set("BuildCompilerVersion", ICINGA_BUILD_COMPILER_VERSION);
+
 	LogSeverity logLevel = Logger::GetConsoleLogSeverity();
 	Logger::SetConsoleLogSeverity(LogWarning);
 
diff --git a/lib/base/application.cpp b/lib/base/application.cpp
index 77c6102..36ea623 100644
--- a/lib/base/application.cpp
+++ b/lib/base/application.cpp
@@ -512,6 +512,11 @@ void Application::DisplayInfoMessage(std::ostream& os, bool skipVersion)
 	   << "  Kernel: " << Utility::GetPlatformKernel() << "\n"
 	   << "  Kernel version: " << Utility::GetPlatformKernelVersion() << "\n"
 	   << "  Architecture: " << Utility::GetPlatformArchitecture() << "\n";
+
+	os << "\n"
+	   << "Build information:" << "\n"
+	   << "  Compiler: " << ScriptGlobal::Get("BuildCompilerName") << " " << ScriptGlobal::Get("BuildCompilerVersion") << "\n"
+	   << "  Build host: " << ScriptGlobal::Get("BuildHostName") << "\n";
 }
 
 /**



More information about the icinga-checkins mailing list