Skip to content

Commit f7a0e87

Browse files
committed
allow building on non-wasm archs
Signed-off-by: Yuval Kohavi <yuval.kohavi@gmail.com>
1 parent e7a6ad0 commit f7a0e87

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

BUILD

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
load("@io_bazel_rules_rust//rust:rust.bzl", "rust_library")
22

3+
config_setting(
4+
name = "wasm",
5+
values = {
6+
"platforms": "@io_bazel_rules_rust//rust/platform:wasm",
7+
},
8+
)
9+
10+
311
rust_library(
412
name = "proxy_wasm",
513
srcs = glob(["src/*.rs"]),
@@ -8,6 +16,8 @@ rust_library(
816
deps = [
917
"//bazel/cargo:hashbrown",
1018
"//bazel/cargo:log",
11-
"//bazel/cargo:wee_alloc",
12-
],
19+
] + select({
20+
":wasm": ["//bazel/cargo:wee_alloc"],
21+
"//conditions:default": []
22+
}),
1323
)

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ edition = "2018"
1111
[dependencies]
1212
hashbrown = { version = "0.8", default-features = false, features = ["ahash", "inline-more"] }
1313
log = "0.4"
14-
wee_alloc = "0.4"
14+
15+
[target.'cfg(target_arch = "wasm32")'.dependencies.wee_alloc]
16+
version = "0.4"
1517

1618
[dev-dependencies]
1719
chrono = "0.4"

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub mod hostcalls;
1616
pub mod traits;
1717
pub mod types;
1818

19+
#[cfg(target_arch = "wasm32")]
1920
mod allocator;
2021
mod dispatcher;
2122
mod logger;

0 commit comments

Comments
 (0)