Move build flags to generated file, stop using cflags

Design doc: go/perfetto-buildflags
Stop passing -DPERFETTO_XXX to cc invocations.
In GN builds, use a perfetto_build_flags.h file generated
at build-time via genrule. For Android, Blaze/Bazel and
amalgamated builds, generate the header when running
tools/gen_xxx, check it into build_configs/xxx/,
point include_dirs that directory in each build system.
This CL also cleans up some GN files that were using
build_with_embedder for the wrong purposes (to check
whether we should use //gn/standalone or the
embedder-provided GN files). The amalgamated build needs
embedder=true but uses standalone GN.

Test: manually tested the following:
  - tools/gen_amalgamated: builds
  - manual chrome roll (linux): builds
  - manual v8 roll (mac): builds

Bug: 132678367
Change-Id: I79aa98d9b08090586c8d23c6fdafe88168ca63a2
diff --git a/Android.bp b/Android.bp
index a77d471..83ca36b 100644
--- a/Android.bp
+++ b/Android.bp
@@ -215,7 +215,6 @@
   cflags: [
     "-DGOOGLE_PROTOBUF_NO_RTTI",
     "-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
-    "-DPERFETTO_BUILD_WITH_ANDROID",
   ],
 }
 
@@ -256,12 +255,15 @@
   static_libs: [
     "libasync_safe",
   ],
+  export_include_dirs: [
+    "include",
+    "include/perfetto/base/build_configs/android_tree",
+  ],
   defaults: [
     "perfetto_defaults",
   ],
   cflags: [
     "-DPERFETTO_ANDROID_ASYNC_SAFE_LOG",
-    "-DPERFETTO_BUILD_WITH_ANDROID",
   ],
   include_dirs: [
     "bionic/libc",
@@ -406,6 +408,10 @@
   static_libs: [
     "perfetto_src_tracing_ipc",
   ],
+  export_include_dirs: [
+    "include",
+    "include/perfetto/base/build_configs/android_tree",
+  ],
   generated_headers: [
     "perfetto_protos_perfetto_common_lite_gen_headers",
     "perfetto_protos_perfetto_common_zero_gen_headers",
@@ -451,7 +457,6 @@
   cflags: [
     "-DGOOGLE_PROTOBUF_NO_RTTI",
     "-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
-    "-DPERFETTO_BUILD_WITH_ANDROID",
   ],
 }
 
@@ -480,12 +485,13 @@
   static_libs: [
     "libhealthhalutils",
   ],
+  export_include_dirs: [
+    "include",
+    "include/perfetto/base/build_configs/android_tree",
+  ],
   defaults: [
     "perfetto_defaults",
   ],
-  cflags: [
-    "-DPERFETTO_BUILD_WITH_ANDROID",
-  ],
   product_variables: {
     pdk: {
       enabled: false,
@@ -606,6 +612,7 @@
   ],
   export_include_dirs: [
     "include",
+    "include/perfetto/base/build_configs/android_tree",
   ],
   generated_headers: [
     "perfetto_protos_perfetto_common_lite_gen_headers",
@@ -691,7 +698,6 @@
   cflags: [
     "-DGOOGLE_PROTOBUF_NO_RTTI",
     "-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
-    "-DPERFETTO_BUILD_WITH_ANDROID",
   ],
 }
 
@@ -856,7 +862,6 @@
     "-DGOOGLE_PROTOBUF_NO_RTTI",
     "-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
     "-DHAVE_HIDDEN",
-    "-DPERFETTO_BUILD_WITH_ANDROID",
   ],
 }
 
@@ -870,8 +875,10 @@
     "-Wno-unused-parameter",
     "-fvisibility=hidden",
   ],
-  local_include_dirs: [
-    "include",
+  include_dirs: [
+    "external/perfetto",
+    "external/perfetto/include",
+    "external/perfetto/include/perfetto/base/build_configs/android_tree",
   ],
   product_variables: {
     debuggable: {
@@ -1132,7 +1139,6 @@
   cflags: [
     "-DGOOGLE_PROTOBUF_NO_RTTI",
     "-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
-    "-DPERFETTO_BUILD_WITH_ANDROID",
   ],
 }
 
@@ -3526,7 +3532,6 @@
   cflags: [
     "-DGOOGLE_PROTOBUF_NO_RTTI",
     "-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
-    "-DPERFETTO_BUILD_WITH_ANDROID",
   ],
 }
 
@@ -3660,7 +3665,6 @@
   cflags: [
     "-DGOOGLE_PROTOBUF_NO_RTTI",
     "-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
-    "-DPERFETTO_BUILD_WITH_ANDROID",
   ],
 }
 
