Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/scripts/wasmedge_image/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright The WasmEdge Authors

set -e

# Load WasmEdge environment if installed via install.sh
if [ -f "$HOME/.wasmedge/env" ]; then
# shellcheck source=/dev/null
source "$HOME/.wasmedge/env"
fi

BUILD_DIR="${BUILD_DIR:-build}"

cmake -B "${BUILD_DIR}" \
-DCMAKE_BUILD_TYPE=Release \
-DWASMEDGE_PLUGIN_IMAGE=ON \
-DWASMEDGE_BUILD_TESTS=ON

cmake --build "${BUILD_DIR}" --config Release -j "$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"

ctest --test-dir "${BUILD_DIR}" -R wasmedgeImageTests --output-on-failure
22 changes: 22 additions & 0 deletions .github/scripts/wasmedge_process/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright The WasmEdge Authors

set -e

# Load WasmEdge environment if installed via install.sh
if [ -f "$HOME/.wasmedge/env" ]; then
# shellcheck source=/dev/null
source "$HOME/.wasmedge/env"
fi

BUILD_DIR="${BUILD_DIR:-build}"

cmake -B "${BUILD_DIR}" \
-DCMAKE_BUILD_TYPE=Release \
-DWASMEDGE_PLUGIN_PROCESS=ON \
-DWASMEDGE_BUILD_TESTS=ON

cmake --build "${BUILD_DIR}" --config Release -j "$(nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2)"

ctest --test-dir "${BUILD_DIR}" -R wasmedgeProcessTests --output-on-failure
38 changes: 38 additions & 0 deletions .github/workflows/build-wasmedge_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: build-wasmedge_image

on:
push:
branches: [main]
pull_request:
branches: [main]
paths:
- '.github/workflows/build-wasmedge_image.yml'
- '.github/scripts/wasmedge_image/**'
- 'plugins/wasmedge_image/**'
- 'test/plugins/wasmedge_image/**'
- 'cmake/**'
- 'CMakeLists.txt'

permissions:
contents: read

jobs:
build:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, ubuntu-24.04, macos-13, macos-14]

steps:
- uses: actions/checkout@v7

- name: Install WasmEdge
run: |
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v 0.17.2

- name: Build and Test wasmedge_image
run: |
bash .github/scripts/wasmedge_image/build.sh
38 changes: 38 additions & 0 deletions .github/workflows/build-wasmedge_process.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: build-wasmedge_process

on:
push:
branches: [main]
pull_request:
branches: [main]
paths:
- '.github/workflows/build-wasmedge_process.yml'
- '.github/scripts/wasmedge_process/**'
- 'plugins/wasmedge_process/**'
- 'test/plugins/wasmedge_process/**'
- 'cmake/**'
- 'CMakeLists.txt'

permissions:
contents: read

jobs:
build:
name: ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, ubuntu-24.04]

steps:
- uses: actions/checkout@v7

- name: Install WasmEdge
run: |
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v 0.17.2

- name: Build and Test wasmedge_process
run: |
bash .github/scripts/wasmedge_process/build.sh
56 changes: 56 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright The WasmEdge Authors

