Allow dev plugins to be skipped on startup

develop
lethosor 2015-04-01 17:50:16 -04:00
parent 8b5b8ed864
commit 9b6d8d2799
3 changed files with 19 additions and 3 deletions

@ -230,6 +230,7 @@ bool Plugin::load(color_ostream &con)
plugin_check_symbol("plugin_self")
plugin_check_symbol("plugin_init")
plugin_check_symbol("plugin_globals")
plugin_check_symbol("plugin_dev")
const char ** plug_name =(const char ** ) LookupPlugin(plug, "name");
const char ** plug_version =(const char ** ) LookupPlugin(plug, "version");
Plugin **plug_self = (Plugin**)LookupPlugin(plug, "plugin_self");
@ -240,6 +241,13 @@ bool Plugin::load(color_ostream &con)
plugin_abort_load;
return false;
}
bool *plug_dev = (bool*)LookupPlugin(plug, "plugin_dev");
if (*plug_dev && getenv("DFHACK_NO_DEV_PLUGINS"))
{
con.print("Skipping dev plugin: %s\n", *plug_name);
plugin_abort_load;
return false;
}
*plug_self = this;
RefAutolock lock(access);
plugin_init = (command_result (*)(color_ostream &, std::vector <PluginCommand> &)) LookupPlugin(plug, "plugin_init");

@ -271,13 +271,20 @@ namespace DFHack
}
};
/// You have to have this in every plugin you write - just once. Ideally on top of the main file.
#define DFHACK_PLUGIN(plugin_name) \
#define DFHACK_PLUGIN_AUX(plugin_name, is_dev) \
DFhackDataExport const char * name = plugin_name;\
DFhackDataExport const char * version = get_dfhack_version();\
DFhackDataExport Plugin *plugin_self = NULL;\
std::vector<std::string> _plugin_globals;\
DFhackDataExport std::vector<std::string>* plugin_globals = &_plugin_globals;
DFhackDataExport std::vector<std::string>* plugin_globals = &_plugin_globals; \
DFhackDataExport bool plugin_dev = is_dev;
/// You have to include DFHACK_PLUGIN("plugin_name") in every plugin you write - just once. Ideally at the top of the main file.
#ifdef DEV_PLUGIN
#define DFHACK_PLUGIN(plugin_name) DFHACK_PLUGIN_AUX(plugin_name, true)
#else
#define DFHACK_PLUGIN(plugin_name) DFHACK_PLUGIN_AUX(plugin_name, false)
#endif
#define DFHACK_PLUGIN_IS_ENABLED(varname) \
DFhackDataExport bool plugin_is_enabled = false; \

@ -2,6 +2,7 @@ IF(UNIX)
DFHACK_PLUGIN(vectors vectors.cpp)
endif()
ADD_DEFINITIONS(-DDEV_PLUGIN)
#DFHACK_PLUGIN(autolabor2 autolabor2.cpp)
DFHACK_PLUGIN(buildprobe buildprobe.cpp)
DFHACK_PLUGIN(counters counters.cpp)