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_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)
# the dfhack libraries will be installed here:
IF(UNIX)
@ -477,7 +479,13 @@ IF(APPLE)
ELSE()
set(DFHACK_PACKAGE_PLATFORM_NAME ${CMAKE_SYSTEM_NAME})
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(FindSphinx.cmake)

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

@ -56,6 +56,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Internals
- 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
## Structures

@ -310,10 +310,13 @@ IF(DFHACK_PRERELEASE)
)
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
COMMAND ${CMAKE_COMMAND}
-D dfhack_SOURCE_DIR:STRING=${dfhack_SOURCE_DIR}
-D GIT_EXECUTABLE:STRING=${GIT_EXECUTABLE}
-D DFHACK_BUILD_ID:STRING=${DFHACK_BUILD_ID}
-P ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake
COMMENT "Obtaining git commit information"
)

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

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

@ -1436,6 +1436,7 @@ static const LuaWrapper::FunctionReg dfhack_module[] = {
WRAP(df2console),
WRAP_VERSION_FUNC(getDFHackVersion, dfhack_version),
WRAP_VERSION_FUNC(getDFHackRelease, dfhack_release),
WRAP_VERSION_FUNC(getDFHackBuildID, dfhack_build_id),
WRAP_VERSION_FUNC(getCompiledDFVersion, df_version),
WRAP_VERSION_FUNC(getGitDescription, git_description),
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_XML_EXPECTED_COMMIT)
git_describe_definition(DFHACK_GIT_XML_COMMIT)
git_describe_definition(DFHACK_BUILD_ID)
if(${DFHACK_GIT_TAGGED_RESULT} EQUAL 0)
file(APPEND ${git_describe_tmp_h} "#define DFHACK_GIT_TAGGED\n")
endif()

@ -1,15 +1,18 @@
#pragma once
namespace DFHack {
namespace Version {
const char *dfhack_version();
const char *df_version();
const char *dfhack_version();
const char *dfhack_release();
const char *dfhack_build_id();
int dfhack_abi_version();
const char *git_description();
const char *git_commit();
const char *git_xml_commit();
const char *git_xml_expected_commit();
bool git_xml_match();
bool is_release();
bool is_prerelease();
}
@ -17,14 +20,17 @@ namespace DFHack {
#ifndef NO_DFHACK_VERSION_MACROS
#define DF_VERSION (DFHack::Version::df_version())
#define DFHACK_RELEASE (DFHack::Version::dfhack_release())
#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_GIT_DESCRIPTION (DFHack::Version::git_description())
#define DFHACK_GIT_COMMIT (DFHack::Version::git_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_MATCH (DFHack::Version::git_xml_match())
#define DFHACK_IS_RELEASE (DFHack::Version::is_release())
#define DFHACK_IS_PRERELEASE (DFHack::Version::is_prerelease())
#endif

@ -1,8 +1,9 @@
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <string>
#include <cmath>
#include <vector>
#include "Core.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, 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)
{
x = start_x; y++;
@ -66,7 +73,7 @@ struct options_version_hook : df::viewscreen_optionst {
INTERPOSE_NEXT(render)();
if (!msg_quit && !in_retire_adv && !msg_peasant &&
!in_retire_dwf_abandon_adv && !in_abandon_dwf && !ending_game)
draw_version(2, gps->dimy - 5);
draw_version(2, gps->dimy - 6);
}
};