Move binder libraries into perfetto binary and save ~5 MB of ram

This change moves the dependencies on libandroir,libbinder & friends
from libtraced_shared.so to the perfetto binary.
Thankfully, in fact, only the short lived client binary requires
those.
Doing so causes a memory reduction of our traced and traced_probes
of roughly 2.5 MB private dirty memory for each of our two daemon
(traced, traced_probes).
The memory is mostly coming from relocations and initializers
coming from the tree of recursive dependencies of those libraries.
For the moment that causes a binary size hit of +268 KB

Memory
------
Before:
  Shared_Clean:       7900 kB
  Shared_Dirty:         80 kB
  Private_Clean:       156 kB
  Private_Dirty:      3176 kB

After:
  Shared_Clean:       1224 kB
  Shared_Dirty:         80 kB
  Private_Clean:       160 kB
  Private_Dirty:       528 kB  !!!

Binary size
-----------
Before:
  bin/traced:                 12 KB
  bin/traced_probes:          12 KB
  bin/perfetto:               12 KB
  lib64/libtraced_shared.so:  468 KB
  *TOTAL*:                    504 KB

After:
  bin/traced:                 12 KB
  bin/traced_probes:          12 KB
  bin/perfetto:               280 KB
  lib64/libtraced_shared.so:  468 KB
  *TOTAL*:                    772 KB
Change-Id: I72bc05a68edf9b485775c51e7e2f18f29594458b
diff --git a/Android.bp b/Android.bp
index 81abbeb..4dce6a3 100644
--- a/Android.bp
+++ b/Android.bp
@@ -25,7 +25,6 @@
     ":perfetto_protos_tracing_service_tracing_service_gen",
     ":perfetto_protos_zero_gen",
     ":perfetto_src_ipc_wire_protocol_gen",
-    "src/base/android_task_runner.cc",
     "src/base/page_allocator.cc",
     "src/base/thread_checker.cc",
     "src/base/unix_task_runner.cc",
@@ -45,7 +44,6 @@
     "src/protozero/protozero_message.cc",
     "src/protozero/protozero_message_handle.cc",
     "src/protozero/scattered_stream_writer.cc",
-    "src/traced/perfetto_cmd/perfetto_cmd.cc",
     "src/traced/probes/ftrace_producer.cc",
     "src/traced/probes/probes.cc",
     "src/traced/service/service.cc",
@@ -61,6 +59,66 @@
     "src/tracing/core/trace_writer_impl.cc",
   ],
   shared_libs: [
+    "liblog",
+    "libprotobuf-cpp-lite",
+  ],
+  static_libs: [
+    "libgtest_prod",
+    "perfetto_src_tracing_ipc",
+  ],
+  generated_headers: [
+    "perfetto_protos_ftrace_lite_gen_headers",
+    "perfetto_protos_ftrace_zero_gen_headers",
+    "perfetto_protos_lite_gen_headers",
+    "perfetto_protos_tracing_service_lite_gen_headers",
+    "perfetto_protos_tracing_service_tracing_service_gen_headers",
+    "perfetto_protos_zero_gen_headers",
+    "perfetto_src_ipc_wire_protocol_gen_headers",
+  ],
+  defaults: [
+    "perfetto_defaults",
+  ],
+}
+
+// GN target: //:perfetto
+cc_binary {
+  name: "perfetto",
+  srcs: [
+    ":perfetto_protos_ftrace_lite_gen",
+    ":perfetto_protos_ftrace_zero_gen",
+    ":perfetto_protos_lite_gen",
+    ":perfetto_protos_tracing_service_lite_gen",
+    ":perfetto_protos_tracing_service_tracing_service_gen",
+    ":perfetto_protos_zero_gen",
+    ":perfetto_src_ipc_wire_protocol_gen",
+    "src/base/android_task_runner.cc",
+    "src/base/page_allocator.cc",
+    "src/base/thread_checker.cc",
+    "src/base/unix_task_runner.cc",
+    "src/ipc/buffered_frame_deserializer.cc",
+    "src/ipc/client_impl.cc",
+    "src/ipc/deferred.cc",
+    "src/ipc/host_impl.cc",
+    "src/ipc/service_proxy.cc",
+    "src/ipc/unix_socket.cc",
+    "src/protozero/proto_utils.cc",
+    "src/protozero/protozero_message.cc",
+    "src/protozero/protozero_message_handle.cc",
+    "src/protozero/scattered_stream_writer.cc",
+    "src/traced/perfetto_cmd/main.cc",
+    "src/traced/perfetto_cmd/perfetto_cmd.cc",
+    "src/tracing/core/chunked_protobuf_input_stream.cc",
+    "src/tracing/core/data_source_config.cc",
+    "src/tracing/core/data_source_descriptor.cc",
+    "src/tracing/core/id_allocator.cc",
+    "src/tracing/core/service_impl.cc",
+    "src/tracing/core/shared_memory_abi.cc",
+    "src/tracing/core/shared_memory_arbiter_impl.cc",
+    "src/tracing/core/trace_config.cc",
+    "src/tracing/core/trace_packet.cc",
+    "src/tracing/core/trace_writer_impl.cc",
+  ],
+  shared_libs: [
     "libandroid",
     "libbinder",
     "liblog",
@@ -89,25 +147,6 @@
   ],
 }
 
-// GN target: //:perfetto
-cc_binary {
-  name: "perfetto",
-  srcs: [
-    "src/traced/perfetto_cmd/main.cc",
-  ],
-  shared_libs: [
-    "libandroid",
-    "libbinder",
-    "liblog",
-    "libservices",
-    "libtraced_shared",
-    "libutils",
-  ],
-  defaults: [
-    "perfetto_defaults",
-  ],
-}
-
 cc_defaults {
   name: "perfetto_defaults",
   cflags: [
@@ -889,12 +928,8 @@
     "src/traced/service/main.cc",
   ],
   shared_libs: [
-    "libandroid",
-    "libbinder",
     "liblog",
-    "libservices",
     "libtraced_shared",
-    "libutils",
   ],
   init_rc: [
     "perfetto.rc",
@@ -911,12 +946,8 @@
     "src/traced/probes/main.cc",
   ],
   shared_libs: [
-    "libandroid",
-    "libbinder",
     "liblog",
-    "libservices",
     "libtraced_shared",
-    "libutils",
   ],
   defaults: [
     "perfetto_defaults",