Make zlib optional

Allow embedders to build perfetto without having to support zlib

Bug: 147789115
Change-Id: Idbb989d269efca7c294bd2e7c61505412b189d5c
diff --git a/gn/BUILD.gn b/gn/BUILD.gn
index cb35cd0..3440b62 100644
--- a/gn/BUILD.gn
+++ b/gn/BUILD.gn
@@ -85,6 +85,7 @@
     "PERFETTO_TP_JSON_IMPORT=$enable_perfetto_trace_processor_json_import",
     "PERFETTO_TP_FUCHSIA=$enable_perfetto_trace_processor_fuchsia",
     "PERFETTO_LOCAL_SYMBOLIZER=$perfetto_local_symbolizer",
+    "PERFETTO_ZLIB=$enable_perfetto_zlib",
   ]
 
   rel_out_path = rebase_path(gen_header_path, "$root_build_dir")
@@ -306,7 +307,7 @@
 }
 
 # Zlib is used both by trace_processor and by perfetto_cmd.
-if (enable_perfetto_trace_processor || enable_perfetto_platform_services) {
+if (enable_perfetto_zlib) {
   group("zlib") {
     if (perfetto_root_path == "//") {
       public_configs = [ "//buildtools:zlib_config" ]
diff --git a/gn/perfetto.gni b/gn/perfetto.gni
index b479435..563db03 100644
--- a/gn/perfetto.gni
+++ b/gn/perfetto.gni
@@ -223,6 +223,11 @@
   # Further per-OS conditionals are applied in gn/BUILD.gn.
   enable_perfetto_trace_processor_httpd =
       enable_perfetto_trace_processor && perfetto_build_standalone
+
+  # Enables Zlib support. This is used both by the "perfetto" cmdline client
+  # (for compressing traces) and by trace processor (for compressed traces).
+  enable_perfetto_zlib =
+      enable_perfetto_trace_processor || enable_perfetto_platform_services
 }
 
 declare_args() {