Skip to content

Commit

Permalink
Add support for DFHACK_BUILD_ID
Browse files Browse the repository at this point in the history
Used for BuildMaster builds, for example
  • Loading branch information
lethosor committed Jul 11, 2018
1 parent e1d1182 commit 7afa369
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 6 deletions.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docs/Lua API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ can be omitted.

* ``dfhack.getDFHackVersion()``
* ``dfhack.getDFHackRelease()``
* ``dfhack.getDFHackBuildID()``
* ``dfhack.getCompiledDFVersion()``
* ``dfhack.getGitDescription()``
* ``dfhack.getGitCommit()``
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 2 additions & 0 deletions library/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 4 additions & 0 deletions library/DFHackVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions library/LuaApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions library/git-describe.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 8 additions & 2 deletions library/include/DFHackVersion.h
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
#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();
}
}

#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
13 changes: 10 additions & 3 deletions plugins/title-version.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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++;
Expand Down Expand Up @@ -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);
}
};

Expand Down

0 comments on commit 7afa369

Please sign in to comment.