Update Build Rules

In some cases, the full set of platform/api code will not be needed.
Instead, just logging can suffice. This CL updates BUILD rules to allow
for that smaller subset of dependencies.

Bug: internal b/186668530
Change-Id: I0df802871610c5839ac2000fc25e4eba028be930
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/2860519
Reviewed-by: Jordan Bayles <jophba@chromium.org>
Commit-Queue: Ryan Keane <rwkeane@google.com>
diff --git a/cast/streaming/BUILD.gn b/cast/streaming/BUILD.gn
index 27e9dd8..013073c 100644
--- a/cast/streaming/BUILD.gn
+++ b/cast/streaming/BUILD.gn
@@ -11,16 +11,37 @@
   sources = [ "remoting.proto" ]
 }
 
+source_set("streaming_configs") {
+  sources = [
+    "capture_configs.h",
+    "constants.h",
+    "message_fields.cc",
+    "message_fields.h",
+    "resolution.cc",
+    "resolution.h",
+  ]
+
+  public_configs = [ "../../build:openscreen_include_dirs" ]
+
+  public_deps = [
+    "../../third_party/abseil",
+    "../../third_party/jsoncpp",
+  ]
+
+  deps = [
+    "../../platform:base",
+    "../../util:base",
+  ]
+}
+
 source_set("common") {
   sources = [
     "answer_messages.cc",
     "answer_messages.h",
-    "capture_configs.h",
     "capture_recommendations.cc",
     "capture_recommendations.h",
     "clock_drift_smoother.cc",
     "clock_drift_smoother.h",
-    "constants.h",
     "encoded_frame.cc",
     "encoded_frame.h",
     "environment.cc",
@@ -30,8 +51,6 @@
     "frame_crypto.h",
     "frame_id.cc",
     "frame_id.h",
-    "message_fields.cc",
-    "message_fields.h",
     "ntp_time.cc",
     "ntp_time.h",
     "offer_messages.cc",
@@ -40,8 +59,6 @@
     "packet_util.h",
     "receiver_message.cc",
     "receiver_message.h",
-    "resolution.cc",
-    "resolution.h",
     "rpc_broker.cc",
     "rpc_broker.h",
     "rtcp_common.cc",
@@ -66,6 +83,7 @@
 
   public_deps = [
     ":remoting_proto",
+    ":streaming_configs",
     "../../third_party/abseil",
     "../../third_party/boringssl",
     "../common:channel",
diff --git a/platform/BUILD.gn b/platform/BUILD.gn
index e98067f..37601f3 100644
--- a/platform/BUILD.gn
+++ b/platform/BUILD.gn
@@ -33,6 +33,15 @@
   public_configs = [ "../build:openscreen_include_dirs" ]
 }
 
+# Public API source files. May depend on nothing except :base.
+source_set("logging") {
+  defines = []
+
+  sources = [ "api/logging.h" ]
+
+  public_deps = [ ":base" ]
+}
+
 # Public API source files. These may depend on nothing except :base.
 source_set("api") {
   defines = []
@@ -56,7 +65,10 @@
     "api/udp_socket.h",
   ]
 
-  public_deps = [ ":base" ]
+  public_deps = [
+    ":base",
+    ":logging",
+  ]
 }
 
 # The following target is only activated in standalone builds (see :platform).
diff --git a/util/BUILD.gn b/util/BUILD.gn
index 3f97e09..90a7fe3 100644
--- a/util/BUILD.gn
+++ b/util/BUILD.gn
@@ -17,31 +17,14 @@
   }
 }
 
-source_set("util") {
+# The set of util classes which have no dependency on platform:api.
+source_set("base") {
   sources = [
-    "alarm.cc",
-    "alarm.h",
     "base64.cc",
     "base64.h",
     "big_endian.cc",
     "big_endian.h",
     "chrono_helpers.h",
-    "crypto/certificate_utils.cc",
-    "crypto/certificate_utils.h",
-    "crypto/digest_sign.cc",
-    "crypto/digest_sign.h",
-    "crypto/openssl_util.cc",
-    "crypto/openssl_util.h",
-    "crypto/pem_helpers.cc",
-    "crypto/pem_helpers.h",
-    "crypto/random_bytes.cc",
-    "crypto/random_bytes.h",
-    "crypto/rsa_private_key.cc",
-    "crypto/rsa_private_key.h",
-    "crypto/secure_hash.cc",
-    "crypto/secure_hash.h",
-    "crypto/sha2.cc",
-    "crypto/sha2.h",
     "enum_name_table.h",
     "flat_map.h",
     "hashing.h",
@@ -59,10 +42,6 @@
     "std_util.h",
     "stringprintf.cc",
     "stringprintf.h",
-    "trace_logging.h",
-    "trace_logging/macro_support.h",
-    "trace_logging/scoped_trace_operations.cc",
-    "trace_logging/scoped_trace_operations.h",
     "url.cc",
     "url.h",
     "weak_ptr.h",
@@ -71,14 +50,13 @@
   ]
 
   public_deps = [
-    "../platform:api",
     "../platform:base",
+    "../platform:logging",
     "../third_party/abseil",
     "../third_party/jsoncpp",
   ]
 
   deps = [
-    "../third_party/boringssl",
     "../third_party/mozilla",
 
     # We do a clone of Chrome's modp_b64 in order to share their BUILD.gn
@@ -86,6 +64,45 @@
     "//third_party/modp_b64",
   ]
 
+  public_configs = [ "../build:openscreen_include_dirs" ]
+}
+
+source_set("util") {
+  sources = [
+    "alarm.cc",
+    "alarm.h",
+    "crypto/certificate_utils.cc",
+    "crypto/certificate_utils.h",
+    "crypto/digest_sign.cc",
+    "crypto/digest_sign.h",
+    "crypto/openssl_util.cc",
+    "crypto/openssl_util.h",
+    "crypto/pem_helpers.cc",
+    "crypto/pem_helpers.h",
+    "crypto/random_bytes.cc",
+    "crypto/random_bytes.h",
+    "crypto/rsa_private_key.cc",
+    "crypto/rsa_private_key.h",
+    "crypto/secure_hash.cc",
+    "crypto/secure_hash.h",
+    "crypto/sha2.cc",
+    "crypto/sha2.h",
+    "trace_logging.h",
+    "trace_logging/macro_support.h",
+    "trace_logging/scoped_trace_operations.cc",
+    "trace_logging/scoped_trace_operations.h",
+  ]
+
+  public_deps = [
+    ":base",
+    "../platform:api",
+    "../platform:base",
+    "../third_party/abseil",
+    "../third_party/jsoncpp",
+  ]
+
+  deps = [ "../third_party/boringssl" ]
+
   public_configs = [
     "../build:openscreen_include_dirs",
     ":trace_logging_config",