Skip to content

Commit f6846e7

Browse files
committed
Get tests passing locally
Signed-off-by: Keith Mattix II <[email protected]>
1 parent 1908f39 commit f6846e7

File tree

8 files changed

+71
-3174
lines changed

8 files changed

+71
-3174
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/bazel-*
2+
.vscode

.vscode/settings.json

-6
This file was deleted.

bazel/dependencies.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def proxy_wasm_cpp_host_dependencies():
3636
extra_target_triples = [
3737
"aarch64-unknown-linux-gnu",
3838
"wasm32-unknown-unknown",
39-
"wasm32-wasi", # TODO: Change to wasm32-wasip1 once https://github.com/bazelbuild/rules_rust/issues/2782 is fixed
39+
"wasm32-wasi", # TODO: Change to wasm32-wasip1 once https://github.com/bazelbuild/rules_rust/issues/2782 is fixed
4040
],
4141
version = "1.79.0",
4242
)

bazel/external/wasm-c-api.BUILD

-60
This file was deleted.

bazel/external/wasmtime.BUILD

+65-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,78 @@
11
load("@rules_rust//rust:defs.bzl", "rust_static_library")
2+
load("@rules_cc//cc:defs.bzl", "cc_library")
23

34
licenses(["notice"]) # Apache 2
45

56
package(default_visibility = ["//visibility:public"])
67

8+
genrule(
9+
name = "wasm-c-api-gen",
10+
srcs = ["crates/c-api/include/wasm.h"],
11+
outs = ["include/wasm.h"],
12+
cmd = "cp $< $@",
13+
)
14+
15+
cc_library(
16+
name = "wasmtime_lib",
17+
hdrs = [
18+
"include/wasm.h",
19+
],
20+
deps = [
21+
":rust_c_api",
22+
],
23+
)
24+
25+
genrule(
26+
name = "prefixed_wasmtime_c_api_headers",
27+
srcs = [
28+
"crates/c-api/include/wasm.h",
29+
],
30+
outs = [
31+
"include/prefixed_wasm.h",
32+
],
33+
cmd = """
34+
sed -e 's/\\ wasm_/\\ wasmtime_wasm_/g' \
35+
-e 's/\\*wasm_/\\*wasmtime_wasm_/g' \
36+
-e 's/(wasm_/(wasmtime_wasm_/g' \
37+
$(<) >$@
38+
""",
39+
)
40+
41+
genrule(
42+
name = "prefixed_wasmtime_c_api_lib",
43+
srcs = [
44+
":rust_c_api",
45+
],
46+
outs = [
47+
"prefixed_wasmtime_c_api.a",
48+
],
49+
cmd = """
50+
for symbol in $$(nm -P $(<) 2>/dev/null | grep -E ^_?wasm_ | cut -d" " -f1); do
51+
echo $$symbol | sed -r 's/^(_?)(wasm_[a-z_]+)$$/\\1\\2 \\1wasmtime_\\2/' >>prefixed
52+
done
53+
# This should be OBJCOPY, but bazel-zig-cc doesn't define it.
54+
objcopy --redefine-syms=prefixed $(<) $@
55+
""",
56+
toolchains = ["@bazel_tools//tools/cpp:current_cc_toolchain"],
57+
)
58+
59+
cc_library(
60+
name = "prefixed_wasmtime_lib",
61+
srcs = [
62+
":prefixed_wasmtime_c_api_lib",
63+
],
64+
hdrs = [
65+
":prefixed_wasmtime_c_api_headers",
66+
],
67+
linkstatic = 1,
68+
)
69+
770
rust_static_library(
871
name = "rust_c_api",
972
srcs = glob(["crates/c-api/src/**/*.rs"]),
10-
crate_features = [],
73+
crate_features = ["cranelift"],
1174
crate_root = "crates/c-api/src/lib.rs",
12-
edition = "2018",
75+
edition = "2021",
1376
proc_macro_deps = [
1477
"@proxy_wasm_cpp_host//bazel/cargo/wasmtime/remote:wasmtime-c-api-macros",
1578
],

bazel/repositories.bzl

+2-11
Original file line numberDiff line numberDiff line change
@@ -245,23 +245,14 @@ def proxy_wasm_cpp_host_repositories():
245245
url = "https://github.com/bytecodealliance/wasmtime/archive/v23.0.1.tar.gz",
246246
)
247247

248-
maybe(
249-
http_archive,
250-
name = "com_github_webassembly_wasm_c_api",
251-
build_file = "@proxy_wasm_cpp_host//bazel/external:wasm-c-api.BUILD",
252-
sha256 = "c774044f51431429e878bd1b9e2a4e38932f861f9211df72f75e9427eb6b8d32",
253-
strip_prefix = "wasm-c-api-c9d31284651b975f05ac27cee0bab1377560b87e",
254-
url = "https://github.com/WebAssembly/wasm-c-api/archive/c9d31284651b975f05ac27cee0bab1377560b87e.tar.gz",
255-
)
256-
257248
native.bind(
258249
name = "wasmtime",
259-
actual = "@com_github_webassembly_wasm_c_api//:wasmtime_lib",
250+
actual = "@com_github_bytecodealliance_wasmtime//:wasmtime_lib",
260251
)
261252

262253
native.bind(
263254
name = "prefixed_wasmtime",
264-
actual = "@com_github_webassembly_wasm_c_api//:prefixed_wasmtime_lib",
255+
actual = "@com_github_bytecodealliance_wasmtime//:prefixed_wasmtime_lib",
265256
)
266257

267258
# WAVM with dependencies.

0 commit comments

Comments
 (0)