Skip to content

Commit

Permalink
updating changes
Browse files Browse the repository at this point in the history
Signed-off-by: Mahfuza <[email protected]>
  • Loading branch information
mhmohona committed Jul 5, 2023
1 parent 5216209 commit 54def63
Show file tree
Hide file tree
Showing 7 changed files with 319 additions and 12 deletions.
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"cSpell.words": ["bytecode", "CNCF", "Emscripten", "wasmedge"]
"cSpell.words": [
"bytecode",
"CNCF",
"Emscripten",
"wasmedge"
],
"docwriter.style": "Auto-detect"
}
2 changes: 1 addition & 1 deletion docs/contribute/plugin/Develop Plugin in C/_category_.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "WasmEdge Plugin System in C",
"label": "WasmEdge Plugin in C",
"position": 2,
"link": {
"type": "generated-index",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ To create a plug-in with host functions and modules, follow these steps:

Therefore, developers can implement their plug-in host functions first, as the same as the [host functions in WasmEdge C API](/embed/c/reference/0.12.0.md#host-functions).

> For the more details about the [external data](/embed/c/host_function.md#host-data) and [calling frame context](/embed/c/host_function.md#calling-frame-context), please refer to the host function guide.
> For the more details about the [external data](/embed/c/host_function.md#host-data) and [calling frame context](/embed/c/host_function.md#calling-frame-context), please refer to the host function guide.

Here's an example of two host functions, `HostFuncAdd` and `HostFuncSub`, that add and subtract two `int32_t` numbers respectively:
Expand Down Expand Up @@ -236,6 +236,8 @@ Remember to implement any additional functions or structures that your plugin re
By following these steps and implementing the necessary functions and descriptors, you can create a plug-in with host functions and modules in WasmEdge C API. You can continue developing your plugin by adding functionality and implementing the desired behavior.
- **Plugin option** - *WORK IN PROGRESS. This section is reserved for the feature in the future.*
## Build your plugin
To build the WasmEdge plug-in shared library, you have two options: building it directly using the compiler or using CMake. Here are the instructions for both methods:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"label": "WasmEdge Plugin System in C++",
"label": "WasmEdge Plugin in C++",
"position": 3,
"link": {
"type": "generated-index",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
sidebar_position: 2
---

# Develop WasmEdge Plug-in in C API
# Develop WasmEdge Plug-in in C++ API

By developing a plugin, one can extend the functionality of WasmEdge and customize it to suit the specific needs. WasmEdge provides a C++ based API for registering extension modules and host functions. While the WasmEdge language SDKs allow registering host functions from a host (wrapping) application, the plugin API allows such extensions to be incorporated into WasmEdge's own building and releasing process.

> It is recommended that developers choose the WasmEdge [C API](develop_plugin_c.md) for plugin development because of the support, compatibility and flexibility provided by the WasmEdge runtime.
Here is a flowchart showing all the steps needed for developing WasmEdge Plugin -

```mermaid
graph TD;
B[Developing WasmEdge Plugin in C]
B[Developing WasmEdge Plugin in C++]
B --> E(Set up development environment)
E --> F(Create project directory)
E --> G(Add configuration files)
Expand All @@ -32,13 +35,13 @@ This flowchart illustrates the process of developing a WasmEdge plugin, showcasi

To start developing WasmEdge plugins, it is essential to set up the development environment properly. This section provides step-by-step instructions for WasmEdge plugin development -

- **Install a WasmEdge runtime**: You can download the latest version of WasmEdge from [GitHub repository](https://github.com/wasmEdge/wasmEdge). Here are the installation instructions for different operating system for [installing WasmEdge](/develop/build-and-run/install.md).
- **Build WasmEdge from source**- For developing WasmEdge plugin in C++ language, you will need to build WasmEdge from source. Follow the[build WasmEdge from source](../source/build_from_src.md) for instructions.

- **Install WasmEdge with plugins (optional)**: Installing WasmEdge with existing plugins can provide you with additional functionality and serve as a reference for your own plugin development. If you want to utilize or test the compatibility of your new plugin with existing plugins, you can install them using the provided installer script. The installed plugins will be available for your development environment.

To see a list of supported plugins and their specific install commands, see the [Install WasmEdge plugins and dependencies](develop/build-and-run/install/#install-wasmedge-plugins-and-dependencies) section.

- **Install a compatible compiler**: The following compilers can be used to compile C code into WebAssembly bytecode:
- **Install a compatible compiler**: The following compilers can be used to compile C++ code into WebAssembly bytecode:

- LLVM: `sudo apt-get install llvm`
- GCC: `sudo apt-get install gcc`
Expand Down Expand Up @@ -96,10 +99,6 @@ To create a plug-in with host functions and modules, follow these steps:

- **Implement host function definitions**: In this step, you need to define the host functions that will be imported when instantiating the WASM module. These functions will perform specific operations and return results.

Therefore, developers can implement their plug-in host functions first, as the same as the [host functions in WasmEdge C API](/embed/c/reference/0.12.0.md#host-functions).

> For the more details about the [external data](/embed/c/host_function.md#host-data) and [calling frame context](/embed/c/host_function.md#calling-frame-context), please refer to the host function guide.

Here's an example of two host functions, `HostFuncAdd` and `HostFuncSub`, that add and subtract two `int32_t` numbers respectively:
```c
Expand Down
8 changes: 8 additions & 0 deletions docs/contribute/plugin/Develop Plugin in Rust/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "WasmEdge Plugin in Rust",
"position": 3,
"link": {
"type": "generated-index",
"description": "We will learn how to develop the WasmEdge Plugin System in Rust Language."
}
}
Loading

0 comments on commit 54def63

Please sign in to comment.