https://github.com/bazelembedded/rules_freertos
A set of Bazel build rules for FreeRTOS
https://github.com/bazelembedded/rules_freertos
Last synced: about 1 year ago
JSON representation
A set of Bazel build rules for FreeRTOS
- Host: GitHub
- URL: https://github.com/bazelembedded/rules_freertos
- Owner: bazelembedded
- License: mit
- Created: 2021-12-21T04:55:40.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-21T08:49:29.000Z (over 4 years ago)
- Last Synced: 2025-06-06T17:11:35.290Z (about 1 year ago)
- Language: C
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/silvergasp/rules_freertos/actions/workflows/ci.yml)
# rules_freertos
A set of Bazel build rules for FreeRTOS.
## Getting started
Add the following to your workspace. This will fetch and setup the main
FreeRTOS repository 'com_github_freertos_freertos_kernel`.
``` python
git_repository(
name = "rules_freertos",
remote = "https://github.com/silvergasp/rules_freertos.git",
# Replace commit with latest.
commit = "",
)
load("@rules_freertos//:freertos_deps.bzl", "freertos_deps")
freertos_deps()
```
In the 'com_github_freertos_freertos_kernel' repository there are three targets
of interest.
- `@com_github_freertos_freertos_kernel//:freertos`: The main kernel. This
target depends on the two configurable targets below.
- `@com_github_freertos_freertos_kernel//:port`: An overridable label_flag[^1] for
the 'port' cc_library target. i.e. this should contain your port macro's.
This target defaults to selecting the 'Posix' or 'CM4F' ports based on your
platforms. PR's for a more complete set of defaults welcome!!
- `@com_github_freertos_freertos_kernel//:config`: An overridable label_flag[^1] that references a cc_library exporting a `FreeRTOSConfig.h`.
To configure the FreeRTOS kernel, retarget the `label_flags` using your
`.bazelrc` e.g.
```
# Optionally override the port. Prefer upstreaming the ports and build files if
# possible.
build --@com_github_freertos_freertos_kernel//:port=//my_project:freertos_port
# Optionally (though strongly recommended) override the config.
build --@com_github_freertos_freertos_kernel//:config=//my_project:freertos_config
```
If you have multiple projects in your workspace it may be useful to configure
backends using select statements. e.g.
``` py
# //my_project:BUILD.bazel
# This target acts as a user configurable 'Multiplexer' for the port.
cc_library(
name = "freertos_port",
deps = select({
"@platforms//os:linux": [":my_linux_port"],
"@platforms//cpu:armv7-m": [":my_cortex_m3_port"],
}),
visibility = ["//visibility:public"],
)
# This target acts as a user configurable 'Multiplexer' for the config.
cc_library(
name = "freertos_config",
deps = select({
"@platforms//os:linux": [":my_linux_config"],
"@platforms//cpu:armv7-m": [":my_cortex_m3_config"],
}),
)
cc_library(
name = "my_cortex_m3_config",
hdrs = ["cortex_m3/FreeRTOSConfig.h"],
includes = ["cortex_m3"],
)
# ...
```
[^1]:[User defined build settings](https://docs.bazel.build/versions/main/skylark/config.html#user-defined-build-settings
)