• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/perfetto.gni")
16
17declare_args() {
18  # Only for local development. When true the binaries (perfetto, traced, ...)
19  # are monolithic and don't use a common shared library. This is mainly to
20  # avoid LD_LIBRARY_PATH dances when testing locally.
21  monolithic_binaries = false
22}
23assert(!monolithic_binaries || !build_with_android)
24
25group("all") {
26  testonly = true  # allow to build also test targets
27  deps = [
28    ":perfetto_unittests",
29    "src/protozero/protoc_plugin($host_toolchain)",
30  ]
31  if (!build_with_chromium) {
32    deps += [
33      ":perfetto",
34      ":perfetto_benchmarks",
35      ":perfetto_integrationtests",
36      ":traced",
37      ":traced_probes",
38      "protos/perfetto/config:merged_config",  # For syntax-checking the proto.
39      "src/ipc/protoc_plugin:ipc_plugin($host_toolchain)",
40      "test/configs",
41      "tools:protoc_helper",
42      "tools/ftrace_proto_gen:ftrace_proto_gen",
43      "tools/proto_to_cpp",
44    ]
45    if (!build_with_android) {
46      deps += [ "tools/trace_to_text" ]
47    }
48    if (is_linux || is_android) {
49      deps += [ "tools/skippy" ]
50    }
51  }
52}
53
54executable("perfetto_unittests") {
55  testonly = true
56  deps = [
57    "gn:default_deps",
58    "gn:gtest_main",
59    "src/base:unittests",
60    "src/protozero:unittests",
61    "src/tracing:unittests",
62  ]
63  if (!build_with_chromium) {
64    deps += [
65      "src/ftrace_reader:unittests",
66      "src/ipc:unittests",
67      "src/perfetto_cmd:unittests",
68      "src/traced/probes:unittests",
69      "src/traced/probes/filesystem:unittests",
70      "tools/ftrace_proto_gen:unittests",
71      "tools/sanitizers_unittests",
72    ]
73  }
74}
75
76if (!build_with_chromium) {
77  executable("perfetto_benchmarks") {
78    testonly = true
79    deps = [
80      "gn:default_deps",
81      "src/ftrace_reader:ftrace_reader_benchmarks",
82      "src/tracing:tracing_benchmarks",
83      "test:benchmark_main",
84      "test:end_to_end_benchmarks",
85    ]
86  }
87
88  executable("perfetto_integrationtests") {
89    testonly = true
90    deps = [
91      "gn:default_deps",
92      "gn:gtest_main",
93      "src/ftrace_reader:ftrace_reader_integrationtests",
94      "test:end_to_end_integrationtests",
95    ]
96    if (build_with_android) {
97      cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
98    }
99  }
100
101  if (monolithic_binaries) {
102    libtraced_shared_target_type = "source_set"
103  } else {
104    libtraced_shared_target_type = "shared_library"
105  }
106
107  target(libtraced_shared_target_type, "libtraced_shared") {
108    deps = [
109      "gn:default_deps",
110      "src/traced/probes",
111      "src/traced/service",
112    ]
113  }
114
115  # The unprivileged trace daemon that listens for Producer and Consumer
116  # connections, handles the coordination of the tracing sessions and owns the
117  # log buffers.
118  executable("traced") {
119    deps = [
120      ":libtraced_shared",
121      "gn:default_deps",
122    ]
123    sources = [
124      "src/traced/service/main.cc",
125    ]
126  }
127
128  # The unprivileged daemon that is allowed to access tracefs (for ftrace).
129  # Registers as a Producer on the traced daemon.
130  executable("traced_probes") {
131    deps = [
132      ":libtraced_shared",
133      "gn:default_deps",
134    ]
135    sources = [
136      "src/traced/probes/main.cc",
137    ]
138  }
139
140  # The command line client for Perfetto. Allows to configure / start / stop
141  # tracing, acting as a Consumer.
142  executable("perfetto") {
143    deps = [
144      "gn:default_deps",
145      "src/perfetto_cmd",
146    ]
147    sources = [
148      "src/perfetto_cmd/main.cc",
149    ]
150    if (is_android) {
151      deps += [ "src/base:android_task_runner" ]
152    }
153    if (build_with_android) {
154      cflags = [ "-DPERFETTO_BUILD_WITH_ANDROID" ]
155      libs = [
156        "binder",
157        "services",
158        "utils",
159      ]
160    }
161  }
162
163  if (build_with_android) {
164    executable("trace_to_text") {
165      testonly = true
166      deps = [
167        "gn:default_deps",
168        "tools/trace_to_text:lib",
169      ]
170    }
171
172    # This target exports perfetto trace protos in the Android build system,
173    # allowing both host and device targets to implement custom parsers based on
174    # our protos.
175    static_library("perfetto_trace_protos") {
176      deps = [
177        "protos/perfetto/trace:lite",
178      ]
179    }
180  }
181}
182
183if (build_with_chromium) {
184  component("libperfetto") {
185    public_configs = [ "gn:public_config" ]
186    deps = [
187      "src/tracing",
188    ]
189    configs -= [ "//build/config/compiler:chromium_code" ]
190    configs += [ "//build/config/compiler:no_chromium_code" ]
191    public_deps = [
192      "include/perfetto/tracing/core",
193    ]
194  }
195}
196