Separate the actual trace to pprof conversion

Bug: b/135648427
Change-Id: I275dc329a40ef9d7a1c9fe8c7b9b4891913ee198
diff --git a/BUILD b/BUILD
index 24967d0..aca32e3 100644
--- a/BUILD
+++ b/BUILD
@@ -120,6 +120,90 @@
     ],
 )
 
+# GN target: //tools/trace_to_text:libpprofbuilder
+cc_library(
+    name = "tools_trace_to_text_libpprofbuilder",
+    srcs = [
+        "src/protozero/message.cc",
+        "src/protozero/message_handle.cc",
+        "src/protozero/proto_decoder.cc",
+        "src/protozero/scattered_heap_buffer.cc",
+        "src/protozero/scattered_stream_null_delegate.cc",
+        "src/protozero/scattered_stream_writer.cc",
+        "tools/trace_to_text/pprof_builder.cc",
+        "tools/trace_to_text/pprof_builder.h",
+        "tools/trace_to_text/utils.cc",
+        "tools/trace_to_text/utils.h",
+    ],
+    hdrs = [
+        "include/perfetto/base/build_config.h",
+        "include/perfetto/base/compiler.h",
+        "include/perfetto/base/export.h",
+        "include/perfetto/base/logging.h",
+        "include/perfetto/base/task_runner.h",
+        "include/perfetto/ext/base/circular_queue.h",
+        "include/perfetto/ext/base/container_annotations.h",
+        "include/perfetto/ext/base/event.h",
+        "include/perfetto/ext/base/file_utils.h",
+        "include/perfetto/ext/base/hash.h",
+        "include/perfetto/ext/base/metatrace.h",
+        "include/perfetto/ext/base/metatrace_events.h",
+        "include/perfetto/ext/base/no_destructor.h",
+        "include/perfetto/ext/base/optional.h",
+        "include/perfetto/ext/base/paged_memory.h",
+        "include/perfetto/ext/base/pipe.h",
+        "include/perfetto/ext/base/scoped_file.h",
+        "include/perfetto/ext/base/small_set.h",
+        "include/perfetto/ext/base/string_splitter.h",
+        "include/perfetto/ext/base/string_utils.h",
+        "include/perfetto/ext/base/string_view.h",
+        "include/perfetto/ext/base/string_writer.h",
+        "include/perfetto/ext/base/temp_file.h",
+        "include/perfetto/ext/base/thread_annotations.h",
+        "include/perfetto/ext/base/thread_checker.h",
+        "include/perfetto/ext/base/thread_task_runner.h",
+        "include/perfetto/ext/base/thread_utils.h",
+        "include/perfetto/ext/base/time.h",
+        "include/perfetto/ext/base/unix_socket.h",
+        "include/perfetto/ext/base/unix_task_runner.h",
+        "include/perfetto/ext/base/utils.h",
+        "include/perfetto/ext/base/watchdog.h",
+        "include/perfetto/ext/base/watchdog_noop.h",
+        "include/perfetto/ext/base/watchdog_posix.h",
+        "include/perfetto/ext/base/weak_ptr.h",
+        "include/perfetto/ext/traced/sys_stats_counters.h",
+        "include/perfetto/protozero/contiguous_memory_range.h",
+        "include/perfetto/protozero/field.h",
+        "include/perfetto/protozero/message.h",
+        "include/perfetto/protozero/message_handle.h",
+        "include/perfetto/protozero/proto_decoder.h",
+        "include/perfetto/protozero/proto_utils.h",
+        "include/perfetto/protozero/scattered_heap_buffer.h",
+        "include/perfetto/protozero/scattered_stream_null_delegate.h",
+        "include/perfetto/protozero/scattered_stream_writer.h",
+    ],
+    deps = [
+        "//third_party/perfetto/protos:common_cc_proto",
+        "//third_party/perfetto/protos:common_zero_cc_proto",
+        "//third_party/perfetto/protos:config_cc_proto",
+        "//third_party/perfetto/protos:protos_third_party_pprof_cc_proto",
+        "//third_party/perfetto/protos:trace_android_cc_proto",
+        "//third_party/perfetto/protos:trace_cc_proto",
+        "//third_party/perfetto/protos:trace_chrome_cc_proto",
+        "//third_party/perfetto/protos:trace_filesystem_cc_proto",
+        "//third_party/perfetto/protos:trace_ftrace_cc_proto",
+        "//third_party/perfetto/protos:trace_gpu_cc_proto",
+        "//third_party/perfetto/protos:trace_interned_data_cc_proto",
+        "//third_party/perfetto/protos:trace_minimal_cc_proto",
+        "//third_party/perfetto/protos:trace_perfetto_cc_proto",
+        "//third_party/perfetto/protos:trace_power_cc_proto",
+        "//third_party/perfetto/protos:trace_profiling_cc_proto",
+        "//third_party/perfetto/protos:trace_ps_cc_proto",
+        "//third_party/perfetto/protos:trace_sys_stats_cc_proto",
+        "//third_party/perfetto/protos:trace_track_event_cc_proto",
+    ],
+)
+
 # GN target: //src/trace_processor:trace_processor
 cc_library(
     name = "trace_processor",
@@ -802,6 +886,8 @@
         "src/trace_processor/window_operator_table.cc",
         "src/trace_processor/window_operator_table.h",
         "tools/trace_to_text/main.cc",
+        "tools/trace_to_text/pprof_builder.cc",
+        "tools/trace_to_text/pprof_builder.h",
         "tools/trace_to_text/proto_full_utils.cc",
         "tools/trace_to_text/proto_full_utils.h",
         "tools/trace_to_text/trace_to_profile.cc",