1.新增自动构建脚本。
99
Kconfig
@@ -8,98 +8,105 @@ menu "Device configure"
|
||||
help
|
||||
"Size of dynamic memory for system."
|
||||
|
||||
config MR_CFG_PRINTF_BUFSZ
|
||||
int "Printf buffer size"
|
||||
default 128
|
||||
range 32 2147483647
|
||||
help
|
||||
"Size of the buffer used by the printf function."
|
||||
|
||||
config MR_USING_ASSERT
|
||||
bool "Enable assert"
|
||||
bool "Use assert"
|
||||
default y
|
||||
help
|
||||
"Enabling this option allows the use of assert statements in the code."
|
||||
"Use this option allows the use of assert statements in the code."
|
||||
|
||||
config MR_USING_LOG
|
||||
bool "Use log"
|
||||
default y
|
||||
help
|
||||
"Use this option allows for the use of log."
|
||||
|
||||
menu "Logging configure"
|
||||
depends on MR_USING_LOG
|
||||
config MR_USING_LOG_ERROR
|
||||
bool "Enable error log"
|
||||
bool "Use error log"
|
||||
default y
|
||||
help
|
||||
"Enabling this option allows for the use of error log."
|
||||
"Use this option allows for the use of error log."
|
||||
|
||||
config MR_USING_LOG_WARN
|
||||
bool "Enable warning log"
|
||||
bool "Use warning log"
|
||||
default y
|
||||
help
|
||||
"Enabling this option allows for the use of warning log."
|
||||
"Use this option allows for the use of warning log."
|
||||
|
||||
config MR_USING_LOG_INFO
|
||||
bool "Enable info log"
|
||||
bool "Use info log"
|
||||
default y
|
||||
help
|
||||
"Enabling this option allows for the use of info log."
|
||||
"Use this option allows for the use of info log."
|
||||
|
||||
config MR_USING_LOG_DEBUG
|
||||
bool "Enable debug log"
|
||||
bool "Use debug log"
|
||||
default y
|
||||
help
|
||||
"Enabling this option allows for the use of debug log."
|
||||
"Use this option allows for the use of debug log."
|
||||
endmenu
|
||||
|
||||
config MR_CFG_NAME_MAX
|
||||
int "Max length of device name"
|
||||
int "Name max length"
|
||||
default 8
|
||||
range 4 1024
|
||||
help
|
||||
"Maximum length of name"
|
||||
"Maximum length of device name"
|
||||
|
||||
config MR_CFG_DESC_MAX
|
||||
int "Max number of descriptors"
|
||||
int "Descriptors max number"
|
||||
default 64
|
||||
range 16 1024
|
||||
help
|
||||
"Maximum number of descriptors"
|
||||
|
||||
config MR_USING_RDWR_CTL
|
||||
bool "Enable read/write control"
|
||||
bool "Use read/write control"
|
||||
default y
|
||||
help
|
||||
"Enabling this option allows for read and write control of devices."
|
||||
"Use this option allows for read and write control of devices."
|
||||
|
||||
config MR_USING_CONSOLE
|
||||
bool "Enable console"
|
||||
bool "Use console"
|
||||
default y
|
||||
help
|
||||
"Enabling this option allows for the use of the console device."
|
||||
"Use this option allows for the use of the console device."
|
||||
|
||||
menu "Console configure"
|
||||
depends on MR_USING_CONSOLE
|
||||
|
||||
config MR_CFG_CONSOLE_NAME
|
||||
string "Console device name"
|
||||
string "Console name"
|
||||
default "serial1"
|
||||
help
|
||||
"This option sets the name of the console device."
|
||||
"Name of the console device."
|
||||
|
||||
config MR_USING_CONSOLE_NONBLOCK
|
||||
bool "Console device non-blocking read/write"
|
||||
bool "Use console non-blocking"
|
||||
default n
|
||||
help
|
||||
"Enable or disable non-blocking read/write for the console device."
|
||||
"Use this option allows for the use of the console device in non-blocking mode."
|
||||
endmenu
|
||||
|
||||
config MR_CFG_PRINTF_BUFSZ
|
||||
int "Size of printf buffer"
|
||||
default 128
|
||||
range 32 2147483647
|
||||
help
|
||||
"This option sets the size of the buffer used for printf operations."
|
||||
|
||||
config MR_USING_ADC
|
||||
bool "Enable ADC device"
|
||||
bool "Use ADC device"
|
||||
default n
|
||||
help
|
||||
"Enabling this option allows for the use of ADC (Analog-to-Digital Converter) devices."
|
||||
"Use this option allows for the use of ADC (Analog-to-Digital Converter) devices."
|
||||
|
||||
config MR_USING_CAN
|
||||
bool "Enable CAN device"
|
||||
bool "Use CAN device"
|
||||
default n
|
||||
help
|
||||
"Enabling this option allows for the use of CAN (Controller Area Network) devices."
|
||||
"Use this option allows for the use of CAN (Controller Area Network) devices."
|
||||
|
||||
menu "CAN configure"
|
||||
depends on MR_USING_CAN
|
||||
@@ -113,16 +120,16 @@ menu "Device configure"
|
||||
endmenu
|
||||
|
||||
config MR_USING_DAC
|
||||
bool "Enable DAC device"
|
||||
bool "Use DAC device"
|
||||
default n
|
||||
help
|
||||
"Enabling this option allows for the use of DAC (Digital-to-Analog Converter) devices."
|
||||
"Use this option allows for the use of DAC (Digital-to-Analog Converter) devices."
|
||||
|
||||
config MR_USING_I2C
|
||||
bool "Enable I2C device"
|
||||
bool "Use I2C device"
|
||||
default n
|
||||
help
|
||||
"Enabling this option allows for the use of I2C (Inter-Integrated Circuit) devices."
|
||||
"Use this option allows for the use of I2C (Inter-Integrated Circuit) devices."
|
||||
|
||||
menu "I2C configure"
|
||||
depends on MR_USING_I2C
|
||||
@@ -136,23 +143,23 @@ menu "Device configure"
|
||||
|
||||
config MR_USING_SOFT_I2C
|
||||
depends on MR_USING_PIN
|
||||
bool "Enable soft I2C"
|
||||
bool "Use Soft I2C"
|
||||
default n
|
||||
help
|
||||
"Enabling this option allows for the use of soft I2C."
|
||||
"Use this option allows for the use of soft I2C."
|
||||
endmenu
|
||||
|
||||
config MR_USING_PIN
|
||||
bool "Enable Pin device"
|
||||
bool "Use Pin device"
|
||||
default n
|
||||
help
|
||||
"Enabling this option allows for the use of Pin devices."
|
||||
"Use this option allows for the use of Pin devices."
|
||||
|
||||
config MR_USING_SERIAL
|
||||
bool "Enable Serial device"
|
||||
bool "Use Serial device"
|
||||
default n
|
||||
help
|
||||
"Enabling this option allows for the use of Serial devices."
|
||||
"Use this option allows for the use of Serial devices."
|
||||
|
||||
menu "Serial configure"
|
||||
depends on MR_USING_SERIAL
|
||||
@@ -173,10 +180,10 @@ menu "Device configure"
|
||||
endmenu
|
||||
|
||||
config MR_USING_SPI
|
||||
bool "Enable SPI device"
|
||||
bool "Use SPI device"
|
||||
default n
|
||||
help
|
||||
"Enabling this option allows for the use of SPI (Serial Peripheral Interface) devices."
|
||||
"Use this option allows for the use of SPI (Serial Peripheral Interface) devices."
|
||||
|
||||
menu "SPI configure"
|
||||
depends on MR_USING_SPI
|
||||
@@ -190,10 +197,10 @@ menu "Device configure"
|
||||
endmenu
|
||||
|
||||
config MR_USING_TIMER
|
||||
bool "Enable Timer device"
|
||||
bool "Use Timer device"
|
||||
default n
|
||||
help
|
||||
"Enabling this option allows for the use of Timer devices."
|
||||
"Use this option allows for the use of Timer devices."
|
||||
endmenu
|
||||
|
||||
source "driver/Kconfig"
|
||||
92
README.md
@@ -14,11 +14,9 @@
|
||||
* [目录结构](#目录结构)
|
||||
* [设备/组件支持一览表](#设备组件支持一览表)
|
||||
* [开始使用](#开始使用)
|
||||
* [配置 `Kconfig` 环境](#配置-kconfig-环境)
|
||||
* [将框架导入工程](#将框架导入工程)
|
||||
* [验证Python环境](#验证python环境)
|
||||
* [将项目导入工程](#将项目导入工程)
|
||||
* [配置菜单选项](#配置菜单选项)
|
||||
* [生成配置文件](#生成配置文件)
|
||||
* [添加包含路径](#添加包含路径)
|
||||
* [先来点个灯吧](#先来点个灯吧)
|
||||
* [Hello World](#hello-world)
|
||||
* [现在您已经完成了入门教程,开始使用MR库吧](#现在您已经完成了入门教程开始使用mr库吧)
|
||||
@@ -106,9 +104,9 @@ int main(void)
|
||||
|
||||
`Kconfig` 会根据配置文件自动生成配置选项界面。开发者可以通过简单的操作来选择需要启用的功能组件和设置相关参数。
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
通过修改参数,快速裁剪所需功能。配置完成后通过 `Python` 脚本自动生成配置文件。
|
||||
|
||||
@@ -152,66 +150,33 @@ int main(void)
|
||||
|
||||
# 开始使用
|
||||
|
||||
## 配置 `Kconfig` 环境
|
||||
## 验证Python环境
|
||||
|
||||
注:`Kconfig` 并非必须的,但是推荐使用(安装和配置非常快捷,后续教程也是以应用 `Kconfig` 为例)。
|
||||
验证系统是否安装Python环境。在命令行中运行 `python --version` 检查Python版本(`MR` 脚本工具依赖Python ,若无Python环境请自行安装)。
|
||||
|
||||
1. 验证系统是否安装Python环境。在命令行中运行 `python --version` 检查Python版本(`Kconfig` 依赖于 ` python`,若无 ` python`
|
||||
环境请自行安装)。
|
||||
|
||||
2. 在命令行中使用所示命令安装 `Kconfig`:
|
||||
|
||||
```cmd
|
||||
python -m pip install windows-curses
|
||||
python -m pip install kconfiglib
|
||||
```
|
||||
|
||||
3. 在命令行中运行 `menuconfig -h` 验证安装是否成功。
|
||||
|
||||
## 将框架导入工程
|
||||
## 将项目导入工程
|
||||
|
||||
1. 从 `Gitee` 或 `Github` 仓库下载最新版本源码到本地。
|
||||
2. 将源码导入到您工程所在的目录。以STM32工程为例:
|
||||
2. 将源码复制到您工程所在的目录。以 `MDK` 工程(CubeMX生成的标准工程)为例:
|
||||
|
||||

|
||||

|
||||
|
||||
3. 如使用的芯片已经做了 `BSP` 适配请参考芯片对应 `BSP` 中的配置教程,完成 `BSP` 配置。
|
||||
4. 移除不需要的文件 `bsp`、`document`、`module` 目录(如不需要`GIT`也可以移除`.git`文件删除)。完成后,目录结构如下所示:
|
||||
3. 将 `bsp` 目录中对应芯片的驱动复制到 `driver`:
|
||||
|
||||

|
||||

|
||||
|
||||
5. 将文件加入到IDE中(大部分IDE都能自动识别工程路径下的文件,无需进行此步骤)。以 `keil` 为例:
|
||||
4. 移除不需要的文件 `bsp`、`document`、`module` 目录(如不需要`GIT`也可以移除`.git`文件)。完成后,目录结构如下所示:
|
||||
|
||||

|
||||

|
||||
|
||||
添加 `source`、`device`、`driver` 目录下的所有文件。
|
||||
5. 将文件加入到IDE中(大部分IDE都能自动识别工程路径下的文件,无需进行此步骤)。编译器中添加 `mr-library`
|
||||
的包含路径。配置GNU语法。如果您使用的是非 `GCC` 编译器,请使能GNU语法。
|
||||
|
||||
## 配置菜单选项
|
||||
`MR` 配置脚本支持 `MDK` 工程自动配置。在 `mr-library` 路径下,打开命令行工具,运行 `python build.py -mdk` 自动完成配置(完成后跳过剩余步骤至 `配置菜单选项`)。
|
||||
|
||||
1. 在 `mr-library` 目录下打开命令行工具,运行 `menuconfig` 进行菜单配置。
|
||||

|
||||
|
||||

|
||||
|
||||
注:当添加对应芯片驱动的后,将显示 `Device configure` 和 `Driver configure`。对应 `Driver configure` 请参考 `BSP` 下教程。
|
||||
|
||||
2. 选中 `Device configure` 回车进入菜单,按照需要配置功能。
|
||||
|
||||

|
||||
|
||||
3. 配置完成后,按 `Q` 退出菜单配置界面,按`Y` 保存配置。
|
||||
|
||||
## 生成配置文件
|
||||
|
||||
1. 在 `mr-library` 目录下打开命令行工具,运行 `python kconfig.py`,自动生成配置文件 `mr_config.h`。
|
||||
|
||||
## 添加包含路径
|
||||
|
||||
1. 在编译器中添加 `mr-library` 的包含路径,以 `keil` 为例:
|
||||
|
||||

|
||||
|
||||
2. 配置自动初始化(GCC环境),查找您工程下以 `.ld` 为后缀的连接脚本文件(通常为 `link.ld`),在脚本文件中添加代码:
|
||||
注:如果您的是在 `keil` 等,能够自动生成链接脚本的环境下,请跳过此步骤。
|
||||
6. 配置自动初始化(GCC环境),查找您工程下以 `.ld` 为后缀的连接脚本文件(通常为 `link.ld`),在脚本文件中添加代码(如使用 `MDK` 等能自动生成链接脚本的环境,请跳过此步骤):
|
||||
|
||||
```c
|
||||
/* mr-library auto init */
|
||||
@@ -221,22 +186,25 @@ int main(void)
|
||||
_mr_auto_init_end = .;
|
||||
```
|
||||
|
||||
示例:
|
||||

|
||||
|
||||

|
||||
## 配置菜单选项
|
||||
|
||||
3. 配置GNU语法。如果您使用的是非 `GCC` 编译器,请使能GNU语法。以 `keil` 为例:
|
||||
1. 在 `mr-library` 目录下打开命令行工具,运行 `python build.py -m` 进行菜单配置。
|
||||
|
||||
AC5:
|
||||

|
||||
|
||||

|
||||
注:当添加对应芯片驱动的后,将显示 `Device configure` 和 `Driver configure`。对应 `Driver configure` 请参考 `bsp` 下文档。
|
||||
|
||||
AC6:
|
||||
2. 选中 `Device configure` 回车进入菜单,按照需要配置功能。
|
||||
|
||||

|
||||

|
||||
|
||||
4. 在您的工程中引入 `#include "include/mr_lib.h"`。
|
||||
5. 在 `main` 函数中添加 `mr_auto_init();` 自动初始化函数。
|
||||
3. 配置完成后,按 `Q` 退出菜单配置界面,按`Y` 保存配置,脚本将自动生成配置文件。
|
||||
|
||||

|
||||
|
||||
4. 工程中引入 `#include "include/mr_lib.h"` 并在 `main` 函数中添加 `mr_auto_init();` 自动初始化函数,即可开始使用。
|
||||
|
||||
----------
|
||||
|
||||
|
||||
116
README_EN.md
@@ -14,12 +14,10 @@
|
||||
* [Directory structure](#directory-structure)
|
||||
* [Device/Component Support Overview](#devicecomponent-support-overview)
|
||||
* [Get Started](#get-started)
|
||||
* [Configure the Kconfig Environment](#configure-the-kconfig-environment)
|
||||
* [Import the Framework into the Project](#import-the-framework-into-the-project)
|
||||
* [Verifying Python environment](#verifying-python-environment)
|
||||
* [Import the project into the workspace](#import-the-project-into-the-workspace)
|
||||
* [Configure Menu Options](#configure-menu-options)
|
||||
* [Generate Configuration File](#generate-configuration-file)
|
||||
* [Add Include Paths](#add-include-paths)
|
||||
* [Let's Light an LED](#lets-light-an-led)
|
||||
* [Let`s Light an LED](#lets-light-an-led)
|
||||
* [Hello World](#hello-world)
|
||||
* [Now that you have completed the introductory tutorial, start using the MR Library.](#now-that-you-have-completed-the-introductory-tutorial-start-using-the-mr-library)
|
||||
<!-- TOC -->
|
||||
@@ -115,9 +113,9 @@ code.
|
||||
`Kconfig` will automatically generate the configuration options interface based on the configuration file. Developers
|
||||
can select the functional components that need to be enabled and set relevant parameters through simple operations.
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
By modifying parameters, you can quickly tailor the required functions. After the configuration is complete,
|
||||
the `Python` script automatically generates the configuration file.
|
||||
@@ -162,74 +160,41 @@ the `Python` script automatically generates the configuration file.
|
||||
|
||||
# Get Started
|
||||
|
||||
## Configure the Kconfig Environment
|
||||
## Verifying Python environment
|
||||
|
||||
Note: Kconfig is not mandatory, but recommended (installation and configuration are very quick, and the following
|
||||
tutorials are based on applying Kconfig).
|
||||
Verify that the Python environment is installed. Run `python --version` on the command line to check the Python
|
||||
version (the `MR` scripting tool relies on Python, install it yourself if there is no Python environment).
|
||||
|
||||
1. Verify that the system has a Python environment installed. Run `python --version` in the command line to check the
|
||||
Python version (Kconfig depends on python, please install python if it is not available).
|
||||
## Import the project into the workspace
|
||||
|
||||
2. Use the following commands to install Kconfig in the command line:
|
||||
1. Download the latest version source code from the `Gitee` or `GitHub` repository to the local.
|
||||
2. Copy the source code to the directory where your project is located. Take the `MDK` project (CubeMX-generated
|
||||
standard project) as an example:
|
||||
|
||||
```cmd
|
||||
python -m pip install windows-curses
|
||||
python -m pip install kconfiglib
|
||||
```
|
||||

|
||||
|
||||
3. Run `menuconfig -h` in the command line to verify successful installation.
|
||||
3. Copy the driver of the corresponding chip in the `bsp` directory to `driver`:
|
||||
|
||||
## Import the Framework into the Project
|
||||

|
||||
|
||||
1. Download the latest version source code from the Gitee or Github repository to the local.
|
||||
2. Import the source code into the directory where your project is located. Taking an STM32 project as an example:
|
||||
4. Remove unnecessary files` bsp `, `document`, `module` directories (you can also remove `.git `files if you don`t
|
||||
need` git `). When complete, the directory structure looks like this:
|
||||
|
||||

|
||||
|
||||
3. If the used chip has BSP adaptation, please refer to the chip's corresponding BSP configuration tutorial to complete
|
||||
the BSP configuration.
|
||||
4. Remove unnecessary files such as `bsp`、`document`、`module` directories (you can also remove the `.git` file to delete
|
||||
GIT if not needed). The directory structure is shown below after completion:
|
||||
|
||||

|
||||

|
||||
|
||||
5. Add the files to the IDE (most ides automatically recognize the files in the project path, eliminating the need for
|
||||
this step). Take `keil` for example:
|
||||
this step). Add `mr-library` to the compiler
|
||||
Contains the path. Configure the GNU syntax. If you are using a non-gcc compiler, enable GNU syntax.
|
||||
|
||||

|
||||
The `MR` configuration script supports the `MDK` project automatic configuration. In the `mr-library` path, open the
|
||||
command line tool and run `python build.py -mdk` to complete the configuration automatically (when done, skip the
|
||||
remaining steps to `Configuration menu options`).
|
||||
|
||||
Add all files in the `source`, `device`, `driver` directories.
|
||||

|
||||
|
||||
## Configure Menu Options
|
||||
|
||||
1. Open the command line tool in the `mr-library` directory and run `menuconfig` to configure the menu.
|
||||
|
||||

|
||||
|
||||
Note: When the corresponding chip driver is added, `Device configure` and `Driver configure` will be displayed.
|
||||
Please refer to the tutorial under `BSP` for `Driver configure`.
|
||||
|
||||
2. Enter the menu by pressing the Enter key on `Device configure`, and configure the desired functions according to
|
||||
needs.
|
||||
|
||||

|
||||
|
||||
3. After configuration is complete, press `Q` to exit the menu configuration interface, press `Y` to save the
|
||||
configuration.
|
||||
|
||||
## Generate Configuration File
|
||||
|
||||
1. Run `python kconfig.py` in the command line tool under `mr-library` directory to automatically generate the
|
||||
configuration file `mr_config.h`.
|
||||
|
||||
## Add Include Paths
|
||||
|
||||
1. Add the include paths of `mr-library` in the compiler, taking `keil` as an example:
|
||||
|
||||

|
||||
|
||||
2. Configure automatic initialization (GCC environment), find the link script file with suffix `.ld` in your project
|
||||
directory (usually `link.ld`), and add the following code to the script file:
|
||||
6. Configure automatic initialization (GCC environment), find the connection script file with suffix `.ld `under your
|
||||
project (usually` link.ld `), and add code to the script file (such as using the environment that can automatically
|
||||
generate link scripts such as` MDK `, please skip this step) :
|
||||
|
||||
```c
|
||||
/* mr-library auto init */
|
||||
@@ -239,26 +204,33 @@ tutorials are based on applying Kconfig).
|
||||
_mr_auto_init_end = .;
|
||||
```
|
||||
|
||||
Example:
|
||||

|
||||
|
||||

|
||||
## Configure Menu Options
|
||||
|
||||
3. Configure the GNU syntax. If you are using a non-gcc compiler, enable GNU syntax. Take `keil` for example:
|
||||
1. Open the command line tool in the `mr-library` directory and run `python build.py -m` for menu configuration.
|
||||
|
||||
AC5:
|
||||

|
||||
|
||||

|
||||
Note: When the corresponding chip driver is added, `Device configure` and `Driver configure` will be displayed.
|
||||
For `Driver configure` please refer to the documentation under `bsp`.
|
||||
|
||||
AC6:
|
||||
2. Enter the menu by pressing the Enter key on `Device configure`, and configure the desired functions according to
|
||||
needs.
|
||||
|
||||

|
||||

|
||||
|
||||
4. Include `#include "include/mr_lib.h"` in your project.
|
||||
5. Add the automatic initialization function `mr_auto_init();` in the main function.
|
||||
3. After configuration is complete, press `Q` to exit the menu configuration interface, press `Y` to save the
|
||||
configuration.
|
||||
|
||||

|
||||
|
||||
4. In the project, introduce `#include` include/mr_lib.h `and add` mr_auto_init() `to` main `function; `
|
||||
Automatically initialize the function and start using it.
|
||||
|
||||
----------
|
||||
|
||||
# Let's Light an LED
|
||||
# Let`s Light an LED
|
||||
|
||||
```c
|
||||
#include "include/mr_lib.h"
|
||||
|
||||
|
Before Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 129 KiB |
|
Before Width: | Height: | Size: 111 KiB |
|
Before Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 62 KiB |
BIN
document/picture/readme/build_m.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
document/picture/readme/build_mdk.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
BIN
document/picture/readme/driver.png
Normal file
|
After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
BIN
document/picture/readme/kconfig_main2.png
Normal file
|
After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
BIN
document/picture/readme/project.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
28
kconfig.py
@@ -1,14 +1,25 @@
|
||||
import argparse
|
||||
import os
|
||||
#!/usr/bin/env python
|
||||
|
||||
import re
|
||||
import sys
|
||||
import textwrap
|
||||
import pip
|
||||
|
||||
from kconfiglib import Kconfig, split_expr, expr_value, expr_str, BOOL, \
|
||||
TRISTATE, TRI_TO_STR, AND, OR
|
||||
|
||||
def generate_config(kconfig_file,config_in, config_out, header_out):
|
||||
def install_package(package):
|
||||
pip.main(['install', package])
|
||||
|
||||
|
||||
try:
|
||||
from kconfiglib import Kconfig
|
||||
except ImportError:
|
||||
install_package('kconfiglib')
|
||||
|
||||
try:
|
||||
import curses
|
||||
except ImportError:
|
||||
install_package('windows-curses')
|
||||
|
||||
|
||||
def generate_config(kconfig_file, config_in, config_out, header_out):
|
||||
print("Parsing " + kconfig_file)
|
||||
kconf = Kconfig(kconfig_file, warn_to_stderr=False,
|
||||
suppress_traceback=True)
|
||||
@@ -23,7 +34,6 @@ def generate_config(kconfig_file,config_in, config_out, header_out):
|
||||
print(kconf.write_autoconf(header_out))
|
||||
|
||||
with open(header_out, 'r+') as header_file:
|
||||
|
||||
content = header_file.read()
|
||||
header_file.truncate(0)
|
||||
header_file.seek(0)
|
||||
@@ -49,6 +59,7 @@ def generate_config(kconfig_file,config_in, config_out, header_out):
|
||||
header_file.write("#endif /* __cplusplus */\n\n")
|
||||
header_file.write("#endif /* _MR_CONFIG_H_ */\n")
|
||||
|
||||
|
||||
def main():
|
||||
kconfig_file = 'Kconfig'
|
||||
config_in = '.config'
|
||||
@@ -56,5 +67,6 @@ def main():
|
||||
header_out = 'include/mr_config.h'
|
||||
generate_config(kconfig_file, config_in, config_out, header_out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||