1# Copyright (c) 2021, Intel Corporation
2#
3# SPDX-License-Identifier: Apache-2.0
4
5if (CONFIG_PERCEPIO_TRACERECORDER OR CONFIG_PERCEPIO_DFM)
6  zephyr_library()
7endif()
8
9if(CONFIG_PERCEPIO_TRACERECORDER)
10
11  set(TRACERECORDER_DIR ${ZEPHYR_CURRENT_MODULE_DIR}/TraceRecorder)
12
13  zephyr_library_sources_ifdef(
14    CONFIG_PERCEPIO_TRACERECORDER
15    ${TRACERECORDER_DIR}/kernelports/Zephyr/trcKernelPort.c
16    ${TRACERECORDER_DIR}/trcAssert.c
17    ${TRACERECORDER_DIR}/trcCounter.c
18    ${TRACERECORDER_DIR}/trcDiagnostics.c
19    ${TRACERECORDER_DIR}/trcEntryTable.c
20    ${TRACERECORDER_DIR}/trcError.c
21    ${TRACERECORDER_DIR}/trcEvent.c
22    ${TRACERECORDER_DIR}/trcEventBuffer.c
23    ${TRACERECORDER_DIR}/trcExtension.c
24    ${TRACERECORDER_DIR}/trcHardwarePort.c
25    ${TRACERECORDER_DIR}/trcHeap.c
26    ${TRACERECORDER_DIR}/trcInternalEventBuffer.c
27    ${TRACERECORDER_DIR}/trcInterval.c
28    ${TRACERECORDER_DIR}/trcISR.c
29    ${TRACERECORDER_DIR}/trcMultiCoreEventBuffer.c
30    ${TRACERECORDER_DIR}/trcObject.c
31    ${TRACERECORDER_DIR}/trcPrint.c
32    ${TRACERECORDER_DIR}/trcStackMonitor.c
33    ${TRACERECORDER_DIR}/trcStateMachine.c
34    ${TRACERECORDER_DIR}/trcStaticBuffer.c
35    ${TRACERECORDER_DIR}/trcStreamingRecorder.c
36    ${TRACERECORDER_DIR}/trcString.c
37    ${TRACERECORDER_DIR}/trcTask.c
38    ${TRACERECORDER_DIR}/trcTimestamp.c
39    ${TRACERECORDER_DIR}/trcDependency.c
40    ${TRACERECORDER_DIR}/trcRunnable.c
41    )
42
43  if(CONFIG_PERCEPIO_TRC_CFG_STREAM_PORT_RTT)
44    zephyr_library_sources(
45      ${TRACERECORDER_DIR}/streamports/Jlink_RTT/trcStreamPort.c
46    )
47
48    zephyr_include_directories(
49      ${TRACERECORDER_DIR}/kernelports/Zephyr/streamports/Jlink_RTT/config/
50      ${TRACERECORDER_DIR}/streamports/Jlink_RTT/include/
51    )
52  endif()
53
54  if(CONFIG_PERCEPIO_TRC_CFG_STREAM_PORT_ITM)
55    zephyr_library_sources(
56      ${TRACERECORDER_DIR}/streamports/ARM_ITM/trcStreamPort.c
57    )
58
59    zephyr_include_directories(
60      ${TRACERECORDER_DIR}/kernelports/Zephyr/streamports/ARM_ITM/config/
61      ${TRACERECORDER_DIR}/streamports/ARM_ITM/include/
62    )
63  endif()
64
65  if(CONFIG_PERCEPIO_TRC_CFG_STREAM_PORT_RINGBUFFER)
66    zephyr_library_sources(
67      ${TRACERECORDER_DIR}/streamports/RingBuffer/trcStreamPort.c
68    )
69
70    zephyr_include_directories(
71      ${TRACERECORDER_DIR}/kernelports/Zephyr/streamports/RingBuffer/config/
72      ${TRACERECORDER_DIR}/streamports/RingBuffer/include/
73    )
74  endif()
75
76  if (CONFIG_PERCEPIO_TRC_CFG_STREAM_PORT_ZEPHYR_SEMIHOST)
77    zephyr_library_sources(
78      ${TRACERECORDER_DIR}/kernelports/Zephyr/streamports/Semihost/trcStreamPort.c
79    )
80
81    zephyr_include_directories(
82      ${TRACERECORDER_DIR}/kernelports/Zephyr/streamports/Semihost/config
83      ${TRACERECORDER_DIR}/kernelports/Zephyr/streamports/Semihost/include
84    )
85  endif()
86
87
88  zephyr_include_directories(
89    ${TRACERECORDER_DIR}/kernelports/Zephyr/include
90    ${TRACERECORDER_DIR}/kernelports/Zephyr/config
91    ${TRACERECORDER_DIR}/kernelports/Zephyr/config/core
92    ${TRACERECORDER_DIR}/include
93    )
94
95  set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
96      COMMAND python3 ${TRACERECORDER_DIR}/kernelports/Zephyr/scripts/tz_parse_syscalls.py ${CMAKE_BINARY_DIR} ${ZEPHYR_BASE}
97    )
98
99endif()
100
101if(CONFIG_PERCEPIO_DFM)
102
103  set(DFM_DIR ${ZEPHYR_CURRENT_MODULE_DIR}/DFM)
104
105  zephyr_library_sources_ifdef(
106    CONFIG_PERCEPIO_DFM
107    ${DFM_DIR}/dfm.c
108    ${DFM_DIR}/dfmAlert.c
109    ${DFM_DIR}/dfmCloud.c
110    ${DFM_DIR}/dfmEntry.c
111    ${DFM_DIR}/dfmSession.c
112    ${DFM_DIR}/dfmStorage.c
113    ${DFM_DIR}/kernelports/Zephyr/dfmKernelPort.c
114    )
115
116  if(CONFIG_PERCEPIO_DFM_CFG_STORAGEPORT_NONE)
117    zephyr_library_sources(
118      ${DFM_DIR}/storageports/Dummy/dfmStoragePort.c
119    )
120
121    zephyr_include_directories(
122      ${DFM_DIR}/storageports/Dummy/include/
123    )
124  endif()
125
126  if(CONFIG_PERCEPIO_DFM_CFG_STORAGEPORT_FLASH)
127    zephyr_library_sources(
128      ${DFM_DIR}/kernelports/Zephyr/storageports/Flash/dfmStoragePort.c
129    )
130
131    zephyr_include_directories(
132      ${DFM_DIR}/kernelports/Zephyr/storageports/Flash/include/
133    )
134  endif()
135
136  if(CONFIG_PERCEPIO_DFM_CFG_CLOUDPORT_NONE)
137    zephyr_library_sources(
138      ${DFM_DIR}/cloudports/Dummy/dfmCloudPort.c
139    )
140
141    zephyr_include_directories(
142      ${DFM_DIR}/cloudports/Dummy/include/
143    )
144  endif()
145
146  if(CONFIG_PERCEPIO_DFM_CFG_CLOUDPORT_SERIAL)
147    zephyr_library_sources(
148      ${DFM_DIR}/kernelports/Zephyr/cloudports/Serial/dfmCloudPort.c
149    )
150
151    zephyr_include_directories(
152      ${DFM_DIR}/kernelports/Zephyr/cloudports/Serial/config/
153      ${DFM_DIR}/kernelports/Zephyr/cloudports/Serial/include/
154    )
155  endif()
156
157  zephyr_include_directories(
158    ${DFM_DIR}/kernelports/Zephyr/config
159    ${DFM_DIR}/kernelports/Zephyr/include
160    ${DFM_DIR}/include
161    )
162
163endif()
164