这个文档说明如何使用示例配置文件来管理 RT-Thread 组件配置与 Rust features 之间的映射关系。
配置系统允许你通过示例配置文件来扩展 RT-Thread 组件配置项与 Rust features 的映射关系,并确保只有依赖了相关组件的应用才会启用对应的 features,用户可以根据需要添加新的组件配置映射。这使得系统更加模块化和可扩展。
位于 tools/feature_config_examples.py 中的 CONFIG_FEATURE_MAP 定义了 RT-Thread 组件配置项到 Rust features 的基础映射关系:
CONFIG_FEATURE_MAP = {
'RUST_LOG_COMPONENT': {
'feature': 'enable-log',
'dependencies': ['em_component_log'],
'description': 'Enable Rust logging component integration'
},
}
系统会自动检查应用程序的 Cargo.toml 文件,确保只有依赖了相关组件的应用才会启用对应的 features。
feature_config_examples.py 中的示例配置Cargo.toml 中添加了相关组件的依赖每个配置项包含以下字段:
feature: 要启用的 Rust feature 名称dependencies: 可选,应用程序必须依赖的组件列表description: 可选,配置项的描述RUST_LOG_COMPONENT 配置项在 feature_config_examples.py 中添加对应的映射:
CONFIG_FEATURE_MAP.update({
'RUST_LOG_COMPONENT': {
'feature': 'enable-log',
'dependencies': ['em_component_log'],
'description': 'Enable Rust logging component integration'
},
})
在需要日志功能的 Rust 应用的 Cargo.toml 中:
[features]
enable-log = ["em_component_log/enable-log"]
[dependencies]
em_component_log = { path = "PATH/TO/components/log" }
Cargo.toml 中定义了相应的 featuresfeature_config_examples.py 文件是否存在且语法正确Cargo.toml 配置