pw_rpc: Make Service independent of Method

Rather than depending on the concrete Method implementation, store a
BaseMethod* and the method implementation's size.

Change-Id: Ic52a9a7526f542ab872ed6a14be5c93e93dd95f1
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/18240
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
diff --git a/pw_rpc/BUILD.gn b/pw_rpc/BUILD.gn
index 8796f26..2c7f67e 100644
--- a/pw_rpc/BUILD.gn
+++ b/pw_rpc/BUILD.gn
@@ -79,10 +79,11 @@
 # Provides the public RPC service definition (but not implementation). Can be
 # used to expose global service registration without depending on the complete
 # RPC library.
-pw_source_set("service") {
-  public_configs = [ ":default_config" ]
-  public_deps = [ "$dir_pw_containers:intrusive_list" ]
-  public = [ "public/pw_rpc/service.h" ]
+# TODO(hepler): Remove this after making the RPC implementation classes fully
+#     independent of the particular implementation. Targets needing the service
+#     should be able to depend on the main RPC library.
+group("service") {
+  deps = [ ":common" ]
 }
 
 # Put these dependencies into a group since they need to be shared by the server
@@ -103,12 +104,15 @@
   public_configs = [ ":default_config" ]
   public_deps = [
     ":protos_pwpb",
+    "$dir_pw_containers:intrusive_list",
     dir_pw_assert,
-    dir_pw_log,
     dir_pw_span,
     dir_pw_status,
   ]
-  public = [ "public/pw_rpc/channel.h" ]
+  public = [
+    "public/pw_rpc/channel.h",
+    "public/pw_rpc/service.h",
+  ]
   sources = [
     "channel.cc",
     "packet.cc",
@@ -118,6 +122,7 @@
     "public/pw_rpc/internal/hash.h",
     "public/pw_rpc/internal/packet.h",
   ]
+  deps = [ dir_pw_log ]
   friend = [ "./*" ]
 }
 
@@ -166,6 +171,7 @@
     ":channel_test",
     ":packet_test",
     ":server_test",
+    ":service_test",
   ]
   group_deps = [ "nanopb:tests" ]
 }
@@ -206,6 +212,16 @@
   sources = [ "packet_test.cc" ]
 }
 
+pw_test("service_test") {
+  deps = [
+    ":common",
+    ":protos_pwpb",
+    ":test_server",
+    dir_pw_assert,
+  ]
+  sources = [ "service_test.cc" ]
+}
+
 pw_test("server_test") {
   deps = [
     ":internal_test_utils_test_server",