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