[rust] Fix `deps` propagation through `rust_bindgen` GN template.

Before this CL, `rust_bindgen` GN template would recognize+consume
`invoker.deps`, but those would only be used to set `-Dsome_define`.
In particular, those would not become `deps` of `rust_static_library`.

The above meant that `rust_bindgen("foo_bindings")` is not
self-contained.  Before this CL targets depending on `foo_bindings`
would also have to depend on `foo` (the C/C++ library defining the
function that the generated bindings wrap).

This CL fixes propagation of `deps` in `rust_bindgen.gni` and then
fixes users of this template to avoid needlessly specifying the C/C++
dependency twice.

Bug: 411418184
Change-Id: I25c36632db572407a220fd7b26085389e259dd1b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6471409
Commit-Queue: Ɓukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1448861}
diff --git a/base/BUILD.gn b/base/BUILD.gn
index 3e2fa6e..b7ed9ee99 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -2552,7 +2552,6 @@
 rust_static_library("rust_logger") {
   allow_unsafe = true  # Unsafe needed for FFI.
   deps = [
-    ":debugging_buildflags",
     ":logging_log_severity_bindgen",
     ":tracing_buildflags",
     "//build:chromeos_buildflags",
diff --git a/build/rust/rust_bindgen.gni b/build/rust/rust_bindgen.gni
index 5c809c6..f046534 100644
--- a/build/rust/rust_bindgen.gni
+++ b/build/rust/rust_bindgen.gni
@@ -100,11 +100,17 @@
     sources = [ crate_root ]
     bindgen_deps = [ ":$_rust_bindgen_generator_name" ]
     allow_unsafe = true
+
+    deps = []
+    if (defined(invoker.deps)) {
+      deps += invoker.deps
+    }
     if (_wrap_static_fns) {
       # Add a dependency on the static_fns library for simplicity if
       # it's declared.
-      deps = [ ":${_rust_bindgen_generator_name}_static_fns" ]
+      deps += [ ":${_rust_bindgen_generator_name}_static_fns" ]
     }
+
     if (defined(cpp) && cpp) {
       # This cfg is used to control the bindings public export.
       rustflags = [
diff --git a/build/rust/tests/bindgen_cpp_test/BUILD.gn b/build/rust/tests/bindgen_cpp_test/BUILD.gn
index 8532fbe..9cb22b4 100644
--- a/build/rust/tests/bindgen_cpp_test/BUILD.gn
+++ b/build/rust/tests/bindgen_cpp_test/BUILD.gn
@@ -19,10 +19,7 @@
 }
 
 rust_executable("bindgen_cpp_test") {
-  deps = [
-    ":cpp_lib",
-    ":cpp_lib_bindgen",
-  ]
+  deps = [ ":cpp_lib_bindgen" ]
   sources = [ "main.rs" ]
   crate_root = "main.rs"
 
diff --git a/build/rust/tests/bindgen_cpp_test_with_cpp_linkage/BUILD.gn b/build/rust/tests/bindgen_cpp_test_with_cpp_linkage/BUILD.gn
index 130d2ae..3568406 100644
--- a/build/rust/tests/bindgen_cpp_test_with_cpp_linkage/BUILD.gn
+++ b/build/rust/tests/bindgen_cpp_test_with_cpp_linkage/BUILD.gn
@@ -19,10 +19,7 @@
 }
 
 rust_static_library("rust_lib") {
-  deps = [
-    ":cpp_lib",
-    ":cpp_lib_bindgen",
-  ]
+  deps = [ ":cpp_lib_bindgen" ]
   sources = [ "lib.rs" ]
   crate_root = "lib.rs"
 
diff --git a/build/rust/tests/bindgen_static_fns_test/BUILD.gn b/build/rust/tests/bindgen_static_fns_test/BUILD.gn
index a07f1ad..7c43fe2 100644
--- a/build/rust/tests/bindgen_static_fns_test/BUILD.gn
+++ b/build/rust/tests/bindgen_static_fns_test/BUILD.gn
@@ -20,16 +20,13 @@
 
 rust_bindgen("c_lib_bindgen") {
   header = "lib.h"
-  deps = [ ":c_lib_headers" ]
+  deps = [ ":c_lib" ]
   wrap_static_fns = true
 }
 
 rust_static_library("bindgen_static_fns_test_lib") {
   allow_unsafe = true
-  deps = [
-    ":c_lib",
-    ":c_lib_bindgen",
-  ]
+  deps = [ ":c_lib_bindgen" ]
   sources = [ "src/lib.rs" ]
   build_native_rust_unit_tests = true
   crate_root = "src/lib.rs"
diff --git a/build/rust/tests/bindgen_test/BUILD.gn b/build/rust/tests/bindgen_test/BUILD.gn
index ab1b9f3..b8e1a8a3 100644
--- a/build/rust/tests/bindgen_test/BUILD.gn
+++ b/build/rust/tests/bindgen_test/BUILD.gn
@@ -23,15 +23,12 @@
 
 rust_bindgen("c_lib_bindgen") {
   header = "lib.h"
-  deps = [ ":c_lib_headers" ]
+  deps = [ ":c_lib" ]
 }
 
 rust_static_library("bindgen_test_lib") {
   allow_unsafe = true
-  deps = [
-    ":c_lib",
-    ":c_lib_bindgen",
-  ]
+  deps = [ ":c_lib_bindgen" ]
   sources = [ "src/lib.rs" ]
   build_native_rust_unit_tests = true
   crate_root = "src/lib.rs"
diff --git a/build/rust/tests/windows_sys_test/BUILD.gn b/build/rust/tests/windows_sys_test/BUILD.gn
index a67e092..e0c119a 100644
--- a/build/rust/tests/windows_sys_test/BUILD.gn
+++ b/build/rust/tests/windows_sys_test/BUILD.gn
@@ -2,9 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-import("//build/rust/rust_bindgen.gni")
 import("//build/rust/rust_executable.gni")
-import("//build/rust/rust_static_library.gni")
 
 rust_executable("windows_sys_test") {
   allow_unsafe = true  # Calls FFI.
diff --git a/mojo/public/rust/BUILD.gn b/mojo/public/rust/BUILD.gn
index 933d3e75..f61b5904 100644
--- a/mojo/public/rust/BUILD.gn
+++ b/mojo/public/rust/BUILD.gn
@@ -74,7 +74,6 @@
 
   deps = [
     ":mojo_c_system_binding",
-    ":mojo_c_system_wrapper",
     "//mojo/public/c/system",
     "//third_party/rust/bitflags/v2:lib",
   ]