Make trace_to_text a non-host-only executable

In the case of cross-compiling mac_arm64 from a
mac_x86 host, we want to cross-compile trace_to_text
in the same way we do for trace_processor_shell, traced
etc.
perfetto_host_executable should be used only for executables
that are invoked by the build system (protoc, ipc_plugin etc).

Bug: 218384527
Change-Id: I19cae24cd1373c6f7bdad23290c86dcd393540c8
diff --git a/BUILD.gn b/BUILD.gn
index 33f8818..6760137 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -45,6 +45,20 @@
   all_targets += [ "src/trace_processor:trace_processor_shell" ]
 }
 
+if (enable_perfetto_tools_trace_to_text) {
+  all_targets += [ "tools/trace_to_text" ]
+  if (is_cross_compiling) {
+    # In many cross-compilation scenarios (typically Android) developers expect
+    # the host version of trace_to_text to be available somewhere in out/, so
+    # they can convert Android traces on their dev machine. Also
+    # tools/gen_android_bp explicitly depends on the host version for the
+    # cc_binary_host("trace_to_text") target in Android.bp.
+    # Note that when cross-compiling the host executable will be available in
+    # out/xxx/gcc_like_host/trace_to_text NOT just out/xxx/trace_to_text.
+    all_targets += [ "tools/trace_to_text($host_toolchain)" ]
+  }
+}
+
 if (enable_perfetto_heapprofd) {
   all_targets += [ "src/profiling/memory:heapprofd" ]