From e8ae1dc4a66b810953b9610570734723f900a728 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 10 Aug 2016 08:03:54 +0200 Subject: [PATCH] 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 09d6da840..9fd1f7ae1 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 521fcb96f..7d67840b4 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 ec76cd665..8ce5b72a0 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". ## Apply diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index 75ef69578..f50450525 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 77c610216..36ea62365 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"; } /**