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/fuzzer.gni")
16import("../../gn/perfetto.gni")
17import("../../gn/perfetto_component.gni")
18import("../../gn/proto_library.gni")
19import("../../gn/test.gni")
20
21# This build file should not be leaked into all embedders. Only select
22# projects should be depending on our IPC layer.
23assert(enable_perfetto_ipc)
24
25if (perfetto_component_type == "static_library") {
26  # In build generators everything else outside should just depend on the
27  # :perfetto_ipc static library (at the end of this file) rather than
28  # individual sub-targets.
29  _ipc_visibility = [ ":*" ]  # Only targets defined in this file.
30} else {
31  _ipc_visibility = [ "*" ]  # Default visibility.
32}
33
34source_set("client") {
35  public_deps = [
36    "../../include/perfetto/ext/ipc",
37    "../base:unix_socket",
38  ]
39  deps = [
40    ":common",
41    "../../gn:default_deps",
42    "../../protos/perfetto/ipc:wire_protocol_cpp",
43    "../base",
44  ]
45  sources = [
46    "client_impl.cc",
47    "client_impl.h",
48    "service_proxy.cc",
49  ]
50  visibility = _ipc_visibility
51}
52
53source_set("host") {
54  public_deps = [
55    "../../include/perfetto/ext/ipc",
56    "../base:unix_socket",
57  ]
58  deps = [
59    ":common",
60    "../../gn:default_deps",
61    "../../protos/perfetto/ipc:wire_protocol_cpp",
62    "../base",
63  ]
64  sources = [
65    "host_impl.cc",
66    "host_impl.h",
67  ]
68  visibility = _ipc_visibility
69}
70
71source_set("common") {
72  public_deps = [
73    "../../include/perfetto/ext/ipc",
74    "../../protos/perfetto/ipc:wire_protocol_cpp",
75  ]
76  deps = [
77    "../../gn:default_deps",
78    "../base",
79  ]
80  sources = [
81    "buffered_frame_deserializer.cc",
82    "buffered_frame_deserializer.h",
83    "deferred.cc",
84    "virtual_destructors.cc",
85  ]
86  visibility = _ipc_visibility
87}
88
89perfetto_fuzzer_test("buffered_frame_deserializer_fuzzer") {
90  sources = [ "buffered_frame_deserializer_fuzzer.cc" ]
91  deps = [
92    ":common",
93    "../../gn:default_deps",
94    "../../protos/perfetto/ipc:wire_protocol_cpp",
95    "../base",
96  ]
97}
98
99perfetto_unittest_source_set("unittests") {
100  testonly = true
101  deps = [
102    ":client",
103    ":common",
104    ":host",
105    ":test_messages_cpp",
106    ":test_messages_ipc",
107    "../../gn:default_deps",
108    "../../gn:gtest_and_gmock",
109    "../../protos/perfetto/ipc:wire_protocol_cpp",
110    "../base",
111    "../base:test_support",
112  ]
113  sources = [
114    "buffered_frame_deserializer_unittest.cc",
115    "client_impl_unittest.cc",
116    "deferred_unittest.cc",
117    "host_impl_unittest.cc",
118    "test/ipc_integrationtest.cc",
119  ]
120}
121
122perfetto_proto_library("test_messages_@TYPE@") {
123  proto_generators = [
124    "ipc",
125    "zero",
126    "cpp",
127  ]
128  sources = [
129    "test/client_unittest_messages.proto",
130    "test/deferred_unittest_messages.proto",
131    "test/greeter_service.proto",
132  ]
133}
134
135# This is used by Bazel BUILD rules. The problem it solves is the following:
136# In GN builds we want to keep client and host separate. This allows reducing
137# the binary size by splitting targets all the way up to the client library
138# (libperfetto_client_experimental). In bazel/blaze we fuse everything together
139# because handling this split is too complex due to the lack of a
140# source_set-equivalent.
141perfetto_component("perfetto_ipc") {
142  public_deps = [
143    ":client",
144    ":host",
145    "../../gn:default_deps",
146  ]
147}
148