• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
17
18package {
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
27// Everything needed to run CHPP on Linux, except for the link layer.
28// Note that this is cc_defaults and not a lib because modules that inherit
29// these defaults may need to change compilation flags for sources here.
30cc_defaults {
31    name: "chre_chpp_core_without_link",
32    vendor: true,
33    cflags: [
34        "-Wall",
35        "-Wcast-align",
36        "-Wcast-qual",
37        "-Wconversion",
38        "-Werror",
39        "-Wextra",
40        "-Wno-strict-aliasing",
41        "-Wpointer-arith",
42        "-Wshadow",
43        "-Wswitch",
44        "-DCHPP_MAX_REGISTERED_CLIENTS=3",
45        "-DCHPP_MAX_REGISTERED_SERVICES=3",
46        "-DCHPP_ENABLE_WORK_MONITOR",
47        "-DCHPP_DEBUG_ASSERT_ENABLED",
48        "-DCHPP_CLIENT_ENABLED_TRANSPORT_LOOPBACK",
49        "-DCHPP_SERVICE_ENABLED_TRANSPORT_LOOPBACK",
50
51        // clock_gettime() requires _POSIX_C_SOURCE >= 199309L
52        "-D_POSIX_C_SOURCE=199309L",
53        // Required for pthread_setname_np()
54        "-D_GNU_SOURCE",
55    ],
56    conlyflags: [
57        "-std=c11",
58        "-Wmissing-prototypes",
59        "-Wsign-compare",
60        "-Wstrict-prototypes",
61    ],
62    srcs: [
63        "transport.c",
64        "app.c",
65        "clients.c",
66        "platform/pal_api.c",
67        "platform/linux/memory.c",
68        "platform/linux/notifier.c",
69        "platform/shared/crc.c",
70        "services.c",
71        "services/discovery.c",
72        "services/loopback.c",
73        "services/nonhandle.c",
74        "services/timesync.c",
75    ],
76    export_include_dirs: [
77        "platform/linux/include",
78        "include",
79    ],
80    header_libs: [
81        "chre_pal",
82        "chre_api",
83    ],
84    export_header_lib_headers: [
85        "chre_pal",
86        "chre_api",
87    ],
88    static_libs: ["chre_pal_linux"],
89    host_supported: true,
90}
91
92// Meant to be combined with chre_chpp_core_without_link to add in the full set
93// of optional clients and services.
94cc_defaults {
95    name: "chre_chpp_clients_and_services",
96    cflags: [
97        "-DCHPP_CLIENT_ENABLED_DISCOVERY",
98        "-DCHPP_CLIENT_ENABLED_LOOPBACK",
99        "-DCHPP_CLIENT_ENABLED_TIMESYNC",
100        "-DCHPP_CLIENT_ENABLED_GNSS",
101        "-DCHPP_CLIENT_ENABLED_WIFI",
102        "-DCHPP_CLIENT_ENABLED_WWAN",
103        "-DCHPP_SERVICE_ENABLED_GNSS",
104        "-DCHPP_SERVICE_ENABLED_WIFI",
105        "-DCHPP_SERVICE_ENABLED_WWAN",
106        "-DCHPP_WIFI_DEFAULT_CAPABILITIES=0xf",
107        "-DCHPP_WWAN_DEFAULT_CAPABILITIES=0x1",
108        "-DCHPP_GNSS_DEFAULT_CAPABILITIES=0x7",
109    ],
110    srcs: [
111        "clients/discovery.c",
112        "clients/loopback.c",
113        "clients/timesync.c",
114        "clients/gnss.c",
115        "clients/wifi.c",
116        "clients/wwan.c",
117        "common/gnss_convert.c",
118        "common/wifi_convert.c",
119        "common/wifi_utils.c",
120        "common/wwan_convert.c",
121        "platform/linux/services/platform_gnss.c",
122        "services/gnss.c",
123        "services/wifi.c",
124        "services/wwan.c",
125    ]
126}
127
128cc_library_static {
129    name: "chre_chpp_linux",
130    defaults: [
131        "chre_chpp_core_without_link",
132        "chre_chpp_clients_and_services",
133    ],
134    srcs: [
135        "platform/linux/link.c",
136    ],
137}
138
139cc_test_host {
140    name: "chre_chpp_linux_tests",
141    // TODO(b/232537107): Evaluate if isolated can be turned on
142    isolated: false,
143    cflags: [
144        "-DCHPP_CLIENT_ENABLED_TRANSPORT_LOOPBACK",
145        "-DCHPP_CHECKSUM_ENABLED",
146        "-DCHPP_MAX_REGISTERED_CLIENTS=3",
147        "-DCHPP_MAX_REGISTERED_SERVICES=3",
148        "-DCHPP_WIFI_DEFAULT_CAPABILITIES=0xf",
149        "-DCHPP_WWAN_DEFAULT_CAPABILITIES=0x1",
150        "-DCHPP_GNSS_DEFAULT_CAPABILITIES=0x7",
151        "-DCHPP_ENABLE_WORK_MONITOR",
152    ],
153    srcs: [
154        "test/app_test_base.cpp",
155        "test/app_test.cpp",
156        "test/gnss_test.cpp",
157        "test/transport_test.cpp",
158        "test/clients_test.cpp",
159    ],
160    static_libs: [
161        "chre_chpp_linux",
162        "chre_pal_linux",
163    ],
164    sanitize: {
165      address: true,
166    }
167}
168
169cc_test_host {
170    name: "chre_chpp_convert_tests",
171    cflags: [
172        "-Wcast-align",
173        "-Wsign-compare",
174    ],
175    header_libs: [
176        "chre_test_common",
177    ],
178    srcs: [
179        "test/wifi_convert_test.cpp",
180        "test/wwan_convert_test.cpp"
181    ],
182    static_libs: ["chre_chpp_linux"],
183}
184
185cc_test_host {
186    name: "chre_chpp_fake_link_sync_tests",
187    defaults: ["chre_chpp_core_without_link"],
188    cflags: [
189        // Speed up tests by setting timeouts to 10 ms
190        "-DCHPP_TRANSPORT_TX_TIMEOUT_NS=10000000",
191        "-DCHPP_TRANSPORT_RX_TIMEOUT_NS=10000000",
192    ],
193    local_include_dirs: [
194        "include",
195
196        // Note: this needs to come before platform/linux/include
197        "test/include/fake_link",
198        "platform/linux/include",
199    ],
200    srcs: [
201        "test/fake_link.cpp",
202        "test/fake_link_sync_test.cpp",
203        "test/packet_util.cpp",
204    ],
205    header_libs: [
206        "libbase_headers",
207    ]
208}
209