Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions checksums/tools/wit-bindgen-wrpc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"tool_name": "wit-bindgen-wrpc",
"github_repo": "bytecodealliance/wrpc",
"latest_version": "0.16.0",
"last_checked": "2026-02-07T00:00:00Z",
"description": "WIT binding generator for WebAssembly Component RPC (wrpc)",
"versions": {
"0.16.0": {
"release_date": "2025-11-18",
"platforms": {
"darwin_arm64": {
"sha256": "d2ef54ca193ee3d16cd23c67adb42713dc8ba2c96968eff53b9bcc3051466a65",
"url_suffix": "wit-bindgen-wrpc-aarch64-apple-darwin"
},
"darwin_amd64": {
"sha256": "e60efb3198774996f250e0168fd555cd9c6e056f863dc3983f373df119d2cdc4",
"url_suffix": "wit-bindgen-wrpc-x86_64-apple-darwin"
},
"linux_amd64": {
"sha256": "ce66c70da2f612c91c5d42b4eff86773dd7d13821b4c6eccea4d1dd62c399326",
"url_suffix": "wit-bindgen-wrpc-x86_64-unknown-linux-musl"
},
"linux_arm64": {
"sha256": "b35772253ef4030ec8b420fde3145610e5de44350d89a0e5135c53248a4f1f9e",
"url_suffix": "wit-bindgen-wrpc-aarch64-unknown-linux-musl"
},
"windows_amd64": {
"sha256": "e08a74f717e77372cf1104e4da6c3aa301c9283ae13b984a55b67bd6ebf84a51",
"url_suffix": "wit-bindgen-wrpc-x86_64-pc-windows-gnu.exe"
}
}
}
},
"supported_platforms": [
"darwin_amd64",
"darwin_arm64",
"linux_amd64",
"linux_arm64",
"windows_amd64"
]
}
42 changes: 42 additions & 0 deletions checksums/tools/wrpc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"tool_name": "wrpc",
"github_repo": "bytecodealliance/wrpc",
"latest_version": "0.16.0",
"last_checked": "2026-02-07T00:00:00Z",
"description": "WebAssembly Component RPC runtime (wrpc-wasmtime)",
"binary_name": "wrpc-wasmtime",
"versions": {
"0.16.0": {
"release_date": "2025-11-18",
"platforms": {
"darwin_arm64": {
"sha256": "4bb3341c8b8ad5d96b87dd95ee1e7e091104d4f64ea83b690ad50a9639b834e1",
"url_suffix": "wrpc-wasmtime-aarch64-apple-darwin"
},
"darwin_amd64": {
"sha256": "9d198256eb72f6246fa424b1f3c384f9eac8476b7da59ac1ddb65323bb2ccb57",
"url_suffix": "wrpc-wasmtime-x86_64-apple-darwin"
},
"linux_amd64": {
"sha256": "5669a01a64da8954b864df9ec934fd8ef318446f7d8f97263d27fbd5f30c07a8",
"url_suffix": "wrpc-wasmtime-x86_64-unknown-linux-musl"
},
"linux_arm64": {
"sha256": "542810b5bd159b2d412fc6a0a32f17e53b9732fca8c9ea66f2bdef1d807cdc9f",
"url_suffix": "wrpc-wasmtime-aarch64-unknown-linux-musl"
},
"windows_amd64": {
"sha256": "bb28a2da97805be2cf3be146bdf68931e3dada7598be3d7750551a5824d2b4a5",
"url_suffix": "wrpc-wasmtime-x86_64-pc-windows-gnu.exe"
}
}
}
},
"supported_platforms": [
"darwin_amd64",
"darwin_arm64",
"linux_amd64",
"linux_arm64",
"windows_amd64"
]
}
12 changes: 12 additions & 0 deletions toolchains/tool_registry.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@ _URL_PATTERNS = {
"base": "https://github.com/{repo}/releases/download/{version}",
"filename": "componentize-py-{version}-{suffix}",
},
"wrpc": {
# wrpc releases are standalone binaries (wrpc-wasmtime)
"base": "https://github.com/{repo}/releases/download/v{version}",
"filename": "{suffix}", # url_suffix IS the filename (e.g., "wrpc-wasmtime-aarch64-apple-darwin")
"is_binary": True,
},
"wit-bindgen-wrpc": {
# wit-bindgen-wrpc releases are standalone binaries
"base": "https://github.com/{repo}/releases/download/v{version}",
"filename": "{suffix}", # url_suffix IS the filename (e.g., "wit-bindgen-wrpc-aarch64-apple-darwin")
"is_binary": True,
},
}

