Crate mnemos_config
source ·Expand description
§MnemOS Configuration
This crate is intended to be used by platform crates in two ways:
§In a build.rs
script
The platform crate should include this library:
[build-dependencies]
config = { path = "../../source/config", features = ["use-std"] }
And ensure your build.rs contains a call to buildtime::render_file
, to
render a single config file:
use mnemos_config::buildtime::render_file;
fn main() {
// to render one config file:
render_file::<YOUR_CONFIG_TYPE>("YOUR_PLATFORM.toml").unwrap();
}
To render all config files in a directory, buildtime::render_all
may be
used instead:
use mnemos_config::buildtime::render_all;
fn main() {
// to render all config files in the `board-configs` directory:
render_all::<YOUR_CONFIG_TYPE>("board-configs").unwrap();
}
§In the main.rs
You’ll need to include this crate again as a normal dependency:
[dependencies]
config = { path = "../../source/config" }
And then you can use this in your main function:
ⓘ
let config = mnemos_config::include_config!(YOUR_CONFIG_TYPE).unwrap();
§Make an external config crate
In order to share data types between your platform crate and the platform
crate’s build.rs, you should make a separate platform-config
crate that
defines the shared data types.
Modules§
- Tools intended for use in build.rs scripts
- Tools intended for use at runtime
Macros§
- Load the configuration created by
render_project
in a build.rs.
Structs§
- The top level configuration type