ove/config.rs
1// Copyright (C) 2026 Kamil Lulko <kamil.lulko@gmail.com>
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4//
5// This file is part of oveRTOS.
6
7//! Build-time configuration exposed as Rust `const`s and `cfg` flags.
8//!
9//! Every `CONFIG_OVE_*` symbol defined in `ove_config.h` lands here:
10//!
11//! - **Boolean symbols** (`CONFIG_OVE_FOO=y`) — appear as
12//! `pub const CONFIG_OVE_FOO: bool = true;` *and* a per-symbol cfg
13//! gate `config_ove_foo` is emitted by `build.rs`. You can write
14//! `#[cfg(config_ove_foo)]` to gate code on this symbol from the
15//! call site.
16//! - **Integer symbols** (`CONFIG_OVE_PM_MAX_WAKE_SOURCES=8`) — appear
17//! as `pub const CONFIG_OVE_PM_MAX_WAKE_SOURCES: i64 = 8;` plus a
18//! matching `_USIZE` const (only when non-negative) for use as an
19//! array size or const-generic parameter.
20//! - **String symbols** (`CONFIG_OVE_APP_NAME="my-app"`) — appear as
21//! `pub const CONFIG_OVE_APP_NAME: &str = "my-app";`.
22//!
23//! Symbols that aren't set (`# CONFIG_OVE_FOO is not set`) are
24//! absent — use `#[cfg(not(config_ove_foo))]` to detect them.
25//!
26//! ## Example
27//!
28//! ```ignore
29//! const SLOTS: usize = ove::config::CONFIG_OVE_PM_MAX_WAKE_SOURCES_USIZE;
30//! let mut wakers: [Option<Waker>; SLOTS] = [const { None }; SLOTS];
31//!
32//! #[cfg(config_ove_async)]
33//! fn ensure_async_runtime() { /* ... */ }
34//! ```
35//!
36//! Mirrors zephyr-lang-rust's `zephyr::kconfig::CONFIG_*` pattern; the
37//! oveRTOS `has_<module>` / `rtos_<backend>` / `board_<name>` cfg
38//! flags continue to coexist as their own facets.
39
40// `OVE_CONFIG_CONSTS` is set by `build.rs` and points at a generated
41// file in `OUT_DIR`. The file consists of `pub const CONFIG_OVE_*: …`
42// lines — see `build.rs`'s G3 block.
43include!(env!("OVE_CONFIG_CONSTS"));