blob: 5dc7be46ebb390028f7558009ccb0fa11cff250b [file] [log] [blame]
Primiano Tucci4f9b6d72017-12-05 20:59:16 +00001# 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")
Primiano Tucciec590132020-11-16 14:16:44 +010016import("../../gn/gen_perfetto_version_header.gni")
Primiano Tucci38faa6f2018-04-01 20:12:08 +020017import("../../gn/perfetto.gni")
Primiano Tucci916f4e52020-10-16 20:40:33 +020018import("../../gn/perfetto_component.gni")
Primiano Tucci02c11762019-08-30 00:57:59 +020019import("../../gn/test.gni")
Primiano Tucci4bdc4c42018-05-10 15:52:33 +010020import("../../gn/wasm.gni")
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000021
Primiano Tucci916f4e52020-10-16 20:40:33 +020022perfetto_component("base") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +000023 deps = [ "../../gn:default_deps" ]
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000024 public_deps = [
25 "../../include/perfetto/base",
Primiano Tucci2c5488f2019-06-01 03:27:28 +010026 "../../include/perfetto/ext/base",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000027 ]
28 sources = [
Primiano Tuccibc2b2442020-12-09 01:30:14 +010029 "event_fd.cc",
Florian Mayer74b73a92018-03-09 17:37:13 +000030 "file_utils.cc",
Primiano Tuccic64b05f2019-12-05 10:30:52 +000031 "logging.cc",
Florian Mayer236ba472018-05-09 15:47:53 +010032 "metatrace.cc",
Eric Seckleredf3f7c2018-10-23 16:44:53 +010033 "paged_memory.cc",
Primiano Tucci1366dd02020-12-02 10:17:10 +010034 "pipe.cc",
Primiano Tuccidf440312020-10-30 16:43:58 +010035 "status.cc",
Primiano Tucci825e6de2018-03-13 05:43:15 +000036 "string_splitter.cc",
Hector Dearman3afb1e02018-04-27 16:46:52 +010037 "string_utils.cc",
Primiano Tucci60c4a2b2019-03-02 17:11:18 +000038 "string_view.cc",
Primiano Tucci1797cd12020-04-14 09:43:24 +010039 "subprocess.cc",
Primiano Tuccie4de2da2020-12-01 14:54:07 +010040 "temp_file.cc",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000041 "thread_checker.cc",
Bruce Dawson2af6ef72018-05-01 15:28:39 +010042 "time.cc",
Primiano Tuccia81d2772020-10-07 00:12:41 +020043 "utils.cc",
Hector Dearmanf275f692019-07-31 12:56:59 +010044 "uuid.cc",
Primiano Tucciec590132020-11-16 14:16:44 +010045 "version.cc",
Primiano Tucci3cbb10a2018-04-10 17:52:40 +010046 "virtual_destructors.cc",
Sami Kyostila389861f2019-07-09 20:52:43 +010047 "waitable_event.cc",
Sami Kyostilafacfa142019-08-08 17:08:43 +010048 "watchdog_posix.cc",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000049 ]
Florian Mayer236ba472018-05-09 15:47:53 +010050
Bruce Dawson2af6ef72018-05-01 15:28:39 +010051 # TODO(brucedawson): Enable these for Windows when possible.
Eric Seckler60eff7d2020-05-20 13:03:07 +010052 if (!is_win && !is_nacl) {
Primiano Tuccibc2b2442020-12-09 01:30:14 +010053 sources += [ "thread_task_runner.cc" ]
Bruce Dawson2af6ef72018-05-01 15:28:39 +010054 }
55
Mikhail Khokhlov0226b682020-12-09 13:47:33 +000056 if (!is_nacl) {
57 sources += [ "unix_task_runner.cc" ]
58 }
59
Primiano Tucci824be142020-07-08 16:15:44 +010060 if (enable_perfetto_stderr_crash_dump) {
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000061 deps += [ ":debug_crash_stack_trace" ]
62 }
Primiano Tucciec590132020-11-16 14:16:44 +010063
64 if (enable_perfetto_version_gen) {
65 deps += [ ":version_gen_h" ]
66 }
67}
68
69if (enable_perfetto_version_gen) {
70 config("version_gen_config") {
71 include_dirs = [ root_gen_dir ]
72 }
73
74 # Note: the build file translators (tools/gn_utils.py) depend on the hardcoded
75 # "//src/base:version_gen_h". If you rename this target, update build file
76 # translators accordingly.
77 gen_perfetto_version_header("version_gen_h") {
78 cpp_out = "${root_gen_dir}/perfetto_version.gen.h"
79 }
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000080}
81
Primiano Tucci824be142020-07-08 16:15:44 +010082if (enable_perfetto_stderr_crash_dump) {
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000083 source_set("debug_crash_stack_trace") {
Primiano Tucci2925e9d2020-01-27 10:15:58 +000084 sources = [ "debug_crash_stack_trace.cc" ]
Primiano Tuccia5ff2a82017-12-20 11:37:00 +010085 deps = [
86 "../../gn:default_deps",
Primiano Tucci2c5488f2019-06-01 03:27:28 +010087 "../../include/perfetto/ext/base",
88 "../../include/perfetto/ext/base",
Primiano Tuccia5ff2a82017-12-20 11:37:00 +010089 ]
Primiano Tucci38faa6f2018-04-01 20:12:08 +020090 if (is_linux || is_android) {
Primiano Tucci13ae72f2019-06-06 10:53:02 +010091 deps += [ "../../gn:libbacktrace" ]
Primiano Tucci38faa6f2018-04-01 20:12:08 +020092 }
Primiano Tucci3cbb10a2018-04-10 17:52:40 +010093 cflags = [ "-Wno-deprecated" ]
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000094 }
95}
96
Primiano Tucci02c11762019-08-30 00:57:59 +020097if (enable_perfetto_ipc) {
Florian Mayerb6c3bff2018-09-13 16:36:49 +010098 # This cannot be in :base as it does not build on WASM.
Primiano Tucci916f4e52020-10-16 20:40:33 +020099 perfetto_component("unix_socket") {
Florian Mayerb6c3bff2018-09-13 16:36:49 +0100100 deps = [
101 "../../gn:default_deps",
Primiano Tucci2c5488f2019-06-01 03:27:28 +0100102 "../../include/perfetto/ext/base",
103 "../../include/perfetto/ext/base",
Florian Mayerb6c3bff2018-09-13 16:36:49 +0100104 ]
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000105 sources = [ "unix_socket.cc" ]
Florian Mayerb6c3bff2018-09-13 16:36:49 +0100106 }
Florian Mayerf427a802018-09-13 11:21:46 +0100107}
108
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000109source_set("test_support") {
110 testonly = true
111 deps = [
112 ":base",
113 "../../gn:default_deps",
114 ]
115 sources = [
Hector Dearman7f71d0e2018-08-09 11:26:10 +0100116 "test/utils.cc",
117 "test/utils.h",
Florian Mayerd8bd81b2018-01-25 12:49:15 +0000118 "test/vm_test_utils.cc",
119 "test/vm_test_utils.h",
Florian Mayerc7255fd2018-01-25 10:29:24 +0000120 ]
Primiano Tuccic2eb5102018-05-15 10:40:01 +0100121
Bruce Dawson78bca4b2018-05-10 17:35:30 +0100122 # The Perfetto task runner is not used on Windows.
123 if (!is_win) {
124 sources += [
125 "test/test_task_runner.cc",
126 "test/test_task_runner.h",
127 ]
128 }
Florian Mayerc7255fd2018-01-25 10:29:24 +0000129}
130
Primiano Tucci02c11762019-08-30 00:57:59 +0200131perfetto_unittest_source_set("unittests") {
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000132 testonly = true
133 deps = [
134 ":base",
Bruce Dawson78bca4b2018-05-10 17:35:30 +0100135 ":test_support",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000136 "../../gn:default_deps",
Primiano Tucci13ae72f2019-06-06 10:53:02 +0100137 "../../gn:gtest_and_gmock",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000138 ]
Florian Mayer236ba472018-05-09 15:47:53 +0100139
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000140 sources = [
Primiano Tucci89795fd2019-02-18 23:08:06 +0000141 "circular_queue_unittest.cc",
Primiano Tucci79dd3bc2019-12-05 13:17:37 +0000142 "flat_set_unittest.cc",
Ryan Savitski478c1182019-04-04 23:28:11 +0100143 "no_destructor_unittest.cc",
Lalit Magantif3e5b072018-11-19 21:51:47 +0000144 "optional_unittest.cc",
Eric Seckleredf3f7c2018-10-23 16:44:53 +0100145 "paged_memory_unittest.cc",
Bruce Dawson2c4a4602018-05-08 19:51:49 +0100146 "scoped_file_unittest.cc",
147 "string_splitter_unittest.cc",
148 "string_utils_unittest.cc",
Primiano Tucci2da5d2e2018-08-10 14:23:31 +0100149 "string_view_unittest.cc",
Lalit Magantibd3fb822019-02-08 10:08:20 +0000150 "string_writer_unittest.cc",
Primiano Tucci1797cd12020-04-14 09:43:24 +0100151 "subprocess_unittest.cc",
Primiano Tuccibc2b2442020-12-09 01:30:14 +0100152 "task_runner_unittest.cc",
Primiano Tuccie4de2da2020-12-01 14:54:07 +0100153 "temp_file_unittest.cc",
Primiano Tuccibc2b2442020-12-09 01:30:14 +0100154 "thread_checker_unittest.cc",
Primiano Tucci8934c6c2018-03-15 11:39:27 +0000155 "time_unittest.cc",
Primiano Tucci1366dd02020-12-02 10:17:10 +0100156 "utils_unittest.cc",
Hector Dearmanf275f692019-07-31 12:56:59 +0100157 "uuid_unittest.cc",
Bruce Dawson2c4a4602018-05-08 19:51:49 +0100158 "weak_ptr_unittest.cc",
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000159 ]
Florian Mayer236ba472018-05-09 15:47:53 +0100160
Primiano Tucci02c11762019-08-30 00:57:59 +0200161 # TODO: Enable these for Windows when possible.
Bruce Dawson2af6ef72018-05-01 15:28:39 +0100162 if (!is_win) {
163 sources += [
Primiano Tuccif80d2d42019-06-05 09:30:59 +0100164 "metatrace_unittest.cc",
Ryan Savitski29885792019-03-14 12:10:13 +0000165 "thread_task_runner_unittest.cc",
Florian Mayer623f0fc2020-11-18 17:37:35 +0000166 "watchdog_posix_unittest.cc",
Bruce Dawson2af6ef72018-05-01 15:28:39 +0100167 ]
168 }
Primiano Tucci4c5efa42018-10-23 13:15:13 +0100169 if (perfetto_build_standalone || perfetto_build_with_android) {
Primiano Tucci02c11762019-08-30 00:57:59 +0200170 # This causes some problems on the chromium waterfall.
Florian Mayerf7f0def2018-09-27 13:59:24 +0100171 if (is_linux || is_android) {
172 sources += [ "watchdog_unittest.cc" ]
173 }
Primiano Tucci63201702020-12-04 17:38:12 +0100174 if (!is_win) {
175 sources += [ "unix_socket_unittest.cc" ]
176 }
Primiano Tuccic96f71b2018-02-06 19:21:09 +0000177 }
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000178}
Primiano Tucci79dd3bc2019-12-05 13:17:37 +0000179
180if (enable_perfetto_benchmarks) {
181 source_set("benchmarks") {
182 testonly = true
183 deps = [
184 ":base",
185 "../../gn:benchmark",
186 "../../gn:default_deps",
187 ]
Primiano Tucci2925e9d2020-01-27 10:15:58 +0000188 sources = [ "flat_set_benchmark.cc" ]
Primiano Tucci79dd3bc2019-12-05 13:17:37 +0000189 }
190}