Commit 94021060 authored by Rye Mutt's avatar Rye Mutt 🍞
Browse files

Include git SHA in build version info

parent 33661bed
# -*- cmake -*-
# Construct the viewer version number based on the indra/VIEWER_VERSION file
option(REVISION_FROM_HG "Get current revision from mercurial" ON)
option(REVISION_FROM_VCS "Get current revision from vcs" ON)
find_package(Git)
if (NOT DEFINED VIEWER_SHORT_VERSION) # will be true in indra/, false in indra/newview/
set(VIEWER_VERSION_BASE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/newview/VIEWER_VERSION.txt")
......@@ -18,8 +20,7 @@ if (NOT DEFINED VIEWER_SHORT_VERSION) # will be true in indra/, false in indra/n
elseif ((NOT REVISION_FROM_HG) AND DEFINED ENV{AUTOBUILD_BUILD_ID})
set(VIEWER_VERSION_REVISION $ENV{AUTOBUILD_BUILD_ID})
message(STATUS "Revision (from autobuild environment): ${VIEWER_VERSION_REVISION}")
else ()
find_package(Git REQUIRED)
elseif (Git_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-list HEAD --count
OUTPUT_VARIABLE GIT_REV_LIST_COUNT
......@@ -32,6 +33,8 @@ if (NOT DEFINED VIEWER_SHORT_VERSION) # will be true in indra/, false in indra/n
else(GIT_REV_LIST_COUNT)
set(VIEWER_VERSION_REVISION 0)
endif(GIT_REV_LIST_COUNT)
else ()
set(VIEWER_VERSION_REVISION 0)
endif ()
message("Building '${VIEWER_CHANNEL}' Version ${VIEWER_SHORT_VERSION}.${VIEWER_VERSION_REVISION}")
else ( EXISTS ${VIEWER_VERSION_BASE_FILE} )
......@@ -42,13 +45,40 @@ if (NOT DEFINED VIEWER_SHORT_VERSION) # will be true in indra/, false in indra/n
message(STATUS "Ultimate fallback, revision was blank or not set: will use 0")
set(VIEWER_VERSION_REVISION 0)
endif ("${VIEWER_VERSION_REVISION}" STREQUAL "")
endif (NOT DEFINED VIEWER_SHORT_VERSION)
if (NOT DEFINED VIEWER_COMMIT_LONG_SHA)
if(Git_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
OUTPUT_VARIABLE GIT_COMMIT_SHA
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(VIEWER_CHANNEL_VERSION_DEFINES
"LL_VIEWER_CHANNEL=${VIEWER_CHANNEL}"
"LL_VIEWER_VERSION_MAJOR=${VIEWER_VERSION_MAJOR}"
"LL_VIEWER_VERSION_MINOR=${VIEWER_VERSION_MINOR}"
"LL_VIEWER_VERSION_PATCH=${VIEWER_VERSION_PATCH}"
"LL_VIEWER_VERSION_BUILD=${VIEWER_VERSION_REVISION}"
"LLBUILD_CONFIG=\"${CMAKE_BUILD_TYPE}\""
if(GIT_COMMIT_SHA)
set(VIEWER_COMMIT_LONG_SHA ${GIT_COMMIT_SHA})
else()
set(VIEWER_COMMIT_LONG_SHA 0)
endif()
else()
set(VIEWER_COMMIT_LONG_SHA 0)
endif()
endif (NOT DEFINED VIEWER_COMMIT_LONG_SHA)
if (NOT DEFINED VIEWER_COMMIT_SHORT_SHA)
if(Git_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
OUTPUT_VARIABLE GIT_COMMIT_SHORT_SHA
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif (NOT DEFINED VIEWER_SHORT_VERSION)
if(GIT_COMMIT_SHORT_SHA)
set(VIEWER_COMMIT_SHORT_SHA ${GIT_COMMIT_SHORT_SHA})
else()
set(VIEWER_COMMIT_SHORT_SHA 0)
endif()
else()
set(VIEWER_COMMIT_SHORT_SHA 0)
endif()
endif (NOT DEFINED VIEWER_COMMIT_SHORT_SHA)
......@@ -1515,11 +1515,6 @@ endif (DARWIN)
if (LINUX)
LIST(APPEND viewer_SOURCE_FILES llappviewerlinux.cpp)
set_source_files_properties(
llappviewerlinux.cpp
PROPERTIES
COMPILE_DEFINITIONS "${VIEWER_CHANNEL_VERSION_DEFINES}"
)
LIST(APPEND viewer_SOURCE_FILES llappviewerlinux_api_dbus.cpp)
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed")
......
......@@ -3109,11 +3109,10 @@ LLSD LLAppViewer::getViewerInfo() const
info["BUILD_TIME"] = __TIME__;
info["CHANNEL"] = LLVersionInfo::getChannel();
info["ADDRESS_SIZE"] = ADDRESS_SIZE;
std::string build_config = LLVersionInfo::getBuildConfig();
if (build_config != "Release")
{
info["BUILD_CONFIG"] = build_config;
}
info["BUILD_CONFIG"] = LLVersionInfo::getBuildConfig();
info["GIT_REV"] = LL_VIEWER_COMMIT_SHA;
info["GIT_SHORT_REV"] = LL_VIEWER_COMMIT_SHORT_SHA;
// return a URL to the release notes for this viewer, such as:
// https://releasenotes.secondlife.com/viewer/2.1.0.123456.html
......@@ -3344,10 +3343,6 @@ std::string LLAppViewer::getViewerInfoString(bool default_string) const
// Now build the various pieces
support << LLTrans::getString("AboutHeader", args, default_string);
if (info.has("BUILD_CONFIG"))
{
support << "\n" << LLTrans::getString("BuildConfig", args, default_string);
}
if (info.has("REGION"))
{
// [RLVa:KB] - Checked: 2014-02-24 (RLVa-1.4.10)
......@@ -3364,10 +3359,25 @@ std::string LLAppViewer::getViewerInfoString(bool default_string) const
support << "\n" << LLTrans::getString("AboutOGL", args, default_string);
support << "\n\n" << LLTrans::getString("AboutSettings", args, default_string);
support << "\n\n" << LLTrans::getString("AboutLibs", args, default_string);
support << "\n";
if (info.has("COMPILER"))
{
support << "\n" << LLTrans::getString("AboutCompiler", args, default_string);
}
if (info.has("BUILD_CONFIG"))
{
support << "\n" << LLTrans::getString("BuildConfig", args, default_string);
}
if (info.has("BUILD_DATE"))
{
support << "\n" << LLTrans::getString("BuildDate", args, default_string);
}
if (info.has("GIT_REV"))
{
support << "\n" << LLTrans::getString("AboutVCSRev", args, default_string);
}
support << "\n";
if (info.has("PACKETS_IN"))
{
support << '\n' << LLTrans::getString("AboutTraffic", args, default_string);
......
......@@ -27,6 +27,10 @@
#ifndef LL_LLVIEWERBUILDCONFIG_H
#define LL_LLVIEWERBUILDCONFIG_H
// Commit SHA
#define LL_VIEWER_COMMIT_SHA "@VIEWER_COMMIT_LONG_SHA@"
#define LL_VIEWER_COMMIT_SHORT_SHA "@VIEWER_COMMIT_SHORT_SHA@"
// Build Configuration
#define LLBUILD_CONFIG "@CMAKE_BUILD_TYPE@"
......
......@@ -31,11 +31,13 @@
<!-- about dialog/support string-->
<string name="AboutHeader">
[APP_NAME] [VIEWER_VERSION_0].[VIEWER_VERSION_1].[VIEWER_VERSION_2] ([VIEWER_VERSION_3]) ([ADDRESS_SIZE] bit) [BUILD_DATE] [BUILD_TIME] ([CHANNEL]) ([DEBUG_TEST])
[APP_NAME] [VIEWER_VERSION_0].[VIEWER_VERSION_1].[VIEWER_VERSION_2] ([VIEWER_VERSION_3]) ([ADDRESS_SIZE] bit) ([CHANNEL]) ([DEBUG_TEST])
[[VIEWER_RELEASE_NOTES_URL] [ReleaseNotes]]
</string>
<string name="AboutCompiler">Built with [COMPILER] version [COMPILER_VERSION]</string>
<string name="BuildConfig">Build Configuration [BUILD_CONFIG]</string>
<string name="AboutCompiler">Compiler Version: [COMPILER] [COMPILER_VERSION]</string>
<string name="AboutVCSRev">Git Revision: [GIT_REV]</string>
<string name="BuildConfig">Build Configuration: [BUILD_CONFIG]</string>
<string name="BuildDate">Build Date: [BUILD_DATE] [BUILD_TIME]</string>
<string name="AboutPosition">
You are at [POSITION_LOCAL_0,number,1], [POSITION_LOCAL_1,number,1], [POSITION_LOCAL_2,number,1] in [REGION] located at &lt;nolink&gt;[HOSTNAME]&lt;/nolink&gt; ([HOSTIP])
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment