The OpenPRoT Technical Charter can be found at https://github.com/OpenPRoT/.github/blob/main/GOVERNANCE.md
NOTE: We are converting our build system to bazel. We recommend installing bazelisk to automatically manage bazel versions.
You can run tasks using the Pigweed workflow launcher pw or bazel.
./pw presubmit- Run presubmit checks: formatting, license checks, C/C++ header checks andclippy../pw format- Run the code formatters.bazel test //...- Run all tests.bazel build //docs- Build documentation.
The project is structured as a bazel module.
Release firmware is published with signed SLSA build provenance. See docs/src/supply-chain.md for how to verify it.
No additional tools are required to build and test - all dependencies are managed by bazel. The sections below are optional and only describe editor setup.
-
Rust toolchain and rust-analyzer. Builds do not use
rustup, but the editor does. Install rustup. The repository'srust-toolchain.tomlpins the nightly channel and lists therust-analyzer,rust-src,rustfmtandclippycomponents, so rustup installs them automatically the first timerustcorcargoruns in the repository. To install them eagerly (or to add the component to an older checkout), run:rustup show # installs the pinned toolchain + components rustup component add rust-analyzer # only if it is missing
-
Buildifier formats
BUILD.bazel/.bzlfiles. Download a prebuilt binary from the buildtools releases and put it on yourPATH(usebuildifier-linux-arm64on ARM Linux, orbuildifier-darwin-amd64/buildifier-darwin-arm64on macOS):sudo curl -fsSL -o /usr/local/bin/buildifier \ https://github.com/bazelbuild/buildtools/releases/latest/download/buildifier-linux-amd64 sudo chmod +x /usr/local/bin/buildifier buildifier --version
Alternatively,
go install github.com/bazelbuild/buildtools/buildifier@latest../pw formatalso runs buildifier, so the editor tool is only for format-on-save.
- Bazel
(
BazelBuild.vscode-bazel): Starlark syntax, target browsing, and buildifier integration. - rust-analyzer
(
rust-lang.rust-analyzer).
There is no Cargo workspace, so rust-analyzer gets its crate graph from a generated
rust-project.json (git-ignored) at the repository root:
bazel run @rules_rust//tools/rust_analyzer:gen_rust_projectThis covers //..., which is large (hundreds of crates) and can use more than 10 GB of
memory in rust-analyzer, which may get it killed on small machines or WSL. Prefer
generating for only the targets you are working on:
bazel run @rules_rust//tools/rust_analyzer:gen_rust_project -- \
//services/orchestrator/... //drivers/usart/...Crates that only build for an embedded target (those with
target_compatible_with = TARGET_COMPATIBLE_WITH, e.g. everything under
target/ast10x0/) are skipped when generating for the host, so their files get no
highlighting or hover. Pass the target's Bazel config to the generator's inner build
with --config:
bazel run @rules_rust//tools/rust_analyzer:gen_rust_project -- \
--config=virt_ast10x0 //target/ast10x0/peripherals:peripheralsThe same applies to Earl Grey:
bazel run @rules_rust//tools/rust_analyzer:gen_rust_project -- \
--config=k_earlgrey //target/earlgrey/...If a file has no highlighting, hover or go-to-definition, its crate is most likely not
in rust-project.json. Check, in order:
-
Is the target listed? Search
rust-project.jsonfor the crate name or file path. If it is missing, add the target (or a parent package such as//path/to/pkg/...) to thegen_rust_projectcommand. Remember that each run overwrites the file. -
Is it embedded-only? If the target uses
target_compatible_with, it is skipped on the host platform, with no error. Pass the config that selects its platform after the--. The configs are defined in.bazelrc:Directory Config target/ast10x0/--config=virt_ast10x0target/earlgrey/--config=k_earlgreytarget/veer/--config=k_veer -
No config exists for your target? Add one to
.bazelrcnext to the existing ones. It must use thecommon:prefix, not justbuild:, so the setting also reaches the generator's inner build:common:k_mytarget --platforms=//target/mytarget:mytarget build:k_mytarget --build_tag_filters=-do_not_build,-kernel_doc_test -
Reload. After regenerating, run "rust-analyzer: Reload Workspace". Double-check the spelling of the command and config names, since a typo in either fails the run.
Notes:
- Put
--configafter the--. Using--platformsonbazel runitself builds the generator for the embedded target and fails. - Each run overwrites
rust-project.json, so list every target you need in one command. - Regenerate after adding crates or changing dependencies, then run "rust-analyzer: Reload Workspace".
.vscode/settings.json is git-ignored, so each developer keeps their own copy. A
suggested starting point:
{
"rust-analyzer.linkedProjects": ["rust-project.json"],
"rust-analyzer.cachePriming.enable": false,
"rust-analyzer.numThreads": 4,
"rust-analyzer.checkOnSave": false,
"rust-analyzer.files.exclude": ["third_party/**", "bazel-*/**"],
"bazel.buildifier.executable": "/usr/local/bin/buildifier",
"bazel.codeLens.enable": true,
"[starlark]": {
"editor.defaultFormatter": "BazelBuild.vscode-bazel",
"editor.formatOnSave": true
}
}linkedProjectsis required; it points rust-analyzer at the generated file.cachePriming.enable,numThreads,checkOnSaveandfiles.excludelimit rust-analyzer's memory use; relax them if your machine has plenty of RAM.- Set
bazel.buildifierExecutableto the output ofwhich buildifier. checkOnSaveis disabled because the defaultcargo checkdoes not work here. Use./pw presubmit(which runs clippy through Bazel) instead.