Skip to content

Commit e641ffa

Browse files
YaoLelum1n0us
YaoLe
andauthored
Add support for WebAssembly Micro Runtime (WAMR). (#142)
Fixes #134. Signed-off-by: Le Yao <le.yao@intel.com> Co-authored-by: Liang He <liang.he@intel.com>
1 parent 31c75e0 commit e641ffa

File tree

9 files changed

+758
-1
lines changed

9 files changed

+758
-1
lines changed

BUILD

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ cc_library(
2323
"src/**/*.h",
2424
],
2525
exclude = [
26-
"src/**/wavm*",
2726
"src/**/v8*",
27+
"src/**/wamr*",
28+
"src/**/wavm*",
2829
],
2930
),
3031
hdrs = glob(["src/**/*.h"]),

WORKSPACE

+4
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ proxy_wasm_cpp_host_repositories()
77
load("@proxy_wasm_cpp_host//bazel:dependencies.bzl", "proxy_wasm_cpp_host_dependencies")
88

99
proxy_wasm_cpp_host_dependencies()
10+
11+
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
12+
13+
rules_foreign_cc_dependencies()

bazel/external/wamr.BUILD

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
licenses(["notice"]) # Apache 2
2+
3+
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
4+
5+
package(default_visibility = ["//visibility:public"])
6+
7+
filegroup(
8+
name = "srcs",
9+
srcs = glob(["**"]),
10+
visibility = ["//visibility:public"],
11+
)
12+
13+
cmake(
14+
name = "libiwasm",
15+
cache_entries = {
16+
"WAMR_BUILD_INTERP": "1",
17+
"WAMR_BUILD_JIT": "0",
18+
"WAMR_BUILD_AOT": "0",
19+
"WAMR_BUILD_SIMD": "0",
20+
"WAMR_BUILD_MULTI_MODULE": "1",
21+
"WAMR_BUILD_LIBC_WASI": "0",
22+
},
23+
lib_source = ":srcs",
24+
out_shared_libs = ["libiwasm.so"],
25+
)

bazel/repositories.bzl

+15
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ def proxy_wasm_cpp_host_repositories():
3636
urls = ["https://github.com/google/googletest/archive/release-1.10.0.tar.gz"],
3737
)
3838

39+
http_archive(
40+
name = "wamr",
41+
build_file = "@proxy_wasm_cpp_host//bazel/external:wamr.BUILD",
42+
sha256 = "1d870f396bb6bdcb5c816326655b19a2877bbdf879255c335b8e84ce4ee37780",
43+
strip_prefix = "wasm-micro-runtime-9710d9325f426121cc1f2c62386a71d0c022d613",
44+
url = "https://github.com/bytecodealliance/wasm-micro-runtime/archive/9710d9325f426121cc1f2c62386a71d0c022d613.tar.gz",
45+
)
46+
3947
http_archive(
4048
name = "wasmtime",
4149
build_file = "@proxy_wasm_cpp_host//bazel/external:wasmtime.BUILD",
@@ -65,3 +73,10 @@ def proxy_wasm_cpp_host_repositories():
6573
strip_prefix = "protobuf-655310ca192a6e3a050e0ca0b7084a2968072260",
6674
url = "https://github.com/protocolbuffers/protobuf/archive/655310ca192a6e3a050e0ca0b7084a2968072260.tar.gz",
6775
)
76+
77+
http_archive(
78+
name = "rules_foreign_cc",
79+
sha256 = "d54742ffbdc6924f222d2179f0e10e911c5c659c4ae74158e9fe827aad862ac6",
80+
strip_prefix = "rules_foreign_cc-0.2.0",
81+
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.2.0.tar.gz",
82+
)

include/proxy-wasm/wamr.h

+26
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> createWamrVm();
25+
26+
} // namespace proxy_wasm

src/wamr/types.h

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 "wasm_c_api.h"
17+
18+
namespace proxy_wasm {
19+
namespace wamr {
20+
21+
using WasmEnginePtr = common::CSmartPtr<wasm_engine_t, wasm_engine_delete>;
22+
using WasmFuncPtr = common::CSmartPtr<wasm_func_t, wasm_func_delete>;
23+
using WasmStorePtr = common::CSmartPtr<wasm_store_t, wasm_store_delete>;
24+
using WasmModulePtr = common::CSmartPtr<wasm_module_t, wasm_module_delete>;
25+
using WasmMemoryPtr = common::CSmartPtr<wasm_memory_t, wasm_memory_delete>;
26+
using WasmTablePtr = common::CSmartPtr<wasm_table_t, wasm_table_delete>;
27+
using WasmInstancePtr = common::CSmartPtr<wasm_instance_t, wasm_instance_delete>;
28+
using WasmFunctypePtr = common::CSmartPtr<wasm_functype_t, wasm_functype_delete>;
29+
using WasmTrapPtr = common::CSmartPtr<wasm_trap_t, wasm_trap_delete>;
30+
using WasmExternPtr = common::CSmartPtr<wasm_extern_t, wasm_extern_delete>;
31+
32+
using WasmByteVec =
33+
common::CSmartType<wasm_byte_vec_t, wasm_byte_vec_new_empty, wasm_byte_vec_delete>;
34+
using WasmImporttypeVec = common::CSmartType<wasm_importtype_vec_t, wasm_importtype_vec_new_empty,
35+
wasm_importtype_vec_delete>;
36+
using WasmExportTypeVec = common::CSmartType<wasm_exporttype_vec_t, wasm_exporttype_vec_new_empty,
37+
wasm_exporttype_vec_delete>;
38+
using WasmExternVec =
39+
common::CSmartType<wasm_extern_vec_t, wasm_extern_vec_new_empty, wasm_extern_vec_delete>;
40+
using WasmValtypeVec =
41+
common::CSmartType<wasm_valtype_vec_t, wasm_valtype_vec_new_empty, wasm_valtype_vec_delete>;
42+
43+
} // namespace wamr
44+
45+
} // namespace proxy_wasm

0 commit comments

Comments
 (0)