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/perfetto.gni") 17import("../../gn/test.gni") 18import("../../gn/wasm.gni") 19 20enable_stack_trace = is_debug && perfetto_build_standalone && !is_wasm 21 22source_set("base") { 23 deps = [ "../../gn:default_deps" ] 24 public_deps = [ 25 "../../include/perfetto/base", 26 "../../include/perfetto/ext/base", 27 ] 28 sources = [ 29 "file_utils.cc", 30 "logging.cc", 31 "metatrace.cc", 32 "paged_memory.cc", 33 "string_splitter.cc", 34 "string_utils.cc", 35 "string_view.cc", 36 "subprocess.cc", 37 "thread_checker.cc", 38 "time.cc", 39 "uuid.cc", 40 "virtual_destructors.cc", 41 "waitable_event.cc", 42 "watchdog_posix.cc", 43 ] 44 45 # TODO(brucedawson): Enable these for Windows when possible. 46 if (!is_win && !is_nacl) { 47 sources += [ 48 "event_fd.cc", 49 "pipe.cc", 50 "temp_file.cc", 51 "thread_task_runner.cc", 52 "unix_task_runner.cc", 53 ] 54 } 55 56 if (enable_stack_trace) { 57 deps += [ ":debug_crash_stack_trace" ] 58 } 59} 60 61if (enable_stack_trace) { 62 source_set("debug_crash_stack_trace") { 63 sources = [ "debug_crash_stack_trace.cc" ] 64 deps = [ 65 "../../gn:default_deps", 66 "../../include/perfetto/ext/base", 67 "../../include/perfetto/ext/base", 68 ] 69 if (is_linux || is_android) { 70 deps += [ "../../gn:libbacktrace" ] 71 } 72 cflags = [ "-Wno-deprecated" ] 73 } 74} 75 76if (enable_perfetto_ipc) { 77 # This cannot be in :base as it does not build on WASM. 78 source_set("unix_socket") { 79 deps = [ 80 "../../gn:default_deps", 81 "../../include/perfetto/ext/base", 82 "../../include/perfetto/ext/base", 83 ] 84 sources = [ "unix_socket.cc" ] 85 } 86} 87 88source_set("test_support") { 89 testonly = true 90 deps = [ 91 ":base", 92 "../../gn:default_deps", 93 ] 94 sources = [ 95 "test/utils.cc", 96 "test/utils.h", 97 "test/vm_test_utils.cc", 98 "test/vm_test_utils.h", 99 ] 100 101 # The Perfetto task runner is not used on Windows. 102 if (!is_win) { 103 sources += [ 104 "test/test_task_runner.cc", 105 "test/test_task_runner.h", 106 ] 107 } 108} 109 110perfetto_unittest_source_set("unittests") { 111 testonly = true 112 deps = [ 113 ":base", 114 ":test_support", 115 "../../gn:default_deps", 116 "../../gn:gtest_and_gmock", 117 ] 118 119 sources = [ 120 "circular_queue_unittest.cc", 121 "flat_set_unittest.cc", 122 "no_destructor_unittest.cc", 123 "optional_unittest.cc", 124 "paged_memory_unittest.cc", 125 "scoped_file_unittest.cc", 126 "string_splitter_unittest.cc", 127 "string_utils_unittest.cc", 128 "string_view_unittest.cc", 129 "string_writer_unittest.cc", 130 "subprocess_unittest.cc", 131 "time_unittest.cc", 132 "uuid_unittest.cc", 133 "weak_ptr_unittest.cc", 134 ] 135 136 # TODO: Enable these for Windows when possible. 137 if (!is_win) { 138 sources += [ 139 "metatrace_unittest.cc", 140 "task_runner_unittest.cc", 141 "temp_file_unittest.cc", 142 "thread_checker_unittest.cc", 143 "thread_task_runner_unittest.cc", 144 "utils_unittest.cc", 145 ] 146 } 147 if (perfetto_build_standalone || perfetto_build_with_android) { 148 # This causes some problems on the chromium waterfall. 149 sources += [ "unix_socket_unittest.cc" ] 150 if (is_linux || is_android) { 151 sources += [ "watchdog_unittest.cc" ] 152 } 153 } 154} 155 156if (enable_perfetto_benchmarks) { 157 source_set("benchmarks") { 158 testonly = true 159 deps = [ 160 ":base", 161 "../../gn:benchmark", 162 "../../gn:default_deps", 163 ] 164 sources = [ "flat_set_benchmark.cc" ] 165 } 166} 167