Skip to content

Commit ef2a8e9

Browse files
authored
wasm_cc_binary: Specify a default OS. Allow users to override platform. (#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 <[email protected]> * Rework platform selection to trigger os:wasi off standalone attr Signed-off-by: Martijn Stevenson <[email protected]> --------- Signed-off-by: Martijn Stevenson <[email protected]>
1 parent a896e3d commit ef2a8e9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

bazel/BUILD

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,11 @@ platform(
8484
"@platforms//cpu:wasm32",
8585
],
8686
)
87+
88+
platform(
89+
name = "platform_wasi",
90+
constraint_values = [
91+
"@platforms//cpu:wasm32",
92+
"@platforms//os:wasi",
93+
],
94+
)

bazel/emscripten_toolchain/wasm_cc_binary.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ def _wasm_transition_impl(settings, attr):
2525
if attr.simd:
2626
features.append("wasm_simd")
2727

28+
platform = "@emsdk//:platform_wasm"
2829
if attr.standalone:
30+
platform = "@emsdk//:platform_wasi"
2931
features.append("wasm_standalone")
3032

3133
return {
@@ -35,7 +37,7 @@ def _wasm_transition_impl(settings, attr):
3537
"//command_line_option:features": features,
3638
"//command_line_option:dynamic_mode": "off",
3739
"//command_line_option:linkopt": linkopts,
38-
"//command_line_option:platforms": ["@emsdk//:platform_wasm"],
40+
"//command_line_option:platforms": [platform],
3941
"//command_line_option:custom_malloc": "@emsdk//emscripten_toolchain:malloc",
4042
}
4143

0 commit comments

Comments
 (0)