Skip to content

Commit

Permalink
Add git branch to build config
Browse files Browse the repository at this point in the history
  • Loading branch information
fruhland committed Oct 22, 2018
1 parent eab5afc commit 1dc07b1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
18 changes: 15 additions & 3 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,27 @@ if (IBPERFMON_GIT_REV STREQUAL "")
set(IBPERFMON_GIT_REV "not available")
endif ()

# Set git branch
execute_process(COMMAND git rev-parse --symbolic-full-name --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE IBPERFMON_GIT_BRANCH ERROR_QUIET)
string(STRIP "${IBPERFMON_GIT_BRANCH}" IBPERFMON_GIT_BRANCH)
if (IBPERFMON_GIT_BRANCH STREQUAL "")
set(IBPERFMON_GIT_BRANCH "not available")
endif ()

# Set build date
string(TIMESTAMP IBPERFMON_BUILD_DATE "%Y-%m-%d %H:%M:%S")

# Print build information
message("IbPerfMon ${IBPERFMON_VERSION} - git ${IBPERFMON_GIT_REV}, build date: ${IBPERFMON_BUILD_DATE}")

message("IbPerfMon ${IBPERFMON_VERSION} - git ${IBPERFMON_GIT_REV}(${IBPERFMON_GIT_BRANCH}), \
build date: ${IBPERFMON_BUILD_DATE}")

# Set preprocessor defines
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIBPERFMON_VERSION='${IBPERFMON_VERSION}'\
-DIBPERFMON_GIT_REV='${IBPERFMON_GIT_REV}' -DIBPERFMON_BUILD_DATE='${IBPERFMON_BUILD_DATE}'")
-DIBPERFMON_GIT_REV='${IBPERFMON_GIT_REV}' -DIBPERFMON_GIT_BRANCH='${IBPERFMON_GIT_BRANCH}' \
-DIBPERFMON_BUILD_DATE='${IBPERFMON_BUILD_DATE}'")

# Set source directory variables
set(IBPERFMON_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/..")
Expand All @@ -68,7 +80,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
# Add IbPerfLib as external project
ExternalProject_Add(IbPerfLib_git
GIT_REPOSITORY https://github.com/hhu-bsinfo/ibperf-lib.git
GIT_TAG master
GIT_TAG ${IBPERFMON_GIT_BRANCH}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/IbPerfLib
INSTALL_COMMAND "")

Expand Down
6 changes: 6 additions & 0 deletions src/IbPerfMon/BuildConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ const char *BuildConfig::BUILD_DATE = XSTRINGIFY(IBPERFMON_BUILD_DATE);
const char *BuildConfig::BUILD_DATE = "0000-00-00 00:00:00";
#endif

#ifdef IBPERFMON_GIT_BRANCH
const char *BuildConfig::GIT_BRANCH = XSTRINGIFY(IBPERFMON_GIT_BRANCH);
#else
const char *BuildConfig::GIT_BRANCH = "unknown";
#endif

}

#undef STRINGIFY
Expand Down
1 change: 1 addition & 0 deletions src/IbPerfMon/BuildConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class BuildConfig {

static const char *VERSION;
static const char *GIT_REV;
static const char *GIT_BRANCH;
static const char *BUILD_DATE;

};
Expand Down
9 changes: 5 additions & 4 deletions src/IbPerfMon/IbPerfMon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,22 @@ IbPerfMon::IbPerfMon(bool compatibility) :
m_compatibility(compatibility),
m_isRunning(true)
{
snprintf(m_helpMessage, 512, "IbPerfMon %s - git %s\n"
snprintf(m_helpMessage, 512, "IbPerfMon %s - git %s(%s)\n"
"Build date: %s\n"
"Copyright (C) 2018 Heinrich-Heine-Universitaet Duesseldorf,\n"
"Institute of Computer Science, Department Operating Systems\n"
"Licensed under GPL v3\n\n"
"Build against:\n"
"IbPerfLib %s - git %s\n"
"IbPerfLib %s - git %s(%s)\n"
"Build date: %s\n\n"
"Up/Down: Navigate menu\n"
"Right/Left: Open/Close menu entry\n"
"Enter: Select for single view\n"
"1/2/3/4: Assign to window\n"
"Tab: Switch window", BuildConfig::VERSION, BuildConfig::GIT_REV,
BuildConfig::BUILD_DATE, IbPerfLib::BuildConfig::VERSION,
IbPerfLib::BuildConfig::GIT_REV, IbPerfLib::BuildConfig::BUILD_DATE);
BuildConfig::GIT_BRANCH, BuildConfig::BUILD_DATE, IbPerfLib::BuildConfig::VERSION,
IbPerfLib::BuildConfig::GIT_REV, IbPerfLib::BuildConfig::GIT_BRANCH,
IbPerfLib::BuildConfig::BUILD_DATE);
}

IbPerfMon::~IbPerfMon() {
Expand Down

0 comments on commit 1dc07b1

Please sign in to comment.