Skip to content

Commit 1d0aa6e

Browse files
committed
tests: add wasi/wasm build tests
1 parent 7775fd4 commit 1d0aa6e

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed

WORKSPACE

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,20 @@ llvm_toolchain(
9797
},
9898
)
9999

100-
# Well known repos; present here only for testing.
100+
# `bazel_skylib`; we're using its `build_test` test
101+
http_archive(
102+
name = "bazel_skylib",
103+
urls = [
104+
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
105+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
106+
],
107+
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
108+
)
109+
110+
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
111+
bazel_skylib_workspace()
101112

113+
# Well known repos; present here only for testing.
102114
http_archive(
103115
name = "com_google_googletest",
104116
sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb",

tests/extra_targets/wasm/BUILD.bazel

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
load("@bazel_skylib//rules:build_test.bzl", "build_test")
2+
load(":transitions.bzl", "wasm_file", "wasi_file")
3+
4+
# config_setting(
5+
# name = "no_shared_objects",
6+
# values = {
7+
# "features": "-supports_dynamic_linker",
8+
# }
9+
# )
10+
11+
# cc_library(
12+
# name = "stdlib-wasm",
13+
# srcs = ["stdlib.cc"],
14+
# hdrs = ["stdlib.h"],
15+
# features = [
16+
# "-supports_dynamic_linker",
17+
# ],
18+
# target_compatible_with = [
19+
# "@platforms//cpu:wasm32",
20+
# "@platforms//os:wasi",
21+
# ],
22+
# )
23+
24+
# TODO: add a rule that transitions --platforms to `//test:wasm` to ensure that
25+
# toolchain resolution picks `@llvm_toolchain//:cc-clang-*_wasm32-unknown-unknown`.
26+
#
27+
# also have it set `--features=-supports_dynamic_linker`; ideally this would be in
28+
# the toolchain definition but the downside of switching to using
29+
# `unix_cc_toolchain_config.bzl` is that we lose this knob
30+
#
31+
# it's not clear yet if supporting different targets runs counter to using
32+
# `unix_cc_toolchain_config.bzl` altogether – so far things are manageable but
33+
# it's already apparent that we'll be sacrificing some power/configurability
34+
35+
###############################################################################
36+
37+
platform(
38+
name = "wasm",
39+
constraint_values = [
40+
"@platforms//cpu:wasm32",
41+
"@platforms//os:none",
42+
],
43+
)
44+
45+
wasm_file(
46+
name = "test.wasm",
47+
src = "//tests:simple_binary",
48+
)
49+
50+
build_test(
51+
name = "wasm_build_chk",
52+
targets = [":test.wasm"],
53+
)
54+
55+
###############################################################################
56+
57+
platform(
58+
name = "wasi",
59+
constraint_values = [
60+
"@platforms//cpu:wasm32",
61+
"@platforms//os:wasi",
62+
],
63+
)
64+
65+
wasi_file(
66+
name = "test.wasi",
67+
src = "//tests:stdlib_binary",
68+
)
69+
70+
build_test(
71+
name = "wasi_build_chk",
72+
targets = [":test.wasi"],
73+
)

0 commit comments

Comments
 (0)