def _build_download_url(tool_name, version, platform, tool_info, github_repo):
Expand Down
4 changes: 4 additions & 0 deletions toolchains/tool_versions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ TOOL_VERSIONS = {
# Signatures and security
"wasmsign2": "0.2.6", # WebAssembly signing tool

# WRPC (WebAssembly Component RPC)
"wrpc": "0.16.0", # wrpc-wasmtime runtime for component RPC
"wit-bindgen-wrpc": "0.16.0", # WIT binding generator for wrpc

# Platform SDKs
"wasi-sdk": "29", # WASI SDK for C/C++ compilation
"tinygo": "0.39.0", # TinyGo compiler for Go→WASM
Expand Down
75 changes: 57 additions & 18 deletions toolchains/wasm_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def _wasm_tools_toolchain_impl(ctx):
wac = ctx.file.wac,
wit_bindgen = ctx.file.wit_bindgen,
wrpc = ctx.file.wrpc,
wit_bindgen_wrpc = ctx.file.wit_bindgen_wrpc,
wasmsign2 = ctx.file.wasmsign2,
)

Expand Down Expand Up @@ -77,7 +78,13 @@ wasm_tools_toolchain = rule(
allow_single_file = True,
executable = True,
cfg = "exec",
doc = "wrpc binary",
doc = "wrpc-wasmtime runtime binary",
),
"wit_bindgen_wrpc": attr.label(
allow_single_file = True,
executable = True,
cfg = "exec",
doc = "wit-bindgen-wrpc binding generator binary",
),
"wasmsign2": attr.label(
allow_single_file = True,
Expand All @@ -86,7 +93,7 @@ wasm_tools_toolchain = rule(
doc = "wasmsign2 WebAssembly signing binary",
),
},
doc = "Declares a WebAssembly toolchain with signing support",
doc = "Declares a WebAssembly toolchain with WRPC and signing support",
)

