1# Copyright (C) 2017 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/gen_perfetto_version_header.gni") 16import("../../gn/perfetto.gni") 17import("../../gn/perfetto_component.gni") 18import("../../gn/test.gni") 19import("../../gn/wasm.gni") 20 21# On standalone builds this is all the OSes we support. On chromium builds, 22# though, this really means !is_fuchsia && !is_nacl. 23_subprocess_supported = 24 is_linux || is_chromeos || is_android || is_mac || is_win 25 26perfetto_component("base") { 27 deps = [ 28 "../../gn:base_platform", 29 "../../gn:default_deps", 30 ] 31 public_deps = [ 32 "../../include/perfetto/base", 33 "../../include/perfetto/ext/base", 34 ] 35 sources = [ 36 "android_utils.cc", 37 "base64.cc", 38 "crash_keys.cc", 39 "ctrl_c_handler.cc", 40 "event_fd.cc", 41 "file_utils.cc", 42 "getopt_compat.cc", 43 "log_ring_buffer.h", 44 "logging.cc", 45 "metatrace.cc", 46 "paged_memory.cc", 47 "periodic_task.cc", 48 "pipe.cc", 49 "scoped_mmap.cc", 50 "status.cc", 51 "string_splitter.cc", 52 "string_utils.cc", 53 "string_view.cc", 54 "temp_file.cc", 55 "thread_checker.cc", 56 "thread_utils.cc", 57 "time.cc", 58 "utils.cc", 59 "uuid.cc", 60 "virtual_destructors.cc", 61 "waitable_event.cc", 62 "watchdog_posix.cc", 63 ] 64 65 if (!is_nacl) { 66 sources += [ 67 "thread_task_runner.cc", 68 "unix_task_runner.cc", 69 ] 70 } 71 72 if (_subprocess_supported) { 73 sources += [ 74 "subprocess.cc", 75 "subprocess_posix.cc", 76 "subprocess_windows.cc", 77 ] 78 } 79 80 if (enable_perfetto_stderr_crash_dump) { 81 deps += [ ":debug_crash_stack_trace" ] 82 } 83} 84 85# This target needs to be named as such because it's exposed directly in Bazel 86# and Android.bp. 87perfetto_component("perfetto_base_default_platform") { 88 deps = [ 89 "../../gn:default_deps", 90 "../../include/perfetto/ext/base", 91 ] 92 sources = [ "default_platform.cc" ] 93} 94 95perfetto_component("version") { 96 deps = [ 97 ":base", 98 "../../gn:default_deps", 99 ] 100 public_deps = [ "../../include/perfetto/ext/base:version" ] 101 sources = [ "version.cc" ] 102 103 if (enable_perfetto_version_gen) { 104 deps += [ ":version_gen_h" ] 105 } 106} 107 108if (enable_perfetto_version_gen) { 109 config("version_gen_config") { 110 include_dirs = [ root_gen_dir ] 111 } 112 113 # Note: the build file translators (tools/gn_utils.py) depend on the hardcoded 114 # "//src/base:version_gen_h". If you rename this target, update build file 115 # translators accordingly. 116 gen_perfetto_version_header("version_gen_h") { 117 cpp_out = "${root_gen_dir}/perfetto_version.gen.h" 118 } 119} 120 121if (enable_perfetto_stderr_crash_dump) { 122 source_set("debug_crash_stack_trace") { 123 sources = [ "debug_crash_stack_trace.cc" ] 124 deps = [ 125 "../../gn:default_deps", 126 "../../include/perfetto/ext/base", 127 "../../include/perfetto/ext/base", 128 ] 129 if (is_linux || is_android) { 130 deps += [ "../../gn:libbacktrace" ] 131 } 132 cflags = [ "-Wno-deprecated" ] 133 } 134} 135 136if (enable_perfetto_ipc) { 137 # This cannot be in :base as it does not build on WASM. 138 perfetto_component("unix_socket") { 139 deps = [ 140 "../../gn:default_deps", 141 "../../include/perfetto/ext/base", 142 ] 143 sources = [ 144 "unix_socket.cc", 145 "vm_sockets.h", 146 ] 147 if (is_win && perfetto_build_standalone) { 148 libs = [ "Ws2_32.lib" ] 149 } 150 } 151} 152 153source_set("test_support") { 154 testonly = true 155 deps = [ 156 ":base", 157 "../../gn:default_deps", 158 "../../gn:gtest_and_gmock", 159 ] 160 sources = [ 161 "test/status_matchers.h", 162 "test/tmp_dir_tree.cc", 163 "test/tmp_dir_tree.h", 164 "test/utils.cc", 165 "test/utils.h", 166 "test/vm_test_utils.cc", 167 "test/vm_test_utils.h", 168 ] 169 170 if (!is_nacl) { 171 # test_task_runner depends on unix_task_runner, which isn't available on 172 # NaCL. 173 sources += [ 174 "test/test_task_runner.cc", 175 "test/test_task_runner.h", 176 ] 177 } 178} 179 180perfetto_unittest_source_set("unittests") { 181 testonly = true 182 deps = [ 183 ":base", 184 ":test_support", 185 "../../gn:default_deps", 186 "../../gn:gtest_and_gmock", 187 ] 188 189 if (enable_perfetto_ipc) { 190 deps += [ "http:unittests" ] 191 } 192 193 sources = [ 194 "base64_unittest.cc", 195 "circular_queue_unittest.cc", 196 "flat_hash_map_unittest.cc", 197 "flat_set_unittest.cc", 198 "getopt_compat_unittest.cc", 199 "hash_unittest.cc", 200 "logging_unittest.cc", 201 "no_destructor_unittest.cc", 202 "paged_memory_unittest.cc", 203 "periodic_task_unittest.cc", 204 "scoped_file_unittest.cc", 205 "scoped_mmap_unittest.cc", 206 "small_vector_unittest.cc", 207 "status_or_unittest.cc", 208 "status_unittest.cc", 209 "string_splitter_unittest.cc", 210 "string_utils_unittest.cc", 211 "string_view_unittest.cc", 212 "string_writer_unittest.cc", 213 "task_runner_unittest.cc", 214 "temp_file_unittest.cc", 215 "thread_checker_unittest.cc", 216 "time_unittest.cc", 217 "utils_unittest.cc", 218 "uuid_unittest.cc", 219 "weak_ptr_unittest.cc", 220 ] 221 if (_subprocess_supported) { 222 # Don't run on Fuchsia, NaCL. They pretend to be POSIX but then give up on 223 # execve(2). 224 sources += [ "subprocess_unittest.cc" ] 225 } 226 227 # TODO: Enable these for Windows when possible. 228 if (!is_win) { 229 sources += [ 230 "metatrace_unittest.cc", 231 "thread_task_runner_unittest.cc", 232 "watchdog_posix_unittest.cc", 233 ] 234 } 235 if (is_fuchsia) { 236 deps += [ "//third_party/fuchsia-sdk/sdk/pkg/fdio" ] # nogncheck 237 } 238 if (perfetto_build_standalone || perfetto_build_with_android) { 239 sources += [ "unix_socket_unittest.cc" ] 240 deps += [ ":unix_socket" ] 241 242 # This causes some problems on the chromium waterfall. 243 if (is_linux || is_android) { 244 sources += [ "watchdog_unittest.cc" ] 245 } 246 } 247} 248 249if (enable_perfetto_benchmarks) { 250 declare_args() { 251 perfetto_benchmark_3p_libs_prefix = "" 252 } 253 source_set("benchmarks") { 254 # If you intend to reproduce the comparison with {Absl, Folly, Tessil} 255 # you need to manually install those libraries and then set the GN arg 256 # perfetto_benchmark_3p_libs_prefix = "/usr/local" 257 testonly = true 258 deps = [ 259 ":base", 260 "../../gn:benchmark", 261 "../../gn:default_deps", 262 ] 263 if (perfetto_benchmark_3p_libs_prefix != "") { 264 defines = [ "PERFETTO_HASH_MAP_COMPARE_THIRD_PARTY_LIBS" ] 265 cflags = [ "-isystem${perfetto_benchmark_3p_libs_prefix}/include" ] 266 libs = [ 267 "${perfetto_benchmark_3p_libs_prefix}/lib/libfolly.a", 268 "${perfetto_benchmark_3p_libs_prefix}/lib/libabsl_raw_hash_set.a", 269 "${perfetto_benchmark_3p_libs_prefix}/lib/libabsl_hash.a", 270 ] 271 } 272 sources = [ 273 "flat_hash_map_benchmark.cc", 274 "flat_set_benchmark.cc", 275 ] 276 } 277} 278