diff --git a/CMakeLists.txt b/CMakeLists.txt index 01c3fab29..6d6118c65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/docs/Lua API.rst b/docs/Lua API.rst index 9a06e2250..3eb053e73 100644 --- a/docs/Lua API.rst +++ b/docs/Lua API.rst @@ -822,6 +822,7 @@ can be omitted. * ``dfhack.getDFHackVersion()`` * ``dfhack.getDFHackRelease()`` +* ``dfhack.getDFHackBuildID()`` * ``dfhack.getCompiledDFVersion()`` * ``dfhack.getGitDescription()`` * ``dfhack.getGitCommit()`` diff --git a/docs/changelog.txt b/docs/changelog.txt index 39b959d63..5629ef7f4 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -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 diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 390efdcfe..22ed67711 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -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" ) diff --git a/library/Core.cpp b/library/Core.cpp index 5bb8b0244..69ef5a132 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -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(); } diff --git a/library/DFHackVersion.cpp b/library/DFHackVersion.cpp index f4f0cf242..7746ebece 100644 --- a/library/DFHackVersion.cpp +++ b/library/DFHackVersion.cpp @@ -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; diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 0f6c06d77..a435c7a8e 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -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), diff --git a/library/git-describe.cmake b/library/git-describe.cmake index f19b556d2..6650dbde4 100644 --- a/library/git-describe.cmake +++ b/library/git-describe.cmake @@ -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() diff --git a/library/include/DFHackVersion.h b/library/include/DFHackVersion.h index c89b94ba5..1b69dfe55 100644 --- a/library/include/DFHackVersion.h +++ b/library/include/DFHackVersion.h @@ -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 diff --git a/plugins/title-version.cpp b/plugins/title-version.cpp index 10df9d35a..66bb159ad 100644 --- a/plugins/title-version.cpp +++ b/plugins/title-version.cpp @@ -1,8 +1,9 @@ -#include +#include #include +#include #include #include -#include +#include #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); } };