From 3a3a4405ef306f7489f4454e77a376571d6841ed Mon Sep 17 00:00:00 2001 From: Mahfuza Date: Tue, 13 Jun 2023 14:30:32 +0600 Subject: [PATCH 1/4] update loadable plugin section Signed-off-by: Mahfuza --- docs/contribute/plugin/intro.md | 55 +++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/docs/contribute/plugin/intro.md b/docs/contribute/plugin/intro.md index 08cf4a09a..718ec2624 100644 --- a/docs/contribute/plugin/intro.md +++ b/docs/contribute/plugin/intro.md @@ -14,9 +14,60 @@ In current, developers can follow the guides to implement the plug-ins in [C API ## Loadable Plug-in -Loadable plugin is a standalone `.so`/`.dylib`/`.dll` file that WasmEdge can load during runtime environment, and provide modules to be imported. +Loadable plugins are standalone shared libraries (`.so`/`.dylib`/`.dll` files) that can be loaded by the WasmEdge runtime environment at runtime. These plugins can provide additional functionality to the WasmEdge runtime environment, such as new modules that can be imported by WebAssembly modules. -Please [refer to the plugin example code](https://github.com/WasmEdge/WasmEdge/tree/master/examples/plugin/get-string). +To create a loadable plugin for WasmEdge, developers can use the WasmEdge Plugin SDK, which provides a set of Rust, C and C++ APIs for creating and registering plugins. The SDK also includes [example code](https://github.com/WasmEdge/WasmEdge/tree/master/examples/plugin/get-string) that demonstrates how to create a simple plugin that returns a string. + +Once a loadable plugin has been created, it can be loaded by the WasmEdge runtime environment using the `WasmEdge_LoadWasmFromFile` or `WasmEdge_LoadWasmFromBuffer` API. The plugin can then be used to provide functionality to WebAssembly modules, such as access to system resources or specialized hardware. + +### Load plug-ins from paths + +To make use of the plug-ins, developers should first load them from specific paths. + +```c +WasmEdge_PluginLoadWithDefaultPaths(); +``` + +After calling this API, the plug-ins located in the default paths will be loaded. The default paths include: + +1. The path given in the environment variable `WASMEDGE_PLUGIN_PATH`. +2. The `../plugin/` directory related to the WasmEdge installation path. +3. The `./wasmedge/` directory under the library path if the WasmEdge is installed in the system directory (such as `/usr` and `/usr/local`). + +To load the plug-ins from a specific path or under a specific directory, developers can use the following API: + +```c +WasmEdge_PluginLoadFromPath("PATH_TO_PLUGIN/plugin.so"); +``` + +Here's a flowchart that shows the basic steps involved in creating and using a loadable plugin in WasmEdge: + +
+
+ graph TD + A[Create Plugin] + B[Compile Plugin] + C[Load Plugin] + D[Register Plugin] + E[Load WebAssembly Module] + F[Import Plugin Module] + G[Execute WebAssembly Module] + A --> B + B --> C + C --> D + D --> E + E --> F + F --> G +
+
+ +This flowchart shows the basic steps involved in creating and using a loadable plugin in WasmEdge. The first step is to create the plugin, which involves writing the code for the plugin functions and compiling the code into a shared library. + +The WasmEdge runtime loads the plugin from specific paths, including the environment variable *WASMEDGE_PLUGIN_PATH*, the `../plugin/` directory related to the WasmEdge installation path, and the `./wasmedge/` directory if WasmEdge is installed in a system directory. The plugin can then be registered with the runtime environment for subsequent usage using the `WasmEdge_RegisterImport` API. + +After the plugin has been registered, a WebAssembly module can be loaded using the `WasmEdge_LoadWasmFromFile` or `WasmEdge_LoadWasmFromBuffer` API. The module can then import the plugin module using the `WasmEdge_VMRegisterModule` API. + +Finally, the WebAssembly module can execute its functions, which may call the functions provided by the plugin module. The plugin functions can then perform their specific tasks, such as accessing system resources or specialized hardware. ## WasmEdge Currently Released Plug-ins From 503219050511f724638a205ba404ae4be67fec2f Mon Sep 17 00:00:00 2001 From: Mahfuza Date: Wed, 14 Jun 2023 06:41:47 +0600 Subject: [PATCH 2/4] update flowchart and format Signed-off-by: Mahfuza --- docs/contribute/plugin/intro.md | 68 ++++++++++++++------------------- 1 file changed, 28 insertions(+), 40 deletions(-) diff --git a/docs/contribute/plugin/intro.md b/docs/contribute/plugin/intro.md index 718ec2624..d1dea69ef 100644 --- a/docs/contribute/plugin/intro.md +++ b/docs/contribute/plugin/intro.md @@ -16,58 +16,46 @@ In current, developers can follow the guides to implement the plug-ins in [C API Loadable plugins are standalone shared libraries (`.so`/`.dylib`/`.dll` files) that can be loaded by the WasmEdge runtime environment at runtime. These plugins can provide additional functionality to the WasmEdge runtime environment, such as new modules that can be imported by WebAssembly modules. -To create a loadable plugin for WasmEdge, developers can use the WasmEdge Plugin SDK, which provides a set of Rust, C and C++ APIs for creating and registering plugins. The SDK also includes [example code](https://github.com/WasmEdge/WasmEdge/tree/master/examples/plugin/get-string) that demonstrates how to create a simple plugin that returns a string. +### Creating Loadable Plug-in -Once a loadable plugin has been created, it can be loaded by the WasmEdge runtime environment using the `WasmEdge_LoadWasmFromFile` or `WasmEdge_LoadWasmFromBuffer` API. The plugin can then be used to provide functionality to WebAssembly modules, such as access to system resources or specialized hardware. +To create a loadable plugin for WasmEdge, developers can use the WasmEdge Plugin SDK, which provides a set of Rust, C and C++ APIs for creating and registering plugins. The SDK also includes [example code](https://github.com/WasmEdge/WasmEdge/tree/master/examples/plugin/get-string) that demonstrates how to create a simple plugin that returns a string. By following the provided examples and leveraging the SDK's APIs, developers can easily build custom plugins tailored to their specific needs. -### Load plug-ins from paths +### Loading plug-in from paths -To make use of the plug-ins, developers should first load them from specific paths. +To make use of the loadable plugins, developers need to load them from specific paths into the WasmEdge runtime environment. The loading process involves the following steps: -```c -WasmEdge_PluginLoadWithDefaultPaths(); -``` - -After calling this API, the plug-ins located in the default paths will be loaded. The default paths include: +- Loadable plugins can be loaded from default paths by calling the `WasmEdge_PluginLoadWithDefaultPaths()` API. The default paths include: + + - The path specified in the environment variable `WASMEDGE_PLUGIN_PATH`. + - The `../plugin/` directory relative to the WasmEdge installation path. + - The `./wasmedge/` directory located under the library path if WasmEdge is installed in a system directory such as `/usr` and `/usr/local`. +- If the plugins are located in a specific path or directory, developers can use the `WasmEdge_PluginLoadFromPath("PATH_TO_PLUGIN/plugin.so")` API to load the plugins from that particular location. -1. The path given in the environment variable `WASMEDGE_PLUGIN_PATH`. -2. The `../plugin/` directory related to the WasmEdge installation path. -3. The `./wasmedge/` directory under the library path if the WasmEdge is installed in the system directory (such as `/usr` and `/usr/local`). +The WasmEdge runtime environment will search for the loadable plugins in the specified paths and load them if found. -To load the plug-ins from a specific path or under a specific directory, developers can use the following API: +### Plugin Loading Flowchart -```c -WasmEdge_PluginLoadFromPath("PATH_TO_PLUGIN/plugin.so"); -``` +The following flowchart depicts the process of loading loadable plugins into the WasmEdge runtime environment from specific paths: -Here's a flowchart that shows the basic steps involved in creating and using a loadable plugin in WasmEdge: - -
-
- graph TD - A[Create Plugin] - B[Compile Plugin] - C[Load Plugin] - D[Register Plugin] - E[Load WebAssembly Module] - F[Import Plugin Module] - G[Execute WebAssembly Module] - A --> B - B --> C - C --> D - D --> E - E --> F +```mermaid +graph LR + A((Start)) --> B(Loadable Plugins) + B --> C{Load Plugins} + C --> D[Load from Default Paths] + C --> E[Load from Specific Path] + C --> F[Load from Specific Directory] + D --> G{Is Plugin Found?} + E --> G F --> G -
-
+ G -- Yes --> H(Load Plugin) + H --> I(End) + G -- No --> I -This flowchart shows the basic steps involved in creating and using a loadable plugin in WasmEdge. The first step is to create the plugin, which involves writing the code for the plugin functions and compiling the code into a shared library. - -The WasmEdge runtime loads the plugin from specific paths, including the environment variable *WASMEDGE_PLUGIN_PATH*, the `../plugin/` directory related to the WasmEdge installation path, and the `./wasmedge/` directory if WasmEdge is installed in a system directory. The plugin can then be registered with the runtime environment for subsequent usage using the `WasmEdge_RegisterImport` API. +``` -After the plugin has been registered, a WebAssembly module can be loaded using the `WasmEdge_LoadWasmFromFile` or `WasmEdge_LoadWasmFromBuffer` API. The module can then import the plugin module using the `WasmEdge_VMRegisterModule` API. +The flowchart shows the process of loading loadable plugins into the WasmEdge runtime environment. The process involves searching for plugins in default paths, a specific path, or a specific directory. If a plugin is found in any of these locations, it is loaded into the runtime environment. The flowchart enables developers to easily load plugins and extend the capabilities of the WasmEdge runtime. -Finally, the WebAssembly module can execute its functions, which may call the functions provided by the plugin module. The plugin functions can then perform their specific tasks, such as accessing system resources or specialized hardware. +By following this flowchart, developers can effectively load loadable plugins into the WasmEdge runtime environment from specific paths, expanding the runtime's functionality according to their requirements. ## WasmEdge Currently Released Plug-ins From 72d95acf74540e37999121f6adde8643b5120f06 Mon Sep 17 00:00:00 2001 From: Mahfuza Date: Thu, 6 Jul 2023 16:37:23 +0600 Subject: [PATCH 3/4] updating format Signed-off-by: Mahfuza --- docs/contribute/plugin/intro.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/contribute/plugin/intro.md b/docs/contribute/plugin/intro.md index d1dea69ef..9ac1112dc 100644 --- a/docs/contribute/plugin/intro.md +++ b/docs/contribute/plugin/intro.md @@ -24,12 +24,13 @@ To create a loadable plugin for WasmEdge, developers can use the WasmEdge Plugin To make use of the loadable plugins, developers need to load them from specific paths into the WasmEdge runtime environment. The loading process involves the following steps: -- Loadable plugins can be loaded from default paths by calling the `WasmEdge_PluginLoadWithDefaultPaths()` API. The default paths include: - - - The path specified in the environment variable `WASMEDGE_PLUGIN_PATH`. - - The `../plugin/` directory relative to the WasmEdge installation path. - - The `./wasmedge/` directory located under the library path if WasmEdge is installed in a system directory such as `/usr` and `/usr/local`. -- If the plugins are located in a specific path or directory, developers can use the `WasmEdge_PluginLoadFromPath("PATH_TO_PLUGIN/plugin.so")` API to load the plugins from that particular location. +- Loadable plugins can be loaded from default paths by calling the `WasmEdge_PluginLoadWithDefaultPaths()` API. The default paths include: + + - The path specified in the environment variable `WASMEDGE_PLUGIN_PATH`. + - The `../plugin/` directory relative to the WasmEdge installation path. + - The `./wasmedge/` directory located under the library path if WasmEdge is installed in a system directory such as `/usr` and `/usr/local`. + +- If the plugins are located in a specific path or directory, developers can use the `WasmEdge_PluginLoadFromPath("PATH_TO_PLUGIN/plugin.so")` API to load the plugins from that particular location. The WasmEdge runtime environment will search for the loadable plugins in the specified paths and load them if found. From 74791e76162f8b2dd7a4a9eb01cc326bc9a6cee6 Mon Sep 17 00:00:00 2001 From: Mahfuza Humayra Mohona Date: Thu, 6 Jul 2023 19:52:22 +0600 Subject: [PATCH 4/4] Updated format Signed-off-by: Mahfuza --- docs/contribute/plugin/intro.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/contribute/plugin/intro.md b/docs/contribute/plugin/intro.md index 9ac1112dc..515c64e1c 100644 --- a/docs/contribute/plugin/intro.md +++ b/docs/contribute/plugin/intro.md @@ -24,13 +24,13 @@ To create a loadable plugin for WasmEdge, developers can use the WasmEdge Plugin To make use of the loadable plugins, developers need to load them from specific paths into the WasmEdge runtime environment. The loading process involves the following steps: -- Loadable plugins can be loaded from default paths by calling the `WasmEdge_PluginLoadWithDefaultPaths()` API. The default paths include: +- Loadable plugins can be loaded from default paths by calling the `WasmEdge_PluginLoadWithDefaultPaths()` API. The default paths include: - - The path specified in the environment variable `WASMEDGE_PLUGIN_PATH`. - - The `../plugin/` directory relative to the WasmEdge installation path. - - The `./wasmedge/` directory located under the library path if WasmEdge is installed in a system directory such as `/usr` and `/usr/local`. + - The path specified in the environment variable `WASMEDGE_PLUGIN_PATH`. + - The `../plugin/` directory relative to the WasmEdge installation path. + - The `./wasmedge/` directory located under the library path if WasmEdge is installed in a system directory such as `/usr` and `/usr/local`. -- If the plugins are located in a specific path or directory, developers can use the `WasmEdge_PluginLoadFromPath("PATH_TO_PLUGIN/plugin.so")` API to load the plugins from that particular location. +- If the plugins are located in a specific path or directory, developers can use the `WasmEdge_PluginLoadFromPath("PATH_TO_PLUGIN/plugin.so")` API to load the plugins from that particular location. The WasmEdge runtime environment will search for the loadable plugins in the specified paths and load them if found. @@ -51,7 +51,6 @@ graph LR G -- Yes --> H(Load Plugin) H --> I(End) G -- No --> I - ``` The flowchart shows the process of loading loadable plugins into the WasmEdge runtime environment. The process involves searching for plugins in default paths, a specific path, or a specific directory. If a plugin is found in any of these locations, it is loaded into the runtime environment. The flowchart enables developers to easily load plugins and extend the capabilities of the WasmEdge runtime.