Log plugin load information to stderr

develop
lethosor 2015-06-26 16:11:41 -04:00
parent 5d1ae9f5ed
commit 935f4dd628
1 changed files with 10 additions and 4 deletions

@ -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,10 +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_description = (const char**) LookupPlugin(plug, "git_description"); 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 *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"
@ -243,14 +245,17 @@ bool Plugin::load(color_ostream &con)
plugin_abort_load; plugin_abort_load;
return false; return false;
} }
if (plug_git_description) if (plug_git_desc_ptr)
{ {
if (strcmp(dfhack_git_desc, *plug_git_description) != 0) if (strcmp(dfhack_git_desc, plug_git_desc) != 0)
con.printerr("Warning: Plugin %s compiled for DFHack %s, running DFHack %s\n", con.printerr("Warning: Plugin %s compiled for DFHack %s, running DFHack %s\n",
*plug_name, *plug_git_description, dfhack_git_desc); *plug_name, plug_git_desc, dfhack_git_desc);
} }
else else
{
con.printerr("Warning: Plugin %s missing git information\n", *plug_name); 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"))
{ {
@ -297,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