Skip to content

Commit 7afa369

Browse files
committed
Add support for DFHACK_BUILD_ID
Used for BuildMaster builds, for example
1 parent e1d1182 commit 7afa369

10 files changed

Lines changed: 40 additions & 6 deletions

File tree

CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}")
171171

172172
set(DFHACK_ABI_VERSION 1)
173173

174+
set(DFHACK_BUILD_ID "" CACHE STRING "Build ID (should be specified on command line)")
175+
174176
## where to install things (after the build is done, classic 'make install' or package structure)
175177
# the dfhack libraries will be installed here:
176178
IF(UNIX)
@@ -477,7 +479,13 @@ IF(APPLE)
477479
ELSE()
478480
set(DFHACK_PACKAGE_PLATFORM_NAME ${CMAKE_SYSTEM_NAME})
479481
ENDIF()
480-
set(CPACK_PACKAGE_FILE_NAME "dfhack-${DFHACK_VERSION}-${DFHACK_PACKAGE_PLATFORM_NAME}-${DFHACK_BUILD_ARCH}${DFHACK_PACKAGE_SUFFIX}")
482+
# set on command line
483+
if(DFHACK_BUILD_ID STREQUAL "")
484+
set(DFHACK_BUILD_ID_PACKAGE "")
485+
else()
486+
set(DFHACK_BUILD_ID_PACKAGE "${DFHACK_BUILD_ID}-")
487+
endif()
488+
set(CPACK_PACKAGE_FILE_NAME "dfhack-${DFHACK_VERSION}-${DFHACK_BUILD_ID_PACKAGE}${DFHACK_PACKAGE_PLATFORM_NAME}-${DFHACK_BUILD_ARCH}${DFHACK_PACKAGE_SUFFIX}")
481489
INCLUDE(CPack)
482490

483491
#INCLUDE(FindSphinx.cmake)

docs/Lua API.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,7 @@ can be omitted.
822822

823823
* ``dfhack.getDFHackVersion()``
824824
* ``dfhack.getDFHackRelease()``
825+
* ``dfhack.getDFHackBuildID()``
825826
* ``dfhack.getCompiledDFVersion()``
826827
* ``dfhack.getGitDescription()``
827828
* ``dfhack.getGitCommit()``

docs/changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
5656

5757
## Internals
5858
- Added documentation for all RPC functions and a build-time check
59+
- Added support for build IDs to development builds
5960
- Use ``dlsym(3)`` to find vtables from libgraphics.so
6061

6162
## Structures

library/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,13 @@ IF(DFHACK_PRERELEASE)
310310
)
311311
ENDIF()
312312

313+
# always re-run git-describe if cmake is re-run (e.g. if build ID or version changes)
314+
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake)
313315
ADD_CUSTOM_TARGET(git-describe
314316
COMMAND ${CMAKE_COMMAND}
315317
-D dfhack_SOURCE_DIR:STRING=${dfhack_SOURCE_DIR}
316318
-D GIT_EXECUTABLE:STRING=${GIT_EXECUTABLE}
319+
-D DFHACK_BUILD_ID:STRING=${DFHACK_BUILD_ID}
317320
-P ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake
318321
COMMENT "Obtaining git commit information"
319322
)

library/Core.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ static string dfhack_version_desc()
263263
else
264264
s << "(development build " << Version::git_description() << ")";
265265
s << " on " << (sizeof(void*) == 8 ? "x86_64" : "x86");
266+
if (strlen(Version::dfhack_build_id()))
267+
s << " [build ID: " << Version::dfhack_build_id() << "]";
266268
return s.str();
267269
}
268270

