aboutsummaryrefslogtreecommitdiff
path: root/third_party/freertos/BUILD.bazel
blob: 01256d41bb99b62090f0e0f83723deb35f2ff2bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# Copyright 2021 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

load(
    "@pigweed//pw_build:pigweed.bzl",
    "pw_cc_library",
)

package(default_visibility = ["//visibility:public"])

licenses(["notice"])

pw_cc_library(
    name = "config_assert",
    hdrs = [
        "public/pw_third_party/freertos/config_assert.h",
    ],
    includes = ["public"],
    deps = [
        "@pigweed//pw_assert",
    ],
)

constraint_setting(
    name = "port",
)

constraint_value(
    name = "port_ARM_CM7",
    constraint_setting = ":port",
)

constraint_value(
    name = "port_ARM_CM4F",
    constraint_setting = ":port",
)

pw_cc_library(
    name = "freertos",
    srcs = [
        "croutine.c",
        "event_groups.c",
        "list.c",
        "queue.c",
        "stream_buffer.c",
        "timers.c",
    ] + select({
        ":port_ARM_CM4F": ["portable/GCC/ARM_CM4F/port.c"],
        ":port_ARM_CM7": ["portable/GCC/ARM_CM7/r0p1/port.c"],
        "//conditions:default": [],
    }),
    includes = ["include/"] + select({
        ":port_ARM_CM4F": ["portable/GCC/ARM_CM4F"],
        ":port_ARM_CM7": ["portable/GCC/ARM_CM7/r0p1"],
        "//conditions:default": [],
    }),
    textual_hdrs = [
        "include/FreeRTOS.h",
        "include/StackMacros.h",
        "include/croutine.h",
        "include/deprecated_definitions.h",
        "include/event_groups.h",
        "include/list.h",
        "include/message_buffer.h",
        "include/mpu_wrappers.h",
        "include/portable.h",
        "include/projdefs.h",
        "include/queue.h",
        "include/semphr.h",
        "include/stack_macros.h",
        "include/stream_buffer.h",
        "include/task.h",
        "include/timers.h",
    ] + select({
        ":port_ARM_CM4F": ["portable/GCC/ARM_CM4F/portmacro.h"],
        ":port_ARM_CM7": ["portable/GCC/ARM_CM7/r0p1/portmacro.h"],
        "//conditions:default": [],
    }),
    deps = [
        ":pigweed_tasks_c",
        "@pigweed_config//:freertos_config",
    ],
    # Required because breaking out tasks_c results in the dependencies between
    # the libraries not being quite correct: to link pigweed_tasks_c you
    # actually need a bunch of the source files from here (e.g., list.c).
    alwayslink = 1,
)

# Constraint setting used to determine if task statics should be disabled.
constraint_setting(
    name = "disable_tasks_statics_setting",
    default_constraint_value = ":no_disable_task_statics",
)

constraint_value(
    name = "disable_task_statics",
    constraint_setting = ":disable_tasks_statics_setting",
)

constraint_value(
    name = "no_disable_task_statics",
    constraint_setting = ":disable_tasks_statics_setting",
)

pw_cc_library(
    name = "pigweed_tasks_c",
    srcs = ["tasks.c"],
    defines = select({
        ":disable_task_statics": [
            "PW_THIRD_PARTY_FREERTOS_NO_STATICS=1",
        ],
        "//conditions:default": [],
    }),
    includes = [
        "include/",
    ] + select({
        ":port_ARM_CM4F": ["portable/GCC/ARM_CM4F/"],
        ":port_ARM_CM7": ["portable/GCC/ARM_CM7/r0p1/"],
        "//conditions:default": [],
    }),
    local_defines = select({
        ":disable_task_statics": [
            "static=",
        ],
        "//conditions:default": [],
    }),
    # tasks.c transitively includes all these headers :/
    textual_hdrs = [
        "include/FreeRTOS.h",
        "include/portable.h",
        "include/projdefs.h",
        "include/list.h",
        "include/deprecated_definitions.h",
        "include/mpu_wrappers.h",
        "include/stack_macros.h",
        "include/task.h",
        "include/timers.h",
    ] + select({
        ":port_ARM_CM4F": ["portable/GCC/ARM_CM4F/portmacro.h"],
        ":port_ARM_CM7": ["portable/GCC/ARM_CM7/r0p1/portmacro.h"],
        "//conditions:default": [],
    }),
    deps = ["@pigweed_config//:freertos_config"],
)

# Constraint setting used to select the FreeRTOSConfig version.
constraint_setting(
    name = "freertos_config_setting",
)

alias(
    name = "freertos_config",
    actual = select({
        "@pigweed//targets/stm32f429i_disc1_stm32cube:freertos_config_cv": "@pigweed//targets/stm32f429i_disc1_stm32cube:freertos_config",
        "//conditions:default": "default_freertos_config",
    }),
)

pw_cc_library(
    name = "default_freertos_config",
    # The "default" config is not compatible with any configuration: you can't
    # build FreeRTOS without choosing a config.
    target_compatible_with = ["@platforms//:incompatible"],
)

# Exported for
# pw_thread_freertos/py/pw_thread_freertos/generate_freertos_tsktcb.py
exports_files(
    ["tasks.c"],
)