Skip to content

Commit 378ef40

Browse files
committed
WasmEdge: Add the WasmEdge runtime supporting for WasmEdge-0.8.2.
Signed-off-by: YiYing He <[email protected]>
1 parent 4634be1 commit 378ef40

File tree

12 files changed

+726
-1
lines changed

12 files changed

+726
-1
lines changed

.github/workflows/cpp.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ jobs:
7979
- name: 'WAMR on macOS'
8080
runtime: 'wamr'
8181
os: macos-11
82+
- name: 'WasmEdge on Linux'
83+
runtime: 'wasmedge'
84+
os: ubuntu-20.04
8285
- name: 'Wasmtime on Linux'
8386
runtime: 'wasmtime'
8487
os: ubuntu-20.04

BUILD

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ load(
33
"@proxy_wasm_cpp_host//bazel:select.bzl",
44
"proxy_wasm_select_runtime_v8",
55
"proxy_wasm_select_runtime_wamr",
6+
"proxy_wasm_select_runtime_wasmedge",
67
"proxy_wasm_select_runtime_wasmtime",
78
"proxy_wasm_select_runtime_wavm",
89
)
@@ -118,6 +119,25 @@ cc_library(
118119
],
119120
)
120121

122+
cc_library(
123+
name = "wasmedge_lib",
124+
srcs = [
125+
"src/common/types.h",
126+
"src/wasmedge/types.h",
127+
"src/wasmedge/wasmedge.cc",
128+
],
129+
hdrs = ["include/proxy-wasm/wasmedge.h"],
130+
defines = ["PROXY_WASM_HAS_RUNTIME_WASMEDGE"],
131+
linkopts = [
132+
"-lrt",
133+
"-ldl",
134+
],
135+
deps = [
136+
":wasm_vm_headers",
137+
"//external:wasmedge",
138+
],
139+
)
140+
121141
cc_library(
122142
name = "wasmtime_lib",
123143
srcs = [
@@ -160,6 +180,8 @@ cc_library(
160180
[":v8_lib"],
161181
) + proxy_wasm_select_runtime_wamr(
162182
[":wamr_lib"],
183+
) + proxy_wasm_select_runtime_wasmedge(
184+
[":wasmedge_lib"],
163185
) + proxy_wasm_select_runtime_wasmtime(
164186
[":wasmtime_lib"],
165187
) + proxy_wasm_select_runtime_wavm(

bazel/BUILD

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ config_setting(
1010
values = {"define": "runtime=wamr"},
1111
)
1212

13+
config_setting(
14+
name = "runtime_wasmedge",
15+
values = {"define": "runtime=wasmedge"},
16+
)
17+
1318
config_setting(
1419
name = "runtime_wasmtime",
1520
values = {"define": "runtime=wasmtime"},

bazel/external/wasmedge.BUILD

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_library")
2+
3+
licenses(["notice"]) # Apache 2
4+
5+
package(default_visibility = ["//visibility:public"])
6+
7+
cc_library(
8+
name = "wasmedge_lib",
9+
srcs = ["lib64/libwasmedge_c.so"],
10+
hdrs = ["include/wasmedge.h"],
11+
strip_include_prefix = "include/",
12+
)

bazel/repositories.bzl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,16 @@ def proxy_wasm_cpp_host_repositories():
184184
],
185185
sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
186186
)
187+
188+
http_archive(
189+
name = "com_github_wasmedge_wasmedge",
190+
build_file = "@proxy_wasm_cpp_host//bazel/external:wasmedge.BUILD",
191+
sha256 = "48c15893f036b86b0f28d96e6269a4ac75d9697a30c44b171e254c83409afb30",
192+
strip_prefix = "WasmEdge-0.8.2-Linux",
193+
url = "https://github.com/WasmEdge/WasmEdge/releases/download/0.8.2/WasmEdge-0.8.2-manylinux2014_x86_64.tar.gz",
194+
)
195+
196+
native.bind(
197+
name = "wasmedge",
198+
actual = "@com_github_wasmedge_wasmedge//:wasmedge_lib",
199+
)

bazel/select.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ def proxy_wasm_select_runtime_wamr(xs):
2424
"//conditions:default": [],
2525
})
2626

27+
def proxy_wasm_select_runtime_wasmedge(xs):
28+
return select({
29+
"@proxy_wasm_cpp_host//bazel:runtime_wasmedge": xs,
30+
"//conditions:default": [],
31+
})
32+
2733
def proxy_wasm_select_runtime_wasmtime(xs):
2834
return select({
2935
"@proxy_wasm_cpp_host//bazel:runtime_wasmtime": xs,

include/proxy-wasm/wasmedge.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2016-2019 Envoy Project Authors
2+
// Copyright 2020 Google LLC
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
#pragma once
17+
18+
#include <memory>
19+
20+
#include "include/proxy-wasm/wasm_vm.h"
21+
22+
namespace proxy_wasm {
23+
24+
std::unique_ptr<WasmVm> createWasmEdgeVm();
25+
26+
} // namespace proxy_wasm

src/wasmedge/types.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2020 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "src/common/types.h"
16+
#include "wasmedge.h"
17+
18+
namespace proxy_wasm {
19+
namespace WasmEdge {
20+
21+
using WasmEdgeStorePtr = common::CSmartPtr<WasmEdge_StoreContext, WasmEdge_StoreDelete>;
22+
using WasmEdgeVMPtr = common::CSmartPtr<WasmEdge_VMContext, WasmEdge_VMDelete>;
23+
using WasmEdgeLoaderPtr = common::CSmartPtr<WasmEdge_LoaderContext, WasmEdge_LoaderDelete>;
24+
using WasmEdgeValidatorPtr = common::CSmartPtr<WasmEdge_ValidatorContext, WasmEdge_ValidatorDelete>;
25+
using WasmEdgeInterpreterPtr =
26+
common::CSmartPtr<WasmEdge_InterpreterContext, WasmEdge_InterpreterDelete>;
27+
using WasmEdgeASTModulePtr = common::CSmartPtr<WasmEdge_ASTModuleContext, WasmEdge_ASTModuleDelete>;
28+
29+
} // namespace WasmEdge
30+
} // namespace proxy_wasm

0 commit comments

Comments
 (0)