• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2022 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://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, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
16
17set(dir_pw_third_party_freertos "" CACHE PATH
18    "Path to the FreeRTOS installation's Source directory. \
19     If set, pw_third_party.freertos is provided")
20set(pw_third_party_freertos_CONFIG "" CACHE STRING
21    "The CMake target which provides the FreeRTOS config header")
22set(pw_third_party_freertos_PORT "" CACHE STRING
23    "The CMake target which provides the port specific includes and sources")
24option(pw_third_party_freertos_DISABLE_TASKS_STATICS
25       "Whether to disable statics inside of tasks.c")
26
27pw_add_module_library(pw_third_party.freertos.disable_warnings
28  PUBLIC_COMPILE_OPTIONS
29    -Wno-unused-parameter
30    -Wno-cast-qual
31)
32
33# If FreeRTOS is not configured, a script that displays an error message is used
34# instead. If the build rule is used in the build it fails with this error.
35if(NOT dir_pw_third_party_freertos)
36  add_custom_target(pw_third_party.freertos._not_configured
37    COMMAND
38      "${CMAKE_COMMAND}" -E echo
39        "ERROR: Attempted to build the pw_third_party.freertos without"
40        "configuring it via dir_pw_third_party_freertos."
41        "See https://pigweed.dev/third_party/freertos."
42    COMMAND
43      "${CMAKE_COMMAND}" -E false
44  )
45  add_library(pw_third_party.freertos INTERFACE)
46  add_dependencies(pw_third_party.freertos
47    pw_third_party.freertos._not_configured)
48  return()
49else(dir_pw_third_party_freertos)
50  if(NOT pw_third_party_freertos_PORT)
51    message(FATAL_ERROR "FreeRTOS is being used, but "
52            "pw_third_party_freertos_PORT is not set.")
53  endif()
54  if(NOT pw_third_party_freertos_CONFIG)
55    message(FATAL_ERROR "FreeRTOS is being used, but "
56            "pw_third_party_freertos_CONFIG is not set.")
57  endif()
58
59  pw_add_module_library(pw_third_party.freertos
60    HEADERS
61      ${dir_pw_third_party_freertos}/include/FreeRTOS.h
62      ${dir_pw_third_party_freertos}/include/StackMacros.h
63      ${dir_pw_third_party_freertos}/include/croutine.h
64      ${dir_pw_third_party_freertos}/include/deprecated_definitions.h
65      ${dir_pw_third_party_freertos}/include/event_groups.h
66      ${dir_pw_third_party_freertos}/include/list.h
67      ${dir_pw_third_party_freertos}/include/message_buffer.h
68      ${dir_pw_third_party_freertos}/include/mpu_prototypes.h
69      ${dir_pw_third_party_freertos}/include/mpu_wrappers.h
70      ${dir_pw_third_party_freertos}/include/portable.h
71      ${dir_pw_third_party_freertos}/include/projdefs.h
72      ${dir_pw_third_party_freertos}/include/queue.h
73      ${dir_pw_third_party_freertos}/include/semphr.h
74      ${dir_pw_third_party_freertos}/include/stack_macros.h
75      ${dir_pw_third_party_freertos}/include/stream_buffer.h
76      ${dir_pw_third_party_freertos}/include/task.h
77      ${dir_pw_third_party_freertos}/include/timers.h
78    PUBLIC_INCLUDES
79      ${dir_pw_third_party_freertos}/include
80    PUBLIC_DEPS
81      ${pw_third_party_freertos_CONFIG}
82      ${pw_third_party_freertos_PORT}
83    SOURCES
84      ${dir_pw_third_party_freertos}/croutine.c
85      ${dir_pw_third_party_freertos}/event_groups.c
86      ${dir_pw_third_party_freertos}/list.c
87      ${dir_pw_third_party_freertos}/queue.c
88      ${dir_pw_third_party_freertos}/stream_buffer.c
89      ${dir_pw_third_party_freertos}/timers.c
90    PRIVATE_DEPS
91      pw_third_party.freertos.freertos_tasks
92      pw_third_party.freertos.disable_warnings
93  )
94endif()
95
96if(pw_third_party_freertos_DISABLE_TASKS_STATICS)
97  set(disable_tasks_statics "static=" "PW_THIRD_PARTY_FREERTOS_NO_STATICS=1")
98endif()
99pw_add_module_library(pw_third_party.freertos.freertos_tasks
100  SOURCES
101    ${dir_pw_third_party_freertos}/tasks.c
102  PRIVATE_DEPS
103    ${pw_third_party_freertos_CONFIG}
104    ${pw_third_party_freertos_PORT}
105    pw_third_party.freertos.disable_warnings
106  PRIVATE_INCLUDES
107    ${dir_pw_third_party_freertos}/include
108  PRIVATE_DEFINES
109    ${disable_tasks_statics}
110)
111
112# ARM CM7 port of FreeRTOS.
113pw_add_module_library(pw_third_party.freertos.arm_cm7
114  HEADERS
115    ${dir_pw_third_party_freertos}/portable/GCC/ARM_CM7/r0p1/portmacro.h
116  PUBLIC_DEPS
117    ${pw_third_party_freertos_CONFIG}
118  PUBLIC_INCLUDES
119    ${dir_pw_third_party_freertos}/include
120    ${dir_pw_third_party_freertos}/portable/GCC/ARM_CM7/r0p1
121  SOURCES
122    ${dir_pw_third_party_freertos}/portable/GCC/ARM_CM7/r0p1/port.c
123  PRIVATE_DEPS
124    pw_third_party.freertos.disable_warnings
125)
126
127# ARM CM4F port of FreeRTOS.
128pw_add_module_library(pw_third_party.freertos.arm_cm4f
129  HEADERS
130    ${dir_pw_third_party_freertos}/portable/GCC/ARM_CM4F/portmacro.h
131  PUBLIC_DEPS
132    ${pw_third_party_freertos_CONFIG}
133  PUBLIC_INCLUDES
134    ${dir_pw_third_party_freertos}/include
135    ${dir_pw_third_party_freertos}/portable/GCC/ARM_CM4F
136  SOURCES
137    ${dir_pw_third_party_freertos}/portable/GCC/ARM_CM4F/port.c
138  PRIVATE_DEPS
139    pw_third_party.freertos.disable_warnings
140)
141
142# ARM CM33F port of FreeRTOS.
143pw_add_module_library(pw_third_party.freertos.arm_cm33f
144  HEADERS
145    ${dir_pw_third_party_freertos}/portable/GCC/ARM_CM33F/portmacro.h
146  PUBLIC_DEPS
147    ${pw_third_party_freertos_CONFIG}
148  PUBLIC_INCLUDES
149    ${dir_pw_third_party_freertos}/include
150    ${dir_pw_third_party_freertos}/portable/GCC/ARM_CM33F
151  SOURCES
152    ${dir_pw_third_party_freertos}/portable/GCC/ARM_CM33F/port.c
153  PRIVATE_DEPS
154    pw_third_party.freertos.disable_warnings
155)
156
157pw_add_module_library(pw_third_party.freertos.config_assert
158  HEADERS
159    public/pw_third_party/freertos/config_assert.h
160  PUBLIC_INCLUDES
161    public
162  PUBLIC_DEPS
163    pw_assert
164)
165