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("//build_overrides/build.gni") 16import("../../gn/gen_perfetto_version_header.gni") 17import("../../gn/perfetto.gni") 18import("../../gn/perfetto_component.gni") 19import("../../gn/test.gni") 20import("../../gn/wasm.gni") 21 22# On standalone builds this is all the OSes we support. On chromium builds, 23# though, this really means !is_fuchsia && !is_nacl. 24_subprocess_supported = 25 is_linux || is_chromeos || is_android || is_mac || is_win 26 27perfetto_component("base") { 28 deps = [ "../../gn:default_deps" ] 29 public_deps = [ 30 "../../include/perfetto/base", 31 "../../include/perfetto/ext/base", 32 ] 33 sources = [ 34 "ctrl_c_handler.cc", 35 "event_fd.cc", 36 "file_utils.cc", 37 "getopt_compat.cc", 38 "logging.cc", 39 "metatrace.cc", 40 "paged_memory.cc", 41 "periodic_task.cc", 42 "pipe.cc", 43 "status.cc", 44 "string_splitter.cc", 45 "string_utils.cc", 46 "string_view.cc", 47 "temp_file.cc", 48 "thread_checker.cc", 49 "time.cc", 50 "utils.cc", 51 "uuid.cc", 52 "version.cc", 53 "virtual_destructors.cc", 54 "waitable_event.cc", 55 "watchdog_posix.cc", 56 ] 57 58 if (!is_nacl) { 59 sources += [ 60 "thread_task_runner.cc", 61 "unix_task_runner.cc", 62 ] 63 } 64 65 if (_subprocess_supported) { 66 sources += [ 67 "subprocess.cc", 68 "subprocess_posix.cc", 69 "subprocess_windows.cc", 70 ] 71 } 72 73 if (enable_perfetto_stderr_crash_dump) { 74 deps += [ ":debug_crash_stack_trace" ] 75 } 76 77 if (enable_perfetto_version_gen) { 78 deps += [ ":version_gen_h" ] 79 } 80} 81 82if (enable_perfetto_version_gen) { 83 config("version_gen_config") { 84 include_dirs = [ root_gen_dir ] 85 } 86 87 # Note: the build file translators (tools/gn_utils.py) depend on the hardcoded 88 # "//src/base:version_gen_h". If you rename this target, update build file 89 # translators accordingly. 90 gen_perfetto_version_header("version_gen_h") { 91 cpp_out = "${root_gen_dir}/perfetto_version.gen.h" 92 } 93} 94 95if (enable_perfetto_stderr_crash_dump) { 96 source_set("debug_crash_stack_trace") { 97 sources = [ "debug_crash_stack_trace.cc" ] 98 deps = [ 99 "../../gn:default_deps", 100 "../../include/perfetto/ext/base", 101 "../../include/perfetto/ext/base", 102 ] 103 if (is_linux || is_android) { 104 deps += [ "../../gn:libbacktrace" ] 105 } 106 cflags = [ "-Wno-deprecated" ] 107 } 108} 109 110if (enable_perfetto_ipc) { 111 # This cannot be in :base as it does not build on WASM. 112 perfetto_component("unix_socket") { 113 deps = [ 114 "../../gn:default_deps", 115 "../../include/perfetto/ext/base", 116 ] 117 sources = [ "unix_socket.cc" ] 118 if (is_win && perfetto_build_standalone) { 119 libs = [ "Ws2_32.lib" ] 120 } 121 } 122} 123 124source_set("test_support") { 125 testonly = true 126 deps = [ 127 ":base", 128 "../../gn:default_deps", 129 ] 130 sources = [ 131 "test/utils.cc", 132 "test/utils.h", 133 "test/vm_test_utils.cc", 134 "test/vm_test_utils.h", 135 ] 136 137 if (!is_nacl) { 138 # test_task_runner depends on unix_task_runner, which isn't available on 139 # NaCL. 140 sources += [ 141 "test/test_task_runner.cc", 142 "test/test_task_runner.h", 143 ] 144 } 145} 146 147perfetto_unittest_source_set("unittests") { 148 testonly = true 149 deps = [ 150 ":base", 151 ":test_support", 152 "../../gn:default_deps", 153 "../../gn:gtest_and_gmock", 154 ] 155 156 sources = [ 157 "circular_queue_unittest.cc", 158 "flat_set_unittest.cc", 159 "getopt_compat_unittest.cc", 160 "logging_unittest.cc", 161 "no_destructor_unittest.cc", 162 "optional_unittest.cc", 163 "paged_memory_unittest.cc", 164 "periodic_task_unittest.cc", 165 "scoped_file_unittest.cc", 166 "string_splitter_unittest.cc", 167 "string_utils_unittest.cc", 168 "string_view_unittest.cc", 169 "string_writer_unittest.cc", 170 "task_runner_unittest.cc", 171 "temp_file_unittest.cc", 172 "thread_checker_unittest.cc", 173 "time_unittest.cc", 174 "utils_unittest.cc", 175 "uuid_unittest.cc", 176 "weak_ptr_unittest.cc", 177 ] 178 if (_subprocess_supported) { 179 # Don't run on Fuchsia, NaCL. They pretend to be POSIX but then give up on 180 # execve(2). 181 sources += [ "subprocess_unittest.cc" ] 182 } 183 184 # TODO: Enable these for Windows when possible. 185 if (!is_win) { 186 sources += [ 187 "metatrace_unittest.cc", 188 "thread_task_runner_unittest.cc", 189 "watchdog_posix_unittest.cc", 190 ] 191 } 192 if (perfetto_build_standalone || perfetto_build_with_android) { 193 # This causes some problems on the chromium waterfall. 194 if (is_linux || is_android) { 195 sources += [ "watchdog_unittest.cc" ] 196 } 197 sources += [ "unix_socket_unittest.cc" ] 198 deps += [ ":unix_socket" ] 199 } 200} 201 202if (enable_perfetto_benchmarks) { 203 source_set("benchmarks") { 204 testonly = true 205 deps = [ 206 ":base", 207 "../../gn:benchmark", 208 "../../gn:default_deps", 209 ] 210 sources = [ "flat_set_benchmark.cc" ] 211 } 212} 213