|
KiCad PCB EDA Suite
|
Responsible for loading plugin definitions for API-based plugins (ones that do not run inside KiCad itself, but instead are launched as external processes by KiCad) More...
#include <api_plugin_manager.h>
Classes | |
| struct | JOB |
Public Member Functions | |
| API_PLUGIN_MANAGER (wxEvtHandler *aParent) | |
| void | ReloadPlugins (std::optional< wxString > aDirectoryToScan=std::nullopt) |
| Clears the loaded plugins and actions and re-scans the filesystem to register new ones. | |
| void | RecreatePluginEnvironment (const wxString &aIdentifier) |
| void | InvokeAction (const wxString &aIdentifier) |
| int | InvokeActionSync (const wxString &aIdentifier, std::vector< wxString > aExtraArgs, wxString *aStdout=nullptr, wxString *aStderr=nullptr) |
| Invokes an action synchronously, capturing its output. | |
| bool | Busy () const |
| std::optional< const PLUGIN_ACTION * > | GetAction (const wxString &aIdentifier) |
| std::vector< const PLUGIN_ACTION * > | GetActionsForScope (PLUGIN_ACTION_SCOPE aScope) |
| std::map< int, wxString > & | ButtonBindings () |
| std::map< int, wxString > & | MenuBindings () |
Private Types | |
| enum class | JOB_TYPE { CREATE_ENV , SETUP_ENV , INSTALL_REQUIREMENTS } |
Private Member Functions | |
| void | processPluginDependencies () |
| void | processNextJob (wxCommandEvent &aEvent) |
| int | doInvokeAction (const wxString &aIdentifier, std::vector< wxString > aExtraArgs, bool aSync=false, wxString *aStdout=nullptr, wxString *aStderr=nullptr) |
Private Attributes | |
| wxEvtHandler * | m_parent |
| std::set< std::unique_ptr< API_PLUGIN >, CompareApiPluginIdentifiers > | m_plugins |
| std::map< wxString, const API_PLUGIN * > | m_pluginsCache |
| std::map< wxString, const PLUGIN_ACTION * > | m_actionsCache |
| std::map< wxString, wxString > | m_environmentCache |
| Map of plugin identifier to a path for the plugin's virtual environment, if it has one. | |
| std::map< int, wxString > | m_buttonBindings |
| Map of button wx item id to action identifier. | |
| std::map< int, wxString > | m_menuBindings |
| Map of menu wx item id to action identifier. | |
| std::set< wxString > | m_readyPlugins |
| std::set< wxString > | m_busyPlugins |
| std::deque< JOB > | m_jobs |
| std::unique_ptr< JSON_SCHEMA_VALIDATOR > | m_schema_validator |
| long | m_lastPid |
| wxTimer * | m_raiseTimer |
Responsible for loading plugin definitions for API-based plugins (ones that do not run inside KiCad itself, but instead are launched as external processes by KiCad)
Definition at line 43 of file api_plugin_manager.h.
|
strongprivate |
| Enumerator | |
|---|---|
| CREATE_ENV | |
| SETUP_ENV | |
| INSTALL_REQUIREMENTS | |
Definition at line 112 of file api_plugin_manager.h.
| API_PLUGIN_MANAGER::API_PLUGIN_MANAGER | ( | wxEvtHandler * | aParent | ) |
Definition at line 45 of file api_plugin_manager.cpp.
References FN_NORMALIZE_FLAGS, PATHS::GetStockDataPath(), m_lastPid, m_parent, m_raiseTimer, m_schema_validator, and processNextJob().
| bool API_PLUGIN_MANAGER::Busy | ( | ) | const |
Definition at line 752 of file api_plugin_manager.cpp.
References m_busyPlugins, and m_jobs.
|
inline |
Definition at line 78 of file api_plugin_manager.h.
References m_buttonBindings.
Referenced by EDA_DRAW_FRAME::AddApiPluginTools(), and EDA_DRAW_FRAME::OnApiPluginInvoke().
|
private |
Definition at line 227 of file api_plugin_manager.cpp.
References PLUGIN_ACTION::args, API_PLUGIN::BasePath(), PLUGIN_ACTION::entrypoint, EXEC, PYTHON_MANAGER::Execute(), PYTHON_MANAGER::ExecuteSync(), FindKicadFile(), PYTHON_MANAGER::GetPythonEnvironment(), PYTHON_MANAGER::GetVirtualPython(), API_PLUGIN::Identifier(), PLUGIN_ACTION::identifier, m_actionsCache, m_lastPid, m_raiseTimer, m_readyPlugins, Pgm(), PLUGIN_ACTION::plugin, PYTHON, API_PLUGIN::Runtime(), traceApi, and PLUGIN_RUNTIME::type.
Referenced by InvokeAction(), and InvokeActionSync().
| std::optional< const PLUGIN_ACTION * > API_PLUGIN_MANAGER::GetAction | ( | const wxString & | aIdentifier | ) |
Definition at line 218 of file api_plugin_manager.cpp.
References m_actionsCache.
Referenced by PLUGINS_GRID_TRICKS::doPopupSelection(), PLUGINS_GRID_TRICKS::showPopupMenu(), and PANEL_PCBNEW_ACTION_PLUGINS::TransferDataFromWindow().
| std::vector< const PLUGIN_ACTION * > API_PLUGIN_MANAGER::GetActionsForScope | ( | PLUGIN_ACTION_SCOPE | aScope | ) |
Definition at line 448 of file api_plugin_manager.cpp.
References m_actionsCache, and m_readyPlugins.
Referenced by EDA_DRAW_FRAME::GetOrderedPluginActions(), and FOOTPRINT_WIZARD_MANAGER::ReloadWizards().
| void API_PLUGIN_MANAGER::InvokeAction | ( | const wxString & | aIdentifier | ) |
Definition at line 435 of file api_plugin_manager.cpp.
References doInvokeAction().
Referenced by EDA_DRAW_FRAME::OnApiPluginInvoke().
| int API_PLUGIN_MANAGER::InvokeActionSync | ( | const wxString & | aIdentifier, |
| std::vector< wxString > | aExtraArgs, | ||
| wxString * | aStdout = nullptr, | ||
| wxString * | aStderr = nullptr ) |
Invokes an action synchronously, capturing its output.
Mainly used for things like wizards that have actions that return quickly and pass data to KiCad via stdout.
| aIdentifier | is the plugin action to invoke |
| aExtraArgs | are extra arguments to pass to the action beyond the ones specified in the plugin configuration file |
| aStdout | is a pointer to a string to fill with the stdout output of the action |
| aStderr | is a pointer to a string to fill with the stderr output of the action |
Definition at line 441 of file api_plugin_manager.cpp.
References doInvokeAction().
Referenced by FOOTPRINT_WIZARD_MANAGER::Generate(), and FOOTPRINT_WIZARD_MANAGER::RefreshInfo().
|
inline |
Definition at line 80 of file api_plugin_manager.h.
References m_menuBindings.
|
private |
Definition at line 534 of file api_plugin_manager.cpp.
References CREATE_ENV, EDA_EVT_PLUGIN_AVAILABILITY_CHANGED, API_PLUGIN_MANAGER::JOB::env_path, PYTHON_MANAGER::Execute(), FindKicadFile(), PYTHON_MANAGER::GetPythonEnvironment(), PYTHON_MANAGER::GetVirtualPython(), API_PLUGIN_MANAGER::JOB::identifier, INSTALL_REQUIREMENTS, m_busyPlugins, m_jobs, m_readyPlugins, Pgm(), API_PLUGIN_MANAGER::JOB::plugin_path, SETUP_ENV, traceApi, and API_PLUGIN_MANAGER::JOB::type.
Referenced by API_PLUGIN_MANAGER().
|
private |
Definition at line 465 of file api_plugin_manager.cpp.
References CREATE_ENV, API_PLUGIN_MANAGER::JOB::env_path, PYTHON_MANAGER::GetPythonEnvironment(), API_PLUGIN_MANAGER::JOB::identifier, INSTALL_REQUIREMENTS, m_busyPlugins, m_environmentCache, m_jobs, m_plugins, m_readyPlugins, API_PLUGIN_MANAGER::JOB::plugin_path, PYTHON, traceApi, and API_PLUGIN_MANAGER::JOB::type.
Referenced by ReloadPlugins().
| void API_PLUGIN_MANAGER::RecreatePluginEnvironment | ( | const wxString & | aIdentifier | ) |
Definition at line 185 of file api_plugin_manager.cpp.
References API_PLUGIN::BasePath(), CREATE_ENV, API_PLUGIN_MANAGER::JOB::env_path, PYTHON_MANAGER::GetPythonEnvironment(), API_PLUGIN::Identifier(), API_PLUGIN_MANAGER::JOB::identifier, m_jobs, m_pluginsCache, API_PLUGIN_MANAGER::JOB::plugin_path, traceApi, and API_PLUGIN_MANAGER::JOB::type.
Referenced by PLUGINS_GRID_TRICKS::doPopupSelection().
| void API_PLUGIN_MANAGER::ReloadPlugins | ( | std::optional< wxString > | aDirectoryToScan = std::nullopt | ) |
Clears the loaded plugins and actions and re-scans the filesystem to register new ones.
| aDirectoryToScan | can be provided to scan an arbitrary directory instead of the stock paths; provided for QA testing. |
Definition at line 90 of file api_plugin_manager.cpp.
References EDA_EVT_PLUGIN_AVAILABILITY_CHANGED, PATHS::GetDefault3rdPartyPath(), PGM_BASE::GetLocalEnvVariables(), PATHS::GetStockPluginsPath(), PATHS::GetUserPluginsPath(), ENV_VAR::GetVersionedEnvVarValue(), m_actionsCache, m_buttonBindings, m_environmentCache, m_menuBindings, m_parent, m_plugins, m_pluginsCache, m_readyPlugins, m_schema_validator, Pgm(), processPluginDependencies(), and traceApi.
Referenced by PANEL_PCBNEW_ACTION_PLUGINS::OnReloadButtonClick().
|
private |
Definition at line 97 of file api_plugin_manager.h.
Referenced by doInvokeAction(), GetAction(), GetActionsForScope(), and ReloadPlugins().
|
private |
Definition at line 110 of file api_plugin_manager.h.
Referenced by Busy(), processNextJob(), and processPluginDependencies().
|
private |
Map of button wx item id to action identifier.
Definition at line 103 of file api_plugin_manager.h.
Referenced by ButtonBindings(), and ReloadPlugins().
|
private |
Map of plugin identifier to a path for the plugin's virtual environment, if it has one.
Definition at line 100 of file api_plugin_manager.h.
Referenced by processPluginDependencies(), and ReloadPlugins().
|
private |
Definition at line 127 of file api_plugin_manager.h.
Referenced by Busy(), processNextJob(), processPluginDependencies(), and RecreatePluginEnvironment().
|
private |
Definition at line 131 of file api_plugin_manager.h.
Referenced by API_PLUGIN_MANAGER(), and doInvokeAction().
|
private |
Map of menu wx item id to action identifier.
Definition at line 106 of file api_plugin_manager.h.
Referenced by MenuBindings(), and ReloadPlugins().
|
private |
Definition at line 91 of file api_plugin_manager.h.
Referenced by API_PLUGIN_MANAGER(), and ReloadPlugins().
|
private |
Definition at line 93 of file api_plugin_manager.h.
Referenced by processPluginDependencies(), and ReloadPlugins().
|
private |
Definition at line 95 of file api_plugin_manager.h.
Referenced by RecreatePluginEnvironment(), and ReloadPlugins().
|
private |
Definition at line 132 of file api_plugin_manager.h.
Referenced by API_PLUGIN_MANAGER(), and doInvokeAction().
|
private |
Definition at line 108 of file api_plugin_manager.h.
Referenced by doInvokeAction(), GetActionsForScope(), processNextJob(), processPluginDependencies(), and ReloadPlugins().
|
private |
Definition at line 129 of file api_plugin_manager.h.
Referenced by API_PLUGIN_MANAGER(), and ReloadPlugins().