From: Gentoo Overlay <gentoo@localhost>
Subject: [PATCH] cbor: gate Rust dependencies on Crubit availability

Keep the build flag, library dependencies and unit test dependencies
conditional on enable_cpp_api_from_rust. Chromium 155 adds Rust bindings
to the unit test dependency list alongside the Rust unit tests.

--- a/components/cbor/BUILD.gn
+++ b/components/cbor/BUILD.gn
@@ -12,7 +12,7 @@
   # TODO(crbug.com/535682335): Remove `USE_CBOR_RUST` buildflag entirely,
   # unconditionally enable Rust CBOR parser, and drop `is_cronet_build` check
   # once Cronet supports Crubit dependencies.
-  flags = [ "USE_CBOR_RUST=!$is_cronet_build" ]
+  flags = [ "USE_CBOR_RUST=!$is_cronet_build && $enable_cpp_api_from_rust" ]
 }
 
 component("cbor") {
@@ -35,7 +35,7 @@
     "//base",
   ]
 
-  if (!is_cronet_build) {
+  if (!is_cronet_build && enable_cpp_api_from_rust) {
     public_deps = [
       "//build/rust/crubit",
       "//components/cbor/rust:cbor_rust_bindings",
@@ -62,7 +62,7 @@
     "//testing/gtest",
     "//third_party/fuzztest",
   ]
-  if (!is_cronet_build) {
+  if (!is_cronet_build && enable_cpp_api_from_rust) {
     deps += [
       "//components/cbor/rust:cbor_rust_bindings",
       "//components/cbor/rust:cbor_rust_unittests",
