Exclude targets depending on sqlite from embedder builds

In embedder builds (e.g. V8) sqlite is not available, which results in
errors when perfetto build files are included. This CL hides all sqlite
stuff behind a flag.

Change-Id: Ibe79344e609244b459d5705b05295e26f8b93db4
diff --git a/gn/BUILD.gn b/gn/BUILD.gn
index 3440b62..7412aa3 100644
--- a/gn/BUILD.gn
+++ b/gn/BUILD.gn
@@ -254,16 +254,18 @@
   }
 }
 
-group("sqlite") {
-  if (perfetto_root_path == "//") {
-    public_deps = [
-      "//buildtools:sqlite",
-    ]
-  } else {
-    public_deps = [
-      "//third_party/sqlite:sqlite",
-    ]
-    public_configs = [ ":sqlite_third_party_include_path" ]
+if (enable_perfetto_trace_processor_sqlite) {
+  group("sqlite") {
+    if (perfetto_root_path == "//") {
+      public_deps = [
+        "//buildtools:sqlite",
+      ]
+    } else {
+      public_deps = [
+        "//third_party/sqlite:sqlite",
+      ]
+      public_configs = [ ":sqlite_third_party_include_path" ]
+    }
   }
 }
 
diff --git a/gn/perfetto.gni b/gn/perfetto.gni
index 563db03..57c27aa 100644
--- a/gn/perfetto.gni
+++ b/gn/perfetto.gni
@@ -200,6 +200,11 @@
   perfetto_verbose_logs_enabled =
       !build_with_chromium || perfetto_force_dlog == "on"
 
+  # Enables the SQL query layer of trace processor.
+  enable_perfetto_trace_processor_sqlite =
+      enable_perfetto_trace_processor &&
+      (build_with_chromium || !perfetto_build_with_embedder)
+
   # Enables the optional SQLite percentile module.
   enable_perfetto_trace_processor_percentile =
       enable_perfetto_trace_processor && perfetto_build_standalone
@@ -237,10 +242,12 @@
       !(build_with_chromium && is_android)
 
   # Enables the trace_to_text tool.
-  enable_perfetto_tools_trace_to_text = enable_perfetto_tools
+  enable_perfetto_tools_trace_to_text =
+      enable_perfetto_tools && enable_perfetto_trace_processor_sqlite
 
   # Allows to build the UI (TypeScript/ HTML / WASM)
-  enable_perfetto_ui = perfetto_build_standalone
+  enable_perfetto_ui =
+      perfetto_build_standalone && enable_perfetto_trace_processor_sqlite
 }
 
 # +---------------------------------------------------------------------------+
diff --git a/gn/perfetto_unittests.gni b/gn/perfetto_unittests.gni
index ead0c8b..11ba49f 100644
--- a/gn/perfetto_unittests.gni
+++ b/gn/perfetto_unittests.gni
@@ -61,8 +61,9 @@
 }
 
 if (enable_perfetto_trace_processor) {
-  perfetto_unittests_targets += [
-    "src/trace_processor:unittests",
-    "src/trace_processor/metrics:unittests",
-  ]
+  perfetto_unittests_targets += [ "src/trace_processor:unittests" ]
+
+  if (enable_perfetto_trace_processor_sqlite) {
+    perfetto_unittests_targets += [ "src/trace_processor/metrics:unittests" ]
+  }
 }