library/DFHackVersion.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ namespace DFHack {
1919
{
2020
return DFHACK_RELEASE;
2121
}
22+
const char *dfhack_build_id()
23+
{
24+
return DFHACK_BUILD_ID;
25+
}
2226
const char *git_description()
2327
{
2428
return DFHACK_GIT_DESCRIPTION;

library/LuaApi.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,6 +1436,7 @@ static const LuaWrapper::FunctionReg dfhack_module[] = {
14361436
WRAP(df2console),
14371437
WRAP_VERSION_FUNC(getDFHackVersion, dfhack_version),
14381438
WRAP_VERSION_FUNC(getDFHackRelease, dfhack_release),
1439+
WRAP_VERSION_FUNC(getDFHackBuildID, dfhack_build_id),
14391440
WRAP_VERSION_FUNC(getCompiledDFVersion, df_version),
14401441
WRAP_VERSION_FUNC(getGitDescription, git_description),
14411442
WRAP_VERSION_FUNC(getGitCommit, git_commit),

library/git-describe.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ git_describe_definition(DFHACK_GIT_DESCRIPTION)
4242
git_describe_definition(DFHACK_GIT_COMMIT)
4343
git_describe_definition(DFHACK_GIT_XML_EXPECTED_COMMIT)
4444
git_describe_definition(DFHACK_GIT_XML_COMMIT)
45+
git_describe_definition(DFHACK_BUILD_ID)
4546
if(${DFHACK_GIT_TAGGED_RESULT} EQUAL 0)
4647
file(APPEND ${git_describe_tmp_h} "#define DFHACK_GIT_TAGGED\n")
4748
endif()

library/include/DFHackVersion.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,36 @@
11
#pragma once
22
namespace DFHack {
33
namespace Version {
4-
const char *dfhack_version();
54
const char *df_version();
5+
const char *dfhack_version();
66
const char *dfhack_release();
7+
const char *dfhack_build_id();
78
int dfhack_abi_version();
9+
810
const char *git_description();
911
const char *git_commit();
1012
const char *git_xml_commit();
1113
const char *git_xml_expected_commit();
1214
bool git_xml_match();
15+
1316
bool is_release();
1417
bool is_prerelease();
1518
}
1619
}
1720

1821
#ifndef NO_DFHACK_VERSION_MACROS
1922
#define DF_VERSION (DFHack::Version::df_version())
20-
#define DFHACK_RELEASE (DFHack::Version::dfhack_release())
2123
#define DFHACK_VERSION (DFHack::Version::dfhack_version())
24+
#define DFHACK_RELEASE (DFHack::Version::dfhack_release())
25+
#define DFHACK_BUILD_ID (DFHack::Version::dfhack_build_id())
2226
#define DFHACK_ABI_VERSION (DFHack::Version::dfhack_abi_version())
27+
2328
#define DFHACK_GIT_DESCRIPTION (DFHack::Version::git_description())
2429
#define DFHACK_GIT_COMMIT (DFHack::Version::git_commit())
2530
#define DFHACK_GIT_XML_COMMIT (DFHack::Version::git_xml_commit())
2631
#define DFHACK_GIT_XML_EXPECTED_COMMIT (DFHack::Version::git_xml_expected_commit())
2732
#define DFHACK_GIT_XML_MATCH (DFHack::Version::git_xml_match())
33+
2834
#define DFHACK_IS_RELEASE (DFHack::Version::is_release())
2935
#define DFHACK_IS_PRERELEASE (DFHack::Version::is_prerelease())
3036
#endif

plugins/title-version.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
#include <vector>
1+
#include <cmath>
22
#include <cstdio>
3+
#include <cstring>
34
#include <stack>
45
#include <string>
5-
#include <cmath>
6+
#include <vector>
67

78
#include "Core.h"
89
#include "Console.h"
@@ -38,6 +39,12 @@ void draw_version(int start_x, int start_y) {
3839
OutputString(COLOR_WHITE, x, y, "Git: ");
3940
OutputString(COLOR_WHITE, x, y, DFHACK_GIT_DESCRIPTION);
4041
}
42+
if (strlen(DFHACK_BUILD_ID))
43+
{
44+
x = start_x; y++;
45+
OutputString(COLOR_WHITE, x, y, "Build ID: ");
46+
OutputString(COLOR_WHITE, x, y, DFHACK_BUILD_ID);
47+
}
4148
if (DFHACK_IS_PRERELEASE)
4249
{
4350
x = start_x; y++;
@@ -66,7 +73,7 @@ struct options_version_hook : df::viewscreen_optionst {
6673
INTERPOSE_NEXT(render)();
6774
if (!msg_quit && !in_retire_adv && !msg_peasant &&
6875
!in_retire_dwf_abandon_adv && !in_abandon_dwf && !ending_game)
69-
draw_version(2, gps->dimy - 5);
76+
draw_version(2, gps->dimy - 6);
7077
}
7178
};
7279

0 commit comments

Comments
 (0)