xref: /aosp_15_r20/system/chre/chpp/Android.bp (revision 84e339476a462649f82315436d70fd732297a399)
1/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package {
18    default_team: "trendy_team_context_hub",
19    // See: http://go/android-license-faq
20    // A large-scale-change added 'default_applicable_licenses' to import
21    // all of the 'license_kinds' from "system_chre_license"
22    // to get the below license kinds:
23    //   SPDX-license-identifier-Apache-2.0
24    default_applicable_licenses: ["system_chre_license"],
25}
26
27cc_defaults {
28    name: "chre_chpp_flags",
29    cflags: [
30        "-DCHPP_CHECKSUM_ENABLED",
31        "-DCHPP_DEBUG_ASSERT_ENABLED",
32        "-DCHPP_ENABLE_WORK_MONITOR",
33        "-DCHPP_EXPECTED_SERVICE_COUNT=3",
34        "-DCHPP_MAX_REGISTERED_CLIENTS=16",
35        "-DCHPP_MAX_REGISTERED_SERVICES=16",
36
37        "-DCHPP_CLIENT_ENABLED_DISCOVERY",
38        "-DCHPP_CLIENT_ENABLED_GNSS",
39        "-DCHPP_CLIENT_ENABLED_LOOPBACK",
40        "-DCHPP_CLIENT_ENABLED_TIMESYNC",
41        "-DCHPP_CLIENT_ENABLED_TRANSPORT_LOOPBACK",
42        "-DCHPP_CLIENT_ENABLED_WIFI",
43        "-DCHPP_CLIENT_ENABLED_WWAN",
44        "-DCHPP_SERVICE_ENABLED_GNSS",
45        "-DCHPP_SERVICE_ENABLED_TRANSPORT_LOOPBACK",
46        "-DCHPP_SERVICE_ENABLED_WIFI",
47        "-DCHPP_SERVICE_ENABLED_WWAN",
48
49        "-DCHPP_GNSS_DEFAULT_CAPABILITIES=0x7",
50        "-DCHPP_WIFI_DEFAULT_CAPABILITIES=0xf",
51        "-DCHPP_WWAN_DEFAULT_CAPABILITIES=0x1",
52    ],
53    visibility: ["//visibility:override"],
54}
55
56filegroup {
57    name: "chre_chpp_core_files",
58    srcs: [
59        "app.c",
60        "clients.c",
61        "platform/linux/memory.c",
62        "platform/linux/notifier.c",
63        "platform/pal_api.c",
64        "platform/shared/crc.c",
65        "services.c",
66        "services/discovery.c",
67        "services/loopback.c",
68        "services/nonhandle.c",
69        "services/timesync.c",
70        "transport.c",
71    ],
72}
73
74// Everything needed to run CHPP on Linux, except for the link layer.
75// Note that this is cc_defaults and not a lib because modules that inherit
76// these defaults may need to change compilation flags for sources here.
77cc_defaults {
78    name: "chre_chpp_core_without_link",
79    vendor: true,
80    cflags: [
81        // Required for pthread_setname_np()
82        "-D_GNU_SOURCE",
83        // clock_gettime() requires _POSIX_C_SOURCE >= 199309L
84        "-D_POSIX_C_SOURCE=199309L",
85        "-Wall",
86        "-Wcast-align",
87        "-Wcast-qual",
88        "-Wconversion",
89        "-Werror",
90        "-Wextra",
91        "-Wno-strict-aliasing",
92        "-Wpointer-arith",
93        "-Wshadow",
94        "-Wswitch",
95        // Enable assert (i.e. CHPP_ASSERT, ...)
96        "-UNDEBUG",
97    ],
98    conlyflags: [
99        "-Wmissing-prototypes",
100        "-Wsign-compare",
101        "-Wstrict-prototypes",
102        "-std=c11",
103    ],
104    srcs: [
105        ":chre_chpp_core_files",
106    ],
107    header_libs: [
108        "chre_api",
109        "chre_pal",
110    ],
111    export_header_lib_headers: [
112        "chre_api",
113        "chre_pal",
114    ],
115    static_libs: ["chre_pal_linux"],
116    host_supported: true,
117}
118
119filegroup {
120    name: "chre_chpp_clients_and_services_files",
121    srcs: [
122        "clients/discovery.c",
123        "clients/gnss.c",
124        "clients/loopback.c",
125        "clients/timesync.c",
126        "clients/wifi.c",
127        "clients/wwan.c",
128        "common/gnss_convert.c",
129        "common/wifi_convert.c",
130        "common/wifi_utils.c",
131        "common/wwan_convert.c",
132        "platform/linux/services/platform_gnss.c",
133        "services/gnss.c",
134        "services/wifi.c",
135        "services/wwan.c",
136    ],
137}
138
139// Meant to be combined with chre_chpp_core_without_link to add in the full set
140// of optional clients and services.
141cc_defaults {
142    name: "chre_chpp_clients_and_services",
143    srcs: [
144        ":chre_chpp_clients_and_services_files",
145    ],
146}
147
148filegroup {
149    name: "chre_chpp_linux_files",
150    srcs: [
151        "platform/linux/link.c",
152    ],
153}
154
155cc_library_static {
156    name: "chre_chpp_linux",
157    defaults: [
158        "chre_chpp_clients_and_services",
159        "chre_chpp_core_without_link",
160        "chre_chpp_flags",
161    ],
162    srcs: [
163        ":chre_chpp_linux_files",
164    ],
165    export_include_dirs: [
166        "include",
167        "platform/linux/include",
168    ],
169}
170
171filegroup {
172    name: "chre_chpp_linux_tests_utility_files",
173    srcs: [
174        "test/transport_util.cpp",
175    ],
176}
177
178filegroup {
179    name: "chre_chpp_linux_tests_files",
180    srcs: [
181        "test/app_discovery_test.cpp",
182        "test/app_notification_test.cpp",
183        "test/app_req_resp_test.cpp",
184        "test/app_test.cpp",
185        "test/app_test_base.cpp",
186        "test/app_timeout_test.cpp",
187        "test/gnss_test.cpp",
188        "test/transport_test.cpp",
189    ],
190}
191
192cc_test_host {
193    name: "chre_chpp_linux_tests",
194    // TODO(b/232537107): Evaluate if isolated can be turned on
195    isolated: false,
196    defaults: [
197        "chre_chpp_flags",
198    ],
199    srcs: [
200        ":chre_chpp_linux_tests_files",
201        ":chre_chpp_linux_tests_utility_files",
202    ],
203    static_libs: [
204        "chre_chpp_linux",
205        "chre_pal_linux",
206    ],
207    sanitize: {
208        address: true,
209    },
210}
211
212cc_test_host {
213    name: "chre_chpp_convert_tests",
214    cflags: [
215        "-Wcast-align",
216        "-Wsign-compare",
217    ],
218    header_libs: [
219        "chre_test_common",
220    ],
221    srcs: [
222        "test/wifi_convert_test.cpp",
223        "test/wwan_convert_test.cpp",
224    ],
225    static_libs: ["chre_chpp_linux"],
226}
227
228cc_test_host {
229    name: "chre_chpp_fake_link_sync_tests",
230    defaults: ["chre_chpp_core_without_link"],
231    cflags: [
232        // Speed up tests by setting timeouts to 50 ms.
233        // Note: the value shouldn't be too low to avoid timeouts on slow test servers.
234        "-DCHPP_TRANSPORT_RX_TIMEOUT_NS=50000000",
235        "-DCHPP_TRANSPORT_TX_TIMEOUT_NS=50000000",
236    ],
237    local_include_dirs: [
238        "include",
239
240        // Note: this needs to come before platform/linux/include
241        "test/include/fake_link",
242
243        "platform/linux/include",
244    ],
245    srcs: [
246        "test/fake_link.cpp",
247        "test/fake_link_sync_test.cpp",
248        "test/packet_util.cpp",
249    ],
250    header_libs: [
251        "libbase_headers",
252    ],
253}
254