cmake_minimum_required(VERSION 3.16)
project(wasmedge_plugins C CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(Helper)

# Plugin build options (default: OFF, per Issue #24)
option(WASMEDGE_PLUGIN_PROCESS "Build wasmedge_process plugin" OFF)
option(WASMEDGE_PLUGIN_IMAGE "Build wasmedge_image plugin" OFF)
option(WASMEDGE_PLUGIN_ZLIB "Build wasmedge_zlib plugin" OFF)
option(WASMEDGE_PLUGIN_WASI_CRYPTO "Build wasi_crypto plugin" OFF)
option(WASMEDGE_PLUGIN_WASI_HTTP "Build wasi_http plugin" OFF)
option(WASMEDGE_PLUGIN_WASI_NN_BACKEND "Build wasi_nn plugin" OFF)
option(WASMEDGE_PLUGIN_WASI_POLL "Build wasi_poll plugin" OFF)
option(WASMEDGE_PLUGIN_WASM_BPF "Build wasm_bpf plugin" OFF)
option(WASMEDGE_PLUGIN_FFMPEG "Build wasmedge_ffmpeg plugin" OFF)
option(WASMEDGE_PLUGIN_OCR "Build wasmedge_ocr plugin" OFF)
option(WASMEDGE_PLUGIN_OPENCVMINI "Build wasmedge_opencvmini plugin" OFF)
option(WASMEDGE_PLUGIN_STABLEDIFFUSION "Build wasmedge_stablediffusion plugin" OFF)
option(WASMEDGE_PLUGIN_TENSORFLOW "Build wasmedge_tensorflow plugin" OFF)
option(WASMEDGE_PLUGIN_TENSORFLOWLITE "Build wasmedge_tensorflowlite plugin" OFF)
option(WASMEDGE_PLUGIN_UNITTESTS "Build plugin loader unit tests" OFF)

option(WASMEDGE_BUILD_TESTS "Build plugin tests" OFF)
option(WASMEDGE_LINK_PLUGINS_STATIC "Link plugins statically against WasmEdge" OFF)

# Locate WasmEdge SDK and headers
wasmedge_find_sdk()

# Build enabled plugins
add_subdirectory(plugins)

# Build tests if requested
if(WASMEDGE_BUILD_TESTS)
enable_testing()
add_compile_definitions(FMT_HEADER_ONLY=1)
find_package(GTest QUIET)
if(NOT TARGET GTest::gtest)
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(googletest)
endif()
set(GTEST_BOTH_LIBRARIES GTest::gtest GTest::gtest_main)
add_subdirectory(test/plugins)
endif()
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,68 @@
# WasmEdge C++ Plugins

This repository hosts standalone C++ plugins for [WasmEdge](https://github.com/WasmEdge/WasmEdge).

Plugins are built standalone against a released WasmEdge SDK rather than tracking unreleased WasmEdge `master`.

## Plugins

| Plugin | Build Option | Platforms | Status |
| :--- | :--- | :--- | :--- |
| `wasmedge_image` | `-DWASMEDGE_PLUGIN_IMAGE=ON` | Linux, macOS | Migrated |
| `wasmedge_process` | `-DWASMEDGE_PLUGIN_PROCESS=ON` | Linux | Migrated |

## Prerequisites

1. **CMake** 3.16 or later (3.24+ recommended)
2. **C++17 Compiler** (GCC, Clang, or MSVC)
3. **WasmEdge SDK** (version 0.17.2 or later)

To install WasmEdge:
```bash
curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- -v 0.17.2
```

## Building Plugins

Plugins are configured with all `WASMEDGE_PLUGIN_*` options set to `OFF` by default. Enable only the plugins you wish to build:

```bash
# Build wasmedge_process
cmake -B build -DWASMEDGE_PLUGIN_PROCESS=ON
cmake --build build

# Build wasmedge_image
cmake -B build -DWASMEDGE_PLUGIN_IMAGE=ON
cmake --build build
```

The compiled plugin shared libraries will be placed under `build/plugins/<plugin_name>/`.

### Locating the WasmEdge SDK

The build system searches for the WasmEdge library and headers in common installation directories (`$HOME/.wasmedge`, `/usr/local`, `/usr`).

You can explicitly provide custom paths using CMake variables or environment variables:
- `WASMEDGE_DIR`: Path to the WasmEdge installation prefix (e.g. `~/.wasmedge`)
- `WASMEDGE_LIB_DIR`: Path to directory containing `libwasmedge.so` / `libwasmedge.dylib`
- `WASMEDGE_INCLUDE_DIR`: Path to WasmEdge headers directory

If headers are not found locally, CMake will automatically fetch headers for the pinned WasmEdge release.

## Running Tests

To build and execute plugin unit tests:

```bash
cmake -B build \
-DWASMEDGE_PLUGIN_PROCESS=ON \
-DWASMEDGE_PLUGIN_IMAGE=ON \
-DWASMEDGE_BUILD_TESTS=ON

cmake --build build
ctest --test-dir build --output-on-failure
```

## Upgrade Policy

Plugins in this repository sync to new WasmEdge APIs **only when WasmEdge cuts an official release**. The minimum target release is pinned via `WASMEDGE_PINNED_VERSION` in `cmake/Helper.cmake` (currently `0.17.2`). Maintainers should not track or depend on unreleased `master` branch changes.
Loading