Skip to content

Commit

Permalink
[Plugin] initial support of the zlib plugin (#2562)
Browse files Browse the repository at this point in the history
* Include wasmedge_zlib in plugins/CMakeLists.txt .

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Add Zlib Plugin as an option in root CMakeLists.txt .

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Add zlib-ng dependency through FetchContent.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added zlib build target for job 'build_ubuntu' in build-extensions.yml .

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added zlib build target for job 'build_manylinux' in build-extensions.yml .

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Init env & base headers, struct Wasm_z_stream & ZStreamMap

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added basic zlib function declarations.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added zlib env implementation & PluginDescriptor.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added zlib module implementation, and added Host Functions.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added zlib plugin WasmEdgeZlibDeflateInit_ implementation.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added zlib plugin WasmEdgeZlibInflateInit_ implementation.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added zlib plugin WasmEdgeZlibDeflate implementation.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added zlib plugin WasmEdgeZlibInflate implementation.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added zlib plugin WasmEdgeZlibDeflateEnd implementation.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added zlib plugin WasmEdgeZlibInflateEnd implementation.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Populated plugins/wasmedge_zlib/CMakeLists.txt to build & link the zlib plugin source.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Fix: Added ZLIB as link dep to wasmedge_zlib plugin.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added basic test for zlib plugin; WIP/TODO.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added test/plugins/wasmedge_zlib/CMakeLists.txt to build and create zlib test executable.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Include zlib plugin test sub directory in test/plugins/CMakeLists.txt.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Fixed naming convention by omitting namespace prefix from function name.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Fix case sensitivity in CMake of zlib library.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Refactor build-extensions.yml to be in-line with upstream master.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Fix typo in build-extensions.yml on zlib cmake option

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Minor type changes to better reflect the Zlib API.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added Deflate Inflate Integration Test

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Removed unnecessary nulling of wasm module's z_stream allocators | The host ignores them.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added static_assert on Wasm_z_stream struct size.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Start writing to the wasm heap from address 1 onwards, to nto collide with the semantic meaning of address/offset 0 as nullptr.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Fix: Correct Version Check and Stream Size Check Error code, and API behaviour, along with relevant test case changes.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added in-code documentation/pointer/reason on why we just compare only the first character of zlib version strings.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Remove unsafe usage of wasm MemStart(pointer from base{0}). Converted to offset based pointer calculation, based on pointer increment after zlib operation..

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added in-code documentation to every field in Wasm_z_stream.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Honor LLVM Naming Convention: Change 'Wasm_z_stream' struct name to 'WasmZStream'.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Honor LLVM Naming Convention: Change 'Wasm_z_stream' struct name to 'WasmZStream'.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Changed c style cast to static_cast.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Updated a few variable name to reflect LLVM standards.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Updated a few more variable name to reflect LLVM standards.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added a more comprehensive Host and Wasm ZStream Syncronization Func, and wrapped all zlib calls with it.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Change few comments.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Add Condition to only add ZStream to internal registry, if init succeeded.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Remove unnecessary zlib version check in wasmedge, delegated it to the zlib implementation.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added WasmEdgeZlibDeflateSetDictionary and WasmEdgeZlibDeflateGetDictionary.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added WasmEdgeZlibDeflateCopy with a comment on impl. ref.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added deflateReset

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added deflateParams

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added deflateTune & deflateBound.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added deflatePending & deflatePrime.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Defined the Wasm gz_header struct.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added few function impl of zlib.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added most of non gz functions.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added adler32, adler32_z, crc32, crc32_z.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Remove _v2 postfix

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Remove duplicate impl. of WasmEdgeZlibInflateSetDictionary.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Remove unused parameter 'Frame' from WasmEdgeZlibZlibCompilerFlags & WasmEdgeZlibCompressBound.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Correct few pointer value usage.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added GZFile support Env & implemented WasmEdgeZlibGZDOpen.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Implemented gzbuffer, gzsetparams & gzread.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added gzfread, gzwrite & gzfwrite.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added gzputs, gzgets, gzputc, gzgetc.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added gzflush & gzrewind

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Remove unused parameter 'Frame'.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added gzeof, gzdirect, gzclose, gzclose_r, gzclose_w.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added gzclearerr.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Change void* to unsigned char*

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added gzgetc & gzungetc.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Fix name Spell mistake.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Fixed no-return on a Expect<void>.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Fix move semantics related to unique_ptr.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added deflateInit2 & inflateInit2 & inflateBackInit2 & Refactor Part 1.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added gzopen | gzseek | gztell | gzoffset | adler32_combine | crc32_combine & Refactor Part 2

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added deflateInit2_ | inflateInit2_ | inflateBackInit_.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added gzgetc_

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added inflateSyncPoint | inflateUndermine | inflateValidate | inflateCodesUsed | inflateResetKeep | deflateResetKeep.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added draft WasmEdgeZlibGZVPrintf.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Removed unused Frame parameter.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Change all remaining naming convention to LLVM style.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added Host Func registration & Refactor Part 3.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Update function presence check to validate al 74 functions.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Update release.yml to include zlib.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added deflatesetheader & inflategetheader.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Change return type of SyncRun.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* SyncRun Func Design & Params Overhaul.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Remove access to moved unique_ptr.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added GZHeader Sync steps in SyncRun.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Registered deflateSetHeader | inflateGetHeader.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Updated Test to check for deflateSetHeader & inflateGetHeader.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Updated function count test to check for 76 functions.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Check if SyncRun fails even with no call to zlib API.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Removed old unused comments, revert usage of named fields & naming convention fixes.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added extensive error logging to Zlib Plugin.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added Function Instance Name, to SyncRun Error messages for better debug experience.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added a space between error msg tag & message.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Added info to error msg if the error is caught inside SyncRun.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Removed usage of a temporary ZRes variable wherever not absolutely necessary.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Fix Bug: Properly return a placeholder number to Module to act as a pointer to Host gzFile_s. We don't need to pass the raw pointer to Module, since gzFile_s is an opaque structure & the zlib app shouldn't try to access any of it's fields.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* [Style Change] Remove trailing _s from GZFile_s.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

* Removed usage of decltype, due to gcc [error: type qualifiers ignored on cast result type]. Using remove_cv to supress, would create code bloat.

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>

---------

Signed-off-by: Saikat Dey <saikatdey2100@gmail.com>
  • Loading branch information
NeelDigonto committed Sep 15, 2023
1 parent c688791 commit 27b3669
Show file tree
Hide file tree
Showing 15 changed files with 2,909 additions and 18 deletions.
26 changes: 18 additions & 8 deletions .github/workflows/build-extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ jobs:
env:
output_prefix: build/plugins
test_prefix: build/test/plugins
build_options: -DWASMEDGE_PLUGIN_WASI_CRYPTO=ON -DWASMEDGE_PLUGIN_WASI_LOGGING=ON -DWASMEDGE_PLUGIN_PROCESS=ON -DWASMEDGE_PLUGIN_TENSORFLOW=ON -DWASMEDGE_PLUGIN_TENSORFLOWLITE=ON -DWASMEDGE_PLUGIN_IMAGE=ON -DWASMEDGE_PLUGIN_WASM_BPF=ON -DWASMEDGE_PLUGIN_RUSTLS=ON -DWASMEDGE_PLUGIN_OPENCVMINI=ON
tar_names: wasi_crypto wasi_logging wasmedge_process wasmedge_tensorflow wasmedge_tensorflowlite wasmedge_image wasm_bpf wasmedge_rustls wasmedge_opencvmini
test_bins: wasiCryptoTests wasiLoggingTests wasmedgeProcessTests wasmedgeTensorflowTests wasmedgeTensorflowLiteTests wasmedgeImageTests wasmBpfTests wasmEdgeRUSTLSTests wasmedgeOpencvminiTests
output_bins: libwasmedgePluginWasiCrypto.so libwasmedgePluginWasiLogging.so libwasmedgePluginWasmEdgeProcess.so libwasmedgePluginWasmEdgeTensorflow.so libwasmedgePluginWasmEdgeTensorflowLite.so libwasmedgePluginWasmEdgeImage.so libwasmedgePluginWasmBpf.so libwasmedge_rustls.so libwasmedgePluginWasmEdgeOpenCVMini.so
build_options: -DWASMEDGE_PLUGIN_WASI_CRYPTO=ON -DWASMEDGE_PLUGIN_WASI_LOGGING=ON -DWASMEDGE_PLUGIN_PROCESS=ON -DWASMEDGE_PLUGIN_TENSORFLOW=ON -DWASMEDGE_PLUGIN_TENSORFLOWLITE=ON -DWASMEDGE_PLUGIN_IMAGE=ON -DWASMEDGE_PLUGIN_WASM_BPF=ON -DWASMEDGE_PLUGIN_RUSTLS=ON -DWASMEDGE_PLUGIN_OPENCVMINI=ON -DWASMEDGE_PLUGIN_ZLIB=ON
tar_names: wasi_crypto wasi_logging wasmedge_process wasmedge_tensorflow wasmedge_tensorflowlite wasmedge_image wasm_bpf wasmedge_rustls wasmedge_opencvmini wasmedge_zlib
test_bins: wasiCryptoTests wasiLoggingTests wasmedgeProcessTests wasmedgeTensorflowTests wasmedgeTensorflowLiteTests wasmedgeImageTests wasmBpfTests wasmEdgeRUSTLSTests wasmedgeOpencvminiTests wasmedgeZlibTests
output_bins: libwasmedgePluginWasiCrypto.so libwasmedgePluginWasiLogging.so libwasmedgePluginWasmEdgeProcess.so libwasmedgePluginWasmEdgeTensorflow.so libwasmedgePluginWasmEdgeTensorflowLite.so libwasmedgePluginWasmEdgeImage.so libwasmedgePluginWasmBpf.so libwasmedge_rustls.so libwasmedgePluginWasmEdgeOpenCVMini.so libwasmedgePluginWasmEdgeZlib.so
needs: [get_version]
container:
image: wasmedge/wasmedge:${{ matrix.docker_tag }}
Expand Down Expand Up @@ -267,6 +267,11 @@ jobs:
with:
name: WasmEdge-plugin-wasmedge_opencvmini-${{ needs.get_version.outputs.version }}-ubuntu22.04-${{ matrix.compiler }}.tar.gz
path: plugin_wasmedge_opencvmini.tar.gz
- name: Upload artifact - wasmedge_zlib
uses: actions/upload-artifact@v3
with:
name: WasmEdge-plugin-wasmedge_zlib-${{ needs.get_version.outputs.version }}-ubuntu22.04-${{ matrix.compiler }}.tar.gz
path: plugin_wasmedge_zlib.tar.gz

# Due to the dependencies and exclusions of WASI-NN, build them saperately.
build_manylinux_wasi_nn:
Expand Down Expand Up @@ -366,16 +371,16 @@ jobs:
env:
output_prefix: build/plugins
test_prefix: build/test/plugins
build_options_all_platforms: -DWASMEDGE_PLUGIN_WASI_CRYPTO=ON -DWASMEDGE_PLUGIN_WASI_LOGGING=ON -DWASMEDGE_PLUGIN_PROCESS=ON -DWASMEDGE_PLUGIN_TENSORFLOW=ON -DWASMEDGE_PLUGIN_TENSORFLOWLITE=ON -DWASMEDGE_PLUGIN_IMAGE=ON -DWASMEDGE_PLUGIN_OPENCVMINI=ON
build_options_all_platforms: -DWASMEDGE_PLUGIN_WASI_CRYPTO=ON -DWASMEDGE_PLUGIN_WASI_LOGGING=ON -DWASMEDGE_PLUGIN_PROCESS=ON -DWASMEDGE_PLUGIN_TENSORFLOW=ON -DWASMEDGE_PLUGIN_TENSORFLOWLITE=ON -DWASMEDGE_PLUGIN_IMAGE=ON -DWASMEDGE_PLUGIN_OPENCVMINI=ON -DWASMEDGE_PLUGIN_ZLIB=ON
build_options_manylinux2014_x86_64: -DWASMEDGE_PLUGIN_WASM_BPF=ON -DWASMEDGE_PLUGIN_RUSTLS=ON -DWASMEDGE_PLUGIN_WASM_BPF_BUILD_LIBBPF_WITH_PKG_CONF=OFF
build_options_manylinux2014_aarch64:
tar_names_all_platforms: wasi_crypto wasi_logging wasmedge_process wasmedge_tensorflow wasmedge_tensorflowlite wasmedge_image wasmedge_opencvmini
tar_names_all_platforms: wasi_crypto wasi_logging wasmedge_process wasmedge_tensorflow wasmedge_tensorflowlite wasmedge_image wasmedge_opencvmini wasmedge_zlib
tar_names_manylinux2014_x86_64: wasm_bpf wasmedge_rustls
tar_names_manylinux2014_aarch64:
test_bins_all_platforms: wasiCryptoTests wasiLoggingTests wasmedgeProcessTests wasmedgeTensorflowTests wasmedgeTensorflowLiteTests wasmedgeImageTests wasmedgeOpencvminiTests
test_bins_all_platforms: wasiCryptoTests wasiLoggingTests wasmedgeProcessTests wasmedgeTensorflowTests wasmedgeTensorflowLiteTests wasmedgeImageTests wasmedgeOpencvminiTests wasmedgeZlibTests
test_bins_manylinux2014_x86_64: wasmBpfTests wasmEdgeRUSTLSTests
test_bins_manylinux2014_aarch64:
output_bins_all_platforms: libwasmedgePluginWasiCrypto.so libwasmedgePluginWasiLogging.so libwasmedgePluginWasmEdgeProcess.so libwasmedgePluginWasmEdgeTensorflow.so libwasmedgePluginWasmEdgeTensorflowLite.so libwasmedgePluginWasmEdgeImage.so libwasmedgePluginWasmEdgeOpenCVMini.so
output_bins_all_platforms: libwasmedgePluginWasiCrypto.so libwasmedgePluginWasiLogging.so libwasmedgePluginWasmEdgeProcess.so libwasmedgePluginWasmEdgeTensorflow.so libwasmedgePluginWasmEdgeTensorflowLite.so libwasmedgePluginWasmEdgeImage.so libwasmedgePluginWasmEdgeOpenCVMini.so libwasmedgePluginWasmEdgeZlib.so
output_bins_manylinux2014_x86_64: libwasmedgePluginWasmBpf.so libwasmedge_rustls.so
output_bins_manylinux2014_aarch64:
needs: [get_version]
Expand Down Expand Up @@ -477,6 +482,11 @@ jobs:
with:
name: WasmEdge-plugin-wasmedge_opencvmini-${{ needs.get_version.outputs.version }}-${{ matrix.docker_tag }}.tar.gz
path: plugin_wasmedge_opencvmini.tar.gz
- name: Upload artifact - wasmedge_zlib
uses: actions/upload-artifact@v3
with:
name: WasmEdge-plugin-wasmedge_zlib-${{ needs.get_version.outputs.version }}-${{ matrix.docker_tag }}.tar.gz
path: plugin_wasmedge_zlib.tar.gz

build_macos:
strategy:
Expand Down
39 changes: 29 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
version: ${{ needs.create_release.outputs.version }}
release: true
secrets: inherit

build_on_alpine_static:
needs: create_release
uses: ./.github/workflows/reusable-build-on-alpine-static.yml
Expand Down Expand Up @@ -206,9 +206,9 @@ jobs:
runs-on: ubuntu-latest
env:
output_prefix: build/plugins
build_options: -DWASMEDGE_PLUGIN_WASI_CRYPTO=ON -DWASMEDGE_PLUGIN_WASI_LOGGING=ON -DWASMEDGE_PLUGIN_RUSTLS=ON -DWASMEDGE_PLUGIN_PROCESS=ON -DWASMEDGE_PLUGIN_TENSORFLOW=ON -DWASMEDGE_PLUGIN_TENSORFLOWLITE=ON -DWASMEDGE_PLUGIN_IMAGE=ON -DWASMEDGE_PLUGIN_WASM_BPF=ON -DWASMEDGE_PLUGIN_OPENCVMINI=ON
tar_names: wasi_crypto wasi_logging wasmedge_rustls wasmedge_process wasmedge_tensorflow wasmedge_tensorflowlite wasmedge_image wasm_bpf wasmedge_opencvmini
output_bins: libwasmedgePluginWasiCrypto.so libwasmedgePluginWasiLogging.so libwasmedge_rustls.so libwasmedgePluginWasmEdgeProcess.so libwasmedgePluginWasmEdgeTensorflow.so libwasmedgePluginWasmEdgeTensorflowLite.so libwasmedgePluginWasmEdgeImage.so libwasmedgePluginWasmBpf.so libwasmedgePluginWasmEdgeOpenCVMini.so
build_options: -DWASMEDGE_PLUGIN_WASI_CRYPTO=ON -DWASMEDGE_PLUGIN_WASI_LOGGING=ON -DWASMEDGE_PLUGIN_RUSTLS=ON -DWASMEDGE_PLUGIN_PROCESS=ON -DWASMEDGE_PLUGIN_TENSORFLOW=ON -DWASMEDGE_PLUGIN_TENSORFLOWLITE=ON -DWASMEDGE_PLUGIN_IMAGE=ON -DWASMEDGE_PLUGIN_WASM_BPF=ON -DWASMEDGE_PLUGIN_OPENCVMINI=ON -DWASMEDGE_PLUGIN_ZLIB=ON
tar_names: wasi_crypto wasi_logging wasmedge_rustls wasmedge_process wasmedge_tensorflow wasmedge_tensorflowlite wasmedge_image wasm_bpf wasmedge_opencvmini wasmedge_zlib
output_bins: libwasmedgePluginWasiCrypto.so libwasmedgePluginWasiLogging.so libwasmedge_rustls.so libwasmedgePluginWasmEdgeProcess.so libwasmedgePluginWasmEdgeTensorflow.so libwasmedgePluginWasmEdgeTensorflowLite.so libwasmedgePluginWasmEdgeImage.so libwasmedgePluginWasmBpf.so libwasmedgePluginWasmEdgeOpenCVMini.so libwasmedgePluginWasmEdgeZlib.so
needs: create_release
container:
image: wasmedge/wasmedge:ubuntu-20.04-build-clang
Expand Down Expand Up @@ -313,6 +313,12 @@ jobs:
run: |
mv plugin_wasmedge_opencvmini.tar.gz WasmEdge-plugin-wasmedge_opencvmini-${{ needs.create_release.outputs.version }}-ubuntu20.04_x86_64.tar.gz
gh release upload ${{ needs.create_release.outputs.version }} WasmEdge-plugin-wasmedge_opencvmini-${{ needs.create_release.outputs.version }}-ubuntu20.04_x86_64.tar.gz --clobber
- name: Upload wasmedge_zlib plugin tar.gz package
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mv plugin_wasmedge_zlib.tar.gz WasmEdge-plugin-wasmedge_zlib-${{ needs.create_release.outputs.version }}-ubuntu20.04_x86_64.tar.gz
gh release upload ${{ needs.create_release.outputs.version }} WasmEdge-plugin-wasmedge_zlib-${{ needs.create_release.outputs.version }}-ubuntu20.04_x86_64.tar.gz --clobber
build_and_upload_wasinn_manylinux:
strategy:
Expand Down Expand Up @@ -415,13 +421,13 @@ jobs:
runs-on: ${{ matrix.host_runner }}
env:
output_prefix: build/plugins
build_options_all_platforms: -DWASMEDGE_PLUGIN_WASI_CRYPTO=ON -DWASMEDGE_PLUGIN_WASI_LOGGING=ON -DWASMEDGE_PLUGIN_PROCESS=ON -DWASMEDGE_PLUGIN_TENSORFLOW=ON -DWASMEDGE_PLUGIN_TENSORFLOWLITE=ON -DWASMEDGE_PLUGIN_IMAGE=ON -DWASMEDGE_PLUGIN_OPENCVMINI=ON
build_options_all_platforms: -DWASMEDGE_PLUGIN_WASI_CRYPTO=ON -DWASMEDGE_PLUGIN_WASI_LOGGING=ON -DWASMEDGE_PLUGIN_PROCESS=ON -DWASMEDGE_PLUGIN_TENSORFLOW=ON -DWASMEDGE_PLUGIN_TENSORFLOWLITE=ON -DWASMEDGE_PLUGIN_IMAGE=ON -DWASMEDGE_PLUGIN_OPENCVMINI=ON -DWASMEDGE_PLUGIN_ZLIB=ON
build_options_manylinux2014_x86_64: -DWASMEDGE_PLUGIN_WASM_BPF=ON -DWASMEDGE_PLUGIN_RUSTLS=ON -DWASMEDGE_PLUGIN_WASM_BPF_BUILD_LIBBPF_WITH_PKG_CONF=OFF
build_options_manylinux2014_aarch64:
tar_names_all_platforms: wasi_crypto wasi_logging wasmedge_process wasmedge_tensorflow wasmedge_tensorflowlite wasmedge_image wasmedge_opencvmini
tar_names_all_platforms: wasi_crypto wasi_logging wasmedge_process wasmedge_tensorflow wasmedge_tensorflowlite wasmedge_image wasmedge_opencvmini wasmedge_zlib
tar_names_manylinux2014_x86_64: wasm_bpf wasmedge_rustls
tar_names_manylinux2014_aarch64:
output_bins_all_platforms: libwasmedgePluginWasiCrypto.so libwasmedgePluginWasiLogging.so libwasmedgePluginWasmEdgeProcess.so libwasmedgePluginWasmEdgeTensorflow.so libwasmedgePluginWasmEdgeTensorflowLite.so libwasmedgePluginWasmEdgeImage.so libwasmedgePluginWasmEdgeOpenCVMini.so
output_bins_all_platforms: libwasmedgePluginWasiCrypto.so libwasmedgePluginWasiLogging.so libwasmedgePluginWasmEdgeProcess.so libwasmedgePluginWasmEdgeTensorflow.so libwasmedgePluginWasmEdgeTensorflowLite.so libwasmedgePluginWasmEdgeImage.so libwasmedgePluginWasmEdgeOpenCVMini.so libwasmedgePluginWasmEdgeZlib.so
output_bins_manylinux2014_x86_64: libwasmedgePluginWasmBpf.so libwasmedge_rustls.so
output_bins_manylinux2014_aarch64:
needs: create_release
Expand Down Expand Up @@ -529,6 +535,12 @@ jobs:
run: |
mv plugin_wasmedge_opencvmini.tar.gz WasmEdge-plugin-wasmedge_opencvmini-${{ needs.create_release.outputs.version }}-${{ matrix.docker_tag }}.tar.gz
gh release upload ${{ needs.create_release.outputs.version }} WasmEdge-plugin-wasmedge_opencvmini-${{ needs.create_release.outputs.version }}-${{ matrix.docker_tag }}.tar.gz --clobber
- name: Upload wasmedge_zlib plugin tar.gz package
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mv plugin_wasmedge_zlib.tar.gz WasmEdge-plugin-wasmedge_zlib-${{ needs.create_release.outputs.version }}-${{ matrix.docker_tag }}.tar.gz
gh release upload ${{ needs.create_release.outputs.version }} WasmEdge-plugin-wasmedge_zlib-${{ needs.create_release.outputs.version }}-${{ matrix.docker_tag }}.tar.gz --clobber
build_and_upload_plugin_macos:
strategy:
Expand All @@ -548,9 +560,9 @@ jobs:
runs-on: ${{ matrix.host_runner }}
env:
output_prefix: build/plugins
build_options: -DWASMEDGE_PLUGIN_WASI_CRYPTO=ON -DWASMEDGE_PLUGIN_WASI_LOGGING=ON -DWASMEDGE_PLUGIN_RUSTLS=ON -DWASMEDGE_PLUGIN_TENSORFLOW=ON -DWASMEDGE_PLUGIN_TENSORFLOWLITE=ON -DWASMEDGE_PLUGIN_IMAGE=ON -DWASMEDGE_PLUGIN_OPENCVMINI=ON
tar_names: wasi_crypto wasi_logging wasmedge_rustls wasmedge_tensorflow wasmedge_tensorflowlite wasmedge_image wasmedge_opencvmini
output_bins: libwasmedgePluginWasiCrypto.dylib libwasmedgePluginWasiLogging.dylib libwasmedge_rustls.dylib libwasmedgePluginWasmEdgeTensorflow.dylib libwasmedgePluginWasmEdgeTensorflowLite.dylib libwasmedgePluginWasmEdgeImage.dylib libwasmedgePluginWasmEdgeOpenCVMini.dylib
build_options: -DWASMEDGE_PLUGIN_WASI_CRYPTO=ON -DWASMEDGE_PLUGIN_WASI_LOGGING=ON -DWASMEDGE_PLUGIN_RUSTLS=ON -DWASMEDGE_PLUGIN_TENSORFLOW=ON -DWASMEDGE_PLUGIN_TENSORFLOWLITE=ON -DWASMEDGE_PLUGIN_IMAGE=ON -DWASMEDGE_PLUGIN_OPENCVMINI=ON -DWASMEDGE_PLUGIN_ZLIB=ON
tar_names: wasi_crypto wasi_logging wasmedge_rustls wasmedge_tensorflow wasmedge_tensorflowlite wasmedge_image wasmedge_opencvmini wasmedge_zlib
output_bins: libwasmedgePluginWasiCrypto.dylib libwasmedgePluginWasiLogging.dylib libwasmedge_rustls.dylib libwasmedgePluginWasmEdgeTensorflow.dylib libwasmedgePluginWasmEdgeTensorflowLite.dylib libwasmedgePluginWasmEdgeImage.dylib libwasmedgePluginWasmEdgeOpenCVMini.dylib libwasmedgePluginWasmEdgeZlib.so
needs: create_release
steps:
- name: Checkout code
Expand Down Expand Up @@ -641,6 +653,13 @@ jobs:
eval $(/opt/homebrew/bin/brew shellenv)
mv plugin_wasmedge_opencvmini.tar.gz WasmEdge-plugin-wasmedge_opencvmini-${{ needs.create_release.outputs.version }}-darwin_${{ matrix.arch }}.tar.gz
gh release upload ${{ needs.create_release.outputs.version }} WasmEdge-plugin-wasmedge_opencvmini-${{ needs.create_release.outputs.version }}-darwin_${{ matrix.arch }}.tar.gz --clobber
- name: Upload wasmedge_zlib plugin tar.gz package
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
eval $(/opt/homebrew/bin/brew shellenv)
mv plugin_wasmedge_zlib.tar.gz WasmEdge-plugin-wasmedge_zlib-${{ needs.create_release.outputs.version }}-darwin_${{ matrix.arch }}.tar.gz
gh release upload ${{ needs.create_release.outputs.version }} WasmEdge-plugin-wasmedge_zlib-${{ needs.create_release.outputs.version }}-darwin_${{ matrix.arch }}.tar.gz --clobber
build_manylinux2014_runtime_only:
name: Build runtime only on manylinux2014 platform
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ option(WASMEDGE_PLUGIN_IMAGE "Enable WasmEdge image plugin." OFF)
option(WASMEDGE_PLUGIN_TENSORFLOW "Enable WasmEdge TensorFlow plugin." OFF)
option(WASMEDGE_PLUGIN_TENSORFLOWLITE "Enable WasmEdge TensorFlow-Lite plugin." OFF)
option(WASMEDGE_PLUGIN_RUSTLS "Enable WasmEdge Rustls plugin." OFF)
option(WASMEDGE_PLUGIN_ZLIB "Enable WasmEdge zlib plugin." OFF)
option(WASMEDGE_DISABLE_LIBTINFO "Disable linking against libtinfo when linking LLVM" OFF)

if(WASMEDGE_BUILD_TOOLS AND WASMEDGE_BUILD_FUZZING)
Expand Down
4 changes: 4 additions & 0 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ endif()
if(WASMEDGE_PLUGIN_RUSTLS)
add_subdirectory(wasmedge_rustls)
endif()

if(WASMEDGE_PLUGIN_ZLIB)
add_subdirectory(wasmedge_zlib)
endif()
50 changes: 50 additions & 0 deletions plugins/wasmedge_zlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2019-2022 Second State INC

# Don't reply on System zlib
# find_package(ZLIB REQUIRED)

set(ZLIB_COMPAT ON)
set(ZLIBNG_ENABLE_TESTS OFF)

FetchContent_Declare(
zlib
GIT_REPOSITORY "https://github.com/zlib-ng/zlib-ng.git"
GIT_TAG 2.0.7
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(zlib)

wasmedge_add_library(wasmedgePluginWasmEdgeZlib
SHARED
zlibenv.cpp
zlibfunc.cpp
zlibmodule.cpp
)

target_compile_options(wasmedgePluginWasmEdgeZlib
PUBLIC
-DWASMEDGE_PLUGIN
)

target_include_directories(wasmedgePluginWasmEdgeZlib
PUBLIC
$<TARGET_PROPERTY:wasmedgePlugin,INCLUDE_DIRECTORIES>
${CMAKE_CURRENT_SOURCE_DIR}
)

if(WASMEDGE_LINK_PLUGINS_STATIC)
target_link_libraries(wasmedgePluginWasmEdgeZlib
PRIVATE
wasmedgeCAPI
zlib
)
else()
target_link_libraries(wasmedgePluginWasmEdgeZlib
PRIVATE
wasmedge_shared
zlib
)
endif()

install(TARGETS wasmedgePluginWasmEdgeZlib DESTINATION ${CMAKE_INSTALL_LIBDIR}/wasmedge)
25 changes: 25 additions & 0 deletions plugins/wasmedge_zlib/zlibbase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2019-2022 Second State INC

#pragma once

#include "zlibenv.h"

#include "common/errcode.h"
#include "runtime/callingframe.h"
#include "runtime/hostfunc.h"

namespace WasmEdge {
namespace Host {

template <typename T> class WasmEdgeZlib : public Runtime::HostFunction<T> {
public:
WasmEdgeZlib(WasmEdgeZlibEnvironment &HostEnv)
: Runtime::HostFunction<T>(0), Env(HostEnv) {}

protected:
WasmEdgeZlibEnvironment &Env;
};

} // namespace Host
} // namespace WasmEdge
39 changes: 39 additions & 0 deletions plugins/wasmedge_zlib/zlibenv.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2019-2022 Second State INC

#include "zlibenv.h"
#include "zlibmodule.h"

namespace WasmEdge {
namespace Host {

namespace {

Runtime::Instance::ModuleInstance *
create(const Plugin::PluginModule::ModuleDescriptor *) noexcept {
return new WasmEdgeZlibModule;
}

Plugin::Plugin::PluginDescriptor Descriptor{
.Name = "wasmedge_zlib",
.Description = "",
.APIVersion = Plugin::Plugin::CurrentAPIVersion,
.Version = {0, 10, 1, 0},
.ModuleCount = 1,
.ModuleDescriptions =
(Plugin::PluginModule::ModuleDescriptor[]){
{
.Name = "wasmedge_zlib",
.Description = "",
.Create = create,
},
},
.AddOptions = nullptr,
};

} // namespace

Plugin::PluginRegister WasmEdgeZlibEnvironment::Register(&Descriptor);

} // namespace Host
} // namespace WasmEdge
Loading

0 comments on commit 27b3669

Please sign in to comment.