Merge branch 'git-describe' into develop

develop
lethosor 2015-06-26 21:10:13 -04:00
commit 790f967120
9 changed files with 62 additions and 3 deletions

@ -143,6 +143,10 @@ include_directories(${ZLIB_INCLUDE_DIRS})
include_directories(depends/clsocket/src) include_directories(depends/clsocket/src)
add_subdirectory(depends) add_subdirectory(depends)
find_package(Git)
if(NOT GIT_FOUND)
message(FATAL_ERROR "could not find git")
endif()
#find_package(Docutils) #find_package(Docutils)

@ -257,6 +257,15 @@ SET_PROPERTY(TARGET dfhack-version APPEND PROPERTY COMPILE_DEFINITIONS
DFHACK_RELEASE="${DFHACK_RELEASE}" DFHACK_RELEASE="${DFHACK_RELEASE}"
) )
ADD_CUSTOM_TARGET(git-describe
COMMAND ${CMAKE_COMMAND}
-D dfhack_SOURCE_DIR:STRING=${dfhack_SOURCE_DIR}
-D GIT_EXECUTABLE:STRING=${GIT_EXECUTABLE}
-P ${CMAKE_CURRENT_SOURCE_DIR}/git-describe.cmake
COMMENT "Obtaining git commit information"
)
ADD_DEPENDENCIES(dfhack-version git-describe)
ADD_LIBRARY(dfhack SHARED ${PROJECT_SOURCES}) ADD_LIBRARY(dfhack SHARED ${PROJECT_SOURCES})
ADD_DEPENDENCIES(dfhack generate_headers) ADD_DEPENDENCIES(dfhack generate_headers)

@ -1229,6 +1229,8 @@ bool Core::Init()
if(errorstate) if(errorstate)
return false; return false;
fprintf(stderr, "DFHack build: %s\n", Version::git_description());
// find out what we are... // find out what we are...
#ifdef LINUX_BUILD #ifdef LINUX_BUILD
const char * path = "hack/symbols.xml"; const char * path = "hack/symbols.xml";

@ -1,8 +1,23 @@
#include "DFHackVersion.h" #include "DFHackVersion.h"
#include "git-describe.h"
#include "Export.h"
namespace DFHack { namespace DFHack {
namespace Version { namespace Version {
const char *dfhack_version() { return DFHACK_VERSION; } const char *dfhack_version()
const char *df_version() { return DF_VERSION; } {
const char *dfhack_release() { return DFHACK_RELEASE; } return DFHACK_VERSION;
}
const char *df_version()
{
return DF_VERSION;
}
const char *dfhack_release()
{
return DFHACK_RELEASE;
}
const char *git_description()
{
return DFHACK_GIT_DESCRIPTION;
}
} }
} }

@ -208,6 +208,7 @@ bool Plugin::load(color_ostream &con)
// enter suspend // enter suspend
CoreSuspender suspend; CoreSuspender suspend;
// open the library, etc // open the library, etc
fprintf(stderr, "loading plugin %s\n", filename.c_str());
DFLibrary * plug = OpenPlugin(filename.c_str()); DFLibrary * plug = OpenPlugin(filename.c_str());
if(!plug) if(!plug)
{ {
@ -232,8 +233,11 @@ bool Plugin::load(color_ostream &con)
plugin_check_symbol("plugin_globals") plugin_check_symbol("plugin_globals")
const char ** plug_name =(const char ** ) LookupPlugin(plug, "name"); const char ** plug_name =(const char ** ) LookupPlugin(plug, "name");
const char ** plug_version =(const char ** ) LookupPlugin(plug, "version"); const char ** plug_version =(const char ** ) LookupPlugin(plug, "version");
const char ** plug_git_desc_ptr = (const char**) LookupPlugin(plug, "git_description");
Plugin **plug_self = (Plugin**)LookupPlugin(plug, "plugin_self"); Plugin **plug_self = (Plugin**)LookupPlugin(plug, "plugin_self");
const char *dfhack_version = Version::dfhack_version(); const char *dfhack_version = Version::dfhack_version();
const char *dfhack_git_desc = Version::git_description();
const char *plug_git_desc = plug_git_desc_ptr ? *plug_git_desc_ptr : "unknown";
if (strcmp(dfhack_version, *plug_version) != 0) if (strcmp(dfhack_version, *plug_version) != 0)
{ {
con.printerr("Plugin %s was not built for this version of DFHack.\n" con.printerr("Plugin %s was not built for this version of DFHack.\n"
@ -241,6 +245,17 @@ bool Plugin::load(color_ostream &con)
plugin_abort_load; plugin_abort_load;
return false; return false;
} }
if (plug_git_desc_ptr)
{
if (strcmp(dfhack_git_desc, plug_git_desc) != 0)
con.printerr("Warning: Plugin %s compiled for DFHack %s, running DFHack %s\n",
*plug_name, plug_git_desc, dfhack_git_desc);
}
else
{
con.printerr("Warning: Plugin %s missing git information\n", *plug_name);
plug_git_desc = "unknown";
}
bool *plug_dev = (bool*)LookupPlugin(plug, "plugin_dev"); bool *plug_dev = (bool*)LookupPlugin(plug, "plugin_dev");
if (plug_dev && *plug_dev && getenv("DFHACK_NO_DEV_PLUGINS")) if (plug_dev && *plug_dev && getenv("DFHACK_NO_DEV_PLUGINS"))
{ {
@ -287,6 +302,7 @@ bool Plugin::load(color_ostream &con)
parent->registerCommands(this); parent->registerCommands(this);
if ((plugin_onupdate || plugin_enable) && !plugin_is_enabled) if ((plugin_onupdate || plugin_enable) && !plugin_is_enabled)
con.printerr("Plugin %s has no enabled var!\n", name.c_str()); con.printerr("Plugin %s has no enabled var!\n", name.c_str());
fprintf(stderr, "loaded plugin %s; DFHack build %s\n", name.c_str(), plug_git_desc);
return true; return true;
} }
else else

@ -0,0 +1,9 @@
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags
WORKING_DIRECTORY "${dfhack_SOURCE_DIR}"
OUTPUT_VARIABLE DFHACK_GIT_DESCRIPTION)
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}\"")
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)

@ -0,0 +1 @@
git-describe.*

@ -4,5 +4,6 @@ namespace DFHack {
const char *dfhack_version(); const char *dfhack_version();
const char *df_version(); const char *df_version();
const char *dfhack_release(); const char *dfhack_release();
const char *git_description();
} }
} }

@ -61,6 +61,7 @@ namespace DFHack
namespace Version { namespace Version {
const char *dfhack_version(); const char *dfhack_version();
const char *git_description();
} }
// anon type, pretty much // anon type, pretty much
@ -289,6 +290,7 @@ namespace DFHack
#define DFHACK_PLUGIN_AUX(plugin_name, is_dev) \ #define DFHACK_PLUGIN_AUX(plugin_name, is_dev) \
DFhackDataExport const char * name = plugin_name;\ DFhackDataExport const char * name = plugin_name;\
DFhackDataExport const char * version = DFHack::Version::dfhack_version();\ DFhackDataExport const char * version = DFHack::Version::dfhack_version();\
DFhackDataExport const char * git_description = DFHack::Version::git_description();\
DFhackDataExport Plugin *plugin_self = NULL;\ DFhackDataExport Plugin *plugin_self = NULL;\
std::vector<std::string> _plugin_globals;\ std::vector<std::string> _plugin_globals;\
DFhackDataExport std::vector<std::string>* plugin_globals = &_plugin_globals; \ DFhackDataExport std::vector<std::string>* plugin_globals = &_plugin_globals; \