配置管理工具之kconfig

Foreword

绕了这么大一圈,似乎只有kconfig是比较成熟的,能与之相媲美的管理工具很少

Kconfig

安装

在windows下使用Kconfig,至少得有python,否则界面等内容无法正常显示

python需要先安装这几个包

python -m pip install windows-curses
python -m pip install kconfiglib

测试安装,可以正常显示命令

menuconfig -h

测试

参考工程sample_1

https://github.com/bobwenstudy/test_kconfig_system

编译所有

make all

修改配置

menuconfig

运行main.exe就能看到结果了

hello, world
CONFIG_TEST_ENABLE
CONFIG_TEST_SHOW_STRING: Test 123
CONFIG_TEST_SHOW_INT: 123
CONFIG_TEST_SUB_0_ENABLE
CONFIG_TEST_SHOW_SUB_INT: 123

可能会报错,这个是因为curses库他需要终端执行,但是不识别你当前使用的终端,换一个就行了,比如cmd

make 提示Redirection is not supported.

这个例子里还只有一种config,还不能支持多config配置,可以看到主要就只能生成一个autoconfig.h

all: main.o
	gcc main.o -o main
main.o: main.c autoconfig.h
	gcc main.c -c -o main.o
clean:
	del main.o main.exe

autoconfig.h:.config
	python ../scripts/kconfig.py Kconfig .config autoconfig.h log.txt .config
.config:
	menuconfig
menuconfig:
	menuconfig

多config

# 默认编译test1
APP ?= app/test1
OUTPUT_PATH := output

INCLUDE_PATH := -I$(APP) -Idriver -I$(OUTPUT_PATH)

# 主要用户定义的配置是在每个app下的,这里也可以单独提取一个对应的版本目录来做
# define user .config setting
USER_CONFIG_SET := 
USER_CONFIG_SET += $(APP)/prj.conf

# define menuconfig .config path
DOTCONFIG_PATH := $(OUTPUT_PATH)/.config

# 用户文件追踪
# define user merged path
USER_RECORD_CONFIG_PATH := $(OUTPUT_PATH)/user_record.conf

# define autoconfig.h path
AUTOCONFIG_H := $(OUTPUT_PATH)/autoconfig.h

#define Kconfig path
KCONFIG_ROOT_PATH := Kconfig


#For windows work.
FIXPATH = $(subst /,\,$1)


all: $(APP)/main.o driver/driver_test.o
	gcc $^ -o $(OUTPUT_PATH)/main.exe
$(APP)/main.o: $(APP)/main.c
	gcc $< $(INCLUDE_PATH) -c -o
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值