1# Copyright (C) 2022 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15import("../../gn/perfetto.gni") 16 17# Prevent that this file is accidentally included in embedder builds. 18assert(enable_perfetto_tools) 19 20# Lists all tools. The root "all" target depends on this. 21group("tools") { 22 testonly = true 23 deps = [ 24 ":copy_protoc", 25 "ftrace_proto_gen", 26 "proto_filter", 27 "proto_merger", 28 "protoprofile", 29 ] 30 if (is_linux || is_android) { 31 deps += [ 32 ":idle_alloc", 33 "busy_threads", 34 "cpu_utilization", 35 "dump_ftrace_stats", 36 "skippy", 37 ] 38 } 39} 40 41if (is_linux && enable_perfetto_heapprofd) { 42 executable("profiling_sample_distribution") { 43 sources = [ "profiling_sample_distribution.cc" ] 44 deps = [ 45 "../../gn:default_deps", 46 "../base", 47 "../profiling/memory:client", 48 ] 49 } 50 51 executable("multithreaded_alloc") { 52 sources = [ "multithreaded_alloc.cc" ] 53 deps = [ 54 "../../gn:default_deps", 55 "../base", 56 "../profiling/memory:client_api_standalone", 57 ] 58 } 59} 60 61if (is_linux || is_android) { 62 executable("idle_alloc") { 63 deps = [ "../../gn:default_deps" ] 64 sources = [ "idle_alloc.cc" ] 65 } 66} 67 68group("unittests") { 69 testonly = true 70 deps = [] 71 72 if (current_toolchain == host_toolchain) { 73 deps += [ "ftrace_proto_gen:unittests" ] 74 } 75} 76 77# The protoc binary can end up in out/protoc or out/gcc_like_host/protoc 78# depending on whether this is a pure-host build vs a host+target (i.e. android) 79# build. This rule ensures that in both cases we end up with a host binary in 80# out/protoc, so tools can consistently refer to that one location. 81protoc_target = "../../gn:protoc($host_toolchain)" 82if (current_toolchain != host_toolchain) { 83 copy("copy_protoc") { 84 testonly = true 85 deps = [ protoc_target ] 86 host_out_dir = get_label_info(protoc_target, "root_out_dir") 87 sources = [ "$host_out_dir/protoc" ] 88 outputs = [ "$root_build_dir/protoc" ] 89 } 90} else { 91 # Nothing to do, in this case protoc is already built in the root out dir. 92 group("copy_protoc") { 93 public_deps = [ protoc_target ] 94 } 95} 96