Skip to content

Commit

Permalink
Added abilty to set build info
Browse files Browse the repository at this point in the history
build info is displayed at startup
Fixes cuberite#1410
  • Loading branch information
worktycho committed Sep 10, 2014
1 parent 76d5aa1 commit 27be179
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Makefile
*.a
*.d
*.so
BuildInfo.h
CMakeCache.txt
CMakeFiles
Makefile
Expand Down
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,25 @@ if(DEFINED ENV{TRAVIS_BUILD_WITH_COVERAGE})
set(BUILD_WITH_COVERAGE $ENV{TRAVIS_BUILD_WITH_COVERAGE})
endif()

if(DEFINED ENV{BUILD_ID})
set(BUILD_ID $ENV{BUILD_ID})
set(BUILD_SERIES_NAME $ENV{BUILD_SERIES_NAME})
set(BUILD_DATETIME $ENV{BUILD_DATETIME})
if(DEFINED ENV{BUILD_COMMIT_ID})
set(BUILD_COMMIT_ID $ENV{BUILD_COMMIT_ID})
else()
message("Commit id not set, attempting to determine id from git")
execute_process(
COMMAND git rev-parse HEAD
RESULT_VARIABLE GIT_EXECUTED
OUTPUT_VARIABLE BUILD_COMMIT_ID)
string(STRIP ${BUILD_COMMIT_ID} BUILD_COMMIT_ID)
if (NOT (GIT_EXECUTED EQUAL 0))
message(FATAL_ERROR "Could not identifiy git commit id")
endif()
endif()
endif()

# This has to be done before any flags have been set up.
if(${BUILD_TOOLS})
add_subdirectory(Tools/MCADefrag/)
Expand Down
15 changes: 15 additions & 0 deletions src/BuildInfo.h.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

#pragma once

#cmakedefine BUILD_ID

#ifdef BUILD_ID

#undef BUILD_ID

#define BUILD_SERIES_NAME "@BUILD_SERIES_NAME@"
#define BUILD_ID "@BUILD_ID@"
#define BUILD_COMMIT_ID "@BUILD_COMMIT_ID@"
#define BUILD_DATETIME "@BUILD_DATETIME@"
#endif

3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ SET (HDRS
BlockInfo.h
BlockTracer.h
BoundingBox.h
BuildInfo.h.cmake
ByteBuffer.h
ChatColor.h
Chunk.h
Expand Down Expand Up @@ -140,6 +141,8 @@ include_directories(".")
include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/sqlite")
include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/SQLiteCpp/include")

configure_file("BuildInfo.h.cmake" "${CMAKE_CURRENT_SOURCE_DIR}/BuildInfo.h")

if (NOT MSVC)
# Bindings need to reference other folders, so they are done here instead
# lib dependencies are not included
Expand Down
6 changes: 6 additions & 0 deletions src/Root.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "DeadlockDetect.h"
#include "OSSupport/Timer.h"
#include "LoggerListeners.h"
#include "BuildInfo.h"

#include "inifile/iniFile.h"

Expand Down Expand Up @@ -111,6 +112,11 @@ void cRoot::Start(void)

LOG("--- Started Log ---\n");

#ifdef BUILD_ID
LOG("MCServer " BUILD_SERIES_NAME " build id: " BUILD_ID );
LOG("from commit id: " BUILD_COMMIT_ID " built at: " BUILD_DATETIME );
#endif

cDeadlockDetect dd;

m_bStop = false;
Expand Down

0 comments on commit 27be179

Please sign in to comment.