You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/contribute/installer.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -134,7 +134,7 @@ The actual installer handles all stuff. It supports python2.7 (not tested on ear
134
134
- Full Option: `--dist ubuntu20.04` or `--dist manylinux2014`
135
135
- Note - the `ubuntu20.04` and `manylinux2014` values are case insensitive and only these two are currently supported.
136
136
- Note - Specifying `--dist` value for `Darwin` has no effect.
137
-
- Note - For `Linux` platform if the distribution matches exactly as `Ubuntu 20.04`, which is checked using `lsb_release` and python's `platform.dist()` functionality is then set to `ubuntu20.04` if not specified, or it is used without questioning. However different release packages for WasmEdge are available only after `0.11.1` release, below which there is no effect of specifying this option.
137
+
- Note - For `Linux` platform if the distribution matches exactly as `Ubuntu 20.04`, which is checked using `lsb_release` and python's `platform.dist()` functionality is then set to `ubuntu20.04` if not specified, or it is used without questioning. However different release packages for WasmEdge are available only after `0.11.1` release, below which there is no effect of specifying this option.
Copy file name to clipboardexpand all lines: docs/contribute/plugin/best_practice.md
+46-46
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,13 @@
2
2
sidebar_position: 6
3
3
---
4
4
5
-
# Best Practice
5
+
# Best Practice
6
6
7
7
When developing a WasmEdge plugin, it's important to follow best practices to ensure the plugin is well purformed, reliable, and efficient. Here are some key best practices to follow:
8
8
9
9
## Using the Latest Version of WasmEdge
10
10
11
-
Always use the latest version of WasmEdge to take advantage of the most recent features, improvements, and security updates.
11
+
Always use the latest version of WasmEdge to take advantage of the most recent features, improvements, and security updates.
12
12
13
13
### Installing the Latest Version
14
14
@@ -20,11 +20,10 @@ If you have existing plugins that were developed with an older version of WasmEd
20
20
21
21
Remember, using the latest version of WasmEdge not only ensures that you're leveraging the most recent features, but also provides the latest security updates to protect your applications.
22
22
23
-
24
23
## Choosing the Appropriate Programming Language
25
24
26
25
WasmEdge plugins can be developed in several languages including [C](develop_plugin_c.md), [C++](develop_plugin_cpp.md), and [Rust](develop_plugin_rustsdk.md). The choice of language depends on the specific requirements of the plugin and the developer's expertise. The C API is recommended for most use cases due to its simplicity and wide support. However, complex plugins might benefit from the enhanced features of C++ or Rust.
27
-
26
+
28
27
## Writing and Compiling the Plugin
29
28
30
29
When creating a WasmEdge plugin:
@@ -41,66 +40,66 @@ Testing is a crucial part of the plugin development process. It ensures that the
41
40
42
41
To run tests for the WasmEdge plugin, you'll need to follow a few steps. In this case, we'll use the `wasmedge-image` plugin as an example.
43
42
44
-
-**Step 1: Build the WasmEdge Runtime and WasmEdge-image Plugin**
43
+
-**Step 1: Build the WasmEdge Runtime and WasmEdge-image Plugin**
45
44
First, you need to build both the [build WasmEdge](../source/build_from_src.md) and the [wasmedge-image](../source/plugin/image.md) plugin.
46
45
47
-
-**Step 2: Run the Tests**
46
+
-**Step 2: Run the Tests**
48
47
The WasmEdge repository provides a set of tests for various plugins, including `wasmedge-image`. You can find the test cases in the `test/plugins/wasmedge_image` directory of the repository.
49
48
50
-
To run these tests, you can use the `ctest` command from the build directory:
49
+
To run these tests, you can use the `ctest` command from the build directory:
51
50
52
-
```bash
53
-
cd ../../../test/plugins/wasmedge_image
54
-
mkdir build && cd build
55
-
cmake ..
56
-
make
57
-
ctest
58
-
```
51
+
```bash
52
+
cd ../../../test/plugins/wasmedge_image
53
+
mkdir build &&cd build
54
+
cmake ..
55
+
make
56
+
ctest
57
+
```
59
58
60
-
This will run all the unit tests and integration tests for the `wasmedge-image`plugin. These tests ensure that the plugin behaves as expected, meets the requirements, and performs optimally. They also verify that the plugin correctly integrates with the WebAssembly program and that the WebAssembly program can call the plugin's functions correctly.
59
+
This will run all the unit tests and integration tests for the `wasmedge-image`plugin. These tests ensure that the plugin behaves as expected, meets the requirements, and performs optimally. They also verify that the plugin correctly integrates with the WebAssembly program and that the WebAssembly program can call the plugin's functions correctly.
61
60
62
-
-**Step 3: Analyze the Test Results**
61
+
-**Step 3: Analyze the Test Results**
63
62
After running the tests, analyze the results to identify any issues or bugs. If any test fails, you should debug the issue, fix the problem, and then rerun the tests to ensure that the fix works as expected.
64
63
65
64
By following these steps, you can effectively run tests for the `wasmedge-image` plugin or any other WasmEdge plugin.
66
65
67
66
<!-- prettier-ignore -->
68
67
:::note
69
68
If you want to develop your own tests follow [Writing Tests for WasmEdge Plugins](test_plugin.md) for details.
70
-
:::
69
+
:::
71
70
72
71
## Securing the Plugin
73
72
74
73
Security is a vital part of any software development process. It involves several aspects, including securing the code, verifying inputs, handling errors properly, and using secure coding practices. When developing a WasmEdge plugin, it's essential to follow these best practices:
75
74
76
-
-**Validate Inputs:** Always validate the inputs to your functions. This can prevent many types of attacks, including buffer overflow attacks and code injection attacks.
75
+
-**Validate Inputs:** Always validate the inputs to your functions. This can prevent many types of attacks, including buffer overflow attacks and code injection attacks.
if (In[0].Type != WasmEdge_ValType_I32 || In[1].Type != WasmEdge_ValType_I32) {
81
+
return WasmEdge_Result_Error;
85
82
}
86
-
```
87
-
88
-
-**Handle Errors:** Always handle errors properly. Don't ignore return values that indicate an error, and don't continue execution after an error occurs.
- **Handle Errors:** Always handle errors properly. Don't ignore return values that indicate an error, and don't continue execution after an error occurs.
-**Use Secure Coding Practices:** Follow secure coding practices in your chosen language. For example, avoid using unsafe functions, use strong types, and avoid using global variables.
102
+
-**Use Secure Coding Practices:** Follow secure coding practices in your chosen language. For example, avoid using unsafe functions, use strong types, and avoid using global variables.
104
103
105
104
## Publishing the Plugin
106
105
@@ -116,38 +115,39 @@ You can create a Rust library that provides a Rust interface to your plugin's fu
116
115
117
116
In the [wasmedge-image](../source/plugin/image.md) plugin's case, you might have something like this:
In this Rust library, a single `load_image` function is provided that calls the `open` function from the `wasmedge-image` plugin.
130
130
131
131
### Building the Rust Library
132
132
133
133
You can build your Rust library using Cargo, the Rust package manager. This will produce a `.so` file that can be loaded by the WasmEdge runtime.
134
134
135
-
```bash
135
+
```bash
136
136
cargo build --release
137
137
```
138
138
139
139
### Packaging the Rust SDK
140
140
141
141
Package the Rust library and the header file into a tarball or a similar package format. This makes it easy for other developers to download and install your SDK.
142
142
143
-
```bash
143
+
```bash
144
144
tar czvf wasmedge_image_rust_sdk.tar.gz libwasmedge_image.so wasmedge_image.h
145
145
```
146
146
147
147
With this package, other rust developers can easily use your plugin in their applications. They just need to include your header file in their code, and link against your rust library when they compile their application.
148
148
149
149
Now, when you're ready to publish your plugin and the corresponding SDK, can publish your plugin on the official WasmEdge [plugin repository](https://github.com/WasmEdge/WasmEdge/tree/master/plugins) by creating a pull request into it or any other repository of your choice. Make sure to include the documentation and any other resources (like test files) with your plugin.
150
-
150
+
151
151
## Contributing to the WasmEdge Community
152
152
153
153
As an open-source contributor, you can share your plugin with the community by submitting it to the official [WasmEdge repository](https://github.com/WasmEdge/WasmEdge). This allows others to benefit from your work.
Copy file name to clipboardexpand all lines: docs/contribute/plugin/intro.md
+1-22
Original file line number
Diff line number
Diff line change
@@ -73,25 +73,4 @@ By following this flowchart, developers can effectively load loadable plug-ins i
73
73
74
74
## WasmEdge Currently Released Plug-ins
75
75
76
-
There are several plug-in releases with the WasmEdge official releases. Please check the following table to check the release status and how to build from the source with the plug-ins.
|[WASI-Crypto][]|[wasi-crypto][]|`manylinux2014 x86_64`, `manylinux2014 aarch64`, and `ubuntu 20.04 x86_64` (since `0.10.1`) |[Build With WASI-Crypto](../source/plugin/wasi_crypto.md)|
82
-
|[WASI-NN with OpenVINO backend](../../develop/rust/wasinn/openvino.md)|[wasi-nn][]|`ubuntu 20.04 x86_64` (since `0.10.1`) |[Build With WASI-NN](../source/plugin/wasi_nn.md#build-wasmedge-with-wasi-nn-openvino-backend)|
83
-
|[WASI-NN with PyTorch backend](../../develop/rust/wasinn/pytorch.md)|[wasi-nn][]|`ubuntu 20.04 x86_64` (since `0.11.1`) |[Build With WASI-NN](../source/plugin/wasi_nn#build-wasmedge-with-wasi-nn-pytorch-backend)|
84
-
|[WASI-NN with TensorFlow-Lite backend](../../develop/rust/wasinn/tensorflow_lite.md)|[wasi-nn][]|`manylinux2014 x86_64`, `manylinux2014 aarch64`, and `ubuntu 20.04 x86_64` (since `0.11.2`) |[Build With WASI-NN](../source/plugin/wasi_nn#build-wasmedge-with-wasi-nn-tensorflow-lite-backend)|
85
-
|[WasmEdge-Image](../source/plugin/image.md)|[wasmedge_tensorflow_interface][]|`manylinux2014 x86_64`, `manylinux2014 aarch64`, `ubuntu 20.04 x86_64`, `darwin x86_64`, and `darwin arm64` (since `0.13.0`) |[Build With WasmEdge-Image](../source/plugin/image.md)|
86
-
|[WasmEdge-Tensorflow](../source/plugin/tensorflow.md)|[wasmedge_tensorflow_interface][]|`manylinux2014 x86_64`, `manylinux2014 aarch64`, `ubuntu 20.04 x86_64`, `darwin x86_64`, and `darwin arm64` (since `0.13.0`) |[Build With WasmEdge-Tensorflow](../source/plugin/tensorflow.md)|
87
-
|[WasmEdge-TensorflowLite](../source/plugin/tensorflowlite.md)|[wasmedge_tensorflow_interface][]|`manylinux2014 x86_64`, `manylinux2014 aarch64`, `ubuntu 20.04 x86_64`, `darwin x86_64`, and `darwin arm64` (since `0.13.0`) |[Build With WasmEdge-TensorflowLite](../source/plugin/tensorflowlite.md)|
88
-
89
-
<!-- prettier-ignore -->
90
-
:::note
91
-
Due to the `OpenVINO` dependency, we only release the WASI-NN plug-in for the `OpenVINO` backend on `Ubuntu 20.04 x86_64` now. We'll work with `manylinux2014` versions in the future.
Copy file name to clipboardexpand all lines: docs/contribute/plugin/test_plugin.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -62,4 +62,4 @@ If everything is set up correctly, this will compile your tests, run them, and r
62
62
63
63
Remember, testing is an iterative process. As you develop new features or fix bugs, you should also update your tests to reflect these changes. This will ensure that your plugin continues to work as expected as it evolves.
64
64
65
-
We hope this guide helps you get started with writing tests for your WasmEdge plugins!
65
+
We hope this guide helps you get started with writing tests for your WasmEdge plugins!
Copy file name to clipboardexpand all lines: docs/contribute/source/build_from_src.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,7 @@ WasmEdge provides various tools for enabling different runtime environments for
51
51
Developers can set the CMake options to customize the WasmEdge building.
52
52
53
53
1.`WASMEDGE_BUILD_TESTS`: build the WasmEdge tests. Default is `OFF`.
54
-
2.`WASMEDGE_BUILD_AOT_RUNTIME`: build with the Ahead-of-Time compiler supporting. Default is `ON`.
54
+
2.`WASMEDGE_USE_LLVM`: build with LLVM-based runtime for supporting Ahead-of-Time and Just-In-Time compiler. Default is `ON`.
55
55
3.`WASMEDGE_BUILD_SHARED_LIB`: build the WasmEdge shared library (`libwasmedge.so`, `libwasmedge.dylib`, or `wasmedge.dll`). Default is `ON`.
56
56
- By default, the WasmEdge shared library will link to the LLVM shared library.
57
57
4.`WASMEDGE_BUILD_STATIC_LIB`: build the WasmEdge static library (`libwasmedge.a`, Linux and MacOS platforms, experimental). Default is `OFF`.
@@ -60,7 +60,7 @@ Developers can set the CMake options to customize the WasmEdge building.
60
60
- For linking with `libwasmedge.a`, developers should also add the `-ldl`, `-pthread`, `-lm`, and `-lstdc++` linker options on both Linux and MacOS platforms, and `-lrt` on Linux platforms.
61
61
5.`WASMEDGE_BUILD_TOOLS`: build the `wasmedge` and `wasmedgec` tools. Default is `ON`.
62
62
- The `wasmedge` and `wasmedgec` tools will link to the WasmEdge shared library by default.
63
-
- If this option is set as `ON` and `WASMEDGE_BUILD_AOT_RUNTIME` is set as `OFF`, the `wasmedgec` tool for the AOT compiler will not be built.
63
+
- If this option is set as `ON` and `WASMEDGE_USE_LLVM` is set as `OFF`, the `wasmedgec` tool for the AOT compiler will not be built.
64
64
- If this option is set as `ON` but the option `WASMEDGE_LINK_TOOLS_STATIC` is set as `OFF`, the option `WASMEDGE_BUILD_SHARED_LIB` will forcefully be set as `ON`.
65
65
- If this option and the option `WASMEDGE_LINK_TOOLS_STATIC` are both set as `ON`, the `WASMEDGE_LINK_LLVM_STATIC` and `WASMEDGE_BUILD_STATIC_LIB` will both be set as `ON`, and the `wasmedge` and `wasmedgec` tools will link to the WasmEdge static library instead. In this case, the plug-ins will not work in tools.
66
66
6.`WASMEDGE_BUILD_PLUGINS`: build the WasmEdge plug-ins. Default is `ON`.
0 commit comments