pw_unit_test: Require 'light' backend for RPC service

The pw_unit_test RPC service only supports the 'light' backend. If it's
used with another backend such as GoogleTest, there will be misleading
compilation errors and the service won't find any of the tests.

This commit adds a build assertion to check that the correct backend is
in use if the RPC service is used.

Change-Id: I184c7476d9f88432cc98a686f1f4f75acd6b0a58
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/97907
Commit-Queue: Eli Lipsitz <elipsitz@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
diff --git a/pw_unit_test/BUILD.gn b/pw_unit_test/BUILD.gn
index 451fd62..73d22b0 100644
--- a/pw_unit_test/BUILD.gn
+++ b/pw_unit_test/BUILD.gn
@@ -167,6 +167,20 @@
   sources = [ "logging_main.cc" ]
 }
 
+pw_build_assert("require_light_test_backend") {
+  # TODO(b/233073669): Simplify once pw_unit_test_PUBLIC_DEPS is removed.
+  condition = (pw_unit_test_PUBLIC_DEPS == [] &&
+               pw_unit_test_GOOGLETEST_BACKEND == "$dir_pw_unit_test:light") ||
+              filter_include(pw_unit_test_PUBLIC_DEPS,
+                             [ "$dir_pw_unit_test:light" ]) != []
+
+  message = "The pw_unit_test RPC service only works with the 'light' test " +
+            "backend.\n(pw_unit_test_GOOGLETEST_BACKEND = " +
+            "$pw_unit_test_GOOGLETEST_BACKEND)\n" +
+            "(pw_unit_test_PUBLIC_DEPS = $pw_unit_test_PUBLIC_DEPS)"
+  visibility = [ ":*" ]
+}
+
 pw_source_set("rpc_service") {
   public_configs = [ ":public_include_path" ]
   public_deps = [
@@ -175,7 +189,10 @@
     ":unit_test_proto.raw_rpc",
     "$dir_pw_containers:vector",
   ]
-  deps = [ dir_pw_log ]
+  deps = [
+    ":require_light_test_backend",
+    dir_pw_log,
+  ]
   public = [
     "public/pw_unit_test/internal/rpc_event_handler.h",
     "public/pw_unit_test/unit_test_service.h",
diff --git a/pw_unit_test/docs.rst b/pw_unit_test/docs.rst
index 7b1edd2..880a3fa 100644
--- a/pw_unit_test/docs.rst
+++ b/pw_unit_test/docs.rst
@@ -378,7 +378,8 @@
 ``pw_unit_test`` provides an RPC service which runs unit tests on demand and
 streams the results back to the client. The service is defined in
 ``pw_unit_test_proto/unit_test.proto``, and implemented by the GN target
-``$dir_pw_unit_test:rpc_service``.
+``$dir_pw_unit_test:rpc_service``. The RPC service is only compatible with the
+default ``pw_unit_test:light`` backend.
 
 To set up RPC-based unit tests in your application, instantiate a
 ``pw::unit_test::UnitTestService`` and register it with your RPC server.