Skip to content

Commit dcea399

Browse files
committed
compile WAMR from source code
using a pre-release archive until passing integration Signed-off-by: liam <[email protected]>
1 parent b59a9d6 commit dcea399

File tree

6 files changed

+43
-28
lines changed

6 files changed

+43
-28
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: 18 additions & 18 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-
],
24-
)
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"
24+
)

bazel/repositories.bzl

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,16 @@ def proxy_wasm_cpp_host_repositories():
4747
http_archive(
4848
name = "wamr",
4949
build_file = "@proxy_wasm_cpp_host//bazel/external:wamr.BUILD",
50-
sha256 = "fb2ca3b0322becb8c62de626181ef66a7be15e36000913f0ad4bf51d4619891b",
51-
strip_prefix = "wamr_pre_release",
52-
url = "https://github.com/lum1n0us/wasm-micro-runtime/releases/download/WAMR-01-29-2021/wamr_pre_release.zip",
50+
sha256 = "88cd7145d7098daacfb0da51548327f4e5303d17ea27611cde6f47c6f7b68059",
51+
url = "https://github.com/lum1n0us/wasm-micro-runtime/releases/download/WAMR-01-29-2021/source.zip",
5352
)
5453

54+
# native.new_local_repository(
55+
# name = "wamr",
56+
# build_file = "@proxy_wasm_cpp_host//bazel/external:wamr.BUILD",
57+
# path = "/source/wamr",
58+
# )
59+
5560
http_archive(
5661
name = "wasm_c_api",
5762
build_file = "@proxy_wasm_cpp_host//bazel/external:wasm-c-api.BUILD",
@@ -73,3 +78,10 @@ def proxy_wasm_cpp_host_repositories():
7378
strip_prefix = "protobuf-655310ca192a6e3a050e0ca0b7084a2968072260",
7479
url = "https://github.com/protocolbuffers/protobuf/archive/655310ca192a6e3a050e0ca0b7084a2968072260.tar.gz",
7580
)
81+
82+
http_archive(
83+
name = "rules_foreign_cc",
84+
sha256 = "d54742ffbdc6924f222d2179f0e10e911c5c659c4ae74158e9fe827aad862ac6",
85+
strip_prefix = "rules_foreign_cc-0.2.0",
86+
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/0.2.0.tar.gz",
87+
)

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: 2 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,7 @@ 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());
171170
return clone;
172171
}
173172

0 commit comments

Comments
 (0)