git-describe: Add git xml information

develop
lethosor 2016-02-01 10:30:53 -05:00
parent a7d254139f
commit 2d23a848cc
4 changed files with 55 additions and 10 deletions

@ -2,6 +2,7 @@
#include "DFHackVersion.h"
#include "git-describe.h"
#include "Export.h"
#include <string>
namespace DFHack {
namespace Version {
const char *dfhack_version()
@ -24,6 +25,23 @@ namespace DFHack {
{
return DFHACK_GIT_COMMIT;
}
const char *git_xml_commit()
{
return DFHACK_GIT_XML_COMMIT;
}
const char *git_xml_expected_commit()
{
return DFHACK_GIT_XML_EXPECTED_COMMIT;
}
bool git_xml_match()
{
#ifdef DFHACK_GIT_XML_MATCH
return true;
#else
return false;
#endif
}
bool is_release()
{

@ -1417,6 +1417,9 @@ static const LuaWrapper::FunctionReg dfhack_module[] = {
WRAP_VERSION_FUNC(getCompiledDFVersion, df_version),
WRAP_VERSION_FUNC(getGitDescription, git_description),
WRAP_VERSION_FUNC(getGitCommit, git_commit),
WRAP_VERSION_FUNC(getGitXmlCommit, git_xml_commit),
WRAP_VERSION_FUNC(getGitXmlExpectedCommit, git_xml_expected_commit),
WRAP_VERSION_FUNC(gitXmlMatch, git_xml_match),
WRAP_VERSION_FUNC(isRelease, is_release),
WRAP_VERSION_FUNC(isPrerelease, is_prerelease),
{ NULL, NULL }

@ -8,16 +8,34 @@ execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --exact-match
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}"
RESULT_VARIABLE DFHACK_GIT_TAGGED_RESULT
OUTPUT_QUIET ERROR_QUIET)
string(STRIP ${DFHACK_GIT_DESCRIPTION} DFHACK_GIT_DESCRIPTION)
file(WRITE ${dfhack_SOURCE_DIR}/library/include/git-describe.tmp.h
"#define DFHACK_GIT_DESCRIPTION \"${DFHACK_GIT_DESCRIPTION}\"\n")
string(STRIP ${DFHACK_GIT_COMMIT} DFHACK_GIT_COMMIT)
file(APPEND ${dfhack_SOURCE_DIR}/library/include/git-describe.tmp.h
"#define DFHACK_GIT_COMMIT \"${DFHACK_GIT_COMMIT}\"\n")
# Check library/xml for matching commits
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD:library/xml
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}"
OUTPUT_VARIABLE DFHACK_GIT_XML_EXPECTED_COMMIT)
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}/library/xml"
OUTPUT_VARIABLE DFHACK_GIT_XML_COMMIT)
set(git_describe_tmp_h ${dfhack_SOURCE_DIR}/library/include/git-describe.tmp.h)
set(git_describe_h ${dfhack_SOURCE_DIR}/library/include/git-describe.h)
file(WRITE ${git_describe_tmp_h} "")
macro(git_describe_definition var)
string(STRIP "${${var}}" GIT_DEF_VALUE)
file(APPEND ${git_describe_tmp_h} "#define ${var} \"${GIT_DEF_VALUE}\"\n")
endmacro()
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)
if(${DFHACK_GIT_TAGGED_RESULT} EQUAL 0)
file(APPEND ${dfhack_SOURCE_DIR}/library/include/git-describe.tmp.h
"#define DFHACK_GIT_TAGGED\n")
file(APPEND ${git_describe_tmp_h} "#define DFHACK_GIT_TAGGED\n")
endif()
if(${DFHACK_GIT_XML_COMMIT} STREQUAL ${DFHACK_GIT_XML_EXPECTED_COMMIT})
file(APPEND ${git_describe_tmp_h} "#define DFHACK_GIT_XML_MATCH\n")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
${dfhack_SOURCE_DIR}/library/include/git-describe.tmp.h
${dfhack_SOURCE_DIR}/library/include/git-describe.h)
${git_describe_tmp_h} ${git_describe_h})

@ -6,6 +6,9 @@ namespace DFHack {
const char *dfhack_release();
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,6 +20,9 @@ namespace DFHack {
#define DFHACK_VERSION (DFHack::Version::dfhack_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