Skip to content

Commit 201e27a

Browse files
committed
WasmEdge: Add the WasmEdge runtime supporting for WasmEdge-0.8.2.
Signed-off-by: YiYing He <[email protected]>
1 parent 860f36a commit 201e27a

File tree

12 files changed

+802
-2
lines changed

12 files changed

+802
-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
@@ -17,3 +17,8 @@ config_setting(
1717
name = "runtime_wavm",
1818
values = {"define": "runtime=wavm"},
1919
)
20+
21+
config_setting(
22+
name = "runtime_wasmedge",
23+
values = {"define": "runtime=wasmedge"},
24+
)

bazel/external/wasmedge.BUILD

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
2+
3+
licenses(["notice"]) # Apache 2
4+
5+
package(default_visibility = ["//visibility:public"])
6+
7+
filegroup(
8+
name = "srcs",
9+
srcs = glob(["**"]),
10+
)
11+
12+
cmake(
13+
name = "wasmedge_lib",
14+
cache_entries = {
15+
"CMAKE_BUILD_TYPE": "Release",
16+
"WASMEDGE_BUILD_AOT_RUNTIME": "OFF",
17+
"WASMEDGE_BUILD_SHARED_LIB": "OFF",
18+
"WASMEDGE_BUILD_STATIC_LIB": "ON",
19+
"WASMEDGE_BUILD_TOOLS": "OFF",
20+
"WASMEDGE_FORCE_DISABLE_LTO": "ON",
21+
},
22+
generate_args = ["-GNinja"],
23+
lib_source = ":srcs",
24+
out_static_libs = [
25+
"libwasmedge_c.a",
26+
],
27+
)

bazel/repositories.bzl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,19 @@ def proxy_wasm_cpp_host_repositories():
107107
url = "https://github.com/WAVM/WAVM/archive/93c3ad73e2938f19c8bb26d4f456b39d6bc4ca01.tar.gz",
108108
)
109109

110+
http_archive(
111+
name = "com_github_wasmedge_wasmedge",
112+
build_file = "@proxy_wasm_cpp_host//bazel/external:wasmedge.BUILD",
113+
sha256 = "d21fac6e213b438371d6ba12308bbc3bef5842f8a89d9965874a5785c4f970fc",
114+
strip_prefix = "WasmEdge-0.8.2",
115+
url = "https://github.com/WasmEdge/WasmEdge/archive/0.8.2.tar.gz",
116+
)
117+
118+
native.bind(
119+
name = "wasmedge",
120+
actual = "@com_github_wasmedge_wasmedge//:wasmedge_lib",
121+
)
122+
110123
native.bind(
111124
name = "wavm",
112125
actual = "@com_github_wavm_wavm//:wavm_lib",

bazel/select.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,9 @@ def proxy_wasm_select_runtime_wavm(xs):
3535
"@proxy_wasm_cpp_host//bazel:runtime_wavm": xs,
3636
"//conditions:default": [],
3737
})
38+
39+
def proxy_wasm_select_runtime_wasmedge(xs):
40+
return select({
41+
"@proxy_wasm_cpp_host//bazel:runtime_wasmedge": xs,
42+
"//conditions:default": [],
43+
})

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)