diff options
author | Clifford Wolf <clifford@clifford.at> | 2014-08-22 13:58:36 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2014-08-22 14:00:11 +0200 |
commit | a3494fa9ed32d7ff2b826dfc921e3a0139158880 (patch) | |
tree | 98793a987d65abe7c663fc5f82f4f5b6a9cae161 /kernel | |
parent | 752650a062cb262b37f1c5ea62663e5c8c9c7928 (diff) | |
download | yosys-a3494fa9ed32d7ff2b826dfc921e3a0139158880.tar.gz yosys-a3494fa9ed32d7ff2b826dfc921e3a0139158880.tar.bz2 yosys-a3494fa9ed32d7ff2b826dfc921e3a0139158880.zip |
Added "plugin" command
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/driver.cc | 15 | ||||
-rw-r--r-- | kernel/yosys.cc | 7 | ||||
-rw-r--r-- | kernel/yosys.h | 5 |
3 files changed, 17 insertions, 10 deletions
diff --git a/kernel/driver.cc b/kernel/driver.cc index d59e68a50..6bd60d7b5 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -27,7 +27,6 @@ #include <string.h> #include <unistd.h> #include <libgen.h> -#include <dlfcn.h> #include <limits.h> #include <errno.h> @@ -38,7 +37,7 @@ int main(int argc, char **argv) std::string frontend_command = "auto"; std::string backend_command = "auto"; std::vector<std::string> passes_commands; - std::vector<void*> loaded_modules; + std::vector<std::string> plugin_filenames; std::string output_filename = ""; std::string scriptfile = ""; bool scriptfile_tcl = false; @@ -82,11 +81,7 @@ int main(int argc, char **argv) passes_commands.push_back("opt"); break; case 'm': - loaded_modules.push_back(dlopen(optarg, RTLD_LAZY|RTLD_GLOBAL)); - if (loaded_modules.back() == NULL) { - fprintf(stderr, "Can't load module `%s': %s\n", optarg, dlerror()); - exit(1); - } + plugin_filenames.push_back(optarg); break; case 'f': frontend_command = optarg; @@ -239,6 +234,9 @@ int main(int argc, char **argv) yosys_setup(); + for (auto &fn : plugin_filenames) + load_plugin(fn, {}); + if (optind == argc && passes_commands.size() == 0 && scriptfile.empty()) { if (!got_output_filename) backend_command = ""; @@ -346,9 +344,6 @@ int main(int argc, char **argv) yosys_shutdown(); - for (auto mod : loaded_modules) - dlclose(mod); - return 0; } diff --git a/kernel/yosys.cc b/kernel/yosys.cc index 599c92d52..ce2487314 100644 --- a/kernel/yosys.cc +++ b/kernel/yosys.cc @@ -22,6 +22,7 @@ #include <readline/readline.h> #include <readline/history.h> +#include <dlfcn.h> #include <unistd.h> #include <limits.h> @@ -98,6 +99,12 @@ void yosys_shutdown() yosys_tcl_interp = NULL; } #endif + + for (auto &it : loaded_plugins) + dlclose(it.second); + + loaded_plugins.clear(); + loaded_plugin_aliases.clear(); } RTLIL::IdString new_id(std::string file, int line, std::string func) diff --git a/kernel/yosys.h b/kernel/yosys.h index 79c90628c..c6cbcabc9 100644 --- a/kernel/yosys.h +++ b/kernel/yosys.h @@ -132,6 +132,11 @@ extern const char *yosys_version_str; extern std::map<std::string, RTLIL::Design*> saved_designs; extern std::vector<RTLIL::Design*> pushed_designs; +// from passes/cmds/pluginc.cc +extern std::map<std::string, void*> loaded_plugins; +extern std::map<std::string, std::string> loaded_plugin_aliases; +void load_plugin(std::string filename, std::vector<std::string> aliases); + YOSYS_NAMESPACE_END #endif |