Skip to content

Commit

Permalink
tests: add wasi/wasm build tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rrbutani committed Sep 13, 2021
1 parent 7775fd4 commit 6c86168
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 1 deletion.
11 changes: 10 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,17 @@ llvm_toolchain(
},
)

# Well known repos; present here only for testing.
# `bazel_skylib`; we're using its `build_test` test
http_archive(
name = "bazel_skylib",
urls = [
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
],
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
)

# Well known repos; present here only for testing.
http_archive(
name = "com_google_googletest",
sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb",
Expand Down
73 changes: 73 additions & 0 deletions tests/extra_targets/wasm/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load(":transitions.bzl", "wasm_file", "wasi_file")

# config_setting(
# name = "no_shared_objects",
# values = {
# "features": "-supports_dynamic_linker",
# }
# )

# cc_library(
# name = "stdlib-wasm",
# srcs = ["stdlib.cc"],
# hdrs = ["stdlib.h"],
# features = [
# "-supports_dynamic_linker",
# ],
# target_compatible_with = [
# "@platforms//cpu:wasm32",
# "@platforms//os:wasi",
# ],
# )

# TODO: add a rule that transitions --platforms to `//test:wasm` to ensure that
# toolchain resolution picks `@llvm_toolchain//:cc-clang-*_wasm32-unknown-unknown`.
#
# also have it set `--features=-supports_dynamic_linker`; ideally this would be in
# the toolchain definition but the downside of switching to using
# `unix_cc_toolchain_config.bzl` is that we lose this knob
#
# it's not clear yet if supporting different targets runs counter to using
# `unix_cc_toolchain_config.bzl` altogether – so far things are manageable but
# it's already apparent that we'll be sacrificing some power/configurability

###############################################################################

platform(
name = "wasm",
constraint_values = [
"@platforms//cpu:wasm32",
"@platforms//os:none",
],
)

wasm_file(
name = "test.wasm",
src = "//tests:simple_binary",
)

build_test(
name = "wasm_build_chk",
targets = [":test.wasm"],
)

###############################################################################

platform(
name = "wasi",
constraint_values = [
"@platforms//cpu:wasm32",
"@platforms//os:wasi",
],
)

wasi_file(
name = "test.wasi",
src = "//tests:stdlib_binary",
)

build_test(
name = "wasi_build_chk",
targets = [":test.wasi"],
)

0 comments on commit 6c86168

Please sign in to comment.