Add support for DFHACK_BUILD_ID

Used for BuildMaster builds, for example
develop
lethosor 2018-07-11 11:47:55 -04:00
parent e1d1182406
commit 7afa3690bf
10 changed files with 40 additions and 6 deletions

@ -171,6 +171,8 @@ set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}")
set(DFHACK_ABI_VERSION 1) set(DFHACK_ABI_VERSION 1)
set(DFHACK_BUILD_ID "" CACHE STRING "Build ID (should be specified on command line)")
## where to install things (after the build is done, classic 'make install' or package structure) ## where to install things (after the build is done, classic 'make install' or package structure)
# the dfhack libraries will be installed here: # the dfhack libraries will be installed here:
IF(UNIX) IF(UNIX)
@ -477,7 +479,13 @@ IF(APPLE)
ELSE() ELSE()
set(DFHACK_PACKAGE_PLATFORM_NAME ${CMAKE_SYSTEM_NAME}) set(DFHACK_PACKAGE_PLATFORM_NAME ${CMAKE_SYSTEM_NAME})
ENDIF() ENDIF()
set(CPACK_PACKAGE_FILE_NAME "dfhack-${DFHACK_VERSION}-${DFHACK_PACKAGE_PLATFORM_NAME}-${DFHACK_BUILD_ARCH}${DFHACK_PACKAGE_SUFFIX}") # set on command line
if(DFHACK_BUILD_ID STREQUAL "")
set(DFHACK_BUILD_ID_PACKAGE "")
else()
set(DFHACK_BUILD_ID_PACKAGE "${DFHACK_BUILD_ID}-")
endif()
set(CPACK_PACKAGE_FILE_NAME "dfhack-${DFHACK_VERSION}-${DFHACK_BUILD_ID_PACKAGE}${DFHACK_PACKAGE_PLATFORM_NAME}-${DFHACK_BUILD_ARCH}${DFHACK_PACKAGE_SUFFIX}")
INCLUDE(CPack) INCLUDE(CPack)
#INCLUDE(FindSphinx.cmake) #INCLUDE(FindSphinx.cmake)

@ -822,6 +822,7 @@ can be omitted.
* ``dfhack.getDFHackVersion()`` * ``dfhack.getDFHackVersion()``
* ``dfhack.getDFHackRelease()`` * ``dfhack.getDFHackRelease()``
* ``dfhack.getDFHackBuildID()``
* ``dfhack.getCompiledDFVersion()`` * ``dfhack.getCompiledDFVersion()``
* ``dfhack.getGitDescription()`` * ``dfhack.getGitDescription()``
* ``dfhack.getGitCommit()`` * ``dfhack.getGitCommit()``

@ -56,6 +56,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Internals ## Internals
- Added documentation for all RPC functions and a build-time check - Added documentation for all RPC functions and a build-time check
- Added support for build IDs to development builds
- Use ``dlsym(3)`` to find vtables from libgraphics.so - Use ``dlsym(3)`` to find vtables from libgraphics.so
## Structures ## Structures

@ -310,10 +310,13 @@ IF(DFHACK_PRERELEASE)
) )
ENDIF() ENDIF()
# always re-run git-describe if cmake is re-run (e.g. if build ID or version changes)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake)
ADD_CUSTOM_TARGET(git-describe ADD_CUSTOM_TARGET(git-describe
COMMAND ${CMAKE_COMMAND} COMMAND ${CMAKE_COMMAND}
-D dfhack_SOURCE_DIR:STRING=${dfhack_SOURCE_DIR} -D dfhack_SOURCE_DIR:STRING=${dfhack_SOURCE_DIR}
-D GIT_EXECUTABLE:STRING=${GIT_EXECUTABLE} -D GIT_EXECUTABLE:STRING=${GIT_EXECUTABLE}
-D DFHACK_BUILD_ID:STRING=${DFHACK_BUILD_ID}
-P ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake
COMMENT "Obtaining git commit information" COMMENT "Obtaining git commit information"
) )

@ -263,6 +263,8 @@ static string dfhack_version_desc()
else else
s << "(development build " << Version::git_description() << ")"; s << "(development build " << Version::git_description() << ")";
s << " on " << (sizeof(void*) == 8 ? "x86_64" : "x86"); s << " on " << (sizeof(void*) == 8 ? "x86_64" : "x86");
if (strlen(Version::dfhack_build_id()))
s << " [build ID: " << Version::dfhack_build_id() << "]";
return s.str(); return s.str();
} }

