Skip to content

Commit

Permalink
wasm_cc_binary: Specify a default OS. Allow users to override platfor…
Browse files Browse the repository at this point in the history
…m. (emscripten-core#1262)

* wasm_cc_binary: Specify a default OS. Allow users to override platform.

Problem: proxy-wasm/proxy-wasm-cpp-sdk#157 (comment)

This is solving the problem in two different ways. Please let me know
your thoughts about both approaches, as either will work.

Signed-off-by: Martijn Stevenson <mstevenson@google.com>

* Rework platform selection to trigger os:wasi off standalone attr

Signed-off-by: Martijn Stevenson <mstevenson@google.com>

---------

Signed-off-by: Martijn Stevenson <mstevenson@google.com>
  • Loading branch information
martijneken authored and shlomif committed Sep 29, 2023
1 parent b25d87e commit c5e02fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,11 @@ platform(
"@platforms//cpu:wasm32",
],
)

platform(
name = "platform_wasi",
constraint_values = [
"@platforms//cpu:wasm32",
"@platforms//os:wasi",
],
)
4 changes: 3 additions & 1 deletion bazel/emscripten_toolchain/wasm_cc_binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def _wasm_transition_impl(settings, attr):
if attr.simd:
features.append("wasm_simd")

platform = "@emsdk//:platform_wasm"
if attr.standalone:
platform = "@emsdk//:platform_wasi"
features.append("wasm_standalone")

return {
Expand All @@ -35,7 +37,7 @@ def _wasm_transition_impl(settings, attr):
"//command_line_option:features": features,
"//command_line_option:dynamic_mode": "off",
"//command_line_option:linkopt": linkopts,
"//command_line_option:platforms": ["@emsdk//:platform_wasm"],
"//command_line_option:platforms": [platform],
"//command_line_option:custom_malloc": "@emsdk//emscripten_toolchain:malloc",
}

Expand Down

0 comments on commit c5e02fa

Please sign in to comment.