From ca7d8f9a7853dd1f8485a06978747b71b9eb8589 Mon Sep 17 00:00:00 2001 From: Channing Conger Date: Mon, 11 May 2026 03:54:06 +0000 Subject: [PATCH] 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. --- codex-rs/v8-poc/src/lib.rs | 11 +++++++++++ patches/v8_bazel_rules.patch | 22 +++++++++++++++++++++- third_party/v8/BUILD.bazel | 20 +++++++++++++++++++- third_party/v8/v8_crate.BUILD.bazel | 5 +++++ 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/codex-rs/v8-poc/src/lib.rs b/codex-rs/v8-poc/src/lib.rs index f43a9a1253..5103cdeb39 100644 --- a/codex-rs/v8-poc/src/lib.rs +++ b/codex-rs/v8-poc/src/lib.rs @@ -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"); + } } diff --git a/patches/v8_bazel_rules.patch b/patches/v8_bazel_rules.patch index 71265b32ae..1c49d06b09 100644 --- a/patches/v8_bazel_rules.patch +++ b/patches/v8_bazel_rules.patch @@ -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", diff --git a/third_party/v8/BUILD.bazel b/third_party/v8/BUILD.bazel index df8e06328c..459d935854 100644 --- a/third_party/v8/BUILD.bazel +++ b/third_party/v8/BUILD.bazel @@ -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": [ diff --git a/third_party/v8/v8_crate.BUILD.bazel b/third_party/v8/v8_crate.BUILD.bazel index f9b2a1998c..3988bc0345 100644 --- a/third_party/v8/v8_crate.BUILD.bazel +++ b/third_party/v8/v8_crate.BUILD.bazel @@ -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"],