This document explains how to use example configuration files to manage the mapping relationship between RT-Thread component configurations and Rust features.
The configuration system allows you to extend the mapping relationship between RT-Thread component configuration items and Rust features through example configuration files, ensuring that only applications that depend on related components will enable corresponding features. Users can add new component configuration mappings as needed. This makes the system more modular and extensible.
The CONFIG_FEATURE_MAP located in tools/feature_config_examples.py defines the basic mapping relationship from RT-Thread component configuration items to Rust features:
CONFIG_FEATURE_MAP = {
'RUST_LOG_COMPONENT': {
'feature': 'enable-log',
'dependencies': ['em_component_log'],
'description': 'Enable Rust logging component integration'
},
}
The system automatically checks the application's Cargo.toml file to ensure that only applications that depend on related components will enable corresponding features.
feature_config_examples.pyCargo.tomlEach configuration item contains the following fields:
feature: The name of the Rust feature to enabledependencies: Optional, list of components that the application must depend ondescription: Optional, description of the configuration itemRUST_LOG_COMPONENT configuration item in RT-Thread's KconfigAdd the corresponding mapping in feature_config_examples.py:
CONFIG_FEATURE_MAP.update({
'RUST_LOG_COMPONENT': {
'feature': 'enable-log',
'dependencies': ['em_component_log'],
'description': 'Enable Rust logging component integration'
},
})
In the Cargo.toml of a Rust application that needs logging functionality:
[features]
enable-log = ["em_component_log/enable-log"]
[dependencies]
em_component_log = { path = "PATH/TO/components/log" }
Cargo.tomlfeature_config_examples.py file exists and has correct syntaxCargo.toml configuration