Skip to content

Commit 807d596

Browse files
anchaoxiaoxiang781216
authored andcommitted
tools/kconfig: add kconfiglib support
Reference: https://github.com/ulfalizer/Kconfiglib Setup: pip install kconfiglib Signed-off-by: chao an <anchao@xiaomi.com>
1 parent aad1a70 commit 807d596

File tree

1 file changed

+39
-9
lines changed

1 file changed

+39
-9
lines changed

tools/Unix.mk

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -605,44 +605,74 @@ pass2dep: context tools/mkdeps$(HOSTEXEEXT) tools/cnvwindeps$(HOSTEXEEXT)
605605
KCONFIG_ENV = APPSDIR=${CONFIG_APPS_DIR} EXTERNALDIR=$(EXTERNALDIR)
606606
KCONFIG_ENV += APPSBINDIR=${CONFIG_APPS_DIR} BINDIR=${TOPDIR}
607607

608+
KCONFIG_LIB = $(shell command -v menuconfig 2> /dev/null)
609+
610+
# Prefer "kconfiglib" if host OS supports it
611+
612+
ifeq ($(KCONFIG_LIB),)
613+
KCONFIG_OLDCONFIG = kconfig-conf --oldconfig Kconfig
614+
KCONFIG_OLDDEFCONFIG = kconfig-conf --olddefconfig Kconfig
615+
KCONFIG_MENUCONFIG = kconfig-mconf Kconfig
616+
KCONFIG_NCONFIG = kconfig-nconf Kconfig
617+
KCONFIG_QCONFIG = kconfig-qconf Kconfig
618+
KCONFIG_GCONFIG = kconfig-gconf Kconfig
619+
KCONFIG_SAVEDEFCONFIG = kconfig-conf Kconfig --savedefconfig
620+
define kconfig_tweak_disable
621+
kconfig-tweak --file $1 -u $2
622+
endef
623+
else
624+
KCONFIG_OLDCONFIG = oldconfig
625+
KCONFIG_OLDDEFCONFIG = olddefconfig
626+
KCONFIG_MENUCONFIG = menuconfig
627+
KCONFIG_NCONFIG = guiconfig
628+
KCONFIG_QCONFIG = ${KCONFIG_NCONFIG}
629+
KCONFIG_GCONFIG = ${KCONFIG_NCONFIG}
630+
KCONFIG_SAVEDEFCONFIG = savedefconfig --out
631+
define kconfig_tweak_disable
632+
sed -i '/$2/d' $1
633+
endef
634+
endif
635+
636+
KCONFIG_CONF = kconfig-conf
637+
608638
config:
609639
$(Q) $(MAKE) clean_context
610640
$(Q) $(MAKE) apps_preconfig
611-
$(Q) ${KCONFIG_ENV} kconfig-conf Kconfig
641+
$(Q) ${KCONFIG_ENV} ${KCONFIG_CONF}
612642

613643
oldconfig:
614644
$(Q) $(MAKE) clean_context
615645
$(Q) $(MAKE) apps_preconfig
616-
$(Q) ${KCONFIG_ENV} kconfig-conf --oldconfig Kconfig
646+
$(Q) ${KCONFIG_ENV} ${KCONFIG_OLDCONFIG}
617647

618648
olddefconfig:
619649
$(Q) $(MAKE) clean_context
620650
$(Q) $(MAKE) apps_preconfig
621-
$(Q) ${KCONFIG_ENV} kconfig-conf --olddefconfig Kconfig
651+
$(Q) ${KCONFIG_ENV} ${KCONFIG_OLDDEFCONFIG}
622652

623653
menuconfig:
624654
$(Q) $(MAKE) clean_context
625655
$(Q) $(MAKE) apps_preconfig
626-
$(Q) ${KCONFIG_ENV} kconfig-mconf Kconfig
656+
$(Q) ${KCONFIG_ENV} ${KCONFIG_MENUCONFIG}
627657

628658
nconfig: apps_preconfig
629659
$(Q) $(MAKE) clean_context
630660
$(Q) $(MAKE) apps_preconfig
631-
$(Q) ${KCONFIG_ENV} kconfig-nconf Kconfig
661+
$(Q) ${KCONFIG_ENV} ${KCONFIG_NCONFIG}
632662

633663
qconfig: apps_preconfig
634664
$(Q) $(MAKE) clean_context
635665
$(Q) $(MAKE) apps_preconfig
636-
$(Q) ${KCONFIG_ENV} kconfig-qconf Kconfig
666+
$(Q) ${KCONFIG_ENV} ${KCONFIG_QCONFIG}
637667

638668
gconfig: apps_preconfig
639669
$(Q) $(MAKE) clean_context
640670
$(Q) $(MAKE) apps_preconfig
641-
$(Q) ${KCONFIG_ENV} kconfig-gconf Kconfig
671+
$(Q) ${KCONFIG_ENV} ${KCONFIG_GCONFIG}
642672

643673
savedefconfig: apps_preconfig
644-
$(Q) ${KCONFIG_ENV} kconfig-conf --savedefconfig defconfig.tmp Kconfig
645-
$(Q) kconfig-tweak --file defconfig.tmp -u CONFIG_APPS_DIR
674+
$(Q) ${KCONFIG_ENV} ${KCONFIG_SAVEDEFCONFIG} defconfig.tmp
675+
$(Q) $(call kconfig_tweak_disable,defconfig.tmp,CONFIG_APPS_DIR)
646676
$(Q) grep "CONFIG_ARCH=" .config >> defconfig.tmp
647677
$(Q) grep "^CONFIG_ARCH_CHIP_" .config >> defconfig.tmp; true
648678
$(Q) grep "CONFIG_ARCH_CHIP=" .config >> defconfig.tmp; true

0 commit comments

Comments
 (0)