mirror of https://github.com/bazelbuild/rules_rust
Update wasm_bindgen to non-deprecated rules_js API (#2934)
`js_info` needs to jump through some hoops to support the legacy names. The new ones are shorter and clearer. Also, set the toolchain on the action to support Auto Exec Groups while I'm here. Co-authored-by: UebelAndre <github@uebelandre.com>
This commit is contained in:
parent
390c998588
commit
ded96a9a08
|
@ -69,6 +69,14 @@ load("@rules_rust//wasm_bindgen/rules_js:repositories.bzl", "js_rust_wasm_bindge
|
|||
|
||||
js_rust_wasm_bindgen_dependencies()
|
||||
|
||||
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
|
||||
|
||||
rules_js_dependencies()
|
||||
|
||||
load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains")
|
||||
|
||||
rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION)
|
||||
|
||||
###############################################################################
|
||||
# Workspace examples
|
||||
###############################################################################
|
||||
|
@ -106,17 +114,6 @@ load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories")
|
|||
|
||||
node_repositories()
|
||||
|
||||
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
|
||||
|
||||
rules_js_dependencies()
|
||||
|
||||
load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")
|
||||
|
||||
nodejs_register_toolchains(
|
||||
name = "nodejs",
|
||||
node_version = DEFAULT_NODE_VERSION,
|
||||
)
|
||||
|
||||
load("@bazel_features//:deps.bzl", "bazel_features_deps")
|
||||
|
||||
bazel_features_deps()
|
||||
|
|
|
@ -78,6 +78,7 @@ def rust_wasm_bindgen_action(ctx, toolchain, wasm_file, target_output, bindgen_f
|
|||
mnemonic = "RustWasmBindgen",
|
||||
progress_message = "Generating WebAssembly bindings for {}...".format(progress_message_label),
|
||||
arguments = [args],
|
||||
toolchain = str(Label("//wasm_bindgen:toolchain_type")),
|
||||
)
|
||||
|
||||
return RustWasmBindgenInfo(
|
||||
|
|
|
@ -14,20 +14,18 @@ def _js_rust_wasm_bindgen_impl(ctx):
|
|||
bindgen_flags = ctx.attr.bindgen_flags,
|
||||
)
|
||||
|
||||
# Return a structure that is compatible with the deps[] of a ts_library.
|
||||
declarations = info.ts
|
||||
es5_sources = info.js
|
||||
|
||||
return [
|
||||
DefaultInfo(
|
||||
files = depset([info.wasm], transitive = [info.js, info.ts]),
|
||||
),
|
||||
info,
|
||||
# Return a structure that is compatible with the deps[] of a ts_library.
|
||||
js_info(
|
||||
declarations = declarations,
|
||||
sources = es5_sources,
|
||||
transitive_declarations = declarations,
|
||||
transitive_sources = es5_sources,
|
||||
target = ctx.label,
|
||||
sources = info.js,
|
||||
transitive_sources = info.js,
|
||||
types = info.ts,
|
||||
transitive_types = info.ts,
|
||||
),
|
||||
]
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@ def js_rust_wasm_bindgen_dependencies():
|
|||
maybe(
|
||||
http_archive,
|
||||
name = "aspect_rules_js",
|
||||
sha256 = "7b2a4d1d264e105eae49a27e2e78065b23e2e45724df2251eacdd317e95bfdfd",
|
||||
strip_prefix = "rules_js-1.31.0",
|
||||
url = "https://github.com/aspect-build/rules_js/releases/download/v1.31.0/rules_js-v1.31.0.tar.gz",
|
||||
sha256 = "75c25a0f15a9e4592bbda45b57aa089e4bf17f9176fd735351e8c6444df87b52",
|
||||
strip_prefix = "rules_js-2.1.0",
|
||||
url = "https://github.com/aspect-build/rules_js/releases/download/v2.1.0/rules_js-v2.1.0.tar.gz",
|
||||
)
|
||||
|
||||
def js_rust_wasm_bindgen_register_toolchains(**kwargs):
|
||||
|
|
Loading…
Reference in New Issue