Added global var for build revision.

Part of #321.
This commit is contained in:
Oliver Hamlet
2014-11-02 15:54:41 +00:00
parent 4b47e48b36
commit 8fa787064d
4 changed files with 31 additions and 4 deletions
+22 -2
View File
@@ -3,6 +3,26 @@
# PROJECT_ARCH = the build architecture
# LIBESPM_ROOT = the path to the root of the libespm source.
##############################
# Get Build Revision
##############################
# Uses the CMake module in this repo: https://github.com/rpavlik/cmake-modules
# On Windows, this requires the msysgit install of Git, as the script won't find
# the one bundled with GitHub for Windows.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
include(GetGitRevisionDescription)
git_describe(GIT_COMMIT_STRING --tags --long)
# We just want the shortened commit ID, so get that.
string(FIND ${GIT_COMMIT_STRING} "-g" REV_POS REVERSE)
MATH(EXPR REV_POS "${REV_POS} + 2")
string(SUBSTRING ${GIT_COMMIT_STRING} ${REV_POS} -1 GIT_COMMIT_STRING)
# Write to file.
configure_file("${CMAKE_SOURCE_DIR}/src/backend/globals.cpp.in" "${CMAKE_BINARY_DIR}/generated/globals.cpp" @ONLY)
##############################
# General Settings
##############################
@@ -56,10 +76,10 @@ find_package(GTest)
set (LOOT_SRC "${CMAKE_SOURCE_DIR}/src/backend/metadata.cpp"
"${CMAKE_SOURCE_DIR}/src/backend/game.cpp"
"${CMAKE_SOURCE_DIR}/src/backend/helpers.cpp"
"${CMAKE_SOURCE_DIR}/src/backend/globals.cpp"
"${CMAKE_SOURCE_DIR}/src/backend/generators.cpp"
"${CMAKE_SOURCE_DIR}/src/backend/graph.cpp"
"${CMAKE_SOURCE_DIR}/src/backend/git.cpp")
"${CMAKE_SOURCE_DIR}/src/backend/git.cpp"
"${CMAKE_BINARY_DIR}/generated/globals.cpp")
set (LOOT_HEADERS "${CMAKE_SOURCE_DIR}/src/backend/metadata.h"
"${CMAKE_SOURCE_DIR}/src/backend/game.h"
@@ -22,8 +22,8 @@
<http://www.gnu.org/licenses/>.
*/
#include "globals.h"
#include "helpers.h"
#include "backend/globals.h"
#include "backend/helpers.h"
namespace loot {
//Version numbers.
@@ -31,6 +31,9 @@ namespace loot {
const unsigned int g_version_minor = 7;
const unsigned int g_version_patch = 0;
// Build revision
const char * g_build_revision = "@GIT_COMMIT_STRING@";
//Common paths.
const boost::filesystem::path g_path_readme = boost::filesystem::current_path() / "docs" / "LOOT Readme.html";
const boost::filesystem::path g_path_report = boost::filesystem::current_path() / "resources" / "report" / "report.html";
+3
View File
@@ -33,6 +33,9 @@ namespace loot {
extern const unsigned int g_version_minor;
extern const unsigned int g_version_patch;
// Build revision
extern const char * g_build_revision;
//Common paths.
extern const boost::filesystem::path g_path_readme;
extern const boost::filesystem::path g_path_report;
+1
View File
@@ -183,6 +183,7 @@ namespace loot {
// Log some useful info.
BOOST_LOG_TRIVIAL(info) << "LOOT Version: " << g_version_major << "." << g_version_minor << "." << g_version_patch;
BOOST_LOG_TRIVIAL(info) << "LOOT Build Revision: " << g_build_revision;
#ifdef _WIN32
// Check if LOOT is being run through Mod Organiser.
bool runFromMO = GetModuleHandle(ToWinWide("hook.dll").c_str()) != NULL;