blob: fcb67cb6d774dc29b11574a6177c95d153c02c97 [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("//build_overrides/build.gni")
import("../../gn/fuzzer.gni")
import("../../gn/perfetto.gni")
import("../../gn/test.gni")
# Core tracing library, platform independent, no transport layer.
source_set("tracing") {
public_deps = [
":common",
"../../include/perfetto/ext/tracing/core",
"../../protos/perfetto/common:lite",
"../../protos/perfetto/trace:minimal_lite",
"../../protos/perfetto/trace:trusted_lite",
"../../protos/perfetto/trace:zero",
"../../protos/perfetto/trace/interned_data:zero",
"../../protos/perfetto/trace/track_event:zero",
]
deps = [
"../../gn:default_deps",
"../../include/perfetto/tracing",
"../../protos/perfetto/config:lite",
"../../protos/perfetto/trace/perfetto:zero", # For MetatraceWriter.
"../base",
"../protozero",
]
sources = [
"core/chrome_config.cc",
"core/commit_data_request.cc",
"core/data_source_config.cc",
"core/data_source_descriptor.cc",
"core/id_allocator.cc",
"core/id_allocator.h",
"core/metatrace_writer.cc",
"core/metatrace_writer.h",
"core/null_trace_writer.cc",
"core/null_trace_writer.h",
"core/observable_events.cc",
"core/packet_stream_validator.cc",
"core/packet_stream_validator.h",
"core/patch_list.h",
"core/shared_memory_abi.cc",
"core/shared_memory_arbiter_impl.cc",
"core/shared_memory_arbiter_impl.h",
"core/sliced_protobuf_input_stream.cc",
"core/startup_trace_writer.cc",
"core/startup_trace_writer_registry.cc",
"core/test_config.cc",
"core/trace_buffer.cc",
"core/trace_buffer.h",
"core/trace_config.cc",
"core/trace_packet.cc",
"core/trace_stats.cc",
"core/trace_writer_impl.cc",
"core/trace_writer_impl.h",
"core/tracing_service_impl.cc",
"core/tracing_service_impl.h",
"core/tracing_service_state.cc",
"core/virtual_destructors.cc",
]
}
perfetto_unittest_source_set("unittests") {
testonly = true
deps = [
":test_support",
":tracing",
"../../gn:default_deps",
"../../gn:gtest_and_gmock",
"../../protos/perfetto/config:lite",
"../../protos/perfetto/trace:lite",
"../../protos/perfetto/trace:zero",
"../base",
"../base:test_support",
]
sources = [
"core/id_allocator_unittest.cc",
"core/null_trace_writer_unittest.cc",
"core/packet_stream_validator_unittest.cc",
"core/patch_list_unittest.cc",
"core/shared_memory_abi_unittest.cc",
"core/sliced_protobuf_input_stream_unittest.cc",
"core/trace_buffer_unittest.cc",
"core/trace_packet_unittest.cc",
"test/aligned_buffer_test.cc",
"test/aligned_buffer_test.h",
"test/fake_packet.cc",
"test/fake_packet.h",
"test/test_shared_memory.cc",
"test/test_shared_memory.h",
]
if (enable_perfetto_ipc) {
deps += [ ":ipc" ]
sources += [
"ipc/posix_shared_memory_unittest.cc",
"test/tracing_integration_test.cc",
]
}
# These tests rely on test_task_runner.h which
# has no Windows implementation.
if (!is_win) {
sources += [
"core/shared_memory_arbiter_impl_unittest.cc",
"core/startup_trace_writer_unittest.cc",
"core/trace_writer_impl_unittest.cc",
"core/tracing_service_impl_unittest.cc",
"test/fake_producer_endpoint.h",
"test/mock_consumer.cc",
"test/mock_consumer.h",
"test/mock_producer.cc",
"test/mock_producer.h",
]
}
}
source_set("test_support") {
testonly = true
public_deps = [
"../../include/perfetto/ext/tracing/core",
"../../protos/perfetto/trace:lite",
"../../protos/perfetto/trace:zero",
"../protozero",
]
sources = [
"core/trace_writer_for_testing.cc",
"core/trace_writer_for_testing.h",
]
}
if (perfetto_build_standalone || perfetto_build_with_android) {
executable("consumer_api_test") {
deps = [
":consumer_api_deprecated",
"../../gn:default_deps",
"../../include/perfetto/public",
"../../protos/perfetto/config:lite",
"../../protos/perfetto/trace:lite",
"../base",
]
sources = [
"api_impl/consumer_api_test.cc",
]
}
# Imlementation of the public-facing consumer API in libperfetto.so (only for
# Android builds).
# TODO(primiano): remove this. This is a legacy and deprecated API. The only
# uses should be moved to the perfetto Client API.
source_set("consumer_api_deprecated") {
deps = [
":ipc",
":tracing",
"../../gn:default_deps",
"../../include/perfetto/public",
"../../protos/perfetto/config:lite",
"../base",
]
sources = [
"api_impl/consumer_api.cc",
]
}
}
if (enable_perfetto_ipc) {
# Posix specialization of the tracing library for Linux / Android / Mac.
# Provides an IPC transport over a UNIX domain socket.
source_set("ipc") {
public_deps = [
"../../include/perfetto/ext/tracing/core",
"../../include/perfetto/ext/tracing/ipc",
]
sources = [
"ipc/consumer/consumer_ipc_client_impl.cc",
"ipc/consumer/consumer_ipc_client_impl.h",
"ipc/default_socket.cc",
"ipc/posix_shared_memory.cc",
"ipc/posix_shared_memory.h",
"ipc/producer/producer_ipc_client_impl.cc",
"ipc/producer/producer_ipc_client_impl.h",
"ipc/service/consumer_ipc_service.cc",
"ipc/service/consumer_ipc_service.h",
"ipc/service/producer_ipc_service.cc",
"ipc/service/producer_ipc_service.h",
"ipc/service/service_ipc_host_impl.cc",
"ipc/service/service_ipc_host_impl.h",
]
deps = [
":tracing",
"../../gn:default_deps",
"../../protos/perfetto/ipc",
"../base",
"../ipc",
]
}
}
# Separate target because the embedder might not want this (e.g. on Windows).
if (is_linux || is_mac || is_android) {
source_set("platform_posix") {
deps = [
"../../gn:default_deps",
"../../include/perfetto/tracing",
"../base",
]
sources = [
"platform_posix.cc",
]
}
}
# Code that both public headers and other non-public sources (e.g.
# src/tracing/core) need to depend on. It cannot be in the root :tracing target
# otherwise there would be a cyclic dependency because public itself needs to
# depend on tracing.
source_set("common") {
deps = [
"../../gn:default_deps",
"../../include/perfetto/tracing",
]
sources = [
"trace_writer_base.cc",
]
}
source_set("client_api") {
deps = [
":common",
"../base",
"../tracing",
]
public_deps = [
"../../gn:default_deps",
"../../include/perfetto/tracing",
]
sources = [
"data_source.cc",
"internal/in_process_tracing_backend.cc",
"internal/in_process_tracing_backend.h",
"internal/tracing_muxer_impl.cc",
"internal/tracing_muxer_impl.h",
"platform.cc",
"tracing.cc",
"track_event.cc",
"virtual_destructors.cc",
]
if (enable_perfetto_ipc) {
deps += [ ":ipc" ]
sources += [
"internal/system_tracing_backend.cc",
"internal/system_tracing_backend.h",
]
}
}
if (enable_perfetto_integration_tests) {
source_set("client_api_integrationtests") {
testonly = true
deps = [
":client_api",
":platform_posix",
"../../:libperfetto_client_experimental",
"../../gn:default_deps",
"../../gn:gtest_and_gmock",
"../../include/perfetto/tracing/core",
"../../protos/perfetto/trace:lite",
"../../protos/perfetto/trace:zero",
"../base",
"test:api_test_support",
]
sources = [
"api_integrationtest.cc",
]
}
}
if (enable_perfetto_benchmarks) {
source_set("benchmarks") {
testonly = true
deps = [
":tracing",
"../../../../gn:benchmark",
"../../../../gn:default_deps",
"../../protos/perfetto/trace:zero",
"../../protos/perfetto/trace/ftrace:zero",
"../protozero",
]
sources = [
"core/packet_stream_validator_benchmark.cc",
]
}
}
perfetto_fuzzer_test("packet_stream_validator_fuzzer") {
sources = [
"core/packet_stream_validator_fuzzer.cc",
]
deps = [
":tracing",
"../../../../gn:default_deps",
]
}