In Chrome, build as shared library rather than directly linked sources

As libperfetto is linked into multiple Chrome components, this should
slightly cut down on linking time.

Change-Id: I885d49042625e00002032737ea5fb43c9bf1af90
diff --git a/BUILD.gn b/BUILD.gn
index c22a7c0..ce1eba4 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -172,11 +172,18 @@
       "protos/perfetto/trace:lite",
     ]
   }
-} else {
-  group("lib") {
+}
+
+if (build_with_chromium) {
+  component("libperfetto") {
     public_configs = [ "gn:public_config" ]
     deps = [
       "src/tracing",
     ]
+    configs -= [ "//build/config/compiler:chromium_code" ]
+    configs += [ "//build/config/compiler:no_chromium_code" ]
+    public_deps = [
+      "include/perfetto/tracing/core",
+    ]
   }
-}  # !build_with_chromium
+}