# Platform detection now uses tool_registry.detect_platform
Expand Down Expand Up @@ -329,12 +336,8 @@ echo "Basic WebAssembly component functionality is not affected"
exit 0
""", executable = True)

# Create placeholder wrpc binary for compatibility
repository_ctx.file("wrpc", """#!/bin/bash
echo "wrpc disabled for production stability"
echo "Use system wrpc or enable building from source"
exit 1
""", executable = True)
# Download wrpc tools from registry (Phase 2 WRPC modernization)
_download_wrpc_tools(repository_ctx, platform)

print("Successfully set up all tools")

Expand Down Expand Up @@ -504,23 +507,44 @@ def _download_wit_bindgen(repository_ctx):
# Use unified tool_registry for download
tool_registry.download(repository_ctx, "wit-bindgen", wit_bindgen_version, platform)

def _download_wrpc(repository_ctx):
"""Download wrpc using modernized git_repository approach"""
def _download_wrpc_tools(repository_ctx, platform):
"""Download wrpc and wit-bindgen-wrpc from registry (Phase 2 WRPC modernization)"""

print("Using modernized wrpc from @wrpc_src git repository")
# Get versions from tool_versions.bzl
wrpc_version = get_tool_version("wrpc")
wit_bindgen_wrpc_version = get_tool_version("wit-bindgen-wrpc")

# Link to git_repository-based wrpc build instead of manual git clone + cargo build
if repository_ctx.path("../wrpc_src").exists:
repository_ctx.symlink("../wrpc_src/wrpc-wasmtime", "wrpc")
print("Linked wrpc from git repository")
# Check if wrpc is available for this platform
wrpc_info = get_tool_info(repository_ctx, "wrpc", wrpc_version, platform)
if wrpc_info:
print("Downloading wrpc {} for {}".format(wrpc_version, platform))
tool_registry.download(repository_ctx, "wrpc", wrpc_version, platform, output_name = "wrpc")
else:
print("Warning: @wrpc_src git repository not available")
print("Warning: wrpc {} not available for platform {}".format(wrpc_version, platform))
repository_ctx.file("wrpc", """#!/bin/bash
echo "wrpc: modernized git repository build not available"
echo "Ensure @wrpc_src is properly configured in MODULE.bazel"
echo "wrpc: Not available for this platform"
echo "Use system wrpc or build from source"
exit 1
""", executable = True)

# Check if wit-bindgen-wrpc is available for this platform
wit_bindgen_wrpc_info = get_tool_info(repository_ctx, "wit-bindgen-wrpc", wit_bindgen_wrpc_version, platform)
if wit_bindgen_wrpc_info:
print("Downloading wit-bindgen-wrpc {} for {}".format(wit_bindgen_wrpc_version, platform))
tool_registry.download(repository_ctx, "wit-bindgen-wrpc", wit_bindgen_wrpc_version, platform, output_name = "wit-bindgen-wrpc")
else:
print("Warning: wit-bindgen-wrpc {} not available for platform {}".format(wit_bindgen_wrpc_version, platform))
repository_ctx.file("wit-bindgen-wrpc", """#!/bin/bash
echo "wit-bindgen-wrpc: Not available for this platform"
echo "Use system wit-bindgen-wrpc or build from source"
exit 1
""", executable = True)

def _download_wrpc(repository_ctx):
"""Legacy wrpc download - redirects to new implementation"""
platform = tool_registry.detect_platform(repository_ctx)
_download_wrpc_tools(repository_ctx, platform)

def _download_wasmsign2(repository_ctx):
"""Setup wasmsign2 placeholder - not available in prebuilt downloads"""

Expand Down Expand Up @@ -586,6 +610,12 @@ alias(
visibility = ["//visibility:public"],
)

alias(
name = "wit_bindgen_wrpc_binary",
actual = "@wrpc_src//:wit_bindgen_wrpc_binary",
visibility = ["//visibility:public"],
)

# wasmsign2 not available in build strategy
filegroup(
name = "wasmsign2_binary",
Expand All @@ -600,6 +630,7 @@ wasm_tools_toolchain(
wac = ":wac_binary",
wit_bindgen = ":wit_bindgen_binary",
wrpc = ":wrpc_binary",
wit_bindgen_wrpc = ":wit_bindgen_wrpc_binary",
wasmsign2 = ":wasmsign2_binary",
)

Expand Down Expand Up @@ -646,6 +677,12 @@ filegroup(
visibility = ["//visibility:public"],
)

filegroup(
name = "wit_bindgen_wrpc_binary",
srcs = ["{wit_bindgen_wrpc_bin}"],
visibility = ["//visibility:public"],
)

filegroup(
name = "wasmsign2_binary",
srcs = ["{wasmsign2_bin}"],
Expand All @@ -659,6 +696,7 @@ wasm_tools_toolchain(
wac = ":wac_binary",
wit_bindgen = ":wit_bindgen_binary",
wrpc = ":wrpc_binary",
wit_bindgen_wrpc = ":wit_bindgen_wrpc_binary",
wasmsign2 = ":wasmsign2_binary",
)

Expand All @@ -680,6 +718,7 @@ toolchain(
wac_bin = "wac{}".format(exe_suffix),
wit_bindgen_bin = "wit-bindgen{}".format(exe_suffix),
wrpc_bin = "wrpc{}".format(exe_suffix),
wit_bindgen_wrpc_bin = "wit-bindgen-wrpc{}".format(exe_suffix),
wasmsign2_bin = "wasmsign2{}".format(exe_suffix),
)

Expand Down
24 changes: 12 additions & 12 deletions wrpc/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,35 @@ def _wrpc_bindgen_impl(ctx):

Generates language bindings for wrpc from WIT interfaces.
Uses ctx.actions.run() for direct tool invocation (Bazel best practice).

Note: This rule uses wit-bindgen-wrpc (the binding generator), not wrpc-wasmtime
(the RPC runtime). wrpc-wasmtime is used by wrpc_serve and wrpc_invoke rules.
"""

# Get the wasm toolchain (which includes wrpc)
# Get the wasm toolchain (which includes wit-bindgen-wrpc)
wasm_toolchain = ctx.toolchains["//toolchains:wasm_tools_toolchain_type"]
wrpc = wasm_toolchain.wrpc
wit_bindgen_wrpc = wasm_toolchain.wit_bindgen_wrpc

# Output files
output_dir = ctx.actions.declare_directory(ctx.attr.name + "_bindings")

# Input WIT file
wit_file = ctx.file.wit

# Build command arguments
# Build command arguments for wit-bindgen-wrpc
args = ctx.actions.args()
args.add("generate")
args.add(ctx.attr.language) # wit-bindgen-wrpc <language> <options>
args.add("--world", ctx.attr.world)
args.add("--wit", wit_file.path)
args.add("--output", output_dir.path)

if ctx.attr.language:
args.add("--language", ctx.attr.language)
args.add("--out-dir", output_dir.path)
args.add(wit_file.path)

# Run wrpc generate - uses ctx.actions.run() (Bazel best practice)
# Run wit-bindgen-wrpc - uses ctx.actions.run() (Bazel best practice)
ctx.actions.run(
executable = wrpc,
executable = wit_bindgen_wrpc,
arguments = [args],
inputs = [wit_file],
outputs = [output_dir],
mnemonic = "WrpcBindgen",
mnemonic = "WitBindgenWrpc",
progress_message = "Generating wrpc bindings for {}".format(ctx.attr.name),
)

Expand Down