blob: ac13eb3bc8483867475922a3f1d13c36b5e0f0a2 [file] [log] [blame]
# Copyright (C) 2017 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("gn/perfetto.gni")
import("gn/test.gni")
# +----------------------------------------------------------------------------+
# | "all" targets definition: defines targets reachable by the various configs |
# +----------------------------------------------------------------------------+
# There is a subtletly here related with chromium and other GN embedders.
# When adding a dependency some_dir/:target_name, some_dir/BUILD.gn is
# "discovered". As a side effect any *other* target defined in some_dir/BUILD.gn
# (and its transitive dependencies) becomes implicitly part of the "default"
# target, the one invoked running ninja -C out/xxx without further args.
# Because of this, care must be taken to wrap dependencies to targets in other
# build files with if (enable_xxx) flags. Accidentally including a harmless
# target that happens to be defined in the same BUILD.gn that contains targets
# incompatible with the chromium build will cause build/roll failures.
all_targets = [ "protos/perfetto/trace:perfetto_trace_protos" ]
if (enable_perfetto_platform_services) {
all_targets += [
"src/perfetto_cmd:perfetto",
"src/perfetto_cmd:trigger_perfetto",
"src/traced/service:traced",
]
if (enable_perfetto_traced_probes) {
all_targets += [ "src/traced/probes:traced_probes" ]
}
}
if (enable_perfetto_trace_processor && enable_perfetto_trace_processor_sqlite) {
all_targets += [ "src/trace_processor:trace_processor_shell" ]
}
if (enable_perfetto_traceconv) {
all_targets += [ "src/traceconv" ]
if (is_cross_compiling) {
# In many cross-compilation scenarios (typically Android) developers expect
# the host version of traceconv to be available somewhere in out/, so
# they can convert Android traces on their dev machine. Also
# tools/gen_android_bp explicitly depends on the host version for the
# cc_binary_host("traceconv") target in Android.bp.
# Note that when cross-compiling the host executable will be available in
# out/xxx/gcc_like_host/traceconv NOT just out/xxx/traceconv.
all_targets += [ "src/traceconv($host_toolchain)" ]
}
}
if (enable_perfetto_heapprofd) {
all_targets += [ "src/profiling/memory:heapprofd" ]
if (is_linux && !is_android) {
all_targets += [ "src/profiling/memory:heapprofd_glibc_preload" ]
}
if (perfetto_build_with_android) {
all_targets += [
"src/profiling/memory:heapprofd_client",
"src/profiling/memory:heapprofd_client_api",
]
}
}
if (enable_perfetto_traced_perf) {
all_targets += [ "src/profiling/perf:traced_perf" ]
}
if (perfetto_build_with_android) {
all_targets += [ "src/android_internal:libperfetto_android_internal" ]
}
if (enable_perfetto_tools) {
all_targets += [ "src/tools" ]
# Windows does not have an IPC implementation.
if (!is_win) {
all_targets += [ "src/websocket_bridge" ]
}
}
if (enable_perfetto_unittests) {
import("gn/perfetto_unittests.gni")
test("perfetto_unittests") {
if (is_fuchsia) {
additional_manifest_fragments =
[ "//build/config/fuchsia/test/network.shard.test-cml" ]
}
deps = perfetto_unittests_targets
}
all_targets += [ ":perfetto_unittests" ]
}
if (enable_perfetto_integration_tests) {
import("gn/perfetto_integrationtests.gni")
test("perfetto_integrationtests") {
deps = perfetto_integrationtests_targets
}
all_targets += [
":perfetto_integrationtests",
"examples/sdk:sdk_example",
"test:client_api_example",
"test/stress_test",
]
if (!is_win) {
all_targets += [ "examples/shared_lib:example_shlib_data_source" ]
}
}
if (enable_perfetto_trace_processor_json) {
test("trace_processor_minimal_smoke_tests") {
testonly = true
deps = [
"gn:default_deps",
"src/trace_processor:storage_minimal_smoke_tests",
]
}
all_targets += [ ":trace_processor_minimal_smoke_tests" ]
}
if (enable_perfetto_benchmarks) {
import("gn/perfetto_benchmarks.gni")
executable("perfetto_benchmarks") {
testonly = true
deps = perfetto_benchmarks_targets
}
all_targets += [ ":perfetto_benchmarks" ]
}
if (enable_perfetto_fuzzers) {
import("gn/perfetto_fuzzers.gni")
group("fuzzers") {
testonly = true
deps = perfetto_fuzzers_targets
}
all_targets += [ ":fuzzers" ]
}
# Less interesting stuff that makes sense only in the standalone build, mainly
# compile-time checks for the CI.
if (perfetto_build_standalone) {
all_targets += [
"test/configs",
# Used to evaluate the Python folder for Bazel script generation.
"python:trace_processor_py",
# For syntax-checking the protos.
"protos/perfetto/trace:merged_trace_lite",
# For checking all generated xxx.gen.{cc,h} files without waiting for
# embedders to try to use them and fail.
"protos/perfetto/config:cpp",
"protos/perfetto/common:cpp",
# Used in the when updating the ftrace protos
"protos/perfetto/trace/ftrace:descriptor",
# Checks that the "fake" backend implementations build.
"src/tracing:client_api_no_backends_compile_test",
]
if (is_linux || is_android || is_mac) {
all_targets += [ "src/tracebox" ]
}
}
# The CTS code is built (but not ran) also in standalone builds. This is to
# catch refactoring breakages earlier without having to wait for treehugger.
if (is_android && (perfetto_build_standalone || perfetto_build_with_android)) {
all_targets += [ "test/cts:perfetto_cts_deps" ]
all_targets += [ "test/vts:perfetto_vts_deps" ]
}
group("all") {
testonly = true # allow to build also test targets
deps = all_targets
}
# This target is used when running ninja without any argument (by default would
# build all reachable targets). This is mainly used to prevent the UI being
# built when running ninja -C out/xxx.
# This has effect only in standalone builds, no effect on chromium builds.
# Chromium's "all" target depends on our "all" target above. However chromium's
# "default" target depends on any target that we cause to be discovered by
# depending on other GN files.
group("default") {
testonly = true
deps = [ ":all" ]
}
# +----------------------------------------------------------------------------+
# | Other definitions: root targets that don't belong to any other subdirectory|
# +----------------------------------------------------------------------------+
if (enable_perfetto_ui) {
group("ui") {
deps = [ "ui" ]
}
}
if (enable_perfetto_site) {
group("site") {
deps = [ "infra/perfetto.dev:site" ]
}
}
# In Android builds, we build the code of traced and traced_probes in one shared
# library that exposes one xxx_main() for each. The executables themselves are
# tiny shells that just invoke their own entry point into the library.
# This is done merely for saving binary size, because the three binaries happen
# to share a lot of code.
# When setting monolithic_binaries=true (only supported in standalone builds)
# it builds more conventional executables, where each binary has the full
# implementation and no shared library dependency. This is to make dev cycles
# on Android faster, avoiding all the LD_LIBRARY_PATH boilerplate.
# libperfetto.so is also used for stuff that is exposed to the rest of the
# Android tree.
if (enable_perfetto_platform_services) {
if (monolithic_binaries) {
libperfetto_target_type = "static_library"
} else {
libperfetto_target_type = "shared_library"
}
target(libperfetto_target_type, "libperfetto") {
if (libperfetto_target_type == "static_library") {
complete_static_lib = true
}
deps = [
"gn:default_deps",
"src/traced/service",
]
if (enable_perfetto_traced_probes) {
deps += [ "src/traced/probes" ]
}
}
}
if (!build_with_chromium) {
# Client library target exposed to the Android tree.
# Still in experimental stage and not API stable yet.
# See "libperfetto_client_example" (in Android.bp.extras) for an example
# on how to use the Perfetto Client API from the android tree.
static_library("libperfetto_client_experimental") {
complete_static_lib = true
public_deps = [
"gn:default_deps",
"src/tracing:client_api",
"src/tracing:platform_impl",
]
sources = [ "include/perfetto/tracing.h" ]
assert_no_deps = [ "//gn:protobuf_lite" ]
}
}
# TODO(primiano): there seem to be two "libperfetto" and one
# "libperfetto_client_experimental" targets defined within this BUILD.gn file.
# Rationalize them with eseckler@. For now seems this one is only used from
# chromium and the other one only from the Android tree.
if (build_with_chromium) {
component("libperfetto") {
public_configs = [ "gn:public_config" ]
deps = [
"src/trace_processor/importers/memory_tracker:graph_processor",
"src/tracing:client_api",
"src/tracing/core",
# TODO(eseckler): Create a platform for chrome and hook it up somehow.
"src/tracing:platform_fake",
]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
public_deps = [
"include/perfetto/ext/trace_processor/importers/memory_tracker",
"include/perfetto/ext/tracing/core",
"include/perfetto/tracing",
"protos/perfetto/common:zero",
"protos/perfetto/trace:zero",
"protos/perfetto/trace/chrome:zero",
"protos/perfetto/trace/interned_data:zero",
"protos/perfetto/trace/profiling:zero",
"protos/perfetto/trace/ps:zero",
"protos/perfetto/trace/track_event:zero",
]
if (enable_perfetto_ipc) {
deps += [
"src/tracing/ipc/producer",
"src/tracing/ipc/service",
]
public_deps += [ "include/perfetto/ext/tracing/ipc:ipc" ]
}
if (!is_nacl) {
deps += [
"src/trace_processor:export_json",
"src/trace_processor:storage_minimal",
]
public_deps += [
"include/perfetto/ext/trace_processor:export_json",
"include/perfetto/trace_processor:storage",
]
}
}
component("libtrace_processor") {
public_configs = [ "gn:public_config" ]
deps = [ "src/trace_processor:lib" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
public_deps = [ "include/perfetto/trace_processor" ]
}
component("perfetto_test_support") {
testonly = true
public_configs = [ "gn:public_config" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
public_deps = [ "include/perfetto/test:test_support" ]
deps = [ "src/tracing/test:test_support" ]
}
}