[bazel] Switch to platforms-based toolchain resolution (#1036)

This commit is contained in:
John Firebaugh
2022-11-08 14:21:06 -08:00
committed by GitHub
parent 92d9023adc
commit 005063304b
11 changed files with 41 additions and 24 deletions

View File

@@ -1,4 +1,4 @@
load(":crosstool.bzl", "emscripten_cc_toolchain_config_rule")
load(":toolchain.bzl", "emscripten_cc_toolchain_config_rule")
package(default_visibility = ["//visibility:public"])
@@ -86,6 +86,13 @@ cc_toolchain_suite(
},
)
toolchain(
name = "cc-toolchain-wasm",
target_compatible_with = ["@platforms//cpu:wasm32"],
toolchain = ":cc-compiler-wasm",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
)
py_binary(
name = "wasm_binary",
srcs = ["wasm_binary.py"],

View File

@@ -1105,7 +1105,7 @@ emscripten_cc_toolchain_config_rule = rule(
attrs = {
"cpu": attr.string(mandatory = True, values = ["asmjs", "wasm"]),
"em_config": attr.label(mandatory = True, allow_single_file = True),
"emscripten_binaries": attr.label(mandatory = True),
"emscripten_binaries": attr.label(mandatory = True, cfg = "exec"),
"script_extension": attr.string(mandatory = True, values = ["sh", "bat"]),
},
provides = [CcToolchainConfigInfo],

View File

@@ -32,7 +32,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": [],
"//command_line_option:platforms": ["@emsdk//:platform_wasm"],
"//command_line_option:custom_malloc": "@emsdk//emscripten_toolchain:malloc",
}