summaryrefslogtreecommitdiff
path: root/components/rust/docs/1.tools
diff options
context:
space:
mode:
authorzhang san <[email protected]>2025-12-08 18:34:25 +0800
committerGitHub <[email protected]>2025-12-08 18:34:25 +0800
commit69980f8b9d29b38dbd4ddf6373b4b45f3a138409 (patch)
tree21dd9a8ce80e3d30192e9ffa56ea39a199bae309 /components/rust/docs/1.tools
parentcd1d47b87c5d47e131730e5506eb3ad77d357653 (diff)
Adding Rust Language Support for RT-Thread #10910
Diffstat (limited to 'components/rust/docs/1.tools')
-rw-r--r--components/rust/docs/1.tools/tools.md86
-rw-r--r--components/rust/docs/1.tools/tools_cn.md87
2 files changed, 173 insertions, 0 deletions
diff --git a/components/rust/docs/1.tools/tools.md b/components/rust/docs/1.tools/tools.md
new file mode 100644
index 0000000000..8e015ef445
--- /dev/null
+++ b/components/rust/docs/1.tools/tools.md
@@ -0,0 +1,86 @@
+# RT-Thread to Rust Feature Configuration System
+
+This document explains how to use example configuration files to manage the mapping relationship between RT-Thread component configurations and Rust features.
+
+## Overview
+
+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.
+
+## Core Components
+
+### 1. Configuration Mapping Table (CONFIG_FEATURE_MAP)
+
+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:
+
+```python
+CONFIG_FEATURE_MAP = {
+ 'RUST_LOG_COMPONENT': {
+ 'feature': 'enable-log',
+ 'dependencies': ['em_component_log'],
+ 'description': 'Enable Rust logging component integration'
+ },
+}
+```
+
+### 2. Dependency Check Mechanism
+
+The system automatically checks the application's `Cargo.toml` file to ensure that only applications that depend on related components will enable corresponding features.
+
+## How to Add New Components
+
+### Using Example Configuration Files
+
+1. View the example configurations in `feature_config_examples.py`
+2. Modify the example configuration file as needed, adding the component configuration mappings you require
+3. The system will automatically load the mappings from the example configuration file
+4. Ensure that related component dependencies are added to the application's `Cargo.toml`
+
+## Configuration Item Format
+
+Each configuration item contains the following fields:
+
+- `feature`: The name of the Rust feature to enable
+- `dependencies`: Optional, list of components that the application must depend on
+- `description`: Optional, description of the configuration item
+
+## Example Scenario
+
+1. Add the `RUST_LOG_COMPONENT` configuration item in RT-Thread's Kconfig
+2. Add the corresponding mapping in `feature_config_examples.py`:
+
+```python
+CONFIG_FEATURE_MAP.update({
+ 'RUST_LOG_COMPONENT': {
+ 'feature': 'enable-log',
+ 'dependencies': ['em_component_log'],
+ 'description': 'Enable Rust logging component integration'
+ },
+})
+```
+
+3. In the `Cargo.toml` of a Rust application that needs logging functionality:
+
+```toml
+[features]
+enable-log = ["em_component_log/enable-log"]
+
+[dependencies]
+em_component_log = { path = "PATH/TO/components/log" }
+```
+
+## Troubleshooting
+
+### Common Issues
+
+1. **Feature not enabled**: Check if the application depends on the related components
+2. **Build failure**: Ensure that the corresponding features are defined in the application's `Cargo.toml`
+3. **Configuration not taking effect**: Verify that the RT-Thread configuration item is correctly enabled
+4. **Example configuration not loaded**: Check if the `feature_config_examples.py` file exists and has correct syntax
+
+### Debugging Steps
+
+1. Check the configuration loading information in the build logs
+2. Verify the syntax of the example configuration file
+3. Check the feature enabling information in the build logs
+4. Verify the application's `Cargo.toml` configuration
+5. Confirm the RT-Thread configuration item status \ No newline at end of file
diff --git a/components/rust/docs/1.tools/tools_cn.md b/components/rust/docs/1.tools/tools_cn.md
new file mode 100644
index 0000000000..9ca28c2d87
--- /dev/null
+++ b/components/rust/docs/1.tools/tools_cn.md
@@ -0,0 +1,87 @@
+# RT-Thread to Rust Feature Configuration System
+
+这个文档说明如何使用示例配置文件来管理 RT-Thread 组件配置与 Rust features 之间的映射关系。
+
+## 概述
+
+配置系统允许你通过示例配置文件来扩展 RT-Thread 组件配置项与 Rust features 的映射关系,并确保只有依赖了相关组件的应用才会启用对应的 features,用户可以根据需要添加新的组件配置映射。这使得系统更加模块化和可扩展。
+
+## 核心组件
+
+
+### 1. 配置映射表 (CONFIG_FEATURE_MAP)
+
+位于 `tools/feature_config_examples.py` 中的 `CONFIG_FEATURE_MAP` 定义了 RT-Thread 组件配置项到 Rust features 的基础映射关系:
+
+```python
+CONFIG_FEATURE_MAP = {
+ 'RUST_LOG_COMPONENT': {
+ 'feature': 'enable-log',
+ 'dependencies': ['em_component_log'],
+ 'description': 'Enable Rust logging component integration'
+ },
+}
+```
+
+### 2. 依赖检查机制
+
+系统会自动检查应用程序的 `Cargo.toml` 文件,确保只有依赖了相关组件的应用才会启用对应的 features。
+
+## 如何添加新的组件
+
+### 使用示例配置文件
+
+1. 查看 `feature_config_examples.py` 中的示例配置
+2. 根据需要修改示例配置文件,添加你需要的组件配置映射
+3. 系统会自动加载示例配置文件中的映射
+4. 确保在应用程序的 `Cargo.toml` 中添加了相关组件的依赖
+
+## 配置项格式
+
+每个配置项包含以下字段:
+
+- `feature`: 要启用的 Rust feature 名称
+- `dependencies`: 可选,应用程序必须依赖的组件列表
+- `description`: 可选,配置项的描述
+
+## 示例场景
+
+1. 在 RT-Thread 的 Kconfig 中添加 `RUST_LOG_COMPONENT` 配置项
+2. 在 `feature_config_examples.py` 中添加对应的映射:
+
+```python
+CONFIG_FEATURE_MAP.update({
+ 'RUST_LOG_COMPONENT': {
+ 'feature': 'enable-log',
+ 'dependencies': ['em_component_log'],
+ 'description': 'Enable Rust logging component integration'
+ },
+})
+```
+
+3. 在需要日志功能的 Rust 应用的 `Cargo.toml` 中:
+
+```toml
+[features]
+enable-log = ["em_component_log/enable-log"]
+
+[dependencies]
+em_component_log = { path = "PATH/TO/components/log" }
+```
+
+## 故障排除
+
+### 常见问题
+
+1. **Feature 未启用**: 检查应用是否依赖了相关组件
+2. **构建失败**: 确保应用的 `Cargo.toml` 中定义了相应的 features
+3. **配置不生效**: 验证 RT-Thread 配置项是否正确启用
+4. **示例配置未加载**: 检查 `feature_config_examples.py` 文件是否存在且语法正确
+
+### 调试步骤
+
+1. 检查构建日志中的配置加载信息
+2. 验证示例配置文件的语法
+3. 检查构建日志中的 feature 启用信息
+4. 验证应用的 `Cargo.toml` 配置
+5. 确认 RT-Thread 配置项状态 \ No newline at end of file