Skip to content

Commit ad5744b

Browse files
author
YaoLe
authored
Merge pull request proxy-wasm#1 from lum1n0us/envoy-wamr-integration
Compile WAMR from Source Code
2 parents bc9ef21 + 3c7eb4c commit ad5744b

File tree

6 files changed

+50
-24
lines changed

6 files changed

+50
-24
lines changed

BUILD

Lines changed: 3 additions & 3 deletions
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/**/wasmtime*",
28+
"src/**/wavm*",
2829
],
2930
),
3031
hdrs = glob(["src/**/*.h"]),
@@ -34,7 +35,6 @@ cc_library(
3435
"@boringssl//:crypto",
3536
"@com_google_protobuf//:protobuf_lite",
3637
"@proxy_wasm_cpp_sdk//:api_lib",
37-
"@wamr//:wamr_lib",
38-
"@wasm_c_api//:wasmtime_lib",
38+
"@wamr//:libiwasm",
3939
],
4040
)

WORKSPACE

Lines changed: 4 additions & 0 deletions
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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
licenses(["notice"]) # Apache 2
22

3-
package(default_visibility = ["//visibility:public"])
3+
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
44

5-
cc_import(
6-
name = "linklib",
7-
shared_library = "library/linux-classic_interp-multi_module-dbg/libiwasm.so",
8-
)
5+
package(default_visibility = ["//visibility:public"])
96

10-
cc_library(
11-
name = "headlib",
12-
hdrs = glob(["include/*.h"]),
13-
srcs = glob(["include/*.c"]),
14-
include_prefix = "wamr",
7+
filegroup(
8+
name = "srcs",
9+
srcs = glob(["**"]),
10+
visibility = ["//visibility:public"],
1511
)
1612

17-
cc_library(
18-
name = "wamr_lib",
19-
defines = ["WASM_WAMR"],
20-
deps = [
21-
"linklib",
22-
"headlib",
23-
],
13+
cmake(
14+
name = "libiwasm",
15+
cache_entries = {
16+
"CMAKE_BUILD_TYPE": "Debug",
17+
"CMAKE_EXPORT_COMPILE_COMMANDS": "On",
18+
"WAMR_BUILD_AOT": "0",
19+
"WAMR_BUILD_SIMD": "0",
20+
},
21+
lib_source = ":srcs",
22+
out_shared_libs = ["libiwasm.so"],
23+
working_directory = "product-mini/platforms/linux"
2424
)

bazel/repositories.bzl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ def proxy_wasm_cpp_host_repositories():
5252
url = "https://github.com/lum1n0us/wasm-micro-runtime/releases/download/WAMR-01-29-2021/wamr_pre_release.zip",
5353
)
5454

55+
http_archive(
56+
name = "wamr",
57+
build_file = "@proxy_wasm_cpp_host//bazel/external:wamr.BUILD",
58+
sha256 = "88cd7145d7098daacfb0da51548327f4e5303d17ea27611cde6f47c6f7b68059",
59+
url = "https://github.com/lum1n0us/wasm-micro-runtime/releases/download/WAMR-01-29-2021/source.zip",
60+
)
61+
62+
# native.new_local_repository(
63+
# name = "wamr",
64+
# build_file = "@proxy_wasm_cpp_host//bazel/external:wamr.BUILD",
65+
# path = "/source/wamr",
66+
# )
67+
5568
http_archive(
5669
name = "wasm_c_api",
5770
build_file = "@proxy_wasm_cpp_host//bazel/external:wasm-c-api.BUILD",
@@ -73,3 +86,10 @@ def proxy_wasm_cpp_host_repositories():
7386
strip_prefix = "protobuf-655310ca192a6e3a050e0ca0b7084a2968072260",
7487
url = "https://github.com/protocolbuffers/protobuf/archive/655310ca192a6e3a050e0ca0b7084a2968072260.tar.gz",
7588
)
89+
90+
http_archive(
91+
name = "rules_foreign_cc",
92+
sha256 = "d54742ffbdc6924f222d2179f0e10e911c5c659c4ae74158e9fe827aad862ac6",
93+
strip_prefix = "rules_foreign_cc-0.2.0",
94+
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.2.0.tar.gz",
95+
)

src/wamr/types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
// limitations under the License.
1414

1515
#include "src/common/types.h"
16-
#include "wamr/include/wasm_c_api.h"
16+
#include "wasm_c_api.h"
1717

1818
namespace proxy_wasm {
1919
namespace wamr {

src/wamr/wamr.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include <vector>
3131

3232
#include "src/wamr/types.h"
33-
#include "wamr/include/wasm_c_api.h"
33+
#include "wasm_c_api.h"
3434

3535
namespace proxy_wasm {
3636
namespace wamr {
@@ -60,7 +60,6 @@ class Wamr : public WasmVm {
6060

6161
Cloneable cloneable() override {
6262
return Cloneable::CompiledBytecode;
63-
;
6463
}
6564
std::unique_ptr<WasmVm> clone() override;
6665

@@ -167,7 +166,8 @@ std::unique_ptr<WasmVm> Wamr::clone() {
167166

168167
WasmByteVec stripped;
169168
clone->module_ =
170-
wasm_module_new(store_.get(), getStrippedSource(&stripped) ? stripped.get() : source_.get());
169+
wasm_module_new(clone->store_.get(), getStrippedSource(&stripped) ? stripped.get() : source_.get());
170+
171171
return clone;
172172
}
173173

@@ -765,3 +765,5 @@ AbiVersion Wamr::getAbiVersion() {
765765
std::unique_ptr<WasmVm> createWamrVm() { return std::make_unique<wamr::Wamr>(); }
766766

767767
} // namespace proxy_wasm
768+
769+

0 commit comments

Comments
 (0)