Skip to content

Commit 8da3a84

Browse files
committed
WasmEdge: Add the WasmEdge runtime supporting for WasmEdge-0.8.2.
Signed-off-by: YiYing He <[email protected]>
1 parent f383473 commit 8da3a84

File tree

12 files changed

+787
-2
lines changed

12 files changed

+787
-2
lines changed

.github/workflows/cpp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
strategy:
6666
fail-fast: false
6767
matrix:
68-
runtime: ["wamr", "wasmtime", "wavm"]
68+
runtime: ["wamr", "wasmtime", "wavm", "WasmEdge"]
6969

7070
steps:
7171
- uses: actions/checkout@v2

BUILD

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ load(
55
"proxy_wasm_select_runtime_wamr",
66
"proxy_wasm_select_runtime_wasmtime",
77
"proxy_wasm_select_runtime_wavm",
8+
"proxy_wasm_select_runtime_wasmedge",
89
)
910

1011
licenses(["notice"]) # Apache 2
@@ -145,6 +146,22 @@ cc_library(
145146
],
146147
)
147148

149+
cc_library(
150+
name = "wasmedge_lib",
151+
srcs = [
152+
"src/common/types.h",
153+
"src/wasmedge/types.h",
154+
"src/wasmedge/wasmedge.cc",
155+
],
156+
hdrs = ["include/proxy-wasm/wasmedge.h"],
157+
linkopts = ["-lrt", "-ldl"],
158+
defines = ["PROXY_WASM_HAS_RUNTIME_WASMEDGE"],
159+
deps = [
160+
":wasm_vm_headers",
161+
"//external:wasmedge",
162+
],
163+
)
164+
148165
cc_library(
149166
name = "lib",
150167
deps = [
@@ -158,5 +175,7 @@ cc_library(
158175
[":wasmtime_lib"],
159176
) + proxy_wasm_select_runtime_wavm(
160177
[":wavm_lib"],
178+
) + proxy_wasm_select_runtime_wasmedge(
179+
[":wasmedge_lib"],
161180
),
162181
)

bazel/BUILD

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

11+
config_setting(
12+
name = "runtime_wasmedge",
13+
values = {"define": "runtime=wasmedge"},
14+
)
15+
1116
config_setting(
1217
name = "runtime_wasmtime",
1318
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
@@ -111,3 +111,16 @@ def proxy_wasm_cpp_host_repositories():
111111
name = "wavm",
112112
actual = "@com_github_wavm_wavm//:wavm_lib",
113113
)
114+
115+
http_archive(
116+
name = "com_github_wasmedge_wasmedge",
117+
build_file = "@proxy_wasm_cpp_host//bazel/external:wasmedge.BUILD",
118+
sha256 = "48c15893f036b86b0f28d96e6269a4ac75d9697a30c44b171e254c83409afb30",
119+
strip_prefix = "WasmEdge-0.8.2-Linux",
120+
url = "https://github.com/WasmEdge/WasmEdge/releases/download/0.8.2/WasmEdge-0.8.2-manylinux2014_x86_64.tar.gz",
121+
)
122+
123+
native.bind(
124+
name = "wasmedge",
125+
actual = "@com_github_wasmedge_wasmedge//:wasmedge_lib",
126+
)

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: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 =
22+
common::CSmartPtr<WasmEdge_StoreContext, WasmEdge_StoreDelete>;
23+
using WasmEdgeVMPtr = common::CSmartPtr<WasmEdge_VMContext, WasmEdge_VMDelete>;
24+
using WasmEdgeLoaderPtr =
25+
common::CSmartPtr<WasmEdge_LoaderContext, WasmEdge_LoaderDelete>;
26+
using WasmEdgeValidatorPtr =
27+
common::CSmartPtr<WasmEdge_ValidatorContext, WasmEdge_ValidatorDelete>;
28+
using WasmEdgeInterpreterPtr =
29+
common::CSmartPtr<WasmEdge_InterpreterContext, WasmEdge_InterpreterDelete>;
30+
using WasmEdgeASTModulePtr =
31+
common::CSmartPtr<WasmEdge_ASTModuleContext, WasmEdge_ASTModuleDelete>;
32+
33+
} // namespace WasmEdge
34+
} // namespace proxy_wasm

0 commit comments

Comments
 (0)