v8: include CRDTP bindings in 147 Bazel builds

Add the `crdtp_binding.cc` source and CRDTP headers to the 147 Bazel V8
binding target so Windows GNU builds provide the symbols required by the
`v8::crdtp` Rust APIs.

Add a regression test that exercises CRDTP JSON conversion and dispatchable
message parsing.
This commit is contained in:
Channing Conger
2026-05-11 03:54:06 +00:00
parent 2f79c7ad9d
commit ca7d8f9a78
4 changed files with 56 additions and 2 deletions

View File

@@ -78,4 +78,15 @@ mod tests {
fn evaluates_string_concatenation() {
assert_eq!(evaluate_expression("'hello ' + 'world'"), "hello world");
}
#[test]
fn parses_crdtp_dispatchable_messages() {
let cbor = v8::crdtp::json_to_cbor(br#"{"id":7,"method":"Runtime.evaluate","params":{}}"#)
.expect("JSON should convert to CBOR");
let dispatchable = v8::crdtp::Dispatchable::new(&cbor);
assert!(dispatchable.ok());
assert_eq!(dispatchable.call_id(), 7);
assert_eq!(dispatchable.method(), b"Runtime.evaluate");
}
}

View File

@@ -218,7 +218,7 @@ index 421ebcd..52283ea 100644
],
)
@@ -4465,6 +4474,15 @@ filegroup(
@@ -4465,6 +4474,35 @@ filegroup(
],
)
@@ -230,6 +230,26 @@ index 421ebcd..52283ea 100644
+ strip_include_prefix = "",
+ visibility = ["//visibility:public"],
+)
+
+cc_library(
+ name = "rusty_v8_crdtp_headers",
+ hdrs = [
+ "third_party/inspector_protocol/crdtp/cbor.h",
+ "third_party/inspector_protocol/crdtp/dispatch.h",
+ "third_party/inspector_protocol/crdtp/error_support.h",
+ "third_party/inspector_protocol/crdtp/export.h",
+ "third_party/inspector_protocol/crdtp/find_by_first.h",
+ "third_party/inspector_protocol/crdtp/frontend_channel.h",
+ "third_party/inspector_protocol/crdtp/json.h",
+ "third_party/inspector_protocol/crdtp/parser_handler.h",
+ "third_party/inspector_protocol/crdtp/protocol_core.h",
+ "third_party/inspector_protocol/crdtp/serializable.h",
+ "third_party/inspector_protocol/crdtp/span.h",
+ "third_party/inspector_protocol/crdtp/status.h",
+ ],
+ strip_include_prefix = "",
+ visibility = ["//visibility:public"],
+)
+
filegroup(
name = "d8_files",

View File

@@ -220,6 +220,20 @@ genrule(
]),
)
genrule(
name = "crdtp_binding_cc_147_4_0",
srcs = ["@v8_crate_147_4_0//:crdtp_binding_cc"],
outs = ["crdtp_binding_147_4_0.cc"],
cmd = " ".join([
"sed",
"-e 's|#include \"support.h\"|#include \"support_147_4_0.h\"|'",
"-e 's|\"v8/third_party/inspector_protocol/|\"third_party/inspector_protocol/|g'",
"$(location @v8_crate_147_4_0//:crdtp_binding_cc)",
">",
'"$@"',
]),
)
copy_file(
name = "support_h_147_4_0",
src = "@v8_crate_147_4_0//:support_h",
@@ -228,11 +242,15 @@ copy_file(
cc_library(
name = "v8_147_4_0_binding",
srcs = [":binding_cc_147_4_0"],
srcs = [
":binding_cc_147_4_0",
":crdtp_binding_cc_147_4_0",
],
hdrs = [":support_h_147_4_0"],
copts = V8_COPTS + V8_CUSTOM_LIBCXX_COPTS,
deps = [
"@v8//:core_lib_icu",
"@v8//:rusty_v8_crdtp_headers",
"@v8//:rusty_v8_internal_headers",
] + select({
":use_rusty_v8_custom_libcxx": [

View File

@@ -5,6 +5,11 @@ filegroup(
srcs = ["src/binding.cc"],
)
filegroup(
name = "crdtp_binding_cc",
srcs = ["src/crdtp_binding.cc"],
)
filegroup(
name = "support_h",
srcs = ["src/support.h"],