@ -19,6 +19,10 @@ namespace DFHack {
{ {
return DFHACK_RELEASE; return DFHACK_RELEASE;
} }
const char *dfhack_build_id()
{
return DFHACK_BUILD_ID;
}
const char *git_description() const char *git_description()
{ {
return DFHACK_GIT_DESCRIPTION; return DFHACK_GIT_DESCRIPTION;

@ -1436,6 +1436,7 @@ static const LuaWrapper::FunctionReg dfhack_module[] = {
WRAP(df2console), WRAP(df2console),
WRAP_VERSION_FUNC(getDFHackVersion, dfhack_version), WRAP_VERSION_FUNC(getDFHackVersion, dfhack_version),
WRAP_VERSION_FUNC(getDFHackRelease, dfhack_release), WRAP_VERSION_FUNC(getDFHackRelease, dfhack_release),
WRAP_VERSION_FUNC(getDFHackBuildID, dfhack_build_id),
WRAP_VERSION_FUNC(getCompiledDFVersion, df_version), WRAP_VERSION_FUNC(getCompiledDFVersion, df_version),
WRAP_VERSION_FUNC(getGitDescription, git_description), WRAP_VERSION_FUNC(getGitDescription, git_description),
WRAP_VERSION_FUNC(getGitCommit, git_commit), WRAP_VERSION_FUNC(getGitCommit, git_commit),

@ -42,6 +42,7 @@ git_describe_definition(DFHACK_GIT_DESCRIPTION)
git_describe_definition(DFHACK_GIT_COMMIT) git_describe_definition(DFHACK_GIT_COMMIT)
git_describe_definition(DFHACK_GIT_XML_EXPECTED_COMMIT) git_describe_definition(DFHACK_GIT_XML_EXPECTED_COMMIT)
git_describe_definition(DFHACK_GIT_XML_COMMIT) git_describe_definition(DFHACK_GIT_XML_COMMIT)
git_describe_definition(DFHACK_BUILD_ID)
if(${DFHACK_GIT_TAGGED_RESULT} EQUAL 0) if(${DFHACK_GIT_TAGGED_RESULT} EQUAL 0)
file(APPEND ${git_describe_tmp_h} "#define DFHACK_GIT_TAGGED\n") file(APPEND ${git_describe_tmp_h} "#define DFHACK_GIT_TAGGED\n")
endif() endif()

@ -1,15 +1,18 @@
#pragma once #pragma once
namespace DFHack { namespace DFHack {
namespace Version { namespace Version {
const char *dfhack_version();
const char *df_version(); const char *df_version();
const char *dfhack_version();
const char *dfhack_release(); const char *dfhack_release();
const char *dfhack_build_id();
int dfhack_abi_version(); int dfhack_abi_version();
const char *git_description(); const char *git_description();
const char *git_commit(); const char *git_commit();
const char *git_xml_commit(); const char *git_xml_commit();
const char *git_xml_expected_commit(); const char *git_xml_expected_commit();
bool git_xml_match(); bool git_xml_match();
bool is_release(); bool is_release();
bool is_prerelease(); bool is_prerelease();
} }
@ -17,14 +20,17 @@ namespace DFHack {
#ifndef NO_DFHACK_VERSION_MACROS #ifndef NO_DFHACK_VERSION_MACROS
#define DF_VERSION (DFHack::Version::df_version()) #define DF_VERSION (DFHack::Version::df_version())
#define DFHACK_RELEASE (DFHack::Version::dfhack_release())
#define DFHACK_VERSION (DFHack::Version::dfhack_version()) #define DFHACK_VERSION (DFHack::Version::dfhack_version())
#define DFHACK_RELEASE (DFHack::Version::dfhack_release())
#define DFHACK_BUILD_ID (DFHack::Version::dfhack_build_id())
#define DFHACK_ABI_VERSION (DFHack::Version::dfhack_abi_version()) #define DFHACK_ABI_VERSION (DFHack::Version::dfhack_abi_version())
#define DFHACK_GIT_DESCRIPTION (DFHack::Version::git_description()) #define DFHACK_GIT_DESCRIPTION (DFHack::Version::git_description())
#define DFHACK_GIT_COMMIT (DFHack::Version::git_commit()) #define DFHACK_GIT_COMMIT (DFHack::Version::git_commit())
#define DFHACK_GIT_XML_COMMIT (DFHack::Version::git_xml_commit()) #define DFHACK_GIT_XML_COMMIT (DFHack::Version::git_xml_commit())
#define DFHACK_GIT_XML_EXPECTED_COMMIT (DFHack::Version::git_xml_expected_commit()) #define DFHACK_GIT_XML_EXPECTED_COMMIT (DFHack::Version::git_xml_expected_commit())
#define DFHACK_GIT_XML_MATCH (DFHack::Version::git_xml_match()) #define DFHACK_GIT_XML_MATCH (DFHack::Version::git_xml_match())
#define DFHACK_IS_RELEASE (DFHack::Version::is_release()) #define DFHACK_IS_RELEASE (DFHack::Version::is_release())
#define DFHACK_IS_PRERELEASE (DFHack::Version::is_prerelease()) #define DFHACK_IS_PRERELEASE (DFHack::Version::is_prerelease())
#endif #endif

@ -1,8 +1,9 @@
#include <vector> #include <cmath>
#include <cstdio> #include <cstdio>
#include <cstring>
#include <stack> #include <stack>
#include <string> #include <string>
#include <cmath> #include <vector>
#include "Core.h" #include "Core.h"
#include "Console.h" #include "Console.h"
@ -38,6 +39,12 @@ void draw_version(int start_x, int start_y) {
OutputString(COLOR_WHITE, x, y, "Git: "); OutputString(COLOR_WHITE, x, y, "Git: ");
OutputString(COLOR_WHITE, x, y, DFHACK_GIT_DESCRIPTION); OutputString(COLOR_WHITE, x, y, DFHACK_GIT_DESCRIPTION);
} }
if (strlen(DFHACK_BUILD_ID))
{
x = start_x; y++;
OutputString(COLOR_WHITE, x, y, "Build ID: ");
OutputString(COLOR_WHITE, x, y, DFHACK_BUILD_ID);
}
if (DFHACK_IS_PRERELEASE) if (DFHACK_IS_PRERELEASE)
{ {
x = start_x; y++; x = start_x; y++;
@ -66,7 +73,7 @@ struct options_version_hook : df::viewscreen_optionst {
INTERPOSE_NEXT(render)(); INTERPOSE_NEXT(render)();
if (!msg_quit && !in_retire_adv && !msg_peasant && if (!msg_quit && !in_retire_adv && !msg_peasant &&
!in_retire_dwf_abandon_adv && !in_abandon_dwf && !ending_game) !in_retire_dwf_abandon_adv && !in_abandon_dwf && !ending_game)
draw_version(2, gps->dimy - 5); draw_version(2, gps->dimy - 6);
} }
}; };