| # Copyright (C) 2022 The Android Open Source Project | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| import("../../gn/perfetto.gni") | |
| import("../../gn/perfetto_host_executable.gni") | |
| import("../../gn/test.gni") | |
| # Prevent that this file is accidentally included in embedder builds. | |
| assert(enable_perfetto_tools) | |
| # Lists all tools. The root "all" target depends on this. | |
| group("tools") { | |
| testonly = true | |
| deps = [ | |
| ":copy_protoc", | |
| ":tracing_proto_extensions", | |
| "ftrace_proto_gen", | |
| "proto_filter", | |
| "proto_merger", | |
| "protoprofile", | |
| "string_filter_tool", | |
| ] | |
| if (is_linux || is_android) { | |
| deps += [ | |
| ":idle_alloc", | |
| "busy_threads", | |
| "cpu_utilization", | |
| "dump_ftrace_stats", | |
| "skippy", | |
| ] | |
| } | |
| } | |
| if (is_linux && enable_perfetto_heapprofd) { | |
| executable("profiling_sample_distribution") { | |
| sources = [ "profiling_sample_distribution.cc" ] | |
| deps = [ | |
| "../../gn:default_deps", | |
| "../base", | |
| "../profiling/memory:client", | |
| ] | |
| } | |
| executable("multithreaded_alloc") { | |
| sources = [ "multithreaded_alloc.cc" ] | |
| deps = [ | |
| "../../gn:default_deps", | |
| "../base", | |
| "../profiling/memory:client_api_standalone", | |
| ] | |
| } | |
| } | |
| if (is_linux || is_android) { | |
| executable("idle_alloc") { | |
| deps = [ "../../gn:default_deps" ] | |
| sources = [ "idle_alloc.cc" ] | |
| } | |
| } | |
| source_set("tracing_proto_extensions_lib") { | |
| deps = [ | |
| "../../gn:default_deps", | |
| "../../gn:protobuf_full", | |
| "../../protos/perfetto/common:zero", | |
| "../base", | |
| "../protozero", | |
| "../protozero:multifile_error_collector", | |
| "../trace_processor/util:simple_json_parser", | |
| ] | |
| sources = [ | |
| "tracing_proto_extensions.cc", | |
| "tracing_proto_extensions.h", | |
| ] | |
| } | |
| perfetto_host_executable("tracing_proto_extensions") { | |
| testonly = true | |
| deps = [ | |
| ":tracing_proto_extensions_lib", | |
| "../../gn:default_deps", | |
| "../base", | |
| "../base:version", | |
| ] | |
| if (enable_perfetto_zlib) { | |
| deps += [ "../../gn:zlib" ] | |
| } | |
| sources = [ "tracing_proto_extensions_main.cc" ] | |
| } | |
| perfetto_unittest_source_set("tracing_proto_extensions_unittests") { | |
| testonly = true | |
| deps = [ | |
| ":tracing_proto_extensions_lib", | |
| "../../gn:default_deps", | |
| "../../gn:gtest_and_gmock", | |
| "../../protos/perfetto/common:zero", | |
| "../base", | |
| "../base:test_support", | |
| "../protozero", | |
| ] | |
| sources = [ "tracing_proto_extensions_unittest.cc" ] | |
| } | |
| group("unittests") { | |
| testonly = true | |
| deps = [ ":tracing_proto_extensions_unittests" ] | |
| if (current_toolchain == host_toolchain) { | |
| deps += [ | |
| "ftrace_proto_gen:unittests", | |
| "proto_merger:unittests", | |
| ] | |
| } | |
| } | |
| # The protoc binary can end up in out/protoc or out/gcc_like_host/protoc | |
| # depending on whether this is a pure-host build vs a host+target (i.e. android) | |
| # build. This rule ensures that in both cases we end up with a host binary in | |
| # out/protoc, so tools can consistently refer to that one location. | |
| protoc_target = "../../gn:protoc($host_toolchain)" | |
| if (current_toolchain != host_toolchain) { | |
| copy("copy_protoc") { | |
| testonly = true | |
| deps = [ protoc_target ] | |
| host_out_dir = get_label_info(protoc_target, "root_out_dir") | |
| sources = [ "$host_out_dir/protoc" ] | |
| outputs = [ "$root_build_dir/protoc" ] | |
| } | |
| } else { | |
| # Nothing to do, in this case protoc is already built in the root out dir. | |
| group("copy_protoc") { | |
| public_deps = [ protoc_target ] | |
| } | |
| } |