xref: /aosp_15_r20/system/chre/platform/shared/CMakeLists.txt (revision 84e339476a462649f82315436d70fd732297a399)
1include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
2include(backend.cmake)
3
4pw_add_facade(chre.platform.shared.authentication INTERFACE
5  BACKEND
6    chre.platform.shared.authentication_BACKEND
7  HEADERS
8    include/chre/platform/shared/authentication.h
9  PUBLIC_INCLUDES
10    include
11)
12
13pw_add_facade(chre.platform.shared.bt_snoop_log INTERFACE
14  BACKEND
15    chre.platform.shared.bt_snoop_log_BACKEND
16  HEADERS
17    include/chre/platform/shared/bt_snoop_log.h
18  PUBLIC_INCLUDES
19    include
20)
21
22# Implements chre_api/chre/audio.h's:
23# - bool chreAudioGetSource(uint32_t handle,
24#                           struct chreAudioSource *audioSource)
25# - bool chreAudioConfigureSource(uint32_t handle, bool enable,
26#                                 uint64_t bufferDuration,
27#                                 uint64_t deliveryInterval)
28# - bool chreAudioGetStatus(uint32_t handle,
29#                           struct chreAudioSourceStatus *status)
30#
31pw_add_library(chre.platform.shared.chre_api_audio STATIC
32  SOURCES
33    chre_api_audio.cc
34  PRIVATE_DEPS
35    chre.chre_api.facade
36    chre.platform.platform_audio
37    chre.util
38    chre.util.system
39)
40# Implements chre_api/chre/ble.h's:
41# - uint32_t chreBleGetCapabilities()
42# - uint32_t chreBleGetFilterCapabilities()
43# - bool chreBleFlushAsync(const void *cookie)
44# - bool chreBleStartScanAsync(chreBleScanMode mode,
45#                              uint32_t reportDelayMs,
46#                              const struct chreBleScanFilter *filter)
47# - bool chreBleStartScanAsyncV1_9(enum chreBleScanMode mode,
48#                                  uint32_t reportDelayMs,
49#                                  const struct chreBleScanFilterV1_9 *filter,
50#                                  const void *cookie)
51# - bool chreBleStopScanAsync()
52# - bool chreBleStopScanAsyncV1_9(const void *cookie)
53# - bool chreBleReadRssiAsync(uint16_t connectionHandle,
54#                             const void *cookie)
55# - bool chreBleGetScanStatus(struct chreBleScanStatus *status)
56#
57pw_add_library(chre.platform.shared.chre_api_ble STATIC
58  SOURCES
59    chre_api_ble.cc
60  PRIVATE_DEPS
61    chre.chre_api.facade
62    chre.core
63    chre.util
64    chre.util.system
65)
66
67# Implements chre_api/chre/event.h's:
68# - bool chreSendEvent(uint16_t eventType, void *eventData,
69#                      chreEventCompleteFunction *freeCallback,
70#                      uint32_t targetInstanceId)
71# - bool chreSendMessageToHost(void *message, uint32_t messageSize,
72#                              uint32_t messageType,
73#                              chreMessageFreeFunction *freeCallback)
74# - bool chreSendMessageToHostEndpoint(
75#       void *message, size_t messageSize, uint32_t messageType,
76#       uint16_t hostEndpoint, chreMessageFreeFunction *freeCallback)
77# - bool chreSendMessageWithPermissions(
78#       void *message, size_t messageSize, uint32_t messageType,
79#       uint16_t hostEndpoint, uint32_t messagePermissions,
80#       chreMessageFreeFunction *freeCallback)
81# - bool chreSendReliableMessageAsync(
82#       void *message, size_t messageSize, uint32_t messageType,
83#       uint16_t hostEndpoint, uint32_t messagePermissions,
84#       chreMessageFreeFunction *freeCallback, const void *cookie)
85# - bool chreGetNanoappInfoByAppId(uint64_t appId, struct chreNanoappInfo *info)
86# - bool chreGetNanoappInfoByInstanceId(uint32_t instanceId,
87#                                       struct chreNanoappInfo *info)
88# - void chreConfigureNanoappInfoEvents(bool enable)
89# - void chreConfigureHostSleepStateEvents(bool enable)
90# - bool chreIsHostAwake()
91# - void chreConfigureDebugDumpEvent(bool enable)
92# - bool chreConfigureHostEndpointNotifications(uint16_t hostEndpointId,
93#                                               bool enable)
94# - bool chrePublishRpcServices(struct chreNanoappRpcService *services,
95#                               size_t numServices)
96# - bool chreGetHostEndpointInfo(uint16_t hostEndpointId,
97#                                struct chreHostEndpointInfo *info)
98#
99pw_add_library(chre.platform.shared.chre_api_core STATIC
100  SOURCES
101    chre_api_core.cc
102  PRIVATE_DEPS
103    chre.chre_api.facade
104    chre.core
105    chre.platform.log
106    chre.util
107    chre.util.system
108)
109
110# Implements chre_api/chre/gnss.h's:
111# - uint32_t chreGnssGetCapabilities()
112# - bool chreGnssLocationSessionStartAsync(
113#       uint32_t minIntervalMs, uint32_t minTimeToNextFixMs,
114#       const void *cookie)
115# - bool chreGnssLocationSessionStopAsync(const void *cookie)
116# - bool chreGnssMeasurementSessionStartAsync(
117#        uint32_t minIntervalMs, const void *cookie)
118# - bool chreGnssMeasurementSessionStopAsync(const void *cookie)
119# - bool chreGnssConfigurePassiveLocationListener(bool enable)
120#
121pw_add_library(chre.platform.shared.chre_api_gnss STATIC
122  SOURCES
123    chre_api_gnss.cc
124  PRIVATE_DEPS
125    chre.chre_api.facade
126    chre.core
127    chre.util
128    chre.util.system
129)
130
131# Implements chre_api/chre/re.h's:
132# - uint32_t chreGetCapabilities()
133# - uint32_t chreGetMessageToHostMaxSize()
134# - uint64_t chreGetAppId(void)
135# - uint32_t chreGetInstanceId(void)
136# - uint64_t chreGetTime()
137# - int64_t chreGetEstimatedHostTimeOffset()
138# - uint32_t chreTimerSet(uint64_t duration, const void *cookie, bool oneShot)
139# - bool chreTimerCancel(uint32_t timerId)
140# - void chreAbort(uint32_t abortCode)
141# - void* chreHeapAlloc(uint32_t bytes)
142# - void chreHeapFree(void *ptr)
143# - chreDebugDumpLog(const char *formatStr, ...)
144#
145# Also provides:
146# - void platform_chreDebugDumpVaLog(const char *formatStr, va_list args)
147#
148# Does not provide:
149# - void chreLog(enum chreLogLevel level, const char *formatStr, ...)
150pw_add_library(chre.platform.shared.chre_api_re STATIC
151  HEADERS
152    include/chre/platform/shared/debug_dump.h
153  PUBLIC_INCLUDES
154    include
155  SOURCES
156    chre_api_re.cc
157  PRIVATE_DEPS
158    chre.chre_api.facade
159    chre.core
160    chre.platform.fatal_error
161    chre.util
162)
163
164# Implements chre_api/chre/sensor.h's:
165# - bool chreSensorFindDefault(uint8_t sensorType, uint32_t *handle)
166# - bool chreSensorFind(uint8_t sensorType, uint8_t sensorIndex,
167#                       uint32_t *handle)
168# - bool chreGetSensorInfo(uint32_t sensorHandle, struct chreSensorInfo *info)
169# - bool chreGetSensorSamplingStatus(uint32_t sensorHandle,
170#                                    struct chreSensorSamplingStatus *status)
171# - bool chreSensorConfigure(uint32_t sensorHandle,
172#                            enum chreSensorConfigureMode mode,
173#                            uint64_t interval, uint64_t latency)
174# - bool chreSensorConfigureBiasEvents(uint32_t sensorHandle, bool enable)
175# - bool chreSensorGetThreeAxisBias(uint32_t sensorHandle,
176#                                   struct chreSensorThreeAxisData *bias)
177# - bool chreSensorFlushAsync(uint32_t sensorHandle, const void *cookie)
178#
179pw_add_library(chre.platform.shared.chre_api_sensor STATIC
180  SOURCES
181    chre_api_sensor.cc
182  PRIVATE_DEPS
183    chre.chre_api.facade
184    chre.core
185    chre.util
186)
187
188# Implements chre_api/chre/user_settings.h's:
189# - int8_t chreUserSettingGetState(uint8_t setting)
190# - void chreUserSettingConfigureEvents(uint8_t setting, bool enable)
191#
192pw_add_library(chre.platform.shared.chre_api_user_settings STATIC
193  SOURCES
194    chre_api_user_settings.cc
195  PRIVATE_DEPS
196    chre.chre_api.facade
197    chre.core
198    chre.util
199)
200
201# Implements chre_api/chre/version.h's:
202# - uint32_t chreGetApiVersion(void)
203# - uint32_t chreGetVersion(void)
204# - uint64_t chreGetPlatformId(void)
205#
206pw_add_library(chre.platform.shared.chre_api_version STATIC
207  SOURCES
208    chre_api_version.cc
209  PRIVATE_DEPS
210    chre.chre_api.facade
211    chre.core
212    chre.util
213)
214
215# Implements chre_api/chre/wifi.h's:
216# - uint32_t chreWifiGetCapabilities()
217# - bool chreWifiNanGetCapabilities(
218#       struct chreWifiNanCapabilities *capabilities)
219# - bool chreWifiConfigureScanMonitorAsync(bool enable, const void *cookie)
220# - bool chreWifiRequestScanAsync(const struct chreWifiScanParams *params,
221#                                 const void *cookie)
222# - bool chreWifiRequestRangingAsync(
223#       const struct chreWifiRangingParams *params, const void *cookie)
224# - bool chreWifiNanSubscribe(struct chreWifiNanSubscribeConfig *config,
225#                             const void *cookie)
226# - bool chreWifiNanSubscribeCancel(uint32_t subscriptionId)
227# - bool chreWifiNanRequestRangingAsync(
228#       const struct chreWifiNanRangingParams *params, const void *cookie)
229#
230pw_add_library(chre.platform.shared.chre_api_wifi STATIC
231  SOURCES
232    chre_api_wifi.cc
233  PRIVATE_DEPS
234    chre.chre_api.facade
235    chre.core
236    chre.util
237    chre.util.system
238)
239
240# Implements chre_api/chre/wwan.h's:
241# - uint32_t chreWwanGetCapabilities()
242# - bool chreWwanGetCellInfoAsync(const void *cookie)
243#
244pw_add_library(chre.platform.shared.chre_api_wwan STATIC
245  SOURCES
246    chre_api_wwan.cc
247  PRIVATE_DEPS
248    chre.chre_api.facade
249    chre.core
250    chre.util
251    chre.util.system
252)
253
254pw_add_library(chre.platform.shared.dlfcn STATIC
255  HEADERS
256    include/chre/platform/shared/libc/dlfcn.h
257  PUBLIC_INCLUDES
258    include/chre/platform/shared/libc
259  SOURCES
260    dlfcn.cc
261  PRIVATE_DEPS
262    chre.platform.assert
263    chre.platform.log
264    chre.platform.shared.nanoapp_loader
265    chre.util
266)
267
268pw_add_library(chre.platform.shared.generated.host_messages_generated INTERFACE
269  HEADERS
270    include/chre/platform/shared/generated/host_messages_generated.h
271  PUBLIC_INCLUDES
272    include
273  PUBLIC_DEPS
274    chre_third_party.flatbuffers
275)
276
277pw_add_library(chre.platform.shared.host_protocol_chre STATIC
278  HEADERS
279    include/chre/platform/shared/host_protocol_chre.h
280  PUBLIC_INCLUDES
281    include
282  PUBLIC_DEPS
283    chre.core
284    chre.platform.shared.generated.host_messages_generated
285    chre.platform.shared.host_protocol_common
286    chre.util
287    chre.util.flatbuffers
288    chre.chre_api
289    chre_third_party.flatbuffers
290  SOURCES
291    host_protocol_chre.cc
292    host_link.cc
293  PRIVATE_DEPS
294    chre.core
295    chre.platform.log
296    chre.platform.shared.host_protocol_chre
297    chre.platform.shared.nanoapp_load_manager
298)
299
300pw_add_library(chre.platform.shared.host_protocol_common STATIC
301  HEADERS
302    include/chre/platform/shared/host_protocol_common.h
303  PUBLIC_INCLUDES
304    include
305  PUBLIC_DEPS
306    chre.util.system
307    chre_third_party.flatbuffers
308  SOURCES
309    host_protocol_common.cc
310  PRIVATE_DEPS
311    chre.platform.shared.generated.host_messages_generated
312)
313
314pw_add_library(chre.platform.shared.loader_util INTERFACE
315  HEADERS
316    include/chre/platform/shared/loader_util.h
317  PUBLIC_INCLUDES
318    include
319  PUBLIC_DEPS
320    chre.variant.config
321)
322
323pw_add_library(chre.platform.shared.log_buffer STATIC
324  HEADERS
325    include/chre/platform/shared/log_buffer.h
326  PUBLIC_INCLUDES
327    include
328  PUBLIC_DEPS
329    chre.core
330    chre.platform.mutex
331    chre.platform.shared.bt_snoop_log
332    chre.platform.shared.generated.host_messages_generated
333  SOURCES
334    log_buffer.cc
335  PRIVATE_DEPS
336    chre.platform.assert
337    chre.util
338)
339
340# This requires the backend to provide an implementation for:
341# - void LogBufferManager::preSecondaryBufferUse() const
342pw_add_facade(chre.platform.shared.log_buffer_manager STATIC
343  BACKEND
344    chre.platform.shared.log_buffer_manager_BACKEND
345  HEADERS
346    include/chre/platform/shared/log_buffer_manager.h
347  PUBLIC_INCLUDES
348    include
349  PUBLIC_DEPS
350    chre.chre_api
351    chre.platform.assert
352    chre.platform.condition_variable
353    chre.platform.mutex
354    chre.platform.shared.bt_snoop_log.facade
355    chre.platform.shared.generated.host_messages_generated
356    chre.platform.shared.log_buffer
357    chre.util
358  SOURCES
359    log_buffer_manager.cc
360  PRIVATE_DEPS
361    chre.core
362    chre.platform.log
363    chre.util
364    pw_log_tokenized.config
365    pw_tokenizer
366)
367
368pw_add_facade(chre.platform.shared.memory INTERFACE
369  BACKEND
370    chre.platform.shared.memory_BACKEND
371  HEADERS
372    include/chre/platform/shared/memory.h
373  PUBLIC_INCLUDES
374    include
375)
376
377# Partial backend for chre.platform.memory_manger which implements:
378# 1) void *MemoryManager::nanoappAlloc(Nanoapp *app, uint32_t bytes)
379# 2) void MemoryManager::nanoappFree(Nanoapp *app, void *ptr)
380# 3) uint32_t MemoryManager::nanoappFreeAll(Nanoapp *app)
381# 4) void MemoryManager::logStateToBuffer(DebugDumpWrapper &debugDump) const
382pw_add_library(chre.platform.shared.memory_manager STATIC
383  SOURCES
384    memory_manager.cc
385  PRIVATE_DEPS
386    chre.platform.assert
387    chre.platform.memory_manager.facade
388    chre.util.system
389)
390
391pw_add_library(chre.platform.shared.nanoapp_dso_util STATIC
392  HEADERS
393    include/chre/platform/shared/nanoapp_dso_util.h
394  PUBLIC_INCLUDES
395    include
396  PUBLIC_DEPS
397    chre.platform.shared.nanoapp_support_lib_dso
398  SOURCES
399    nanoapp/nanoapp_dso_util.cc
400  PRIVATE_DEPS
401    chre.platform.log
402)
403
404# This is itself a facade for:
405# 1) bool NanoappLoader::relocateTable(DynamicHeader *dyn, int tag)
406# 2) bool NanoappLoader::resolveGot()
407# 3) if CHREX_SYMBOL_EXTENSIONS is set, providing
408#    `const ExportedData chre::kVendorExportedData[]` via
409#    `chre/extensions/platform/symbol_list.h`.
410pw_add_facade(chre.platform.shared.nanoapp_loader STATIC
411  BACKEND
412    chre.platform.shared.nanoapp_loader_BACKEND
413  HEADERS
414    include/chre/platform/shared/nanoapp_loader.h
415  PUBLIC_INCLUDES
416    include
417  PUBLIC_DEPS
418    chre.util
419    chre.platform.shared.loader_util
420  SOURCES
421    nanoapp_loader.cc
422  PRIVATE_DEPS
423    chre.chre_api
424    chre.platform.assert
425    chre.platform.fatal_error
426    chre.platform.shared.chre_api_re
427    chre.platform.shared.dlfcn
428    chre.platform.shared.memory
429    chre.platform.shared.nanoapp_tokenized_log
430    chre.platform.shared.platform_cache_management
431    chre.variant.config
432)
433
434pw_add_library(chre.platform.shared.nanoapp_load_manager STATIC
435  HEADERS
436    include/chre/platform/shared/nanoapp_load_manager.h
437  PUBLIC_INCLUDES
438    include
439  PUBLIC_DEPS
440    chre.core
441    chre.util
442  SOURCES
443    nanoapp_load_manager.cc
444)
445
446# Note that this does NOT actually implement, which are only required for
447# nanoapp builds:
448# - const struct chreNslNanoappInfo *getChreNslDsoNanoappInfo()
449# - bool chreNslDsoGetApi(uint32_t apiId, void **apiHandle)
450pw_add_library(chre.platform.shared.nanoapp_support_lib_dso INTERFACE
451  HEADERS
452    include/chre/platform/shared/nanoapp_support_lib_dso.h
453  PUBLIC_INCLUDES
454    include
455  PUBLIC_DEPS
456    chre.chre_api
457)
458
459pw_add_library(chre.platform.shared.nanoapp_tokenized_log STATIC
460  HEADERS
461    nanoapp/include/chre/platform/shared/nanoapp/tokenized_log.h
462  PUBLIC_INCLUDES
463    nanoapp/include
464  PUBLIC_DEPS
465    chre.chre_api
466  SOURCES
467    tokenized_log.cc
468  PRIVATE_DEPS
469    chre.core
470    chre.platform.log
471    chre.platform.shared.log_buffer_manager
472    pw_log_tokenized.config
473    pw_tokenizer
474)
475
476pw_add_library(chre.platform.shared.pal_audio_stub STATIC
477  SOURCES
478    pal_audio_stub.cc
479  PRIVATE_DEPS
480    chre.pal.audio.facade
481)
482
483pw_add_library(chre.platform.shared.pal_ble_stub STATIC
484  SOURCES
485    pal_ble_stub.cc
486  PRIVATE_DEPS
487    chre.pal.ble.facade
488)
489
490pw_add_library(chre.platform.shared.pal_gnss_stub STATIC
491  SOURCES
492    pal_gnss_stub.cc
493  PRIVATE_DEPS
494    chre.pal.gnss.facade
495)
496
497pw_add_library(chre.platform.shared.pal_sensor_stub STATIC
498  SOURCES
499    pal_sensor_stub.cc
500  PRIVATE_DEPS
501    chre.pal.sensor.facade
502)
503
504pw_add_facade(chre.platform.shared.pal_system_api STATIC
505  BACKEND
506    chre.platform.shared.pal_system_api_BACKEND
507  HEADERS
508    include/chre/platform/shared/pal_system_api.h
509  PUBLIC_INCLUDES
510    include
511  PUBLIC_DEPS
512    chre.pal.system
513  SOURCES
514    pal_system_api.cc
515  PRIVATE_DEPS
516   chre.platform.log
517   chre.platform.memory
518   chre.platform.system_time
519)
520
521pw_add_library(chre.platform.shared.pal_wifi_stub STATIC
522  SOURCES
523    pal_wifi_stub.cc
524  PRIVATE_DEPS
525    chre.pal.wifi.facade
526)
527
528pw_add_library(chre.platform.shared.pal_wwan_stub STATIC
529  SOURCES
530    pal_wwan_stub.cc
531  PRIVATE_DEPS
532    chre.pal.wwan.facade
533)
534
535pw_add_library(chre.platform.shared.platform_ble_pal STATIC
536  HEADERS
537    public_platform_ble_pal/chre/target_platform/platform_ble_base.h
538  PUBLIC_INCLUDES
539    public_platform_ble_pal
540  PUBLIC_DEPS
541    chre.pal.ble
542    chre.platform.shared.platform_pal
543  SOURCES
544    platform_ble.cc
545  PRIVATE_DEPS
546    chre.chre_api
547    chre.core
548    chre.platform.log
549    chre.platform.platform_ble.facade
550    chre.platform.shared.bt_snoop_log
551    chre.platform.shared.pal_system_api
552    chre.variant.config
553)
554
555pw_add_facade(chre.platform.shared.platform_cache_management INTERFACE
556  BACKEND
557    chre.platform.shared.platform_cache_management_BACKEND
558  HEADERS
559    include/chre/platform/shared/platform_cache_management.h
560  PUBLIC_INCLUDES
561    include
562)
563
564# The optional CHPP and ASH integration is not supported.
565pw_add_library(chre.platform.shared.platform_debug_dump_manager STATIC
566  HEADERS
567    public_platform_debug_dump_manager/chre/target_platform/platform_debug_dump_manager_base.h
568  PUBLIC_INCLUDES
569    public_platform_debug_dump_manager
570  PUBLIC_DEPS
571    chre.variant.config
572  SOURCES
573    platform_debug_dump_manager.cc
574  PRIVATE_DEPS
575    chre.core
576    chre.platform.host_link
577    chre.platform.log
578    chre.platform.platform_debug_dump_manager.facade
579    chre.util
580)
581
582pw_add_library(chre.platform.shared.platform_gnss_pal STATIC
583  HEADERS
584    public_platform_gnss_pal/chre/target_platform/platform_gnss_base.h
585  PUBLIC_INCLUDES
586    public_platform_gnss_pal
587  PUBLIC_DEPS
588    chre.pal.gnss
589    chre.platform.shared.platform_pal
590  SOURCES
591    platform_gnss.cc
592  PRIVATE_DEPS
593    chre.core
594    chre.platform.log
595    chre.platform.platform_gnss.facade
596    chre.platform.shared.pal_system_api
597    chre.variant.config
598)
599
600pw_add_facade(chre.platform.shared.platform_pal INTERFACE
601  BACKEND
602    chre.platform.shared.platform_pal_BACKEND
603  HEADERS
604    include/chre/platform/shared/platform_pal.h
605  PUBLIC_INCLUDES
606    include
607)
608
609pw_add_library(chre.platform.shared.platform_wifi_pal STATIC
610  HEADERS
611    public_platform_wifi_pal/chre/target_platform/platform_wifi_base.h
612  PUBLIC_INCLUDES
613    public_platform_wifi_pal
614  PUBLIC_DEPS
615    chre.pal.wifi
616    chre.platform.shared.platform_pal
617  SOURCES
618    platform_wifi.cc
619  PRIVATE_DEPS
620    chre.core
621    chre.platform.log
622    chre.platform.platform_wifi.facade
623    chre.platform.shared.pal_system_api
624    chre.util.system
625    chre.variant.config
626)
627
628pw_add_library(chre.platform.shared.platform_wwan_pal STATIC
629  HEADERS
630    public_platform_wwan_pal/chre/target_platform/platform_wwan_base.h
631  PUBLIC_INCLUDES
632    public_platform_wwan_pal
633  PUBLIC_DEPS
634    chre.pal.wwan
635    chre.platform.shared.platform_pal
636  SOURCES
637    platform_wwan.cc
638  PRIVATE_DEPS
639    chre.core
640    chre.platform.log
641    chre.platform.platform_wwan.facade
642    chre.platform.shared.pal_system_api
643    chre.variant.config
644)
645