@@ -3932,6 +3936,7 @@
   ],
   export_include_dirs: [
     "include",
+    "include/perfetto/base/build_configs/android_tree",
   ],
   generated_headers: [
     "perfetto_protos_perfetto_common_lite_gen_headers",
@@ -4017,7 +4022,6 @@
   cflags: [
     "-DGOOGLE_PROTOBUF_NO_RTTI",
     "-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
-    "-DPERFETTO_BUILD_WITH_ANDROID",
   ],
 }
 
@@ -4056,6 +4060,7 @@
   host_supported: true,
   export_include_dirs: [
     "include",
+    "include/perfetto/base/build_configs/android_tree",
   ],
   generated_headers: [
     "perfetto_protos_perfetto_common_lite_gen_headers",
@@ -4461,7 +4466,6 @@
     "-DGOOGLE_PROTOBUF_NO_RTTI",
     "-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
     "-DHAVE_HIDDEN",
-    "-DPERFETTO_BUILD_WITH_ANDROID",
   ],
 }
 
@@ -4623,7 +4627,6 @@
     "-DGOOGLE_PROTOBUF_NO_RTTI",
     "-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
     "-DHAVE_HIDDEN",
-    "-DPERFETTO_BUILD_WITH_ANDROID",
   ],
   target: {
     android: {
@@ -4865,7 +4868,6 @@
     "-DGOOGLE_PROTOBUF_NO_RTTI",
     "-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
     "-DHAVE_HIDDEN",
-    "-DPERFETTO_BUILD_WITH_ANDROID",
   ],
 }
 
@@ -4885,9 +4887,6 @@
   defaults: [
     "perfetto_defaults",
   ],
-  cflags: [
-    "-DPERFETTO_BUILD_WITH_ANDROID",
-  ],
 }
 
 // GN target: //:traced_probes
@@ -4903,9 +4902,6 @@
   defaults: [
     "perfetto_defaults",
   ],
-  cflags: [
-    "-DPERFETTO_BUILD_WITH_ANDROID",
-  ],
   required: [
     "libperfetto_android_internal",
     "trigger_perfetto",
@@ -5065,7 +5061,6 @@
   cflags: [
     "-DGOOGLE_PROTOBUF_NO_RTTI",
     "-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
-    "-DPERFETTO_BUILD_WITH_ANDROID",
   ],
 }
 
@@ -5087,9 +5082,6 @@
     "test/task_runner_thread_delegates.cc",
     "test/test_helper.cc",
   ],
-  export_include_dirs: [
-    ".",
-  ],
   shared_libs: [
     "libprotobuf-cpp-lite",
   ],
@@ -5099,8 +5091,8 @@
     "perfetto_src_tracing_ipc",
     "perfetto_trace_protos",
   ],
-  cflags: [
-    "-DPERFETTO_BUILD_WITH_ANDROID",
+  defaults: [
+    "perfetto_defaults",
   ],
 }
 
@@ -5114,15 +5106,12 @@
   shared_libs: [
     "libprotobuf-cpp-lite",
   ],
-  export_include_dirs: [
-    ".",
-  ],
   static_libs: [
     "libgtest",
     "perfetto_src_tracing_ipc",
   ],
-  cflags: [
-    "-DPERFETTO_BUILD_WITH_ANDROID",
+  defaults: [
+    "perfetto_defaults",
   ],
 }
 
@@ -5152,12 +5141,11 @@
     "libprotobuf-cpp-lite",
     "liblog",
   ],
-  local_include_dirs: [
-    "include",
-  ],
   cflags: [
     "-DGOOGLE_PROTOBUF_NO_RTTI",
     "-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
-    "-DPERFETTO_BUILD_WITH_ANDROID",
+  ],
+  defaults: [
+    "perfetto_defaults",
   ],
 }
\ No newline at end of file