22 #ifdef YOSYS_ENABLE_PLUGINS
31 #ifdef YOSYS_ENABLE_PLUGINS
32 void load_plugin(std::string filename, std::vector<std::string> aliases)
34 if (filename.find(
'/') == std::string::npos)
35 filename =
"./" + filename;
38 void *hdl = dlopen(filename.c_str(), RTLD_LAZY|RTLD_LOCAL);
40 log_cmd_error(
"Can't load module `%s': %s\n", filename.c_str(), dlerror());
45 for (
auto &alias : aliases)
51 log_error(
"This version of yosys is built without plugin support.\n");
61 log(
" plugin [options]\n");
63 log(
"Load and list loaded plugins.\n");
65 log(
" -i <plugin_filename>\n");
66 log(
" Load (install) the specified plugin.\n");
68 log(
" -a <alias_name>\n");
69 log(
" Register the specified alias name for the loaded plugin\n");
72 log(
" List loaded plugins\n");
77 std::string plugin_filename;
78 std::vector<std::string> plugin_aliases;
79 bool list_mode =
false;
82 for (argidx = 1; argidx < args.size(); argidx++)
84 if ((args[argidx] ==
"-i") && argidx+1 < args.size() && plugin_filename.empty()) {
85 plugin_filename = args[++argidx];
88 if ((args[argidx] ==
"-a") && argidx+1 < args.size()) {
89 plugin_aliases.push_back(args[++argidx]);
92 if (args[argidx] ==
"-l") {
100 if (!plugin_filename.empty())
107 log(
"No plugins loaded.\n");
109 log(
"Loaded plugins:\n");
112 log(
" %s\n", it.first.c_str());
116 int max_alias_len = 1;
118 max_alias_len = std::max(max_alias_len,
GetSize(it.first));
119 for (
auto &it : loaded_plugin_aliases)
120 log(
"Alias: %-*s %s\n", max_alias_len, it.first.c_str(), it.second.c_str());
virtual void execute(std::vector< std::string > args, RTLIL::Design *design)
#define YOSYS_NAMESPACE_END
YOSYS_NAMESPACE_BEGIN std::map< std::string, void * > loaded_plugins
void log_error(const char *format,...)
void load_plugin(std::string, std::vector< std::string >)
int GetSize(RTLIL::Wire *wire)
void log_cmd_error(const char *format,...)
std::map< std::string, std::string > loaded_plugin_aliases
#define YOSYS_NAMESPACE_BEGIN
void log(const char *format,...)
static void init_register()
void extra_args(std::vector< std::string > args, size_t argidx, RTLIL::Design *design, bool select=true)