kconfig: re-sync with Linux 4.17-rc4
Align Kconfig to Linux 4.17-rc4 with minimal impact on non-kconfig files. Previous Kconfig sync was done by commitbf7ab1e70f
("kconfig: re-sync with Linux 4.10") and it achieved almost perfect alignment with a few (intended) exceptions, caused by below U-boot commits: [A] v2015.045f9eb22075
("kbuild: remove scripts/multiconfig.sh") [B] v2015.0720c20826ef
("Kconfig: Enable usage of escape char '\' in string values") [C] v2016.01da58dec866
("Various Makefiles: Add SPDX-License-Identifier tags") [D] v2016.035b8031ccb4
("Add more SPDX-License-Identifier tags") [E] v2016.03192bc6948b
("Fix GCC format-security errors and convert sprintfs.") Here is the list of Kconfig commits which followed the v4.10 alignment: [F] v2018.010931ed3c0d
("kconfig/symbol.c: use correct pointer type argument for sizeof") [G] v2018.031414e09b4f
("kconfig: revert change that was not needed for -Wformat-security") [H] v2018.0583d290c56f
("SPDX: Convert all of our single license tags to Linux Kernel style") Commit [F] was subsequently applied to Linux kernel as commit [I] with the same patch id, so it won't contribute to further misalignment. [I] v4.15-rc1 88127dae6ed9 ("kconfig/symbol.c: use correct pointer type argument for sizeof") Commit [G] is a Kconfig-specific revert of commit [E]. Commit [H] relocated and reformatted the license doing no functional change. In summary, the only functional change that makes U-boot Kconfig diverge from Linux Kconfig is commit [B]. After a brief analysis, the purpose of [B] seems to be placing "\n" literals in string symbols like CONFIG_AUTOBOOT_PROMPT="autoboot in %d seconds\n" in order to pass them directly to printf and expect correct output at runtime. Currently, Linux doesn't seem to have this requirement, so for the moment [B] looks like a U-boot specific feature/fix. From point of view of further Kconfig alignment and backporting efforts, it is highly desired that commits like [B] are propagated to Linux and any Kconfig fixes/features are contributed to Linux kernel first. This specific Kconfig re-sync just keeps [B] in place. Contrary to 4.10 Kconfig re-sync (which achieves zero non-kconfig changes), 4.17-rc4 re-sync does some amount of updates in Kbuild (striving to keep them at minimum), due to a number of reasons: * Kbuild is affected by the removal of Kconfig "*shipped" files and now requires flex and bison pre-installed on the host. * PYTHON{2,3} variables are defined in top-level Makefile as prerequisite for running the newly developed Kconfig unit tests. * silentoldconfig becomes an "internal implementation detail" deprecated for external use, being renamed to syncconfig. The exact non-kconfig files touched by this commit are: $ git show --format="" --stat -- ':!scripts/kconfig' .gitignore | 2 ++ Makefile | 9 +++++++-- scripts/Makefile.build | 11 +++++++++++ scripts/Makefile.lib | 41 ++++++++++++----------------------------- The imported Linux commits touching the above files are: c054be10ffdbd5 ("remove gperf left-overs from build system") 73a4f6dbe70a1b ("kbuild: add LEX and YACC variables") 033dba2ec06c47 ("kbuild: prepare to remove C files pre-generated by flex and bison") eea199b445f64c ("kbuild: remove unnecessary LEX_PREFIX and YACC_PREFIX") e71de5ee08dcb0 ("kbuild: remove remaining use of undefined YACC_PREFIX") d59fbbd09d5d6b ("kbuild: replace hardcoded bison in cmd_bison_h with $(YACC)") 911a91c39cabcb H ("kconfig: rename silentoldconfig to syncconfig") 59889300274569 (".gitignore: move *.lex.c *.tab.[ch] patterns to the top-level .gitignore") 9a8dfb394c0467 ("kbuild: clean up *.lex.c and *.tab.[ch] patterns from top-level Makefile") 833e622459432e H ("genksyms: generate lexer and parser during build instead of shipping") b23d1a241f4eb4 H ("kbuild: add %.lex.c and %.tab.[ch] to 'targets' automatically") e9781b52d4e0e3 H ("kbuild: add PYTHON2 and PYTHON3 variables") The commits marked with 'H' are assessed as "hard" (build will fail) prerequisites and the rest of them are assessed as "soft" prerequisites for the re-sync. In spite of relatively high number of non-H commits, they belong to this Kconfig update topic-wise and decrease the number of cherry pick conflicts for many commits in this series. Additional effort can be put in eliminating the soft prerequisites, if really needed. The commits which contributed to this Kconfig re-sync are listed below. Whenever a conflict resolution has been performed (mostly by hand, but sometimes automatically by git), it is revealed by the '!' sign in the second column, which means a patch id mismatch between Linux and U-boot commits: 9be3213b14d44f ("gconfig: remove misleading parentheses around a condition") ff85a1a80e0034 ("kconfig: Check for libncurses before menuconfig") ad8181060788c8 ("kconfig: fix sparse warnings in nconfig") cb77f0d623ff33 ! ("scripts: Switch to more portable Perl shebang") bb3290d91695bb ! ("Remove gperf usage from toolchain") c054be10ffdbd5 ("remove gperf left-overs from build system") b24413180f5600 ! ("License cleanup: add SPDX GPL-2.0 license identifier to files with no license") 9059a3493efea6 ! ("kconfig: fix relational operators for bool and tristate symbols") 2c37e08464a850 ("kconfig: Warn if choice default is not in choice") 33ca1a24866373 ("kconfig: Document the 'menu' struct") 52aede4ba5efd1 ("kconfig: Document the 'symbol' struct") c873443430ebd1 ("kconfig: Sync zconf.y with zconf.tab.c_shipped") 9a826842ff2fbd ("kconfig: Rename menu_check_dep() to rewrite_m()") fa8cedaef814ce ("kconfig: Clarify expression rewriting") f77850d3fe0c96 ("kconfig: Clean up modules handling and fix crash") e3b03bf29d6b99 ("kconfig: display recursive dependency resolution hint just once") 73a4f6dbe70a1b ! ("kbuild: add LEX and YACC variables") 033dba2ec06c47 ! ("kbuild: prepare to remove C files pre-generated by flex and bison") 29c833061c1d8c ("kconfig: generate lexer and parser during build instead of shipping") 26e47a3c11a25c ("kconfig: Don't leak symbol names during parsing") 24161a6711c945 ("kconfig: Don't leak 'source' filenames during parsing") bc28fe1d5ede88 ("kconfig: Don't leak 'option' arguments during parsing") 0724a7c32a54e3 ("kconfig: Don't leak main menus during parsing") ae7440ef0c8013 ("kconfig: Fix automatic menu creation mem leak") 5b1374b3b3c2fc ("kconfig: Fix expr_free() E_NOT leak") 7cf33f88e29410 ("kconfig: Fix choice symbol expression leak") 05cccce580456d ("kconfig: Document automatic submenu creation code") 0735f7e5def2ab ("kconfig: Document important expression functions") df60f4b92d3d0b ("kconfig: Remove menu_end_entry()") b92d804a51796b ("kconfig: drop 'boolean' keyword") 6479f327dea60d ("kconfig: Warn if there is more than one help text") 52e58a3caeba5d ("kconfig: make input_mode static") 5a3dc717b3c785 ("kconfig: make xfgets() really static") 84dd95d4f87a0d ("kconfig: make conf_unsaved a local variable of conf_read()") 765f4cdef6f80d ("kconfig: use default 'yy' prefix for lexer and parser") eea199b445f64c ("kbuild: remove unnecessary LEX_PREFIX and YACC_PREFIX") e71de5ee08dcb0 ("kbuild: remove remaining use of undefined YACC_PREFIX") d59fbbd09d5d6b ! ("kbuild: replace hardcoded bison in cmd_bison_h with $(YACC)") 3e41ba05b6d60c ("kconfig: Document SYMBOL_OPTIONAL logic") d3465af60f4471 ("kconfig: Clarify choice dependency propagation") 9d1a9e8bc18bea ("kconfig: Document 'if' flattening logic") b53688014e3325 ("kconfig: Clarify menu and 'if' dependency propagation") d0fd0428ecf04b ("kconfig: fix make xconfig when gettext is missing") 312ee68752faaa ("kconfig: announce removal of oldnoconfig if used") 1ccb27143360bd ("kconfig: make "Selected by:" and "Implied by:" readable") cedd55d49dee94 ! ("kconfig: Remove silentoldconfig from help and docs; fix kconfig/conf's help") 1b9eda2e4892cb ("kconfig: Warn if help text is blank") cb67ab2cd2b8ab ("kconfig: do not write choice values when their dependency becomes n") 4f208f392103e8 ("kconfig: show '?' prompt even if no help text is available") cd58a91def2acc ("kconfig: remove 'config*' pattern from .gitignnore") d2a04648a5dbc3 ("kconfig: remove check_stdin()") f3ff6fb5db68bc ("kconfig: echo stdin to stdout if either is redirected") 9e3e10c725360b ("kconfig: send error messages to stderr") d717f24d8c6808 ("kconfig: add xrealloc() helper") 523ca58b7db2e3 ("kconfig: remove const qualifier from sym_expand_string_value()") cd81fc82b93fa4 ("kconfig: add xstrdup() helper") f4bc1eefc1608e ("kconfig: set SYMBOL_AUTO to the symbol marked with defconfig_list") bf0bbdcf100322 ("kconfig: Don't leak choice names during parsing") 1a90ce36c6eff6 ("kconfig: Update ncurses package names for menuconfig") 5ae6fcc4bb82bd ("kconfig: fix line number in recursive inclusion error message") 07a422bb213adb ! ("kbuild: restore autoksyms.h touch to the top Makefile") 9a47ceec543bfb ("kconfig: clean-up reverse dependency help implementation") d9119b5925a03b ("kconfig: Print reverse dependencies in groups") f467c5640c29ad ("kconfig: only write '# CONFIG_FOO is not set' for visible symbols") 59a80b5e892dde ("kconfig: do not call check_conf() for olddefconfig") 4bb3a5b085cd6f ("kconfig: remove unneeded input_mode test in conf()") 99f0b6578bab44 ("kconfig: remove redundant input_mode test for check_conf() loop") 2aad9b89621386 ("kconfig: hide irrelevant sub-menus for oldconfig") 81d2bc2273052e ("kconfig: invoke oldconfig instead of silentoldconfig from local*config") 911a91c39cabcb ! ("kconfig: rename silentoldconfig to syncconfig") 2a61625835c7c8 ! ("kconfig: remove redundant streamline_config.pl prerequisite") 022a4bf6b59dfd ("kconfig: tests: add framework for Kconfig unit testing") 1903c511905984 ("kconfig: tests: add basic choice tests") 49ac3c0c3aa3b7 ("kconfig: tests: test automatic submenu creation") b76960c0f6b25d ("kconfig: tests: test if new symbols in choice are asked") 930c429a656fdb ("kconfig: tests: check unneeded "is not set" with unmet dependency") ee236610653ede ("kconfig: tests: check visibility of tristate choice values in y choice") beaaddb625400e ("kconfig: tests: test defconfig when two choices interact") 3e4888c2e3d77d ("kconfig: tests: test randconfig for choice in choice") 29c434f367ea7b ("kconfig: tests: test if recursive dependencies are detected") e2c75e7667c737 ("kconfig: tests: test if recursive inclusion is detected") f622f827958162 ("kconfig: warn unmet direct dependency of tristate symbols selected by y") f8f69dc0b4e070 ("kconfig: make unmet dependency warnings readable") 26561514cc9def ("kconfig: do not include both curses.h and ncurses.h for nconfig") 32a94b8b0c3e5a ("kconfig: remove duplicated file name and lineno of recursive inclusion") 379a8eb8eb1a55 ("kconfig: detect recursive inclusion earlier") 18492685e479fd ("kconfig: use yylineno option instead of manual lineno increments") 59889300274569 ! (".gitignore: move *.lex.c *.tab.[ch] patterns to the top-level .gitignore") 9a8dfb394c0467 ! ("kbuild: clean up *.lex.c and *.tab.[ch] patterns from top-level Makefile") 833e622459432e ! ("genksyms: generate lexer and parser during build instead of shipping") b23d1a241f4eb4 ! ("kbuild: add %.lex.c and %.tab.[ch] to 'targets' automatically") 17baab68d337a0 ("kconfig: extend output of 'listnewconfig'") e9781b52d4e0e3 ! ("kbuild: add PYTHON2 and PYTHON3 variables") The current Kconfig update generates below build-time warnings: YACC scripts/dtc/dtc-parser.tab.h scripts/dtc/dtc-parser.y: warning: 3 shift/reduce conflicts [-Wconflicts-sr] YACC scripts/dtc/dtc-parser.tab.c scripts/dtc/dtc-parser.y: warning: 3 shift/reduce conflicts [-Wconflicts-sr] This seems to happen because the Kbuild updates apparently didn't make room for both "*shipped"-based builds and flex/bison-based builds. A similar problem has been reported for genksyms parser in v4.17-rc1 commit 833e622459432e ("genksyms: generate lexer and parser during build instead of shipping"). I have figured out empirically that the warnings are healed after updating the in-tree U-boot DTC to upstream v1.4.6-9, same as done by Linux v4.17-rc1 commit 9130ba88464032 ("scripts/dtc: Update to upstream version v1.4.6-9-gaadd0b65c987"). Whether fixing the DTC-related yacc warnings should be done together with the Kconfig re-sync, I would like to hear from community. My testing was limited to: - make defconfig all - make ARCH=arm CROSS_COMPILE=aarch64-linux-gnu- r8a7795_ulcb_defconfig all - comparing .config before and after the re-sync - running the newly imported Kconfig unit tests as seen below: $ make testconfig Tested-by: Petr Vorel <petr.vorel@gmail.com> ============================= test session starts ============================= scripts/kconfig/tests/auto_submenu/__init__.py::test PASSED [ 7%] scripts/kconfig/tests/choice/__init__.py::test_oldask0 PASSED [ 14%] scripts/kconfig/tests/choice/__init__.py::test_oldask1 PASSED [ 21%] scripts/kconfig/tests/choice/__init__.py::test_allyes PASSED [ 28%] scripts/kconfig/tests/choice/__init__.py::test_allmod PASSED [ 35%] scripts/kconfig/tests/choice/__init__.py::test_allno PASSED [ 42%] scripts/kconfig/tests/choice/__init__.py::test_alldef PASSED [ 50%] scripts/kconfig/tests/choice_value_with_m_dep/__init__.py::test PASSED [ 57%] scripts/kconfig/tests/err_recursive_inc/__init__.py::test PASSED [ 64%] scripts/kconfig/tests/inter_choice/__init__.py::test PASSED [ 71%] scripts/kconfig/tests/new_choice_with_dep/__init__.py::test PASSED [ 78%] scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py::test PASSED [ 85%] scripts/kconfig/tests/rand_nested_choice/__init__.py::test PASSED [ 92%] scripts/kconfig/tests/warn_recursive_dep/__init__.py::test PASSED [100%] ========================== 14 passed in 0.34 seconds ========================== Signed-off-by: Eugeniu Rosca <erosca@de.adit-jv.com> Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com> Tested-by: Petr Vorel <petr.vorel@gmail.com>
This commit is contained in:
parent
8ada17dde8
commit
e91610da7c
2
.gitignore
vendored
2
.gitignore
vendored
@ -13,6 +13,7 @@
|
||||
*.su
|
||||
*.mod.c
|
||||
*.i
|
||||
*.lex.c
|
||||
*.lst
|
||||
*.order
|
||||
*.elf
|
||||
@ -20,6 +21,7 @@
|
||||
*.bin
|
||||
*.patch
|
||||
*.cfgtmp
|
||||
*.tab.[ch]
|
||||
|
||||
# host programs on Cygwin
|
||||
*.exe
|
||||
|
9
Makefile
9
Makefile
@ -353,9 +353,13 @@ LDR = $(CROSS_COMPILE)ldr
|
||||
STRIP = $(CROSS_COMPILE)strip
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
OBJDUMP = $(CROSS_COMPILE)objdump
|
||||
LEX = flex
|
||||
YACC = bison
|
||||
AWK = awk
|
||||
PERL = perl
|
||||
PYTHON ?= python
|
||||
PYTHON2 = python2
|
||||
PYTHON3 = python3
|
||||
DTC ?= $(objtree)/scripts/dtc/dtc
|
||||
CHECK = sparse
|
||||
|
||||
@ -378,7 +382,7 @@ export VERSION PATCHLEVEL SUBLEVEL UBOOTRELEASE UBOOTVERSION
|
||||
export ARCH CPU BOARD VENDOR SOC CPUDIR BOARDDIR
|
||||
export CONFIG_SHELL HOSTCC HOSTCFLAGS HOSTLDFLAGS CROSS_COMPILE AS LD CC
|
||||
export CPP AR NM LDR STRIP OBJCOPY OBJDUMP
|
||||
export MAKE AWK PERL PYTHON
|
||||
export MAKE LEX YACC AWK PERL PYTHON PYTHON2 PYTHON3
|
||||
export HOSTCXX HOSTCXXFLAGS CHECK CHECKFLAGS DTC DTC_FLAGS
|
||||
|
||||
export KBUILD_CPPFLAGS NOSTDINC_FLAGS UBOOTINCLUDE OBJCOPYFLAGS LDFLAGS
|
||||
@ -514,7 +518,7 @@ $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ;
|
||||
# if auto.conf.cmd is missing then we are probably in a cleaned tree so
|
||||
# we execute the config step to be sure to catch updated Kconfig files
|
||||
include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
|
||||
$(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
|
||||
$(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
|
||||
@# If the following part fails, include/config/auto.conf should be
|
||||
@# deleted so "make silentoldconfig" will be re-run on the next build.
|
||||
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.autoconf || \
|
||||
@ -1617,6 +1621,7 @@ clean: $(clean-dirs)
|
||||
\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
|
||||
-o -name '*.ko.*' -o -name '*.su' -o -name '*.cfgtmp' \
|
||||
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
|
||||
-o -name '*.lex.c' -o -name '*.tab.[ch]' \
|
||||
-o -name '*.symtypes' -o -name 'modules.order' \
|
||||
-o -name modules.builtin -o -name '.tmp_*.o.*' \
|
||||
-o -name 'dsdt.aml' -o -name 'dsdt.asl.tmp' -o -name 'dsdt.c' \
|
||||
|
@ -415,6 +415,17 @@ $(call multi_depend, $(multi-used-m), .o, -objs -y)
|
||||
targets += $(multi-used-y) $(multi-used-m)
|
||||
|
||||
|
||||
# Add intermediate targets:
|
||||
# When building objects with specific suffix patterns, add intermediate
|
||||
# targets that the final targets are derived from.
|
||||
intermediate_targets = $(foreach sfx, $(2), \
|
||||
$(patsubst %$(strip $(1)),%$(sfx), \
|
||||
$(filter %$(strip $(1)), $(targets))))
|
||||
# %.lex.o <- %.lex.c <- %.l
|
||||
# %.tab.o <- %.tab.[ch] <- %.y
|
||||
targets += $(call intermediate_targets, .lex.o, .lex.c) \
|
||||
$(call intermediate_targets, .tab.o, .tab.c .tab.h)
|
||||
|
||||
# Descending
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
@ -209,47 +209,30 @@ $(foreach m, $(notdir $1), \
|
||||
$(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))))))
|
||||
endef
|
||||
|
||||
ifdef REGENERATE_PARSERS
|
||||
|
||||
# GPERF
|
||||
# ---------------------------------------------------------------------------
|
||||
quiet_cmd_gperf = GPERF $@
|
||||
cmd_gperf = gperf -t --output-file $@ -a -C -E -g -k 1,3,$$ -p -t $<
|
||||
|
||||
.PRECIOUS: $(src)/%.hash.c_shipped
|
||||
$(src)/%.hash.c_shipped: $(src)/%.gperf
|
||||
$(call cmd,gperf)
|
||||
|
||||
# LEX
|
||||
# ---------------------------------------------------------------------------
|
||||
LEX_PREFIX = $(if $(LEX_PREFIX_${baseprereq}),$(LEX_PREFIX_${baseprereq}),yy)
|
||||
|
||||
quiet_cmd_flex = LEX $@
|
||||
cmd_flex = flex -o$@ -L -P $(LEX_PREFIX) $<
|
||||
cmd_flex = $(LEX) -o$@ -L $<
|
||||
|
||||
.PRECIOUS: $(src)/%.lex.c_shipped
|
||||
$(src)/%.lex.c_shipped: $(src)/%.l
|
||||
$(call cmd,flex)
|
||||
.PRECIOUS: $(obj)/%.lex.c
|
||||
$(obj)/%.lex.c: $(src)/%.l FORCE
|
||||
$(call if_changed,flex)
|
||||
|
||||
# YACC
|
||||
# ---------------------------------------------------------------------------
|
||||
YACC_PREFIX = $(if $(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy)
|
||||
|
||||
quiet_cmd_bison = YACC $@
|
||||
cmd_bison = bison -o$@ -t -l -p $(YACC_PREFIX) $<
|
||||
cmd_bison = $(YACC) -o$@ -t -l $<
|
||||
|
||||
.PRECIOUS: $(src)/%.tab.c_shipped
|
||||
$(src)/%.tab.c_shipped: $(src)/%.y
|
||||
$(call cmd,bison)
|
||||
.PRECIOUS: $(obj)/%.tab.c
|
||||
$(obj)/%.tab.c: $(src)/%.y FORCE
|
||||
$(call if_changed,bison)
|
||||
|
||||
quiet_cmd_bison_h = YACC $@
|
||||
cmd_bison_h = bison -o/dev/null --defines=$@ -t -l -p $(YACC_PREFIX) $<
|
||||
cmd_bison_h = $(YACC) -o/dev/null --defines=$@ -t -l $<
|
||||
|
||||
.PRECIOUS: $(src)/%.tab.h_shipped
|
||||
$(src)/%.tab.h_shipped: $(src)/%.y
|
||||
$(call cmd,bison_h)
|
||||
|
||||
endif
|
||||
.PRECIOUS: $(obj)/%.tab.h
|
||||
$(obj)/%.tab.h: $(src)/%.y FORCE
|
||||
$(call if_changed,bison_h)
|
||||
|
||||
# Shipped files
|
||||
# ===========================================================================
|
||||
|
5
scripts/kconfig/.gitignore
vendored
5
scripts/kconfig/.gitignore
vendored
@ -1,11 +1,6 @@
|
||||
#
|
||||
# Generated files
|
||||
#
|
||||
config*
|
||||
*.lex.c
|
||||
*.tab.c
|
||||
*.tab.h
|
||||
zconf.hash.c
|
||||
*.moc
|
||||
gconf.glade.h
|
||||
*.pot
|
||||
|
@ -3,7 +3,7 @@
|
||||
# Kernel configuration targets
|
||||
# These targets are used from top-level makefile
|
||||
|
||||
PHONY += xconfig gconfig menuconfig config silentoldconfig update-po-config \
|
||||
PHONY += xconfig gconfig menuconfig config syncconfig update-po-config \
|
||||
localmodconfig localyesconfig
|
||||
|
||||
# Added for U-Boot
|
||||
@ -40,24 +40,24 @@ config: $(obj)/conf
|
||||
nconfig: $(obj)/nconf
|
||||
$< $(silent) $(Kconfig)
|
||||
|
||||
silentoldconfig: $(obj)/conf
|
||||
# This has become an internal implementation detail and is now deprecated
|
||||
# for external use.
|
||||
syncconfig: $(obj)/conf
|
||||
$(Q)mkdir -p include/config include/generated
|
||||
$(Q)test -e include/generated/autoksyms.h || \
|
||||
touch include/generated/autoksyms.h
|
||||
$< $(silent) --$@ $(Kconfig)
|
||||
|
||||
localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf
|
||||
localyesconfig localmodconfig: $(obj)/conf
|
||||
$(Q)mkdir -p include/config include/generated
|
||||
$(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config
|
||||
$(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
|
||||
$(Q)if [ -f .config ]; then \
|
||||
cmp -s .tmp.config .config || \
|
||||
(mv -f .config .config.old.1; \
|
||||
mv -f .tmp.config .config; \
|
||||
$(obj)/conf $(silent) --silentoldconfig $(Kconfig); \
|
||||
$< $(silent) --oldconfig $(Kconfig); \
|
||||
mv -f .config.old.1 .config.old) \
|
||||
else \
|
||||
mv -f .tmp.config .config; \
|
||||
$(obj)/conf $(silent) --silentoldconfig $(Kconfig); \
|
||||
$< $(silent) --oldconfig $(Kconfig); \
|
||||
fi
|
||||
$(Q)rm -f .tmp.config
|
||||
|
||||
@ -92,12 +92,21 @@ PHONY += $(simple-targets)
|
||||
$(simple-targets): $(obj)/conf
|
||||
$< $(silent) --$@ $(Kconfig)
|
||||
|
||||
PHONY += oldnoconfig savedefconfig defconfig
|
||||
PHONY += oldnoconfig silentoldconfig savedefconfig defconfig
|
||||
|
||||
# oldnoconfig is an alias of olddefconfig, because people already are dependent
|
||||
# on its behavior (sets new symbols to their default value but not 'n') with the
|
||||
# counter-intuitive name.
|
||||
oldnoconfig: olddefconfig
|
||||
@echo " WARNING: \"oldnoconfig\" target will be removed after Linux 4.19"
|
||||
@echo " Please use \"olddefconfig\" instead, which is an alias."
|
||||
|
||||
# We do not expect manual invokcation of "silentoldcofig" (or "syncconfig").
|
||||
silentoldconfig: syncconfig
|
||||
@echo " WARNING: \"silentoldconfig\" has been renamed to \"syncconfig\""
|
||||
@echo " and is now an internal implementation detail."
|
||||
@echo " What you want is probably \"oldconfig\"."
|
||||
@echo " \"silentoldconfig\" will be removed after Linux 4.19"
|
||||
|
||||
savedefconfig: $(obj)/conf
|
||||
$< $(silent) --$@=defconfig $(Kconfig)
|
||||
@ -141,6 +150,14 @@ PHONY += tinyconfig
|
||||
tinyconfig:
|
||||
$(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config
|
||||
|
||||
# CHECK: -o cache_dir=<path> working?
|
||||
PHONY += testconfig
|
||||
testconfig: $(obj)/conf
|
||||
$(PYTHON3) -B -m pytest $(srctree)/$(src)/tests \
|
||||
-o cache_dir=$(abspath $(obj)/tests/.cache) \
|
||||
$(if $(findstring 1,$(KBUILD_VERBOSE)),--capture=no)
|
||||
clean-dirs += tests/.cache
|
||||
|
||||
# Help text used by make help
|
||||
help:
|
||||
@echo ' config - Update current config utilising a line-oriented program'
|
||||
@ -152,7 +169,6 @@ help:
|
||||
@echo ' oldconfig - Update current config utilising a provided .config as base'
|
||||
@echo ' localmodconfig - Update current config disabling modules not loaded'
|
||||
@echo ' localyesconfig - Update current config converting local mods to core'
|
||||
@echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
|
||||
@echo ' defconfig - New config with default from ARCH supplied defconfig'
|
||||
@echo ' savedefconfig - Save current config as ./defconfig (minimal config)'
|
||||
@echo ' allnoconfig - New config where all options are answered with no'
|
||||
@ -161,8 +177,8 @@ help:
|
||||
@echo ' alldefconfig - New config with all symbols set to default'
|
||||
@echo ' randconfig - New config with random answer to all options'
|
||||
@echo ' listnewconfig - List new options'
|
||||
@echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their'
|
||||
@echo ' default value'
|
||||
@echo ' olddefconfig - Same as oldconfig but sets new symbols to their'
|
||||
@echo ' default value without prompting'
|
||||
# @echo ' kvmconfig - Enable additional options for kvm guest kernel support'
|
||||
# @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support'
|
||||
# @echo ' tinyconfig - Configure the tiniest possible kernel'
|
||||
@ -201,13 +217,14 @@ gconf-objs := gconf.o zconf.tab.o
|
||||
|
||||
hostprogs-y := conf nconf mconf kxgettext qconf gconf
|
||||
|
||||
targets += zconf.lex.c
|
||||
clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck
|
||||
clean-files += zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h
|
||||
clean-files += gconf.glade.h
|
||||
clean-files += config.pot linux.pot
|
||||
|
||||
# Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
|
||||
PHONY += $(obj)/dochecklxdialog
|
||||
$(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog
|
||||
$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/dochecklxdialog
|
||||
$(obj)/dochecklxdialog:
|
||||
$(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTLOADLIBES_mconf)
|
||||
|
||||
@ -215,14 +232,12 @@ always := dochecklxdialog
|
||||
|
||||
# Add environment specific flags
|
||||
HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
|
||||
HOST_EXTRACXXFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCXX) $(HOSTCXXFLAGS))
|
||||
|
||||
# generated files seem to need this to find local include files
|
||||
HOSTCFLAGS_zconf.lex.o := -I$(src)
|
||||
HOSTCFLAGS_zconf.tab.o := -I$(src)
|
||||
|
||||
LEX_PREFIX_zconf := zconf
|
||||
YACC_PREFIX_zconf := zconf
|
||||
|
||||
HOSTLOADLIBES_qconf = $(KC_QT_LIBS)
|
||||
HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS)
|
||||
|
||||
@ -291,7 +306,7 @@ $(obj)/.tmp_gtkcheck:
|
||||
fi
|
||||
endif
|
||||
|
||||
$(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.hash.c
|
||||
$(obj)/zconf.tab.o: $(obj)/zconf.lex.c
|
||||
|
||||
$(obj)/qconf.o: $(obj)/qconf.moc
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Needed for systems without gettext
|
||||
$* -x c -o /dev/null - > /dev/null 2>&1 << EOF
|
||||
#include <libintl.h>
|
||||
|
@ -20,11 +20,10 @@
|
||||
|
||||
static void conf(struct menu *menu);
|
||||
static void check_conf(struct menu *menu);
|
||||
static void xfgets(char *str, int size, FILE *in);
|
||||
|
||||
enum input_mode {
|
||||
oldaskconfig,
|
||||
silentoldconfig,
|
||||
syncconfig,
|
||||
oldconfig,
|
||||
allnoconfig,
|
||||
allyesconfig,
|
||||
@ -35,11 +34,11 @@ enum input_mode {
|
||||
savedefconfig,
|
||||
listnewconfig,
|
||||
olddefconfig,
|
||||
} input_mode = oldaskconfig;
|
||||
};
|
||||
static enum input_mode input_mode = oldaskconfig;
|
||||
|
||||
static int indent = 1;
|
||||
static int tty_stdio;
|
||||
static int valid_stdin = 1;
|
||||
static int sync_kconfig;
|
||||
static int conf_cnt;
|
||||
static char line[PATH_MAX];
|
||||
@ -72,14 +71,14 @@ static void strip(char *str)
|
||||
*p-- = 0;
|
||||
}
|
||||
|
||||
static void check_stdin(void)
|
||||
/* Helper function to facilitate fgets() by Jean Sacren. */
|
||||
static void xfgets(char *str, int size, FILE *in)
|
||||
{
|
||||
if (!valid_stdin) {
|
||||
printf(_("aborted!\n\n"));
|
||||
printf(_("Console input/output is redirected. "));
|
||||
printf(_("Run 'make oldconfig' to update configuration.\n\n"));
|
||||
exit(1);
|
||||
}
|
||||
if (!fgets(str, size, in))
|
||||
fprintf(stderr, "\nError in reading or end of file.\n");
|
||||
|
||||
if (!tty_stdio)
|
||||
printf("%s", str);
|
||||
}
|
||||
|
||||
static int conf_askvalue(struct symbol *sym, const char *def)
|
||||
@ -101,18 +100,15 @@ static int conf_askvalue(struct symbol *sym, const char *def)
|
||||
|
||||
switch (input_mode) {
|
||||
case oldconfig:
|
||||
case silentoldconfig:
|
||||
case syncconfig:
|
||||
if (sym_has_value(sym)) {
|
||||
printf("%s\n", def);
|
||||
return 0;
|
||||
}
|
||||
check_stdin();
|
||||
/* fall through */
|
||||
case oldaskconfig:
|
||||
fflush(stdout);
|
||||
xfgets(line, sizeof(line), stdin);
|
||||
if (!tty_stdio)
|
||||
printf("\n");
|
||||
return 1;
|
||||
default:
|
||||
break;
|
||||
@ -192,9 +188,7 @@ static int conf_sym(struct menu *menu)
|
||||
printf("/m");
|
||||
if (oldval != yes && sym_tristate_within_range(sym, yes))
|
||||
printf("/y");
|
||||
if (menu_has_help(menu))
|
||||
printf("/?");
|
||||
printf("] ");
|
||||
printf("/?] ");
|
||||
if (!conf_askvalue(sym, sym_get_string_value(sym)))
|
||||
return 0;
|
||||
strip(line);
|
||||
@ -296,19 +290,15 @@ static int conf_choice(struct menu *menu)
|
||||
printf("[1]: 1\n");
|
||||
goto conf_childs;
|
||||
}
|
||||
printf("[1-%d", cnt);
|
||||
if (menu_has_help(menu))
|
||||
printf("?");
|
||||
printf("]: ");
|
||||
printf("[1-%d?]: ", cnt);
|
||||
switch (input_mode) {
|
||||
case oldconfig:
|
||||
case silentoldconfig:
|
||||
case syncconfig:
|
||||
if (!is_new) {
|
||||
cnt = def;
|
||||
printf("%d\n", cnt);
|
||||
break;
|
||||
}
|
||||
check_stdin();
|
||||
/* fall through */
|
||||
case oldaskconfig:
|
||||
fflush(stdout);
|
||||
@ -368,10 +358,11 @@ static void conf(struct menu *menu)
|
||||
|
||||
switch (prop->type) {
|
||||
case P_MENU:
|
||||
if ((input_mode == silentoldconfig ||
|
||||
input_mode == listnewconfig ||
|
||||
input_mode == olddefconfig) &&
|
||||
rootEntry != menu) {
|
||||
/*
|
||||
* Except in oldaskconfig mode, we show only menus that
|
||||
* contain new symbols.
|
||||
*/
|
||||
if (input_mode != oldaskconfig && rootEntry != menu) {
|
||||
check_conf(menu);
|
||||
return;
|
||||
}
|
||||
@ -431,10 +422,20 @@ static void check_conf(struct menu *menu)
|
||||
if (sym_is_changable(sym) ||
|
||||
(sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
|
||||
if (input_mode == listnewconfig) {
|
||||
if (sym->name && !sym_is_choice_value(sym)) {
|
||||
printf("%s%s\n", CONFIG_, sym->name);
|
||||
if (sym->name) {
|
||||
const char *str;
|
||||
|
||||
if (sym->type == S_STRING) {
|
||||
str = sym_get_string_value(sym);
|
||||
str = sym_escape_string_value(str);
|
||||
printf("%s%s=%s\n", CONFIG_, sym->name, str);
|
||||
free((void *)str);
|
||||
} else {
|
||||
str = sym_get_string_value(sym);
|
||||
printf("%s%s=%s\n", CONFIG_, sym->name, str);
|
||||
}
|
||||
} else if (input_mode != olddefconfig) {
|
||||
}
|
||||
} else {
|
||||
if (!conf_cnt++)
|
||||
printf(_("*\n* Restart config...\n*\n"));
|
||||
rootEntry = menu_get_parent_menu(menu);
|
||||
@ -450,7 +451,7 @@ static void check_conf(struct menu *menu)
|
||||
static struct option long_opts[] = {
|
||||
{"oldaskconfig", no_argument, NULL, oldaskconfig},
|
||||
{"oldconfig", no_argument, NULL, oldconfig},
|
||||
{"silentoldconfig", no_argument, NULL, silentoldconfig},
|
||||
{"syncconfig", no_argument, NULL, syncconfig},
|
||||
{"defconfig", optional_argument, NULL, defconfig},
|
||||
{"savedefconfig", required_argument, NULL, savedefconfig},
|
||||
{"allnoconfig", no_argument, NULL, allnoconfig},
|
||||
@ -477,8 +478,9 @@ static void conf_usage(const char *progname)
|
||||
printf(" --listnewconfig List new options\n");
|
||||
printf(" --oldaskconfig Start a new configuration using a line-oriented program\n");
|
||||
printf(" --oldconfig Update a configuration using a provided .config as base\n");
|
||||
printf(" --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n");
|
||||
printf(" --olddefconfig Same as silentoldconfig but sets new symbols to their default value\n");
|
||||
printf(" --syncconfig Similar to oldconfig but generates configuration in\n"
|
||||
" include/{generated/,config/}\n");
|
||||
printf(" --olddefconfig Same as oldconfig but sets new symbols to their default value\n");
|
||||
printf(" --oldnoconfig An alias of olddefconfig\n");
|
||||
printf(" --defconfig <file> New config with default defined in <file>\n");
|
||||
printf(" --savedefconfig <file> Save the minimal current configuration to <file>\n");
|
||||
@ -500,7 +502,7 @@ int main(int ac, char **av)
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
|
||||
tty_stdio = isatty(0) && isatty(1) && isatty(2);
|
||||
tty_stdio = isatty(0) && isatty(1);
|
||||
|
||||
while ((opt = getopt_long(ac, av, "s", long_opts, NULL)) != -1) {
|
||||
if (opt == 's') {
|
||||
@ -509,7 +511,7 @@ int main(int ac, char **av)
|
||||
}
|
||||
input_mode = (enum input_mode)opt;
|
||||
switch (opt) {
|
||||
case silentoldconfig:
|
||||
case syncconfig:
|
||||
sync_kconfig = 1;
|
||||
break;
|
||||
case defconfig:
|
||||
@ -557,7 +559,7 @@ int main(int ac, char **av)
|
||||
}
|
||||
}
|
||||
if (ac == optind) {
|
||||
printf(_("%s: Kconfig file missing\n"), av[0]);
|
||||
fprintf(stderr, _("%s: Kconfig file missing\n"), av[0]);
|
||||
conf_usage(progname);
|
||||
exit(1);
|
||||
}
|
||||
@ -582,14 +584,16 @@ int main(int ac, char **av)
|
||||
if (!defconfig_file)
|
||||
defconfig_file = conf_get_default_confname();
|
||||
if (conf_read(defconfig_file)) {
|
||||
printf(_("***\n"
|
||||
fprintf(stderr,
|
||||
_("***\n"
|
||||
"*** Can't find default configuration \"%s\"!\n"
|
||||
"***\n"), defconfig_file);
|
||||
"***\n"),
|
||||
defconfig_file);
|
||||
exit(1);
|
||||
}
|
||||
break;
|
||||
case savedefconfig:
|
||||
case silentoldconfig:
|
||||
case syncconfig:
|
||||
case oldaskconfig:
|
||||
case oldconfig:
|
||||
case listnewconfig:
|
||||
@ -642,7 +646,6 @@ int main(int ac, char **av)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
valid_stdin = tty_stdio;
|
||||
}
|
||||
|
||||
switch (input_mode) {
|
||||
@ -670,24 +673,24 @@ int main(int ac, char **av)
|
||||
case oldaskconfig:
|
||||
rootEntry = &rootmenu;
|
||||
conf(&rootmenu);
|
||||
input_mode = silentoldconfig;
|
||||
input_mode = oldconfig;
|
||||
/* fall through */
|
||||
case oldconfig:
|
||||
case listnewconfig:
|
||||
case olddefconfig:
|
||||
case silentoldconfig:
|
||||
case syncconfig:
|
||||
/* Update until a loop caused no more changes */
|
||||
do {
|
||||
conf_cnt = 0;
|
||||
check_conf(&rootmenu);
|
||||
} while (conf_cnt &&
|
||||
(input_mode != listnewconfig &&
|
||||
input_mode != olddefconfig));
|
||||
} while (conf_cnt);
|
||||
break;
|
||||
case olddefconfig:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (sync_kconfig) {
|
||||
/* silentoldconfig is used during the build so we shall update autoconf.
|
||||
/* syncconfig is used during the build so we shall update autoconf.
|
||||
* All other commands are only used to generate a config.
|
||||
*/
|
||||
if (conf_get_changed() && conf_write(NULL)) {
|
||||
@ -712,12 +715,3 @@ int main(int ac, char **av)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper function to facilitate fgets() by Jean Sacren.
|
||||
*/
|
||||
void xfgets(char *str, int size, FILE *in)
|
||||
{
|
||||
if (fgets(str, size, in) == NULL)
|
||||
fprintf(stderr, "\nError in reading or end of file.\n");
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ static void conf_message(const char *fmt, ...)
|
||||
__attribute__ ((format (printf, 1, 2)));
|
||||
|
||||
static const char *conf_filename;
|
||||
static int conf_lineno, conf_warnings, conf_unsaved;
|
||||
static int conf_lineno, conf_warnings;
|
||||
|
||||
const char conf_defname[] = "arch/$ARCH/defconfig";
|
||||
|
||||
@ -174,7 +174,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
|
||||
case S_HEX:
|
||||
done:
|
||||
if (sym_string_valid(sym, p)) {
|
||||
sym->def[def].val = strdup(p);
|
||||
sym->def[def].val = xstrdup(p);
|
||||
sym->flags |= def_flags;
|
||||
} else {
|
||||
if (def != S_DEF_AUTO)
|
||||
@ -197,7 +197,7 @@ static int add_byte(int c, char **lineptr, size_t slen, size_t *n)
|
||||
if (new_size > *n) {
|
||||
new_size += LINE_GROWTH - 1;
|
||||
new_size *= 2;
|
||||
nline = realloc(*lineptr, new_size);
|
||||
nline = xrealloc(*lineptr, new_size);
|
||||
if (!nline)
|
||||
return -1;
|
||||
|
||||
@ -286,7 +286,6 @@ load:
|
||||
conf_filename = name;
|
||||
conf_lineno = 0;
|
||||
conf_warnings = 0;
|
||||
conf_unsaved = 0;
|
||||
|
||||
def_flags = SYMBOL_DEF << def;
|
||||
for_all_symbols(i, sym) {
|
||||
@ -405,6 +404,7 @@ setsym:
|
||||
int conf_read(const char *name)
|
||||
{
|
||||
struct symbol *sym;
|
||||
int conf_unsaved = 0;
|
||||
int i;
|
||||
|
||||
sym_set_change_count(0);
|
||||
@ -1121,7 +1121,7 @@ void set_all_choice_values(struct symbol *csym)
|
||||
bool conf_set_all_new_symbols(enum conf_def_mode mode)
|
||||
{
|
||||
struct symbol *sym, *csym;
|
||||
int i, cnt, pby, pty, ptm; /* pby: probability of boolean = y
|
||||
int i, cnt, pby, pty, ptm; /* pby: probability of bool = y
|
||||
* pty: probability of tristate = y
|
||||
* ptm: probability of tristate = m
|
||||
*/
|
||||
|
@ -94,7 +94,7 @@ struct expr *expr_copy(const struct expr *org)
|
||||
e->right.expr = expr_copy(org->right.expr);
|
||||
break;
|
||||
default:
|
||||
printf("can't copy type %d\n", e->type);
|
||||
fprintf(stderr, "can't copy type %d\n", e->type);
|
||||
free(e);
|
||||
e = NULL;
|
||||
break;
|
||||
@ -113,7 +113,7 @@ void expr_free(struct expr *e)
|
||||
break;
|
||||
case E_NOT:
|
||||
expr_free(e->left.expr);
|
||||
return;
|
||||
break;
|
||||
case E_EQUAL:
|
||||
case E_GEQ:
|
||||
case E_GTH:
|
||||
@ -127,7 +127,7 @@ void expr_free(struct expr *e)
|
||||
expr_free(e->right.expr);
|
||||
break;
|
||||
default:
|
||||
printf("how to free type %d?\n", e->type);
|
||||
fprintf(stderr, "how to free type %d?\n", e->type);
|
||||
break;
|
||||
}
|
||||
free(e);
|
||||
@ -138,8 +138,18 @@ static int trans_count;
|
||||
#define e1 (*ep1)
|
||||
#define e2 (*ep2)
|
||||
|
||||
/*
|
||||
* expr_eliminate_eq() helper.
|
||||
*
|
||||
* Walks the two expression trees given in 'ep1' and 'ep2'. Any node that does
|
||||
* not have type 'type' (E_OR/E_AND) is considered a leaf, and is compared
|
||||
* against all other leaves. Two equal leaves are both replaced with either 'y'
|
||||
* or 'n' as appropriate for 'type', to be eliminated later.
|
||||
*/
|
||||
static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct expr **ep2)
|
||||
{
|
||||
/* Recurse down to leaves */
|
||||
|
||||
if (e1->type == type) {
|
||||
__expr_eliminate_eq(type, &e1->left.expr, &e2);
|
||||
__expr_eliminate_eq(type, &e1->right.expr, &e2);
|
||||
@ -150,12 +160,18 @@ static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct e
|
||||
__expr_eliminate_eq(type, &e1, &e2->right.expr);
|
||||
return;
|
||||
}
|
||||
|
||||
/* e1 and e2 are leaves. Compare them. */
|
||||
|
||||
if (e1->type == E_SYMBOL && e2->type == E_SYMBOL &&
|
||||
e1->left.sym == e2->left.sym &&
|
||||
(e1->left.sym == &symbol_yes || e1->left.sym == &symbol_no))
|
||||
return;
|
||||
if (!expr_eq(e1, e2))
|
||||
return;
|
||||
|
||||
/* e1 and e2 are equal leaves. Prepare them for elimination. */
|
||||
|
||||
trans_count++;
|
||||
expr_free(e1); expr_free(e2);
|
||||
switch (type) {
|
||||
@ -172,6 +188,35 @@ static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct e
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Rewrites the expressions 'ep1' and 'ep2' to remove operands common to both.
|
||||
* Example reductions:
|
||||
*
|
||||
* ep1: A && B -> ep1: y
|
||||
* ep2: A && B && C -> ep2: C
|
||||
*
|
||||
* ep1: A || B -> ep1: n
|
||||
* ep2: A || B || C -> ep2: C
|
||||
*
|
||||
* ep1: A && (B && FOO) -> ep1: FOO
|
||||
* ep2: (BAR && B) && A -> ep2: BAR
|
||||
*
|
||||
* ep1: A && (B || C) -> ep1: y
|
||||
* ep2: (C || B) && A -> ep2: y
|
||||
*
|
||||
* Comparisons are done between all operands at the same "level" of && or ||.
|
||||
* For example, in the expression 'e1 && (e2 || e3) && (e4 || e5)', the
|
||||
* following operands will be compared:
|
||||
*
|
||||
* - 'e1', 'e2 || e3', and 'e4 || e5', against each other
|
||||
* - e2 against e3
|
||||
* - e4 against e5
|
||||
*
|
||||
* Parentheses are irrelevant within a single level. 'e1 && (e2 && e3)' and
|
||||
* '(e1 && e2) && e3' are both a single level.
|
||||
*
|
||||
* See __expr_eliminate_eq() as well.
|
||||
*/
|
||||
void expr_eliminate_eq(struct expr **ep1, struct expr **ep2)
|
||||
{
|
||||
if (!e1 || !e2)
|
||||
@ -197,6 +242,12 @@ void expr_eliminate_eq(struct expr **ep1, struct expr **ep2)
|
||||
#undef e1
|
||||
#undef e2
|
||||
|
||||
/*
|
||||
* Returns true if 'e1' and 'e2' are equal, after minor simplification. Two
|
||||
* &&/|| expressions are considered equal if every operand in one expression
|
||||
* equals some operand in the other (operands do not need to appear in the same
|
||||
* order), recursively.
|
||||
*/
|
||||
static int expr_eq(struct expr *e1, struct expr *e2)
|
||||
{
|
||||
int res, old_count;
|
||||
@ -243,6 +294,17 @@ static int expr_eq(struct expr *e1, struct expr *e2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Recursively performs the following simplifications in-place (as well as the
|
||||
* corresponding simplifications with swapped operands):
|
||||
*
|
||||
* expr && n -> n
|
||||
* expr && y -> expr
|
||||
* expr || n -> expr
|
||||
* expr || y -> y
|
||||
*
|
||||
* Returns the optimized expression.
|
||||
*/
|
||||
static struct expr *expr_eliminate_yn(struct expr *e)
|
||||
{
|
||||
struct expr *tmp;
|
||||
@ -516,12 +578,21 @@ static struct expr *expr_join_and(struct expr *e1, struct expr *e2)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* expr_eliminate_dups() helper.
|
||||
*
|
||||
* Walks the two expression trees given in 'ep1' and 'ep2'. Any node that does
|
||||
* not have type 'type' (E_OR/E_AND) is considered a leaf, and is compared
|
||||
* against all other leaves to look for simplifications.
|
||||
*/
|
||||
static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2)
|
||||
{
|
||||
#define e1 (*ep1)
|
||||
#define e2 (*ep2)
|
||||
struct expr *tmp;
|
||||
|
||||
/* Recurse down to leaves */
|
||||
|
||||
if (e1->type == type) {
|
||||
expr_eliminate_dups1(type, &e1->left.expr, &e2);
|
||||
expr_eliminate_dups1(type, &e1->right.expr, &e2);
|
||||
@ -532,6 +603,9 @@ static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct
|
||||
expr_eliminate_dups1(type, &e1, &e2->right.expr);
|
||||
return;
|
||||
}
|
||||
|
||||
/* e1 and e2 are leaves. Compare and process them. */
|
||||
|
||||
if (e1 == e2)
|
||||
return;
|
||||
|
||||
@ -568,6 +642,17 @@ static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct
|
||||
#undef e2
|
||||
}
|
||||
|
||||
/*
|
||||
* Rewrites 'e' in-place to remove ("join") duplicate and other redundant
|
||||
* operands.
|
||||
*
|
||||
* Example simplifications:
|
||||
*
|
||||
* A || B || A -> A || B
|
||||
* A && B && A=y -> A=y && B
|
||||
*
|
||||
* Returns the deduplicated expression.
|
||||
*/
|
||||
struct expr *expr_eliminate_dups(struct expr *e)
|
||||
{
|
||||
int oldcount;
|
||||
@ -584,6 +669,7 @@ struct expr *expr_eliminate_dups(struct expr *e)
|
||||
;
|
||||
}
|
||||
if (!trans_count)
|
||||
/* No simplifications done in this pass. We're done */
|
||||
break;
|
||||
e = expr_eliminate_yn(e);
|
||||
}
|
||||
@ -591,6 +677,12 @@ struct expr *expr_eliminate_dups(struct expr *e)
|
||||
return e;
|
||||
}
|
||||
|
||||
/*
|
||||
* Performs various simplifications involving logical operators and
|
||||
* comparisons.
|
||||
*
|
||||
* Allocates and returns a new expression.
|
||||
*/
|
||||
struct expr *expr_transform(struct expr *e)
|
||||
{
|
||||
struct expr *tmp;
|
||||
@ -805,6 +897,20 @@ bool expr_depends_symbol(struct expr *dep, struct symbol *sym)
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Inserts explicit comparisons of type 'type' to symbol 'sym' into the
|
||||
* expression 'e'.
|
||||
*
|
||||
* Examples transformations for type == E_UNEQUAL, sym == &symbol_no:
|
||||
*
|
||||
* A -> A!=n
|
||||
* !A -> A=n
|
||||
* A && B -> !(A=n || B=n)
|
||||
* A || B -> !(A=n && B=n)
|
||||
* A && (B || C) -> !(A=n || (B=n && C=n))
|
||||
*
|
||||
* Allocates and returns a new expression.
|
||||
*/
|
||||
struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym)
|
||||
{
|
||||
struct expr *e1, *e2;
|
||||
@ -893,7 +999,10 @@ static enum string_value_kind expr_parse_string(const char *str,
|
||||
switch (type) {
|
||||
case S_BOOLEAN:
|
||||
case S_TRISTATE:
|
||||
return k_string;
|
||||
val->s = !strcmp(str, "n") ? 0 :
|
||||
!strcmp(str, "m") ? 1 :
|
||||
!strcmp(str, "y") ? 2 : -1;
|
||||
return k_signed;
|
||||
case S_INT:
|
||||
val->s = strtoll(str, &tail, 10);
|
||||
kind = k_signed;
|
||||
@ -1028,49 +1137,9 @@ static int expr_compare_type(enum expr_type t1, enum expr_type t2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline struct expr *
|
||||
expr_get_leftmost_symbol(const struct expr *e)
|
||||
{
|
||||
|
||||
if (e == NULL)
|
||||
return NULL;
|
||||
|
||||
while (e->type != E_SYMBOL)
|
||||
e = e->left.expr;
|
||||
|
||||
return expr_copy(e);
|
||||
}
|
||||
|
||||
/*
|
||||
* Given expression `e1' and `e2', returns the leaf of the longest
|
||||
* sub-expression of `e1' not containing 'e2.
|
||||
*/
|
||||
struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2)
|
||||
{
|
||||
struct expr *ret;
|
||||
|
||||
switch (e1->type) {
|
||||
case E_OR:
|
||||
return expr_alloc_and(
|
||||
expr_simplify_unmet_dep(e1->left.expr, e2),
|
||||
expr_simplify_unmet_dep(e1->right.expr, e2));
|
||||
case E_AND: {
|
||||
struct expr *e;
|
||||
e = expr_alloc_and(expr_copy(e1), expr_copy(e2));
|
||||
e = expr_eliminate_dups(e);
|
||||
ret = (!expr_eq(e, e1)) ? e1 : NULL;
|
||||
expr_free(e);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ret = e1;
|
||||
break;
|
||||
}
|
||||
|
||||
return expr_get_leftmost_symbol(ret);
|
||||
}
|
||||
|
||||
void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken)
|
||||
void expr_print(struct expr *e,
|
||||
void (*fn)(void *, struct symbol *, const char *),
|
||||
void *data, int prevtoken)
|
||||
{
|
||||
if (!e) {
|
||||
fn(data, NULL, "y");
|
||||
@ -1204,3 +1273,33 @@ void expr_gstr_print(struct expr *e, struct gstr *gs)
|
||||
{
|
||||
expr_print(e, expr_print_gstr_helper, gs, E_NONE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Transform the top level "||" tokens into newlines and prepend each
|
||||
* line with a minus. This makes expressions much easier to read.
|
||||
* Suitable for reverse dependency expressions.
|
||||
*/
|
||||
static void expr_print_revdep(struct expr *e,
|
||||
void (*fn)(void *, struct symbol *, const char *),
|
||||
void *data, tristate pr_type, const char **title)
|
||||
{
|
||||
if (e->type == E_OR) {
|
||||
expr_print_revdep(e->left.expr, fn, data, pr_type, title);
|
||||
expr_print_revdep(e->right.expr, fn, data, pr_type, title);
|
||||
} else if (expr_calc_value(e) == pr_type) {
|
||||
if (*title) {
|
||||
fn(data, NULL, *title);
|
||||
*title = NULL;
|
||||
}
|
||||
|
||||
fn(data, NULL, " - ");
|
||||
expr_print(e, fn, data, E_NONE);
|
||||
fn(data, NULL, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
void expr_gstr_print_revdep(struct expr *e, struct gstr *gs,
|
||||
tristate pr_type, const char *title)
|
||||
{
|
||||
expr_print_revdep(e, expr_print_gstr_helper, gs, pr_type, &title);
|
||||
}
|
||||
|
@ -74,17 +74,60 @@ enum {
|
||||
S_DEF_COUNT
|
||||
};
|
||||
|
||||
/*
|
||||
* Represents a configuration symbol.
|
||||
*
|
||||
* Choices are represented as a special kind of symbol and have the
|
||||
* SYMBOL_CHOICE bit set in 'flags'.
|
||||
*/
|
||||
struct symbol {
|
||||
/* The next symbol in the same bucket in the symbol hash table */
|
||||
struct symbol *next;
|
||||
|
||||
/* The name of the symbol, e.g. "FOO" for 'config FOO' */
|
||||
char *name;
|
||||
|
||||
/* S_BOOLEAN, S_TRISTATE, ... */
|
||||
enum symbol_type type;
|
||||
|
||||
/*
|
||||
* The calculated value of the symbol. The SYMBOL_VALID bit is set in
|
||||
* 'flags' when this is up to date. Note that this value might differ
|
||||
* from the user value set in e.g. a .config file, due to visibility.
|
||||
*/
|
||||
struct symbol_value curr;
|
||||
|
||||
/*
|
||||
* Values for the symbol provided from outside. def[S_DEF_USER] holds
|
||||
* the .config value.
|
||||
*/
|
||||
struct symbol_value def[S_DEF_COUNT];
|
||||
|
||||
/*
|
||||
* An upper bound on the tristate value the user can set for the symbol
|
||||
* if it is a boolean or tristate. Calculated from prompt dependencies,
|
||||
* which also inherit dependencies from enclosing menus, choices, and
|
||||
* ifs. If 'n', the user value will be ignored.
|
||||
*
|
||||
* Symbols lacking prompts always have visibility 'n'.
|
||||
*/
|
||||
tristate visible;
|
||||
|
||||
/* SYMBOL_* flags */
|
||||
int flags;
|
||||
|
||||
/* List of properties. See prop_type. */
|
||||
struct property *prop;
|
||||
|
||||
/* Dependencies from enclosing menus, choices, and ifs */
|
||||
struct expr_value dir_dep;
|
||||
|
||||
/* Reverse dependencies through being selected by other symbols */
|
||||
struct expr_value rev_dep;
|
||||
|
||||
/*
|
||||
* "Weak" reverse dependencies through being implied by other symbols
|
||||
*/
|
||||
struct expr_value implied;
|
||||
};
|
||||
|
||||
@ -133,7 +176,7 @@ enum prop_type {
|
||||
P_UNKNOWN,
|
||||
P_PROMPT, /* prompt "foo prompt" or "BAZ Value" */
|
||||
P_COMMENT, /* text associated with a comment */
|
||||
P_MENU, /* prompt associated with a menuconfig option */
|
||||
P_MENU, /* prompt associated with a menu or menuconfig symbol */
|
||||
P_DEFAULT, /* default y */
|
||||
P_CHOICE, /* choice value */
|
||||
P_SELECT, /* select BAR */
|
||||
@ -166,22 +209,67 @@ struct property {
|
||||
for (st = sym->prop; st; st = st->next) \
|
||||
if (st->text)
|
||||
|
||||
/*
|
||||
* Represents a node in the menu tree, as seen in e.g. menuconfig (though used
|
||||
* for all front ends). Each symbol, menu, etc. defined in the Kconfig files
|
||||
* gets a node. A symbol defined in multiple locations gets one node at each
|
||||
* location.
|
||||
*/
|
||||
struct menu {
|
||||
/* The next menu node at the same level */
|
||||
struct menu *next;
|
||||
|
||||
/* The parent menu node, corresponding to e.g. a menu or choice */
|
||||
struct menu *parent;
|
||||
|
||||
/* The first child menu node, for e.g. menus and choices */
|
||||
struct menu *list;
|
||||
|
||||
/*
|
||||
* The symbol associated with the menu node. Choices are implemented as
|
||||
* a special kind of symbol. NULL for menus, comments, and ifs.
|
||||
*/
|
||||
struct symbol *sym;
|
||||
|
||||
/*
|
||||
* The prompt associated with the node. This holds the prompt for a
|
||||
* symbol as well as the text for a menu or comment, along with the
|
||||
* type (P_PROMPT, P_MENU, etc.)
|
||||
*/
|
||||
struct property *prompt;
|
||||
|
||||
/*
|
||||
* 'visible if' dependencies. If more than one is given, they will be
|
||||
* ANDed together.
|
||||
*/
|
||||
struct expr *visibility;
|
||||
|
||||
/*
|
||||
* Ordinary dependencies from e.g. 'depends on' and 'if', ANDed
|
||||
* together
|
||||
*/
|
||||
struct expr *dep;
|
||||
|
||||
/* MENU_* flags */
|
||||
unsigned int flags;
|
||||
|
||||
/* Any help text associated with the node */
|
||||
char *help;
|
||||
|
||||
/* The location where the menu node appears in the Kconfig files */
|
||||
struct file *file;
|
||||
int lineno;
|
||||
|
||||
/* For use by front ends that need to store auxiliary data */
|
||||
void *data;
|
||||
};
|
||||
|
||||
/*
|
||||
* Set on a menu node when the corresponding symbol changes state in some way.
|
||||
* Can be checked by front ends.
|
||||
*/
|
||||
#define MENU_CHANGED 0x0001
|
||||
|
||||
#define MENU_ROOT 0x0002
|
||||
|
||||
struct jump_key {
|
||||
@ -217,11 +305,12 @@ struct expr *expr_transform(struct expr *e);
|
||||
int expr_contains_symbol(struct expr *dep, struct symbol *sym);
|
||||
bool expr_depends_symbol(struct expr *dep, struct symbol *sym);
|
||||
struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym);
|
||||
struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2);
|
||||
|
||||
void expr_fprint(struct expr *e, FILE *out);
|
||||
struct gstr; /* forward */
|
||||
void expr_gstr_print(struct expr *e, struct gstr *gs);
|
||||
void expr_gstr_print_revdep(struct expr *e, struct gstr *gs,
|
||||
tristate pr_type, const char *title);
|
||||
|
||||
static inline int expr_is_yes(struct expr *e)
|
||||
{
|
||||
|
@ -914,7 +914,7 @@ on_treeview2_button_press_event(GtkWidget * widget,
|
||||
current = menu;
|
||||
display_tree_part();
|
||||
gtk_widget_set_sensitive(back_btn, TRUE);
|
||||
} else if ((col == COL_OPTION)) {
|
||||
} else if (col == COL_OPTION) {
|
||||
toggle_sym_value(menu);
|
||||
gtk_tree_view_expand_row(view, path, TRUE);
|
||||
}
|
||||
|
53
scripts/kconfig/kconf_id.c
Normal file
53
scripts/kconfig/kconf_id.c
Normal file
@ -0,0 +1,53 @@
|
||||
|
||||
static struct kconf_id kconf_id_array[] = {
|
||||
{ "mainmenu", T_MAINMENU, TF_COMMAND },
|
||||
{ "menu", T_MENU, TF_COMMAND },
|
||||
{ "endmenu", T_ENDMENU, TF_COMMAND },
|
||||
{ "source", T_SOURCE, TF_COMMAND },
|
||||
{ "choice", T_CHOICE, TF_COMMAND },
|
||||
{ "endchoice", T_ENDCHOICE, TF_COMMAND },
|
||||
{ "comment", T_COMMENT, TF_COMMAND },
|
||||
{ "config", T_CONFIG, TF_COMMAND },
|
||||
{ "menuconfig", T_MENUCONFIG, TF_COMMAND },
|
||||
{ "help", T_HELP, TF_COMMAND },
|
||||
{ "---help---", T_HELP, TF_COMMAND },
|
||||
{ "if", T_IF, TF_COMMAND|TF_PARAM },
|
||||
{ "endif", T_ENDIF, TF_COMMAND },
|
||||
{ "depends", T_DEPENDS, TF_COMMAND },
|
||||
{ "optional", T_OPTIONAL, TF_COMMAND },
|
||||
{ "default", T_DEFAULT, TF_COMMAND, S_UNKNOWN },
|
||||
{ "prompt", T_PROMPT, TF_COMMAND },
|
||||
{ "tristate", T_TYPE, TF_COMMAND, S_TRISTATE },
|
||||
{ "def_tristate", T_DEFAULT, TF_COMMAND, S_TRISTATE },
|
||||
{ "bool", T_TYPE, TF_COMMAND, S_BOOLEAN },
|
||||
{ "def_bool", T_DEFAULT, TF_COMMAND, S_BOOLEAN },
|
||||
{ "int", T_TYPE, TF_COMMAND, S_INT },
|
||||
{ "hex", T_TYPE, TF_COMMAND, S_HEX },
|
||||
{ "string", T_TYPE, TF_COMMAND, S_STRING },
|
||||
{ "select", T_SELECT, TF_COMMAND },
|
||||
{ "imply", T_IMPLY, TF_COMMAND },
|
||||
{ "range", T_RANGE, TF_COMMAND },
|
||||
{ "visible", T_VISIBLE, TF_COMMAND },
|
||||
{ "option", T_OPTION, TF_COMMAND },
|
||||
{ "on", T_ON, TF_PARAM },
|
||||
{ "modules", T_OPT_MODULES, TF_OPTION },
|
||||
{ "defconfig_list", T_OPT_DEFCONFIG_LIST, TF_OPTION },
|
||||
{ "env", T_OPT_ENV, TF_OPTION },
|
||||
{ "allnoconfig_y", T_OPT_ALLNOCONFIG_Y, TF_OPTION },
|
||||
};
|
||||
|
||||
#define KCONF_ID_ARRAY_SIZE (sizeof(kconf_id_array)/sizeof(struct kconf_id))
|
||||
|
||||
static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < KCONF_ID_ARRAY_SIZE; i++) {
|
||||
struct kconf_id *id = kconf_id_array+i;
|
||||
int l = strlen(id->name);
|
||||
|
||||
if (len == l && !memcmp(str, id->name, len))
|
||||
return id;
|
||||
}
|
||||
return NULL;
|
||||
}
|
@ -101,7 +101,7 @@ static struct message *message__new(const char *msg, char *option,
|
||||
if (self->files == NULL)
|
||||
goto out_fail;
|
||||
|
||||
self->msg = strdup(msg);
|
||||
self->msg = xstrdup(msg);
|
||||
if (self->msg == NULL)
|
||||
goto out_fail_msg;
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#ifndef LIST_H
|
||||
#define LIST_H
|
||||
|
||||
|
@ -62,12 +62,13 @@ enum conf_def_mode {
|
||||
#define T_OPT_ALLNOCONFIG_Y 4
|
||||
|
||||
struct kconf_id {
|
||||
int name;
|
||||
const char *name;
|
||||
int token;
|
||||
unsigned int flags;
|
||||
enum symbol_type stype;
|
||||
};
|
||||
|
||||
extern int yylineno;
|
||||
void zconfdump(FILE *out);
|
||||
void zconf_starthelp(void);
|
||||
FILE *zconf_fopen(const char *name);
|
||||
@ -100,7 +101,6 @@ void menu_warn(struct menu *menu, const char *fmt, ...);
|
||||
struct menu *menu_add_menu(void);
|
||||
void menu_end_menu(void);
|
||||
void menu_add_entry(struct symbol *sym);
|
||||
void menu_end_entry(void);
|
||||
void menu_add_dep(struct expr *dep);
|
||||
void menu_add_visibility(struct expr *dep);
|
||||
struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
|
||||
@ -115,6 +115,8 @@ struct file *file_lookup(const char *name);
|
||||
int file_write_dep(const char *name);
|
||||
void *xmalloc(size_t size);
|
||||
void *xcalloc(size_t nmemb, size_t size);
|
||||
void *xrealloc(void *p, size_t size);
|
||||
char *xstrdup(const char *s);
|
||||
|
||||
struct gstr {
|
||||
size_t len;
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
#include <stdarg.h>
|
||||
|
||||
/* confdata.c */
|
||||
@ -30,7 +31,7 @@ extern struct symbol * symbol_hash[SYMBOL_HASHSIZE];
|
||||
|
||||
struct symbol * sym_lookup(const char *name, int flags);
|
||||
struct symbol * sym_find(const char *name);
|
||||
const char * sym_expand_string_value(const char *in);
|
||||
char *sym_expand_string_value(const char *in);
|
||||
const char * sym_escape_string_value(const char *in);
|
||||
struct symbol ** sym_re_search(const char *pattern);
|
||||
const char * sym_type_name(enum symbol_type type);
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Check ncurses compatibility
|
||||
|
||||
# What library to link
|
||||
@ -54,7 +55,8 @@ EOF
|
||||
echo " *** required header files." 1>&2
|
||||
echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2
|
||||
echo " *** " 1>&2
|
||||
echo " *** Install ncurses (ncurses-devel) and try again." 1>&2
|
||||
echo " *** Install ncurses (ncurses-devel or libncurses-dev " 1>&2
|
||||
echo " *** depending on your distribution) and try again." 1>&2
|
||||
echo " *** " 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
@ -246,7 +246,7 @@ search_help[] = N_(
|
||||
" Selected by: BAR [=n]\n"
|
||||
"-----------------------------------------------------------------\n"
|
||||
"o The line 'Type:' shows the type of the configuration option for\n"
|
||||
" this symbol (boolean, tristate, string, ...)\n"
|
||||
" this symbol (bool, tristate, string, ...)\n"
|
||||
"o The line 'Prompt:' shows the text used in the menu structure for\n"
|
||||
" this symbol\n"
|
||||
"o The 'Defined at' line tells at what file / line number the symbol\n"
|
||||
|
@ -62,13 +62,8 @@ void menu_add_entry(struct symbol *sym)
|
||||
menu_add_symbol(P_SYMBOL, sym, NULL);
|
||||
}
|
||||
|
||||
void menu_end_entry(void)
|
||||
{
|
||||
}
|
||||
|
||||
struct menu *menu_add_menu(void)
|
||||
{
|
||||
menu_end_entry();
|
||||
last_entry_ptr = ¤t_entry->list;
|
||||
return current_menu = current_entry;
|
||||
}
|
||||
@ -79,19 +74,23 @@ void menu_end_menu(void)
|
||||
current_menu = current_menu->parent;
|
||||
}
|
||||
|
||||
static struct expr *menu_check_dep(struct expr *e)
|
||||
/*
|
||||
* Rewrites 'm' to 'm' && MODULES, so that it evaluates to 'n' when running
|
||||
* without modules
|
||||
*/
|
||||
static struct expr *rewrite_m(struct expr *e)
|
||||
{
|
||||
if (!e)
|
||||
return e;
|
||||
|
||||
switch (e->type) {
|
||||
case E_NOT:
|
||||
e->left.expr = menu_check_dep(e->left.expr);
|
||||
e->left.expr = rewrite_m(e->left.expr);
|
||||
break;
|
||||
case E_OR:
|
||||
case E_AND:
|
||||
e->left.expr = menu_check_dep(e->left.expr);
|
||||
e->right.expr = menu_check_dep(e->right.expr);
|
||||
e->left.expr = rewrite_m(e->left.expr);
|
||||
e->right.expr = rewrite_m(e->right.expr);
|
||||
break;
|
||||
case E_SYMBOL:
|
||||
/* change 'm' into 'm' && MODULES */
|
||||
@ -106,7 +105,7 @@ static struct expr *menu_check_dep(struct expr *e)
|
||||
|
||||
void menu_add_dep(struct expr *dep)
|
||||
{
|
||||
current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep));
|
||||
current_entry->dep = expr_alloc_and(current_entry->dep, dep);
|
||||
}
|
||||
|
||||
void menu_set_type(int type)
|
||||
@ -131,7 +130,7 @@ static struct property *menu_add_prop(enum prop_type type, char *prompt, struct
|
||||
|
||||
prop->menu = current_entry;
|
||||
prop->expr = expr;
|
||||
prop->visible.expr = menu_check_dep(dep);
|
||||
prop->visible.expr = dep;
|
||||
|
||||
if (prompt) {
|
||||
if (isspace(*prompt)) {
|
||||
@ -213,6 +212,7 @@ void menu_add_option(int token, char *arg)
|
||||
sym_defconfig_list = current_entry->sym;
|
||||
else if (sym_defconfig_list != current_entry->sym)
|
||||
zconf_error("trying to redefine defconfig symbol");
|
||||
sym_defconfig_list->flags |= SYMBOL_AUTO;
|
||||
break;
|
||||
case T_OPT_ENV:
|
||||
prop_add_env(arg);
|
||||
@ -252,6 +252,16 @@ static void sym_check_prop(struct symbol *sym)
|
||||
"'%s': number is invalid",
|
||||
sym->name);
|
||||
}
|
||||
if (sym_is_choice(sym)) {
|
||||
struct property *choice_prop =
|
||||
sym_get_choice_prop(sym2);
|
||||
|
||||
if (!choice_prop ||
|
||||
prop_get_symbol(choice_prop) != sym)
|
||||
prop_warn(prop,
|
||||
"choice default symbol '%s' is not contained in the choice",
|
||||
sym2->name);
|
||||
}
|
||||
break;
|
||||
case P_SELECT:
|
||||
case P_IMPLY:
|
||||
@ -260,13 +270,13 @@ static void sym_check_prop(struct symbol *sym)
|
||||
if (sym->type != S_BOOLEAN && sym->type != S_TRISTATE)
|
||||
prop_warn(prop,
|
||||
"config symbol '%s' uses %s, but is "
|
||||
"not boolean or tristate", sym->name, use);
|
||||
"not bool or tristate", sym->name, use);
|
||||
else if (sym2->type != S_UNKNOWN &&
|
||||
sym2->type != S_BOOLEAN &&
|
||||
sym2->type != S_TRISTATE)
|
||||
prop_warn(prop,
|
||||
"'%s' has wrong type. '%s' only "
|
||||
"accept arguments of boolean and "
|
||||
"accept arguments of bool and "
|
||||
"tristate type", sym2->name, use);
|
||||
break;
|
||||
case P_RANGE:
|
||||
@ -292,6 +302,11 @@ void menu_finalize(struct menu *parent)
|
||||
|
||||
sym = parent->sym;
|
||||
if (parent->list) {
|
||||
/*
|
||||
* This menu node has children. We (recursively) process them
|
||||
* and propagate parent dependencies before moving on.
|
||||
*/
|
||||
|
||||
if (sym && sym_is_choice(sym)) {
|
||||
if (sym->type == S_UNKNOWN) {
|
||||
/* find the first choice value to find out choice type */
|
||||
@ -309,30 +324,83 @@ void menu_finalize(struct menu *parent)
|
||||
if (menu->sym && menu->sym->type == S_UNKNOWN)
|
||||
menu_set_type(sym->type);
|
||||
}
|
||||
|
||||
/*
|
||||
* Use the choice itself as the parent dependency of
|
||||
* the contained items. This turns the mode of the
|
||||
* choice into an upper bound on the visibility of the
|
||||
* choice value symbols.
|
||||
*/
|
||||
parentdep = expr_alloc_symbol(sym);
|
||||
} else if (parent->prompt)
|
||||
/* Menu node for 'menu' */
|
||||
parentdep = parent->prompt->visible.expr;
|
||||
else
|
||||
/* Menu node for 'if' */
|
||||
parentdep = parent->dep;
|
||||
|
||||
/* For each child menu node... */
|
||||
for (menu = parent->list; menu; menu = menu->next) {
|
||||
basedep = expr_transform(menu->dep);
|
||||
/*
|
||||
* Propagate parent dependencies to the child menu
|
||||
* node, also rewriting and simplifying expressions
|
||||
*/
|
||||
basedep = rewrite_m(menu->dep);
|
||||
basedep = expr_transform(basedep);
|
||||
basedep = expr_alloc_and(expr_copy(parentdep), basedep);
|
||||
basedep = expr_eliminate_dups(basedep);
|
||||
menu->dep = basedep;
|
||||
|
||||
if (menu->sym)
|
||||
/*
|
||||
* Note: For symbols, all prompts are included
|
||||
* too in the symbol's own property list
|
||||
*/
|
||||
prop = menu->sym->prop;
|
||||
else
|
||||
/*
|
||||
* For non-symbol menu nodes, we just need to
|
||||
* handle the prompt
|
||||
*/
|
||||
prop = menu->prompt;
|
||||
|
||||
/* For each property... */
|
||||
for (; prop; prop = prop->next) {
|
||||
if (prop->menu != menu)
|
||||
/*
|
||||
* Two possibilities:
|
||||
*
|
||||
* 1. The property lacks dependencies
|
||||
* and so isn't location-specific,
|
||||
* e.g. an 'option'
|
||||
*
|
||||
* 2. The property belongs to a symbol
|
||||
* defined in multiple locations and
|
||||
* is from some other location. It
|
||||
* will be handled there in that
|
||||
* case.
|
||||
*
|
||||
* Skip the property.
|
||||
*/
|
||||
continue;
|
||||
dep = expr_transform(prop->visible.expr);
|
||||
|
||||
/*
|
||||
* Propagate parent dependencies to the
|
||||
* property's condition, rewriting and
|
||||
* simplifying expressions at the same time
|
||||
*/
|
||||
dep = rewrite_m(prop->visible.expr);
|
||||
dep = expr_transform(dep);
|
||||
dep = expr_alloc_and(expr_copy(basedep), dep);
|
||||
dep = expr_eliminate_dups(dep);
|
||||
if (menu->sym && menu->sym->type != S_TRISTATE)
|
||||
dep = expr_trans_bool(dep);
|
||||
prop->visible.expr = dep;
|
||||
|
||||
/*
|
||||
* Handle selects and implies, which modify the
|
||||
* dependencies of the selected/implied symbol
|
||||
*/
|
||||
if (prop->type == P_SELECT) {
|
||||
struct symbol *es = prop_get_symbol(prop);
|
||||
es->rev_dep.expr = expr_alloc_or(es->rev_dep.expr,
|
||||
@ -344,34 +412,81 @@ void menu_finalize(struct menu *parent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sym && sym_is_choice(sym))
|
||||
expr_free(parentdep);
|
||||
|
||||
/*
|
||||
* Recursively process children in the same fashion before
|
||||
* moving on
|
||||
*/
|
||||
for (menu = parent->list; menu; menu = menu->next)
|
||||
menu_finalize(menu);
|
||||
} else if (sym) {
|
||||
/*
|
||||
* Automatic submenu creation. If sym is a symbol and A, B, C,
|
||||
* ... are consecutive items (symbols, menus, ifs, etc.) that
|
||||
* all depend on sym, then the following menu structure is
|
||||
* created:
|
||||
*
|
||||
* sym
|
||||
* +-A
|
||||
* +-B
|
||||
* +-C
|
||||
* ...
|
||||
*
|
||||
* This also works recursively, giving the following structure
|
||||
* if A is a symbol and B depends on A:
|
||||
*
|
||||
* sym
|
||||
* +-A
|
||||
* | +-B
|
||||
* +-C
|
||||
* ...
|
||||
*/
|
||||
|
||||
basedep = parent->prompt ? parent->prompt->visible.expr : NULL;
|
||||
basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no);
|
||||
basedep = expr_eliminate_dups(expr_transform(basedep));
|
||||
|
||||
/* Examine consecutive elements after sym */
|
||||
last_menu = NULL;
|
||||
for (menu = parent->next; menu; menu = menu->next) {
|
||||
dep = menu->prompt ? menu->prompt->visible.expr : menu->dep;
|
||||
if (!expr_contains_symbol(dep, sym))
|
||||
/* No dependency, quit */
|
||||
break;
|
||||
if (expr_depends_symbol(dep, sym))
|
||||
/* Absolute dependency, put in submenu */
|
||||
goto next;
|
||||
|
||||
/*
|
||||
* Also consider it a dependency on sym if our
|
||||
* dependencies contain sym and are a "superset" of
|
||||
* sym's dependencies, e.g. '(sym || Q) && R' when sym
|
||||
* depends on R.
|
||||
*
|
||||
* Note that 'R' might be from an enclosing menu or if,
|
||||
* making this a more common case than it might seem.
|
||||
*/
|
||||
dep = expr_trans_compare(dep, E_UNEQUAL, &symbol_no);
|
||||
dep = expr_eliminate_dups(expr_transform(dep));
|
||||
dep2 = expr_copy(basedep);
|
||||
expr_eliminate_eq(&dep, &dep2);
|
||||
expr_free(dep);
|
||||
if (!expr_is_yes(dep2)) {
|
||||
/* Not superset, quit */
|
||||
expr_free(dep2);
|
||||
break;
|
||||
}
|
||||
/* Superset, put in submenu */
|
||||
expr_free(dep2);
|
||||
next:
|
||||
menu_finalize(menu);
|
||||
menu->parent = parent;
|
||||
last_menu = menu;
|
||||
}
|
||||
expr_free(basedep);
|
||||
if (last_menu) {
|
||||
parent->list = parent->next;
|
||||
parent->next = last_menu->next;
|
||||
@ -420,6 +535,35 @@ void menu_finalize(struct menu *parent)
|
||||
*ep = expr_alloc_one(E_LIST, NULL);
|
||||
(*ep)->right.sym = menu->sym;
|
||||
}
|
||||
|
||||
/*
|
||||
* This code serves two purposes:
|
||||
*
|
||||
* (1) Flattening 'if' blocks, which do not specify a submenu
|
||||
* and only add dependencies.
|
||||
*
|
||||
* (Automatic submenu creation might still create a submenu
|
||||
* from an 'if' before this code runs.)
|
||||
*
|
||||
* (2) "Undoing" any automatic submenus created earlier below
|
||||
* promptless symbols.
|
||||
*
|
||||
* Before:
|
||||
*
|
||||
* A
|
||||
* if ... (or promptless symbol)
|
||||
* +-B
|
||||
* +-C
|
||||
* D
|
||||
*
|
||||
* After:
|
||||
*
|
||||
* A
|
||||
* if ... (or promptless symbol)
|
||||
* B
|
||||
* C
|
||||
* D
|
||||
*/
|
||||
if (menu->list && (!menu->prompt || !menu->prompt->text)) {
|
||||
for (last_menu = menu->list; ; last_menu = last_menu->next) {
|
||||
last_menu->parent = parent;
|
||||
@ -444,6 +588,15 @@ void menu_finalize(struct menu *parent)
|
||||
sym->flags |= SYMBOL_WARNED;
|
||||
}
|
||||
|
||||
/*
|
||||
* For non-optional choices, add a reverse dependency (corresponding to
|
||||
* a select) of '<visibility> && m'. This prevents the user from
|
||||
* setting the choice mode to 'n' when the choice is visible.
|
||||
*
|
||||
* This would also work for non-choice symbols, but only non-optional
|
||||
* choices clear SYMBOL_OPTIONAL as of writing. Choices are implemented
|
||||
* as a type of symbol.
|
||||
*/
|
||||
if (sym && !sym_is_optional(sym) && parent->prompt) {
|
||||
sym->rev_dep.expr = expr_alloc_or(sym->rev_dep.expr,
|
||||
expr_alloc_and(parent->prompt->visible.expr,
|
||||
@ -675,16 +828,16 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym,
|
||||
|
||||
get_symbol_props_str(r, sym, P_SELECT, _(" Selects: "));
|
||||
if (sym->rev_dep.expr) {
|
||||
str_append(r, _(" Selected by: "));
|
||||
expr_gstr_print(sym->rev_dep.expr, r);
|
||||
str_append(r, "\n");
|
||||
expr_gstr_print_revdep(sym->rev_dep.expr, r, yes, " Selected by [y]:\n");
|
||||
expr_gstr_print_revdep(sym->rev_dep.expr, r, mod, " Selected by [m]:\n");
|
||||
expr_gstr_print_revdep(sym->rev_dep.expr, r, no, " Selected by [n]:\n");
|
||||
}
|
||||
|
||||
get_symbol_props_str(r, sym, P_IMPLY, _(" Implies: "));
|
||||
if (sym->implied.expr) {
|
||||
str_append(r, _(" Implied by: "));
|
||||
expr_gstr_print(sym->implied.expr, r);
|
||||
str_append(r, "\n");
|
||||
expr_gstr_print_revdep(sym->implied.expr, r, yes, " Implied by [y]:\n");
|
||||
expr_gstr_print_revdep(sym->implied.expr, r, mod, " Implied by [m]:\n");
|
||||
expr_gstr_print_revdep(sym->implied.expr, r, no, " Implied by [n]:\n");
|
||||
}
|
||||
|
||||
str_append(r, "\n\n");
|
||||
|
@ -271,7 +271,7 @@ static struct mitem k_menu_items[MAX_MENU_ITEMS];
|
||||
static int items_num;
|
||||
static int global_exit;
|
||||
/* the currently selected button */
|
||||
const char *current_instructions = menu_instructions;
|
||||
static const char *current_instructions = menu_instructions;
|
||||
|
||||
static char *dialog_input_result;
|
||||
static int dialog_input_result_len;
|
||||
@ -305,7 +305,7 @@ struct function_keys {
|
||||
};
|
||||
|
||||
static const int function_keys_num = 9;
|
||||
struct function_keys function_keys[] = {
|
||||
static struct function_keys function_keys[] = {
|
||||
{
|
||||
.key_str = "F1",
|
||||
.func = "Help",
|
||||
@ -508,7 +508,7 @@ static int get_mext_match(const char *match_str, match_f flag)
|
||||
index = (index + items_num) % items_num;
|
||||
while (true) {
|
||||
char *str = k_menu_items[index].str;
|
||||
if (strcasestr(str, match_str) != 0)
|
||||
if (strcasestr(str, match_str) != NULL)
|
||||
return index;
|
||||
if (flag == FIND_NEXT_MATCH_UP ||
|
||||
flag == MATCH_TINKER_PATTERN_UP)
|
||||
@ -1067,7 +1067,7 @@ static int do_match(int key, struct match_state *state, int *ans)
|
||||
|
||||
static void conf(struct menu *menu)
|
||||
{
|
||||
struct menu *submenu = 0;
|
||||
struct menu *submenu = NULL;
|
||||
const char *prompt = menu_get_prompt(menu);
|
||||
struct symbol *sym;
|
||||
int res;
|
||||
@ -1234,7 +1234,7 @@ static void show_help(struct menu *menu)
|
||||
static void conf_choice(struct menu *menu)
|
||||
{
|
||||
const char *prompt = _(menu_get_prompt(menu));
|
||||
struct menu *child = 0;
|
||||
struct menu *child = NULL;
|
||||
struct symbol *active;
|
||||
int selected_index = 0;
|
||||
int last_top_row = 0;
|
||||
@ -1456,7 +1456,7 @@ static void conf_save(void)
|
||||
}
|
||||
}
|
||||
|
||||
void setup_windows(void)
|
||||
static void setup_windows(void)
|
||||
{
|
||||
int lines, columns;
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
*
|
||||
*/
|
||||
#include "nconf.h"
|
||||
#include "lkc.h"
|
||||
|
||||
/* a list of all the different widgets we use */
|
||||
attributes_t attributes[ATTR_MAX+1] = {0};
|
||||
@ -129,7 +130,7 @@ static void no_colors_theme(void)
|
||||
mkattrn(FUNCTION_TEXT, A_REVERSE);
|
||||
}
|
||||
|
||||
void set_colors()
|
||||
void set_colors(void)
|
||||
{
|
||||
start_color();
|
||||
use_default_colors();
|
||||
@ -192,7 +193,7 @@ const char *get_line(const char *text, int line_no)
|
||||
int lines = 0;
|
||||
|
||||
if (!text)
|
||||
return 0;
|
||||
return NULL;
|
||||
|
||||
for (i = 0; text[i] != '\0' && lines < line_no; i++)
|
||||
if (text[i] == '\n')
|
||||
@ -374,7 +375,7 @@ int dialog_inputbox(WINDOW *main_window,
|
||||
|
||||
if (strlen(init)+1 > *result_len) {
|
||||
*result_len = strlen(init)+1;
|
||||
*resultp = result = realloc(result, *result_len);
|
||||
*resultp = result = xrealloc(result, *result_len);
|
||||
}
|
||||
|
||||
/* find the widest line of msg: */
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <locale.h>
|
||||
#include <curses.h>
|
||||
#include <ncurses.h>
|
||||
#include <menu.h>
|
||||
#include <panel.h>
|
||||
#include <form.h>
|
||||
@ -24,8 +24,6 @@
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "ncurses.h"
|
||||
|
||||
#define max(a, b) ({\
|
||||
typeof(a) _a = a;\
|
||||
typeof(b) _b = b;\
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/perl -w
|
||||
#!/usr/bin/env perl
|
||||
#
|
||||
# Copyright 2005-2009 - Steven Rostedt
|
||||
# Licensed under the terms of the GNU GPL License version 2
|
||||
@ -42,6 +42,7 @@
|
||||
# mv config_strip .config
|
||||
# make oldconfig
|
||||
#
|
||||
use warnings;
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
|
||||
|
@ -77,7 +77,7 @@ const char *sym_type_name(enum symbol_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case S_BOOLEAN:
|
||||
return "boolean";
|
||||
return "bool";
|
||||
case S_TRISTATE:
|
||||
return "tristate";
|
||||
case S_INT:
|
||||
@ -183,7 +183,7 @@ static void sym_validate_range(struct symbol *sym)
|
||||
sprintf(str, "%lld", val2);
|
||||
else
|
||||
sprintf(str, "0x%llx", val2);
|
||||
sym->curr.val = strdup(str);
|
||||
sym->curr.val = xstrdup(str);
|
||||
}
|
||||
|
||||
static void sym_set_changed(struct symbol *sym)
|
||||
@ -243,7 +243,7 @@ static void sym_calc_visibility(struct symbol *sym)
|
||||
tri = yes;
|
||||
if (sym->dir_dep.expr)
|
||||
tri = expr_calc_value(sym->dir_dep.expr);
|
||||
if (tri == mod)
|
||||
if (tri == mod && sym_get_type(sym) == S_BOOLEAN)
|
||||
tri = yes;
|
||||
if (sym->dir_dep.tri != tri) {
|
||||
sym->dir_dep.tri = tri;
|
||||
@ -333,6 +333,27 @@ static struct symbol *sym_calc_choice(struct symbol *sym)
|
||||
return def_sym;
|
||||
}
|
||||
|
||||
static void sym_warn_unmet_dep(struct symbol *sym)
|
||||
{
|
||||
struct gstr gs = str_new();
|
||||
|
||||
str_printf(&gs,
|
||||
"\nWARNING: unmet direct dependencies detected for %s\n",
|
||||
sym->name);
|
||||
str_printf(&gs,
|
||||
" Depends on [%c]: ",
|
||||
sym->dir_dep.tri == mod ? 'm' : 'n');
|
||||
expr_gstr_print(sym->dir_dep.expr, &gs);
|
||||
str_printf(&gs, "\n");
|
||||
|
||||
expr_gstr_print_revdep(sym->rev_dep.expr, &gs, yes,
|
||||
" Selected by [y]:\n");
|
||||
expr_gstr_print_revdep(sym->rev_dep.expr, &gs, mod,
|
||||
" Selected by [m]:\n");
|
||||
|
||||
fputs(str_get(&gs), stderr);
|
||||
}
|
||||
|
||||
void sym_calc_value(struct symbol *sym)
|
||||
{
|
||||
struct symbol_value newval, oldval;
|
||||
@ -371,11 +392,13 @@ void sym_calc_value(struct symbol *sym)
|
||||
sym->curr.tri = no;
|
||||
return;
|
||||
}
|
||||
if (!sym_is_choice_value(sym))
|
||||
sym->flags &= ~SYMBOL_WRITE;
|
||||
|
||||
sym_calc_visibility(sym);
|
||||
|
||||
if (sym->visible != no)
|
||||
sym->flags |= SYMBOL_WRITE;
|
||||
|
||||
/* set default if recursively called */
|
||||
sym->curr = newval;
|
||||
|
||||
@ -390,7 +413,6 @@ void sym_calc_value(struct symbol *sym)
|
||||
/* if the symbol is visible use the user value
|
||||
* if available, otherwise try the default value
|
||||
*/
|
||||
sym->flags |= SYMBOL_WRITE;
|
||||
if (sym_has_value(sym)) {
|
||||
newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri,
|
||||
sym->visible);
|
||||
@ -402,9 +424,10 @@ void sym_calc_value(struct symbol *sym)
|
||||
if (!sym_is_choice(sym)) {
|
||||
prop = sym_get_default_prop(sym);
|
||||
if (prop) {
|
||||
sym->flags |= SYMBOL_WRITE;
|
||||
newval.tri = EXPR_AND(expr_calc_value(prop->expr),
|
||||
prop->visible.tri);
|
||||
if (newval.tri != no)
|
||||
sym->flags |= SYMBOL_WRITE;
|
||||
}
|
||||
if (sym->implied.tri != no) {
|
||||
sym->flags |= SYMBOL_WRITE;
|
||||
@ -412,18 +435,8 @@ void sym_calc_value(struct symbol *sym)
|
||||
}
|
||||
}
|
||||
calc_newval:
|
||||
if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) {
|
||||
struct expr *e;
|
||||
e = expr_simplify_unmet_dep(sym->rev_dep.expr,
|
||||
sym->dir_dep.expr);
|
||||
fprintf(stderr, "warning: (");
|
||||
expr_fprint(e, stderr);
|
||||
fprintf(stderr, ") selects %s which has unmet direct dependencies (",
|
||||
sym->name);
|
||||
expr_fprint(sym->dir_dep.expr, stderr);
|
||||
fprintf(stderr, ")\n");
|
||||
expr_free(e);
|
||||
}
|
||||
if (sym->dir_dep.tri < sym->rev_dep.tri)
|
||||
sym_warn_unmet_dep(sym);
|
||||
newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
|
||||
}
|
||||
if (newval.tri == mod &&
|
||||
@ -433,13 +446,10 @@ void sym_calc_value(struct symbol *sym)
|
||||
case S_STRING:
|
||||
case S_HEX:
|
||||
case S_INT:
|
||||
if (sym->visible != no) {
|
||||
sym->flags |= SYMBOL_WRITE;
|
||||
if (sym_has_value(sym)) {
|
||||
if (sym->visible != no && sym_has_value(sym)) {
|
||||
newval.val = sym->def[S_DEF_USER].val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
prop = sym_get_default_prop(sym);
|
||||
if (prop) {
|
||||
struct symbol *ds = prop_get_symbol(prop);
|
||||
@ -851,7 +861,7 @@ struct symbol *sym_lookup(const char *name, int flags)
|
||||
: !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE))))
|
||||
return symbol;
|
||||
}
|
||||
new_name = strdup(name);
|
||||
new_name = xstrdup(name);
|
||||
} else {
|
||||
new_name = NULL;
|
||||
hash = 0;
|
||||
@ -901,12 +911,16 @@ struct symbol *sym_find(const char *name)
|
||||
* name to be expanded shall be prefixed by a '$'. Unknown symbol expands to
|
||||
* the empty string.
|
||||
*/
|
||||
const char *sym_expand_string_value(const char *in)
|
||||
char *sym_expand_string_value(const char *in)
|
||||
{
|
||||
const char *src;
|
||||
char *res;
|
||||
size_t reslen;
|
||||
|
||||
/*
|
||||
* Note: 'in' might come from a token that's about to be
|
||||
* freed, so make sure to always allocate a new string
|
||||
*/
|
||||
reslen = strlen(in) + 1;
|
||||
res = xmalloc(reslen);
|
||||
res[0] = '\0';
|
||||
@ -934,7 +948,7 @@ const char *sym_expand_string_value(const char *in)
|
||||
newlen = strlen(res) + strlen(symval) + strlen(src) + 1;
|
||||
if (newlen > reslen) {
|
||||
reslen = newlen;
|
||||
res = realloc(res, reslen);
|
||||
res = xrealloc(res, reslen);
|
||||
}
|
||||
|
||||
strcat(res, symval);
|
||||
@ -1150,8 +1164,7 @@ static void sym_check_print_recursive(struct symbol *last_sym)
|
||||
if (stack->sym == last_sym)
|
||||
fprintf(stderr, "%s:%d:error: recursive dependency detected!\n",
|
||||
prop->file->name, prop->lineno);
|
||||
fprintf(stderr, "For a resolution refer to Documentation/kbuild/kconfig-language.txt\n");
|
||||
fprintf(stderr, "subsection \"Kconfig recursive dependency limitations\"\n");
|
||||
|
||||
if (stack->expr) {
|
||||
fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n",
|
||||
prop->file->name, prop->lineno,
|
||||
@ -1181,6 +1194,11 @@ static void sym_check_print_recursive(struct symbol *last_sym)
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr,
|
||||
"For a resolution refer to Documentation/kbuild/kconfig-language.txt\n"
|
||||
"subsection \"Kconfig recursive dependency limitations\"\n"
|
||||
"\n");
|
||||
|
||||
if (check_top == &cv_stack)
|
||||
dep_stack_remove();
|
||||
}
|
||||
@ -1215,7 +1233,7 @@ static struct symbol *sym_check_expr_deps(struct expr *e)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
printf("Oops! How to check %d?\n", e->type);
|
||||
fprintf(stderr, "Oops! How to check %d?\n", e->type);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
50
scripts/kconfig/tests/auto_submenu/Kconfig
Normal file
50
scripts/kconfig/tests/auto_submenu/Kconfig
Normal file
@ -0,0 +1,50 @@
|
||||
config A
|
||||
bool "A"
|
||||
default y
|
||||
|
||||
config A0
|
||||
bool "A0"
|
||||
depends on A
|
||||
default y
|
||||
help
|
||||
This depends on A, so should be a submenu of A.
|
||||
|
||||
config A0_0
|
||||
bool "A1_0"
|
||||
depends on A0
|
||||
help
|
||||
Submenus are created recursively.
|
||||
This should be a submenu of A0.
|
||||
|
||||
config A1
|
||||
bool "A1"
|
||||
depends on A
|
||||
default y
|
||||
help
|
||||
This should line up with A0.
|
||||
|
||||
choice
|
||||
prompt "choice"
|
||||
depends on A1
|
||||
help
|
||||
Choice should become a submenu as well.
|
||||
|
||||
config A1_0
|
||||
bool "A1_0"
|
||||
|
||||
config A1_1
|
||||
bool "A1_1"
|
||||
|
||||
endchoice
|
||||
|
||||
config B
|
||||
bool "B"
|
||||
help
|
||||
This is independent of A.
|
||||
|
||||
config C
|
||||
bool "C"
|
||||
depends on A
|
||||
help
|
||||
This depends on A, but not a consecutive item, so can/should not
|
||||
be a submenu.
|
12
scripts/kconfig/tests/auto_submenu/__init__.py
Normal file
12
scripts/kconfig/tests/auto_submenu/__init__.py
Normal file
@ -0,0 +1,12 @@
|
||||
"""
|
||||
Create submenu for symbols that depend on the preceding one.
|
||||
|
||||
If a symbols has dependency on the preceding symbol, the menu entry
|
||||
should become the submenu of the preceding one, and displayed with
|
||||
deeper indentation.
|
||||
"""
|
||||
|
||||
|
||||
def test(conf):
|
||||
assert conf.oldaskconfig() == 0
|
||||
assert conf.stdout_contains('expected_stdout')
|
10
scripts/kconfig/tests/auto_submenu/expected_stdout
Normal file
10
scripts/kconfig/tests/auto_submenu/expected_stdout
Normal file
@ -0,0 +1,10 @@
|
||||
A (A) [Y/n/?] (NEW)
|
||||
A0 (A0) [Y/n/?] (NEW)
|
||||
A1_0 (A0_0) [N/y/?] (NEW)
|
||||
A1 (A1) [Y/n/?] (NEW)
|
||||
choice
|
||||
> 1. A1_0 (A1_0) (NEW)
|
||||
2. A1_1 (A1_1) (NEW)
|
||||
choice[1-2?]:
|
||||
B (B) [N/y/?] (NEW)
|
||||
C (C) [N/y/?] (NEW)
|
54
scripts/kconfig/tests/choice/Kconfig
Normal file
54
scripts/kconfig/tests/choice/Kconfig
Normal file
@ -0,0 +1,54 @@
|
||||
config MODULES
|
||||
bool "Enable loadable module support"
|
||||
option modules
|
||||
default y
|
||||
|
||||
choice
|
||||
prompt "boolean choice"
|
||||
default BOOL_CHOICE1
|
||||
|
||||
config BOOL_CHOICE0
|
||||
bool "choice 0"
|
||||
|
||||
config BOOL_CHOICE1
|
||||
bool "choice 1"
|
||||
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "optional boolean choice"
|
||||
optional
|
||||
default OPT_BOOL_CHOICE1
|
||||
|
||||
config OPT_BOOL_CHOICE0
|
||||
bool "choice 0"
|
||||
|
||||
config OPT_BOOL_CHOICE1
|
||||
bool "choice 1"
|
||||
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "tristate choice"
|
||||
default TRI_CHOICE1
|
||||
|
||||
config TRI_CHOICE0
|
||||
tristate "choice 0"
|
||||
|
||||
config TRI_CHOICE1
|
||||
tristate "choice 1"
|
||||
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "optional tristate choice"
|
||||
optional
|
||||
default OPT_TRI_CHOICE1
|
||||
|
||||
config OPT_TRI_CHOICE0
|
||||
tristate "choice 0"
|
||||
|
||||
config OPT_TRI_CHOICE1
|
||||
tristate "choice 1"
|
||||
|
||||
endchoice
|
40
scripts/kconfig/tests/choice/__init__.py
Normal file
40
scripts/kconfig/tests/choice/__init__.py
Normal file
@ -0,0 +1,40 @@
|
||||
"""
|
||||
Basic choice tests.
|
||||
|
||||
The handling of 'choice' is a bit complicated part in Kconfig.
|
||||
|
||||
The behavior of 'y' choice is intuitive. If choice values are tristate,
|
||||
the choice can be 'm' where each value can be enabled independently.
|
||||
Also, if a choice is marked as 'optional', the whole choice can be
|
||||
invisible.
|
||||
"""
|
||||
|
||||
|
||||
def test_oldask0(conf):
|
||||
assert conf.oldaskconfig() == 0
|
||||
assert conf.stdout_contains('oldask0_expected_stdout')
|
||||
|
||||
|
||||
def test_oldask1(conf):
|
||||
assert conf.oldaskconfig('oldask1_config') == 0
|
||||
assert conf.stdout_contains('oldask1_expected_stdout')
|
||||
|
||||
|
||||
def test_allyes(conf):
|
||||
assert conf.allyesconfig() == 0
|
||||
assert conf.config_contains('allyes_expected_config')
|
||||
|
||||
|
||||
def test_allmod(conf):
|
||||
assert conf.allmodconfig() == 0
|
||||
assert conf.config_contains('allmod_expected_config')
|
||||
|
||||
|
||||
def test_allno(conf):
|
||||
assert conf.allnoconfig() == 0
|
||||
assert conf.config_contains('allno_expected_config')
|
||||
|
||||
|
||||
def test_alldef(conf):
|
||||
assert conf.alldefconfig() == 0
|
||||
assert conf.config_contains('alldef_expected_config')
|
5
scripts/kconfig/tests/choice/alldef_expected_config
Normal file
5
scripts/kconfig/tests/choice/alldef_expected_config
Normal file
@ -0,0 +1,5 @@
|
||||
CONFIG_MODULES=y
|
||||
# CONFIG_BOOL_CHOICE0 is not set
|
||||
CONFIG_BOOL_CHOICE1=y
|
||||
# CONFIG_TRI_CHOICE0 is not set
|
||||
# CONFIG_TRI_CHOICE1 is not set
|
9
scripts/kconfig/tests/choice/allmod_expected_config
Normal file
9
scripts/kconfig/tests/choice/allmod_expected_config
Normal file
@ -0,0 +1,9 @@
|
||||
CONFIG_MODULES=y
|
||||
# CONFIG_BOOL_CHOICE0 is not set
|
||||
CONFIG_BOOL_CHOICE1=y
|
||||
# CONFIG_OPT_BOOL_CHOICE0 is not set
|
||||
CONFIG_OPT_BOOL_CHOICE1=y
|
||||
CONFIG_TRI_CHOICE0=m
|
||||
CONFIG_TRI_CHOICE1=m
|
||||
CONFIG_OPT_TRI_CHOICE0=m
|
||||
CONFIG_OPT_TRI_CHOICE1=m
|
5
scripts/kconfig/tests/choice/allno_expected_config
Normal file
5
scripts/kconfig/tests/choice/allno_expected_config
Normal file
@ -0,0 +1,5 @@
|
||||
# CONFIG_MODULES is not set
|
||||
# CONFIG_BOOL_CHOICE0 is not set
|
||||
CONFIG_BOOL_CHOICE1=y
|
||||
# CONFIG_TRI_CHOICE0 is not set
|
||||
CONFIG_TRI_CHOICE1=y
|
9
scripts/kconfig/tests/choice/allyes_expected_config
Normal file
9
scripts/kconfig/tests/choice/allyes_expected_config
Normal file
@ -0,0 +1,9 @@
|
||||
CONFIG_MODULES=y
|
||||
# CONFIG_BOOL_CHOICE0 is not set
|
||||
CONFIG_BOOL_CHOICE1=y
|
||||
# CONFIG_OPT_BOOL_CHOICE0 is not set
|
||||
CONFIG_OPT_BOOL_CHOICE1=y
|
||||
# CONFIG_TRI_CHOICE0 is not set
|
||||
CONFIG_TRI_CHOICE1=y
|
||||
# CONFIG_OPT_TRI_CHOICE0 is not set
|
||||
CONFIG_OPT_TRI_CHOICE1=y
|
10
scripts/kconfig/tests/choice/oldask0_expected_stdout
Normal file
10
scripts/kconfig/tests/choice/oldask0_expected_stdout
Normal file
@ -0,0 +1,10 @@
|
||||
Enable loadable module support (MODULES) [Y/n/?] (NEW)
|
||||
boolean choice
|
||||
1. choice 0 (BOOL_CHOICE0) (NEW)
|
||||
> 2. choice 1 (BOOL_CHOICE1) (NEW)
|
||||
choice[1-2?]:
|
||||
optional boolean choice [N/y/?] (NEW)
|
||||
tristate choice [M/y/?] (NEW)
|
||||
choice 0 (TRI_CHOICE0) [N/m/?] (NEW)
|
||||
choice 1 (TRI_CHOICE1) [N/m/?] (NEW)
|
||||
optional tristate choice [N/m/y/?] (NEW)
|
2
scripts/kconfig/tests/choice/oldask1_config
Normal file
2
scripts/kconfig/tests/choice/oldask1_config
Normal file
@ -0,0 +1,2 @@
|
||||
# CONFIG_MODULES is not set
|
||||
CONFIG_OPT_BOOL_CHOICE0=y
|
15
scripts/kconfig/tests/choice/oldask1_expected_stdout
Normal file
15
scripts/kconfig/tests/choice/oldask1_expected_stdout
Normal file
@ -0,0 +1,15 @@
|
||||
Enable loadable module support (MODULES) [N/y/?]
|
||||
boolean choice
|
||||
1. choice 0 (BOOL_CHOICE0) (NEW)
|
||||
> 2. choice 1 (BOOL_CHOICE1) (NEW)
|
||||
choice[1-2?]:
|
||||
optional boolean choice [Y/n/?] (NEW)
|
||||
optional boolean choice
|
||||
> 1. choice 0 (OPT_BOOL_CHOICE0)
|
||||
2. choice 1 (OPT_BOOL_CHOICE1) (NEW)
|
||||
choice[1-2?]:
|
||||
tristate choice
|
||||
1. choice 0 (TRI_CHOICE0) (NEW)
|
||||
> 2. choice 1 (TRI_CHOICE1) (NEW)
|
||||
choice[1-2?]:
|
||||
optional tristate choice [N/y/?]
|
19
scripts/kconfig/tests/choice_value_with_m_dep/Kconfig
Normal file
19
scripts/kconfig/tests/choice_value_with_m_dep/Kconfig
Normal file
@ -0,0 +1,19 @@
|
||||
config MODULES
|
||||
def_bool y
|
||||
option modules
|
||||
|
||||
config DEP
|
||||
tristate
|
||||
default m
|
||||
|
||||
choice
|
||||
prompt "Tristate Choice"
|
||||
|
||||
config CHOICE0
|
||||
tristate "Choice 0"
|
||||
|
||||
config CHOICE1
|
||||
tristate "Choice 1"
|
||||
depends on DEP
|
||||
|
||||
endchoice
|
15
scripts/kconfig/tests/choice_value_with_m_dep/__init__.py
Normal file
15
scripts/kconfig/tests/choice_value_with_m_dep/__init__.py
Normal file
@ -0,0 +1,15 @@
|
||||
"""
|
||||
Hide tristate choice values with mod dependency in y choice.
|
||||
|
||||
If tristate choice values depend on symbols set to 'm', they should be
|
||||
hidden when the choice containing them is changed from 'm' to 'y'
|
||||
(i.e. exclusive choice).
|
||||
|
||||
Related Linux commit: fa64e5f6a35efd5e77d639125d973077ca506074
|
||||
"""
|
||||
|
||||
|
||||
def test(conf):
|
||||
assert conf.oldaskconfig('config', 'y') == 0
|
||||
assert conf.config_contains('expected_config')
|
||||
assert conf.stdout_contains('expected_stdout')
|
2
scripts/kconfig/tests/choice_value_with_m_dep/config
Normal file
2
scripts/kconfig/tests/choice_value_with_m_dep/config
Normal file
@ -0,0 +1,2 @@
|
||||
CONFIG_CHOICE0=m
|
||||
CONFIG_CHOICE1=m
|
@ -0,0 +1,3 @@
|
||||
CONFIG_MODULES=y
|
||||
CONFIG_DEP=m
|
||||
CONFIG_CHOICE0=y
|
@ -0,0 +1,4 @@
|
||||
Tristate Choice [M/y/?] y
|
||||
Tristate Choice
|
||||
> 1. Choice 0 (CHOICE0)
|
||||
choice[1]: 1
|
291
scripts/kconfig/tests/conftest.py
Normal file
291
scripts/kconfig/tests/conftest.py
Normal file
@ -0,0 +1,291 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# Copyright (C) 2018 Masahiro Yamada <yamada.masahiro@socionext.com>
|
||||
#
|
||||
|
||||
"""
|
||||
Kconfig unit testing framework.
|
||||
|
||||
This provides fixture functions commonly used from test files.
|
||||
"""
|
||||
|
||||
import os
|
||||
import pytest
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
CONF_PATH = os.path.abspath(os.path.join('scripts', 'kconfig', 'conf'))
|
||||
|
||||
|
||||
class Conf:
|
||||
"""Kconfig runner and result checker.
|
||||
|
||||
This class provides methods to run text-based interface of Kconfig
|
||||
(scripts/kconfig/conf) and retrieve the resulted configuration,
|
||||
stdout, and stderr. It also provides methods to compare those
|
||||
results with expectations.
|
||||
"""
|
||||
|
||||
def __init__(self, request):
|
||||
"""Create a new Conf instance.
|
||||
|
||||
request: object to introspect the requesting test module
|
||||
"""
|
||||
# the directory of the test being run
|
||||
self._test_dir = os.path.dirname(str(request.fspath))
|
||||
|
||||
# runners
|
||||
def _run_conf(self, mode, dot_config=None, out_file='.config',
|
||||
interactive=False, in_keys=None, extra_env={}):
|
||||
"""Run text-based Kconfig executable and save the result.
|
||||
|
||||
mode: input mode option (--oldaskconfig, --defconfig=<file> etc.)
|
||||
dot_config: .config file to use for configuration base
|
||||
out_file: file name to contain the output config data
|
||||
interactive: flag to specify the interactive mode
|
||||
in_keys: key inputs for interactive modes
|
||||
extra_env: additional environments
|
||||
returncode: exit status of the Kconfig executable
|
||||
"""
|
||||
command = [CONF_PATH, mode, 'Kconfig']
|
||||
|
||||
# Override 'srctree' environment to make the test as the top directory
|
||||
extra_env['srctree'] = self._test_dir
|
||||
|
||||
# Run Kconfig in a temporary directory.
|
||||
# This directory is automatically removed when done.
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
|
||||
# if .config is given, copy it to the working directory
|
||||
if dot_config:
|
||||
shutil.copyfile(os.path.join(self._test_dir, dot_config),
|
||||
os.path.join(temp_dir, '.config'))
|
||||
|
||||
ps = subprocess.Popen(command,
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
cwd=temp_dir,
|
||||
env=dict(os.environ, **extra_env))
|
||||
|
||||
# If input key sequence is given, feed it to stdin.
|
||||
if in_keys:
|
||||
ps.stdin.write(in_keys.encode('utf-8'))
|
||||
|
||||
while ps.poll() is None:
|
||||
# For interactive modes such as oldaskconfig, oldconfig,
|
||||
# send 'Enter' key until the program finishes.
|
||||
if interactive:
|
||||
ps.stdin.write(b'\n')
|
||||
|
||||
self.retcode = ps.returncode
|
||||
self.stdout = ps.stdout.read().decode()
|
||||
self.stderr = ps.stderr.read().decode()
|
||||
|
||||
# Retrieve the resulted config data only when .config is supposed
|
||||
# to exist. If the command fails, the .config does not exist.
|
||||
# 'listnewconfig' does not produce .config in the first place.
|
||||
if self.retcode == 0 and out_file:
|
||||
with open(os.path.join(temp_dir, out_file)) as f:
|
||||
self.config = f.read()
|
||||
else:
|
||||
self.config = None
|
||||
|
||||
# Logging:
|
||||
# Pytest captures the following information by default. In failure
|
||||
# of tests, the captured log will be displayed. This will be useful to
|
||||
# figure out what has happened.
|
||||
|
||||
print("[command]\n{}\n".format(' '.join(command)))
|
||||
|
||||
print("[retcode]\n{}\n".format(self.retcode))
|
||||
|
||||
print("[stdout]")
|
||||
print(self.stdout)
|
||||
|
||||
print("[stderr]")
|
||||
print(self.stderr)
|
||||
|
||||
if self.config is not None:
|
||||
print("[output for '{}']".format(out_file))
|
||||
print(self.config)
|
||||
|
||||
return self.retcode
|
||||
|
||||
def oldaskconfig(self, dot_config=None, in_keys=None):
|
||||
"""Run oldaskconfig.
|
||||
|
||||
dot_config: .config file to use for configuration base (optional)
|
||||
in_key: key inputs (optional)
|
||||
returncode: exit status of the Kconfig executable
|
||||
"""
|
||||
return self._run_conf('--oldaskconfig', dot_config=dot_config,
|
||||
interactive=True, in_keys=in_keys)
|
||||
|
||||
def oldconfig(self, dot_config=None, in_keys=None):
|
||||
"""Run oldconfig.
|
||||
|
||||
dot_config: .config file to use for configuration base (optional)
|
||||
in_key: key inputs (optional)
|
||||
returncode: exit status of the Kconfig executable
|
||||
"""
|
||||
return self._run_conf('--oldconfig', dot_config=dot_config,
|
||||
interactive=True, in_keys=in_keys)
|
||||
|
||||
def olddefconfig(self, dot_config=None):
|
||||
"""Run olddefconfig.
|
||||
|
||||
dot_config: .config file to use for configuration base (optional)
|
||||
returncode: exit status of the Kconfig executable
|
||||
"""
|
||||
return self._run_conf('--olddefconfig', dot_config=dot_config)
|
||||
|
||||
def defconfig(self, defconfig):
|
||||
"""Run defconfig.
|
||||
|
||||
defconfig: defconfig file for input
|
||||
returncode: exit status of the Kconfig executable
|
||||
"""
|
||||
defconfig_path = os.path.join(self._test_dir, defconfig)
|
||||
return self._run_conf('--defconfig={}'.format(defconfig_path))
|
||||
|
||||
def _allconfig(self, mode, all_config):
|
||||
if all_config:
|
||||
all_config_path = os.path.join(self._test_dir, all_config)
|
||||
extra_env = {'KCONFIG_ALLCONFIG': all_config_path}
|
||||
else:
|
||||
extra_env = {}
|
||||
|
||||
return self._run_conf('--{}config'.format(mode), extra_env=extra_env)
|
||||
|
||||
def allyesconfig(self, all_config=None):
|
||||
"""Run allyesconfig.
|
||||
|
||||
all_config: fragment config file for KCONFIG_ALLCONFIG (optional)
|
||||
returncode: exit status of the Kconfig executable
|
||||
"""
|
||||
return self._allconfig('allyes', all_config)
|
||||
|
||||
def allmodconfig(self, all_config=None):
|
||||
"""Run allmodconfig.
|
||||
|
||||
all_config: fragment config file for KCONFIG_ALLCONFIG (optional)
|
||||
returncode: exit status of the Kconfig executable
|
||||
"""
|
||||
return self._allconfig('allmod', all_config)
|
||||
|
||||
def allnoconfig(self, all_config=None):
|
||||
"""Run allnoconfig.
|
||||
|
||||
all_config: fragment config file for KCONFIG_ALLCONFIG (optional)
|
||||
returncode: exit status of the Kconfig executable
|
||||
"""
|
||||
return self._allconfig('allno', all_config)
|
||||
|
||||
def alldefconfig(self, all_config=None):
|
||||
"""Run alldefconfig.
|
||||
|
||||
all_config: fragment config file for KCONFIG_ALLCONFIG (optional)
|
||||
returncode: exit status of the Kconfig executable
|
||||
"""
|
||||
return self._allconfig('alldef', all_config)
|
||||
|
||||
def randconfig(self, all_config=None):
|
||||
"""Run randconfig.
|
||||
|
||||
all_config: fragment config file for KCONFIG_ALLCONFIG (optional)
|
||||
returncode: exit status of the Kconfig executable
|
||||
"""
|
||||
return self._allconfig('rand', all_config)
|
||||
|
||||
def savedefconfig(self, dot_config):
|
||||
"""Run savedefconfig.
|
||||
|
||||
dot_config: .config file for input
|
||||
returncode: exit status of the Kconfig executable
|
||||
"""
|
||||
return self._run_conf('--savedefconfig', out_file='defconfig')
|
||||
|
||||
def listnewconfig(self, dot_config=None):
|
||||
"""Run listnewconfig.
|
||||
|
||||
dot_config: .config file to use for configuration base (optional)
|
||||
returncode: exit status of the Kconfig executable
|
||||
"""
|
||||
return self._run_conf('--listnewconfig', dot_config=dot_config,
|
||||
out_file=None)
|
||||
|
||||
# checkers
|
||||
def _read_and_compare(self, compare, expected):
|
||||
"""Compare the result with expectation.
|
||||
|
||||
compare: function to compare the result with expectation
|
||||
expected: file that contains the expected data
|
||||
"""
|
||||
with open(os.path.join(self._test_dir, expected)) as f:
|
||||
expected_data = f.read()
|
||||
return compare(self, expected_data)
|
||||
|
||||
def _contains(self, attr, expected):
|
||||
return self._read_and_compare(
|
||||
lambda s, e: getattr(s, attr).find(e) >= 0,
|
||||
expected)
|
||||
|
||||
def _matches(self, attr, expected):
|
||||
return self._read_and_compare(lambda s, e: getattr(s, attr) == e,
|
||||
expected)
|
||||
|
||||
def config_contains(self, expected):
|
||||
"""Check if resulted configuration contains expected data.
|
||||
|
||||
expected: file that contains the expected data
|
||||
returncode: True if result contains the expected data, False otherwise
|
||||
"""
|
||||
return self._contains('config', expected)
|
||||
|
||||
def config_matches(self, expected):
|
||||
"""Check if resulted configuration exactly matches expected data.
|
||||
|
||||
expected: file that contains the expected data
|
||||
returncode: True if result matches the expected data, False otherwise
|
||||
"""
|
||||
return self._matches('config', expected)
|
||||
|
||||
def stdout_contains(self, expected):
|
||||
"""Check if resulted stdout contains expected data.
|
||||
|
||||
expected: file that contains the expected data
|
||||
returncode: True if result contains the expected data, False otherwise
|
||||
"""
|
||||
return self._contains('stdout', expected)
|
||||
|
||||
def stdout_matches(self, expected):
|
||||
"""Check if resulted stdout exactly matches expected data.
|
||||
|
||||
expected: file that contains the expected data
|
||||
returncode: True if result matches the expected data, False otherwise
|
||||
"""
|
||||
return self._matches('stdout', expected)
|
||||
|
||||
def stderr_contains(self, expected):
|
||||
"""Check if resulted stderr contains expected data.
|
||||
|
||||
expected: file that contains the expected data
|
||||
returncode: True if result contains the expected data, False otherwise
|
||||
"""
|
||||
return self._contains('stderr', expected)
|
||||
|
||||
def stderr_matches(self, expected):
|
||||
"""Check if resulted stderr exactly matches expected data.
|
||||
|
||||
expected: file that contains the expected data
|
||||
returncode: True if result matches the expected data, False otherwise
|
||||
"""
|
||||
return self._matches('stderr', expected)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def conf(request):
|
||||
"""Create a Conf instance and provide it to test functions."""
|
||||
return Conf(request)
|
1
scripts/kconfig/tests/err_recursive_inc/Kconfig
Normal file
1
scripts/kconfig/tests/err_recursive_inc/Kconfig
Normal file
@ -0,0 +1 @@
|
||||
source "Kconfig.inc1"
|
4
scripts/kconfig/tests/err_recursive_inc/Kconfig.inc1
Normal file
4
scripts/kconfig/tests/err_recursive_inc/Kconfig.inc1
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
|
||||
|
||||
source "Kconfig.inc2"
|
3
scripts/kconfig/tests/err_recursive_inc/Kconfig.inc2
Normal file
3
scripts/kconfig/tests/err_recursive_inc/Kconfig.inc2
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
source "Kconfig.inc3"
|
1
scripts/kconfig/tests/err_recursive_inc/Kconfig.inc3
Normal file
1
scripts/kconfig/tests/err_recursive_inc/Kconfig.inc3
Normal file
@ -0,0 +1 @@
|
||||
source "Kconfig.inc1"
|
10
scripts/kconfig/tests/err_recursive_inc/__init__.py
Normal file
10
scripts/kconfig/tests/err_recursive_inc/__init__.py
Normal file
@ -0,0 +1,10 @@
|
||||
"""
|
||||
Detect recursive inclusion error.
|
||||
|
||||
If recursive inclusion is detected, it should fail with error messages.
|
||||
"""
|
||||
|
||||
|
||||
def test(conf):
|
||||
assert conf.oldaskconfig() != 0
|
||||
assert conf.stderr_contains('expected_stderr')
|
6
scripts/kconfig/tests/err_recursive_inc/expected_stderr
Normal file
6
scripts/kconfig/tests/err_recursive_inc/expected_stderr
Normal file
@ -0,0 +1,6 @@
|
||||
Recursive inclusion detected.
|
||||
Inclusion path:
|
||||
current file : Kconfig.inc1
|
||||
included from: Kconfig.inc3:1
|
||||
included from: Kconfig.inc2:3
|
||||
included from: Kconfig.inc1:4
|
23
scripts/kconfig/tests/inter_choice/Kconfig
Normal file
23
scripts/kconfig/tests/inter_choice/Kconfig
Normal file
@ -0,0 +1,23 @@
|
||||
config MODULES
|
||||
def_bool y
|
||||
option modules
|
||||
|
||||
choice
|
||||
prompt "Choice"
|
||||
|
||||
config CHOICE_VAL0
|
||||
tristate "Choice 0"
|
||||
|
||||
config CHOIVE_VAL1
|
||||
tristate "Choice 1"
|
||||
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "Another choice"
|
||||
depends on CHOICE_VAL0
|
||||
|
||||
config DUMMY
|
||||
bool "dummy"
|
||||
|
||||
endchoice
|
14
scripts/kconfig/tests/inter_choice/__init__.py
Normal file
14
scripts/kconfig/tests/inter_choice/__init__.py
Normal file
@ -0,0 +1,14 @@
|
||||
"""
|
||||
Do not affect user-assigned choice value by another choice.
|
||||
|
||||
Handling of state flags for choices is complecated. In old days,
|
||||
the defconfig result of a choice could be affected by another choice
|
||||
if those choices interact by 'depends on', 'select', etc.
|
||||
|
||||
Related Linux commit: fbe98bb9ed3dae23e320c6b113e35f129538d14a
|
||||
"""
|
||||
|
||||
|
||||
def test(conf):
|
||||
assert conf.defconfig('defconfig') == 0
|
||||
assert conf.config_contains('expected_config')
|
1
scripts/kconfig/tests/inter_choice/defconfig
Normal file
1
scripts/kconfig/tests/inter_choice/defconfig
Normal file
@ -0,0 +1 @@
|
||||
CONFIG_CHOICE_VAL0=y
|
4
scripts/kconfig/tests/inter_choice/expected_config
Normal file
4
scripts/kconfig/tests/inter_choice/expected_config
Normal file
@ -0,0 +1,4 @@
|
||||
CONFIG_MODULES=y
|
||||
CONFIG_CHOICE_VAL0=y
|
||||
# CONFIG_CHOIVE_VAL1 is not set
|
||||
CONFIG_DUMMY=y
|
37
scripts/kconfig/tests/new_choice_with_dep/Kconfig
Normal file
37
scripts/kconfig/tests/new_choice_with_dep/Kconfig
Normal file
@ -0,0 +1,37 @@
|
||||
config A
|
||||
bool "A"
|
||||
help
|
||||
This is a new symbol.
|
||||
|
||||
choice
|
||||
prompt "Choice ?"
|
||||
depends on A
|
||||
help
|
||||
"depends on A" has been newly added.
|
||||
|
||||
config CHOICE_B
|
||||
bool "Choice B"
|
||||
|
||||
config CHOICE_C
|
||||
bool "Choice C"
|
||||
help
|
||||
This is a new symbol, so should be asked.
|
||||
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "Choice2 ?"
|
||||
|
||||
config CHOICE_D
|
||||
bool "Choice D"
|
||||
|
||||
config CHOICE_E
|
||||
bool "Choice E"
|
||||
|
||||
config CHOICE_F
|
||||
bool "Choice F"
|
||||
depends on A
|
||||
help
|
||||
This is a new symbol, so should be asked.
|
||||
|
||||
endchoice
|
14
scripts/kconfig/tests/new_choice_with_dep/__init__.py
Normal file
14
scripts/kconfig/tests/new_choice_with_dep/__init__.py
Normal file
@ -0,0 +1,14 @@
|
||||
"""
|
||||
Ask new choice values when they become visible.
|
||||
|
||||
If new choice values are added with new dependency, and they become
|
||||
visible during user configuration, oldconfig should recognize them
|
||||
as (NEW), and ask the user for choice.
|
||||
|
||||
Related Linux commit: 5d09598d488f081e3be23f885ed65cbbe2d073b5
|
||||
"""
|
||||
|
||||
|
||||
def test(conf):
|
||||
assert conf.oldconfig('config', 'y') == 0
|
||||
assert conf.stdout_contains('expected_stdout')
|
3
scripts/kconfig/tests/new_choice_with_dep/config
Normal file
3
scripts/kconfig/tests/new_choice_with_dep/config
Normal file
@ -0,0 +1,3 @@
|
||||
CONFIG_CHOICE_B=y
|
||||
# CONFIG_CHOICE_D is not set
|
||||
CONFIG_CHOICE_E=y
|
10
scripts/kconfig/tests/new_choice_with_dep/expected_stdout
Normal file
10
scripts/kconfig/tests/new_choice_with_dep/expected_stdout
Normal file
@ -0,0 +1,10 @@
|
||||
A (A) [N/y/?] (NEW) y
|
||||
Choice ?
|
||||
> 1. Choice B (CHOICE_B)
|
||||
2. Choice C (CHOICE_C) (NEW)
|
||||
choice[1-2?]:
|
||||
Choice2 ?
|
||||
1. Choice D (CHOICE_D)
|
||||
> 2. Choice E (CHOICE_E)
|
||||
3. Choice F (CHOICE_F) (NEW)
|
||||
choice[1-3?]:
|
14
scripts/kconfig/tests/no_write_if_dep_unmet/Kconfig
Normal file
14
scripts/kconfig/tests/no_write_if_dep_unmet/Kconfig
Normal file
@ -0,0 +1,14 @@
|
||||
config A
|
||||
bool "A"
|
||||
|
||||
choice
|
||||
prompt "Choice ?"
|
||||
depends on A
|
||||
|
||||
config CHOICE_B
|
||||
bool "Choice B"
|
||||
|
||||
config CHOICE_C
|
||||
bool "Choice C"
|
||||
|
||||
endchoice
|
19
scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py
Normal file
19
scripts/kconfig/tests/no_write_if_dep_unmet/__init__.py
Normal file
@ -0,0 +1,19 @@
|
||||
"""
|
||||
Do not write choice values to .config if the dependency is unmet.
|
||||
|
||||
"# CONFIG_... is not set" should not be written into the .config file
|
||||
for symbols with unmet dependency.
|
||||
|
||||
This was not working correctly for choice values because choice needs
|
||||
a bit different symbol computation.
|
||||
|
||||
This checks that no unneeded "# COFIG_... is not set" is contained in
|
||||
the .config file.
|
||||
|
||||
Related Linux commit: cb67ab2cd2b8abd9650292c986c79901e3073a59
|
||||
"""
|
||||
|
||||
|
||||
def test(conf):
|
||||
assert conf.oldaskconfig('config', 'n') == 0
|
||||
assert conf.config_matches('expected_config')
|
1
scripts/kconfig/tests/no_write_if_dep_unmet/config
Normal file
1
scripts/kconfig/tests/no_write_if_dep_unmet/config
Normal file
@ -0,0 +1 @@
|
||||
CONFIG_A=y
|
@ -0,0 +1,5 @@
|
||||
#
|
||||
# Automatically generated file; DO NOT EDIT.
|
||||
# Linux Kernel Configuration
|
||||
#
|
||||
# CONFIG_A is not set
|
7
scripts/kconfig/tests/pytest.ini
Normal file
7
scripts/kconfig/tests/pytest.ini
Normal file
@ -0,0 +1,7 @@
|
||||
[pytest]
|
||||
addopts = --verbose
|
||||
|
||||
# Pytest requires that test files have unique names, because pytest imports
|
||||
# them as top-level modules. It is silly to prefix or suffix a test file with
|
||||
# the directory name that contains it. Use __init__.py for all test files.
|
||||
python_files = __init__.py
|
33
scripts/kconfig/tests/rand_nested_choice/Kconfig
Normal file
33
scripts/kconfig/tests/rand_nested_choice/Kconfig
Normal file
@ -0,0 +1,33 @@
|
||||
choice
|
||||
prompt "choice"
|
||||
|
||||
config A
|
||||
bool "A"
|
||||
|
||||
config B
|
||||
bool "B"
|
||||
|
||||
if B
|
||||
choice
|
||||
prompt "sub choice"
|
||||
|
||||
config C
|
||||
bool "C"
|
||||
|
||||
config D
|
||||
bool "D"
|
||||
|
||||
if D
|
||||
choice
|
||||
prompt "subsub choice"
|
||||
|
||||
config E
|
||||
bool "E"
|
||||
|
||||
endchoice
|
||||
endif # D
|
||||
|
||||
endchoice
|
||||
endif # B
|
||||
|
||||
endchoice
|
16
scripts/kconfig/tests/rand_nested_choice/__init__.py
Normal file
16
scripts/kconfig/tests/rand_nested_choice/__init__.py
Normal file
@ -0,0 +1,16 @@
|
||||
"""
|
||||
Set random values recursively in nested choices.
|
||||
|
||||
Kconfig can create a choice-in-choice structure by using 'if' statement.
|
||||
randconfig should correctly set random choice values.
|
||||
|
||||
Related Linux commit: 3b9a19e08960e5cdad5253998637653e592a3c29
|
||||
"""
|
||||
|
||||
|
||||
def test(conf):
|
||||
for i in range(20):
|
||||
assert conf.randconfig() == 0
|
||||
assert (conf.config_contains('expected_stdout0') or
|
||||
conf.config_contains('expected_stdout1') or
|
||||
conf.config_contains('expected_stdout2'))
|
@ -0,0 +1,2 @@
|
||||
CONFIG_A=y
|
||||
# CONFIG_B is not set
|
@ -0,0 +1,4 @@
|
||||
# CONFIG_A is not set
|
||||
CONFIG_B=y
|
||||
CONFIG_C=y
|
||||
# CONFIG_D is not set
|
@ -0,0 +1,5 @@
|
||||
# CONFIG_A is not set
|
||||
CONFIG_B=y
|
||||
# CONFIG_C is not set
|
||||
CONFIG_D=y
|
||||
CONFIG_E=y
|
62
scripts/kconfig/tests/warn_recursive_dep/Kconfig
Normal file
62
scripts/kconfig/tests/warn_recursive_dep/Kconfig
Normal file
@ -0,0 +1,62 @@
|
||||
# depends on itself
|
||||
|
||||
config A
|
||||
bool "A"
|
||||
depends on A
|
||||
|
||||
# select itself
|
||||
|
||||
config B
|
||||
bool
|
||||
select B
|
||||
|
||||
# depends on each other
|
||||
|
||||
config C1
|
||||
bool "C1"
|
||||
depends on C2
|
||||
|
||||
config C2
|
||||
bool "C2"
|
||||
depends on C1
|
||||
|
||||
# depends on and select
|
||||
|
||||
config D1
|
||||
bool "D1"
|
||||
depends on D2
|
||||
select D2
|
||||
|
||||
config D2
|
||||
bool
|
||||
|
||||
# depends on and imply
|
||||
# This is not recursive dependency
|
||||
|
||||
config E1
|
||||
bool "E1"
|
||||
depends on E2
|
||||
imply E2
|
||||
|
||||
config E2
|
||||
bool "E2"
|
||||
|
||||
# property
|
||||
|
||||
config F1
|
||||
bool "F1"
|
||||
default F2
|
||||
|
||||
config F2
|
||||
bool "F2"
|
||||
depends on F1
|
||||
|
||||
# menu
|
||||
|
||||
menu "menu depending on its content"
|
||||
depends on G
|
||||
|
||||
config G
|
||||
bool "G"
|
||||
|
||||
endmenu
|
9
scripts/kconfig/tests/warn_recursive_dep/__init__.py
Normal file
9
scripts/kconfig/tests/warn_recursive_dep/__init__.py
Normal file
@ -0,0 +1,9 @@
|
||||
"""
|
||||
Warn recursive inclusion.
|
||||
|
||||
Recursive dependency should be warned.
|
||||
"""
|
||||
|
||||
def test(conf):
|
||||
assert conf.oldaskconfig() == 0
|
||||
assert conf.stderr_contains('expected_stderr')
|
30
scripts/kconfig/tests/warn_recursive_dep/expected_stderr
Normal file
30
scripts/kconfig/tests/warn_recursive_dep/expected_stderr
Normal file
@ -0,0 +1,30 @@
|
||||
Kconfig:9:error: recursive dependency detected!
|
||||
Kconfig:9: symbol B is selected by B
|
||||
For a resolution refer to Documentation/kbuild/kconfig-language.txt
|
||||
subsection "Kconfig recursive dependency limitations"
|
||||
|
||||
Kconfig:3:error: recursive dependency detected!
|
||||
Kconfig:3: symbol A depends on A
|
||||
For a resolution refer to Documentation/kbuild/kconfig-language.txt
|
||||
subsection "Kconfig recursive dependency limitations"
|
||||
|
||||
Kconfig:15:error: recursive dependency detected!
|
||||
Kconfig:15: symbol C1 depends on C2
|
||||
Kconfig:19: symbol C2 depends on C1
|
||||
For a resolution refer to Documentation/kbuild/kconfig-language.txt
|
||||
subsection "Kconfig recursive dependency limitations"
|
||||
|
||||
Kconfig:30:error: recursive dependency detected!
|
||||
Kconfig:30: symbol D2 is selected by D1
|
||||
Kconfig:25: symbol D1 depends on D2
|
||||
For a resolution refer to Documentation/kbuild/kconfig-language.txt
|
||||
subsection "Kconfig recursive dependency limitations"
|
||||
|
||||
Kconfig:59:error: recursive dependency detected!
|
||||
Kconfig:59: symbol G depends on G
|
||||
For a resolution refer to Documentation/kbuild/kconfig-language.txt
|
||||
subsection "Kconfig recursive dependency limitations"
|
||||
|
||||
Kconfig:50:error: recursive dependency detected!
|
||||
Kconfig:50: symbol F2 depends on F1
|
||||
Kconfig:48: symbol F1 default value contains F2
|
@ -14,11 +14,11 @@
|
||||
struct file *file_lookup(const char *name)
|
||||
{
|
||||
struct file *file;
|
||||
const char *file_name = sym_expand_string_value(name);
|
||||
char *file_name = sym_expand_string_value(name);
|
||||
|
||||
for (file = file_list; file; file = file->next) {
|
||||
if (!strcmp(name, file->name)) {
|
||||
free((void *)file_name);
|
||||
free(file_name);
|
||||
return file;
|
||||
}
|
||||
}
|
||||
@ -104,7 +104,7 @@ void str_append(struct gstr *gs, const char *s)
|
||||
if (s) {
|
||||
l = strlen(gs->s) + strlen(s) + 1;
|
||||
if (l > gs->len) {
|
||||
gs->s = realloc(gs->s, l);
|
||||
gs->s = xrealloc(gs->s, l);
|
||||
gs->len = l;
|
||||
}
|
||||
strcat(gs->s, s);
|
||||
@ -145,3 +145,23 @@ void *xcalloc(size_t nmemb, size_t size)
|
||||
fprintf(stderr, "Out of memory.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void *xrealloc(void *p, size_t size)
|
||||
{
|
||||
p = realloc(p, size);
|
||||
if (p)
|
||||
return p;
|
||||
fprintf(stderr, "Out of memory.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
char *xstrdup(const char *s)
|
||||
{
|
||||
char *p;
|
||||
|
||||
p = strdup(s);
|
||||
if (p)
|
||||
return p;
|
||||
fprintf(stderr, "Out of memory.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -1,50 +0,0 @@
|
||||
%language=ANSI-C
|
||||
%define hash-function-name kconf_id_hash
|
||||
%define lookup-function-name kconf_id_lookup
|
||||
%define string-pool-name kconf_id_strings
|
||||
%compare-strncmp
|
||||
%enum
|
||||
%pic
|
||||
%struct-type
|
||||
|
||||
struct kconf_id;
|
||||
|
||||
static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
|
||||
|
||||
%%
|
||||
mainmenu, T_MAINMENU, TF_COMMAND
|
||||
menu, T_MENU, TF_COMMAND
|
||||
endmenu, T_ENDMENU, TF_COMMAND
|
||||
source, T_SOURCE, TF_COMMAND
|
||||
choice, T_CHOICE, TF_COMMAND
|
||||
endchoice, T_ENDCHOICE, TF_COMMAND
|
||||
comment, T_COMMENT, TF_COMMAND
|
||||
config, T_CONFIG, TF_COMMAND
|
||||
menuconfig, T_MENUCONFIG, TF_COMMAND
|
||||
help, T_HELP, TF_COMMAND
|
||||
---help---, T_HELP, TF_COMMAND
|
||||
if, T_IF, TF_COMMAND|TF_PARAM
|
||||
endif, T_ENDIF, TF_COMMAND
|
||||
depends, T_DEPENDS, TF_COMMAND
|
||||
optional, T_OPTIONAL, TF_COMMAND
|
||||
default, T_DEFAULT, TF_COMMAND, S_UNKNOWN
|
||||
prompt, T_PROMPT, TF_COMMAND
|
||||
tristate, T_TYPE, TF_COMMAND, S_TRISTATE
|
||||
def_tristate, T_DEFAULT, TF_COMMAND, S_TRISTATE
|
||||
bool, T_TYPE, TF_COMMAND, S_BOOLEAN
|
||||
boolean, T_TYPE, TF_COMMAND, S_BOOLEAN
|
||||
def_bool, T_DEFAULT, TF_COMMAND, S_BOOLEAN
|
||||
int, T_TYPE, TF_COMMAND, S_INT
|
||||
hex, T_TYPE, TF_COMMAND, S_HEX
|
||||
string, T_TYPE, TF_COMMAND, S_STRING
|
||||
select, T_SELECT, TF_COMMAND
|
||||
imply, T_IMPLY, TF_COMMAND
|
||||
range, T_RANGE, TF_COMMAND
|
||||
visible, T_VISIBLE, TF_COMMAND
|
||||
option, T_OPTION, TF_COMMAND
|
||||
on, T_ON, TF_PARAM
|
||||
modules, T_OPT_MODULES, TF_OPTION
|
||||
defconfig_list, T_OPT_DEFCONFIG_LIST,TF_OPTION
|
||||
env, T_OPT_ENV, TF_OPTION
|
||||
allnoconfig_y, T_OPT_ALLNOCONFIG_Y,TF_OPTION
|
||||
%%
|
@ -1,297 +0,0 @@
|
||||
/* ANSI-C code produced by gperf version 3.0.4 */
|
||||
/* Command-line: gperf -t --output-file scripts/kconfig/zconf.hash.c_shipped -a -C -E -g -k '1,3,$' -p -t scripts/kconfig/zconf.gperf */
|
||||
|
||||
#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
|
||||
&& ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
|
||||
&& (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
|
||||
&& ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
|
||||
&& ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
|
||||
&& ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
|
||||
&& ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
|
||||
&& ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
|
||||
&& ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
|
||||
&& ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
|
||||
&& ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
|
||||
&& ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
|
||||
&& ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
|
||||
&& ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
|
||||
&& ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
|
||||
&& ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
|
||||
&& ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
|
||||
&& ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
|
||||
&& ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
|
||||
&& ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
|
||||
&& ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
|
||||
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
|
||||
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
|
||||
/* The character set is not based on ISO-646. */
|
||||
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
|
||||
#endif
|
||||
|
||||
#line 10 "scripts/kconfig/zconf.gperf"
|
||||
struct kconf_id;
|
||||
|
||||
static const struct kconf_id *kconf_id_lookup(register const char *str, register unsigned int len);
|
||||
/* maximum key range = 71, duplicates = 0 */
|
||||
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#else
|
||||
#ifdef __cplusplus
|
||||
inline
|
||||
#endif
|
||||
#endif
|
||||
static unsigned int
|
||||
kconf_id_hash (register const char *str, register unsigned int len)
|
||||
{
|
||||
static const unsigned char asso_values[] =
|
||||
{
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 0, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 10, 25, 25,
|
||||
0, 0, 0, 5, 0, 0, 73, 73, 5, 0,
|
||||
10, 5, 45, 73, 20, 20, 0, 15, 15, 73,
|
||||
20, 0, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
|
||||
73, 73, 73, 73, 73, 73
|
||||
};
|
||||
register int hval = len;
|
||||
|
||||
switch (hval)
|
||||
{
|
||||
default:
|
||||
hval += asso_values[(unsigned char)str[2]];
|
||||
/*FALLTHROUGH*/
|
||||
case 2:
|
||||
case 1:
|
||||
hval += asso_values[(unsigned char)str[0]];
|
||||
break;
|
||||
}
|
||||
return hval + asso_values[(unsigned char)str[len - 1]];
|
||||
}
|
||||
|
||||
struct kconf_id_strings_t
|
||||
{
|
||||
char kconf_id_strings_str2[sizeof("if")];
|
||||
char kconf_id_strings_str3[sizeof("int")];
|
||||
char kconf_id_strings_str5[sizeof("endif")];
|
||||
char kconf_id_strings_str7[sizeof("default")];
|
||||
char kconf_id_strings_str8[sizeof("tristate")];
|
||||
char kconf_id_strings_str9[sizeof("endchoice")];
|
||||
char kconf_id_strings_str10[sizeof("---help---")];
|
||||
char kconf_id_strings_str12[sizeof("def_tristate")];
|
||||
char kconf_id_strings_str13[sizeof("def_bool")];
|
||||
char kconf_id_strings_str14[sizeof("defconfig_list")];
|
||||
char kconf_id_strings_str17[sizeof("on")];
|
||||
char kconf_id_strings_str18[sizeof("optional")];
|
||||
char kconf_id_strings_str21[sizeof("option")];
|
||||
char kconf_id_strings_str22[sizeof("endmenu")];
|
||||
char kconf_id_strings_str23[sizeof("mainmenu")];
|
||||
char kconf_id_strings_str25[sizeof("menuconfig")];
|
||||
char kconf_id_strings_str27[sizeof("modules")];
|
||||
char kconf_id_strings_str28[sizeof("allnoconfig_y")];
|
||||
char kconf_id_strings_str29[sizeof("menu")];
|
||||
char kconf_id_strings_str31[sizeof("select")];
|
||||
char kconf_id_strings_str32[sizeof("comment")];
|
||||
char kconf_id_strings_str33[sizeof("env")];
|
||||
char kconf_id_strings_str35[sizeof("range")];
|
||||
char kconf_id_strings_str36[sizeof("choice")];
|
||||
char kconf_id_strings_str39[sizeof("bool")];
|
||||
char kconf_id_strings_str41[sizeof("source")];
|
||||
char kconf_id_strings_str42[sizeof("visible")];
|
||||
char kconf_id_strings_str43[sizeof("hex")];
|
||||
char kconf_id_strings_str46[sizeof("config")];
|
||||
char kconf_id_strings_str47[sizeof("boolean")];
|
||||
char kconf_id_strings_str50[sizeof("imply")];
|
||||
char kconf_id_strings_str51[sizeof("string")];
|
||||
char kconf_id_strings_str54[sizeof("help")];
|
||||
char kconf_id_strings_str56[sizeof("prompt")];
|
||||
char kconf_id_strings_str72[sizeof("depends")];
|
||||
};
|
||||
static const struct kconf_id_strings_t kconf_id_strings_contents =
|
||||
{
|
||||
"if",
|
||||
"int",
|
||||
"endif",
|
||||
"default",
|
||||
"tristate",
|
||||
"endchoice",
|
||||
"---help---",
|
||||
"def_tristate",
|
||||
"def_bool",
|
||||
"defconfig_list",
|
||||
"on",
|
||||
"optional",
|
||||
"option",
|
||||
"endmenu",
|
||||
"mainmenu",
|
||||
"menuconfig",
|
||||
"modules",
|
||||
"allnoconfig_y",
|
||||
"menu",
|
||||
"select",
|
||||
"comment",
|
||||
"env",
|
||||
"range",
|
||||
"choice",
|
||||
"bool",
|
||||
"source",
|
||||
"visible",
|
||||
"hex",
|
||||
"config",
|
||||
"boolean",
|
||||
"imply",
|
||||
"string",
|
||||
"help",
|
||||
"prompt",
|
||||
"depends"
|
||||
};
|
||||
#define kconf_id_strings ((const char *) &kconf_id_strings_contents)
|
||||
#ifdef __GNUC__
|
||||
__inline
|
||||
#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
|
||||
__attribute__ ((__gnu_inline__))
|
||||
#endif
|
||||
#endif
|
||||
const struct kconf_id *
|
||||
kconf_id_lookup (register const char *str, register unsigned int len)
|
||||
{
|
||||
enum
|
||||
{
|
||||
TOTAL_KEYWORDS = 35,
|
||||
MIN_WORD_LENGTH = 2,
|
||||
MAX_WORD_LENGTH = 14,
|
||||
MIN_HASH_VALUE = 2,
|
||||
MAX_HASH_VALUE = 72
|
||||
};
|
||||
|
||||
static const struct kconf_id wordlist[] =
|
||||
{
|
||||
{-1}, {-1},
|
||||
#line 26 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2, T_IF, TF_COMMAND|TF_PARAM},
|
||||
#line 37 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str3, T_TYPE, TF_COMMAND, S_INT},
|
||||
{-1},
|
||||
#line 27 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str5, T_ENDIF, TF_COMMAND},
|
||||
{-1},
|
||||
#line 30 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7, T_DEFAULT, TF_COMMAND, S_UNKNOWN},
|
||||
#line 32 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str8, T_TYPE, TF_COMMAND, S_TRISTATE},
|
||||
#line 20 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str9, T_ENDCHOICE, TF_COMMAND},
|
||||
#line 25 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str10, T_HELP, TF_COMMAND},
|
||||
{-1},
|
||||
#line 33 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_TRISTATE},
|
||||
#line 36 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN},
|
||||
#line 47 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_OPT_DEFCONFIG_LIST,TF_OPTION},
|
||||
{-1}, {-1},
|
||||
#line 45 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_ON, TF_PARAM},
|
||||
#line 29 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_OPTIONAL, TF_COMMAND},
|
||||
{-1}, {-1},
|
||||
#line 44 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_OPTION, TF_COMMAND},
|
||||
#line 17 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_ENDMENU, TF_COMMAND},
|
||||
#line 15 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_MAINMENU, TF_COMMAND},
|
||||
{-1},
|
||||
#line 23 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str25, T_MENUCONFIG, TF_COMMAND},
|
||||
{-1},
|
||||
#line 46 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_OPT_MODULES, TF_OPTION},
|
||||
#line 49 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_OPT_ALLNOCONFIG_Y,TF_OPTION},
|
||||
#line 16 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str29, T_MENU, TF_COMMAND},
|
||||
{-1},
|
||||
#line 40 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SELECT, TF_COMMAND},
|
||||
#line 21 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND},
|
||||
#line 48 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_OPT_ENV, TF_OPTION},
|
||||
{-1},
|
||||
#line 42 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_RANGE, TF_COMMAND},
|
||||
#line 19 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_CHOICE, TF_COMMAND},
|
||||
{-1}, {-1},
|
||||
#line 34 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str39, T_TYPE, TF_COMMAND, S_BOOLEAN},
|
||||
{-1},
|
||||
#line 18 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_SOURCE, TF_COMMAND},
|
||||
#line 43 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str42, T_VISIBLE, TF_COMMAND},
|
||||
#line 38 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str43, T_TYPE, TF_COMMAND, S_HEX},
|
||||
{-1}, {-1},
|
||||
#line 22 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str46, T_CONFIG, TF_COMMAND},
|
||||
#line 35 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str47, T_TYPE, TF_COMMAND, S_BOOLEAN},
|
||||
{-1}, {-1},
|
||||
#line 41 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str50, T_IMPLY, TF_COMMAND},
|
||||
#line 39 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str51, T_TYPE, TF_COMMAND, S_STRING},
|
||||
{-1}, {-1},
|
||||
#line 24 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str54, T_HELP, TF_COMMAND},
|
||||
{-1},
|
||||
#line 31 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str56, T_PROMPT, TF_COMMAND},
|
||||
{-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
|
||||
{-1}, {-1}, {-1}, {-1}, {-1}, {-1},
|
||||
#line 28 "scripts/kconfig/zconf.gperf"
|
||||
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str72, T_DEPENDS, TF_COMMAND}
|
||||
};
|
||||
|
||||
if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
|
||||
{
|
||||
register int key = kconf_id_hash (str, len);
|
||||
|
||||
if (key <= MAX_HASH_VALUE && key >= 0)
|
||||
{
|
||||
register int o = wordlist[key].name;
|
||||
if (o >= 0)
|
||||
{
|
||||
register const char *s = o + kconf_id_strings;
|
||||
|
||||
if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
|
||||
return &wordlist[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#line 50 "scripts/kconfig/zconf.gperf"
|
||||
|
@ -1,5 +1,5 @@
|
||||
%option nostdinit noyywrap never-interactive full ecs
|
||||
%option 8bit nodefault perf-report perf-report
|
||||
%option 8bit nodefault yylineno
|
||||
%option noinput
|
||||
%x COMMAND HELP STRING PARAM
|
||||
%{
|
||||
@ -52,7 +52,7 @@ static void append_string(const char *str, int size)
|
||||
if (new_size > text_asize) {
|
||||
new_size += START_STRSIZE - 1;
|
||||
new_size &= -START_STRSIZE;
|
||||
text = realloc(text, new_size);
|
||||
text = xrealloc(text, new_size);
|
||||
text_asize = new_size;
|
||||
}
|
||||
memcpy(text + text_size, str, size);
|
||||
@ -83,7 +83,6 @@ n [A-Za-z0-9_-]
|
||||
|
||||
[ \t]*#.*\n |
|
||||
[ \t]*\n {
|
||||
current_file->lineno++;
|
||||
return T_EOL;
|
||||
}
|
||||
[ \t]*#.*
|
||||
@ -104,19 +103,18 @@ n [A-Za-z0-9_-]
|
||||
const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
|
||||
BEGIN(PARAM);
|
||||
current_pos.file = current_file;
|
||||
current_pos.lineno = current_file->lineno;
|
||||
current_pos.lineno = yylineno;
|
||||
if (id && id->flags & TF_COMMAND) {
|
||||
zconflval.id = id;
|
||||
yylval.id = id;
|
||||
return id->token;
|
||||
}
|
||||
alloc_string(yytext, yyleng);
|
||||
zconflval.string = text;
|
||||
yylval.string = text;
|
||||
return T_WORD;
|
||||
}
|
||||
. warn_ignored_character(*yytext);
|
||||
\n {
|
||||
BEGIN(INITIAL);
|
||||
current_file->lineno++;
|
||||
return T_EOL;
|
||||
}
|
||||
}
|
||||
@ -138,19 +136,19 @@ n [A-Za-z0-9_-]
|
||||
new_string();
|
||||
BEGIN(STRING);
|
||||
}
|
||||
\n BEGIN(INITIAL); current_file->lineno++; return T_EOL;
|
||||
\n BEGIN(INITIAL); return T_EOL;
|
||||
({n}|[/.])+ {
|
||||
const struct kconf_id *id = kconf_id_lookup(yytext, yyleng);
|
||||
if (id && id->flags & TF_PARAM) {
|
||||
zconflval.id = id;
|
||||
yylval.id = id;
|
||||
return id->token;
|
||||
}
|
||||
alloc_string(yytext, yyleng);
|
||||
zconflval.string = text;
|
||||
yylval.string = text;
|
||||
return T_WORD;
|
||||
}
|
||||
#.* /* comment */
|
||||
\\\n current_file->lineno++;
|
||||
\\\n ;
|
||||
[[:blank:]]+
|
||||
. warn_ignored_character(*yytext);
|
||||
<<EOF>> {
|
||||
@ -161,7 +159,7 @@ n [A-Za-z0-9_-]
|
||||
<STRING>{
|
||||
[^'"\\\n]+/\n {
|
||||
append_string(yytext, yyleng);
|
||||
zconflval.string = text;
|
||||
yylval.string = text;
|
||||
return T_WORD_QUOTE;
|
||||
}
|
||||
[^'"\\\n]+ {
|
||||
@ -169,7 +167,7 @@ n [A-Za-z0-9_-]
|
||||
}
|
||||
\\.?/\n {
|
||||
append_string(yytext + 1, yyleng - 1);
|
||||
zconflval.string = text;
|
||||
yylval.string = text;
|
||||
return T_WORD_QUOTE;
|
||||
}
|
||||
\\.? {
|
||||
@ -178,14 +176,15 @@ n [A-Za-z0-9_-]
|
||||
\'|\" {
|
||||
if (str == yytext[0]) {
|
||||
BEGIN(PARAM);
|
||||
zconflval.string = text;
|
||||
yylval.string = text;
|
||||
return T_WORD_QUOTE;
|
||||
} else
|
||||
append_string(yytext, 1);
|
||||
}
|
||||
\n {
|
||||
printf("%s:%d:warning: multi-line strings not supported\n", zconf_curname(), zconf_lineno());
|
||||
current_file->lineno++;
|
||||
fprintf(stderr,
|
||||
"%s:%d:warning: multi-line strings not supported\n",
|
||||
zconf_curname(), zconf_lineno());
|
||||
BEGIN(INITIAL);
|
||||
return T_EOL;
|
||||
}
|
||||
@ -218,12 +217,10 @@ n [A-Za-z0-9_-]
|
||||
}
|
||||
}
|
||||
[ \t]*\n/[^ \t\n] {
|
||||
current_file->lineno++;
|
||||
zconf_endhelp();
|
||||
return T_HELPTEXT;
|
||||
}
|
||||
[ \t]*\n {
|
||||
current_file->lineno++;
|
||||
append_string("\n", 1);
|
||||
}
|
||||
[^ \t\n].* {
|
||||
@ -261,7 +258,7 @@ void zconf_starthelp(void)
|
||||
|
||||
static void zconf_endhelp(void)
|
||||
{
|
||||
zconflval.string = text;
|
||||
yylval.string = text;
|
||||
BEGIN(INITIAL);
|
||||
}
|
||||
|
||||
@ -294,7 +291,7 @@ void zconf_initscan(const char *name)
|
||||
{
|
||||
yyin = zconf_fopen(name);
|
||||
if (!yyin) {
|
||||
printf("can't find file %s\n", name);
|
||||
fprintf(stderr, "can't find file %s\n", name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -302,7 +299,7 @@ void zconf_initscan(const char *name)
|
||||
memset(current_buf, 0, sizeof(*current_buf));
|
||||
|
||||
current_file = file_lookup(name);
|
||||
current_file->lineno = 1;
|
||||
yylineno = 1;
|
||||
}
|
||||
|
||||
void zconf_nextfile(const char *name)
|
||||
@ -315,7 +312,7 @@ void zconf_nextfile(const char *name)
|
||||
current_buf->state = YY_CURRENT_BUFFER;
|
||||
yyin = zconf_fopen(file->name);
|
||||
if (!yyin) {
|
||||
printf("%s:%d: can't open file \"%s\"\n",
|
||||
fprintf(stderr, "%s:%d: can't open file \"%s\"\n",
|
||||
zconf_curname(), zconf_lineno(), file->name);
|
||||
exit(1);
|
||||
}
|
||||
@ -323,27 +320,26 @@ void zconf_nextfile(const char *name)
|
||||
buf->parent = current_buf;
|
||||
current_buf = buf;
|
||||
|
||||
for (iter = current_file->parent; iter; iter = iter->parent ) {
|
||||
if (!strcmp(current_file->name,iter->name) ) {
|
||||
printf("%s:%d: recursive inclusion detected. "
|
||||
"Inclusion path:\n current file : '%s'\n",
|
||||
zconf_curname(), zconf_lineno(),
|
||||
zconf_curname());
|
||||
iter = current_file->parent;
|
||||
while (iter && \
|
||||
strcmp(iter->name,current_file->name)) {
|
||||
printf(" included from: '%s:%d'\n",
|
||||
iter->name, iter->lineno-1);
|
||||
current_file->lineno = yylineno;
|
||||
file->parent = current_file;
|
||||
|
||||
for (iter = current_file; iter; iter = iter->parent) {
|
||||
if (!strcmp(iter->name, file->name)) {
|
||||
fprintf(stderr,
|
||||
"Recursive inclusion detected.\n"
|
||||
"Inclusion path:\n"
|
||||
" current file : %s\n", file->name);
|
||||
iter = file;
|
||||
do {
|
||||
iter = iter->parent;
|
||||
}
|
||||
if (iter)
|
||||
printf(" included from: '%s:%d'\n",
|
||||
iter->name, iter->lineno+1);
|
||||
fprintf(stderr, " included from: %s:%d\n",
|
||||
iter->name, iter->lineno - 1);
|
||||
} while (strcmp(iter->name, file->name));
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
file->lineno = 1;
|
||||
file->parent = current_file;
|
||||
|
||||
yylineno = 1;
|
||||
current_file = file;
|
||||
}
|
||||
|
||||
@ -352,6 +348,8 @@ static void zconf_endfile(void)
|
||||
struct buffer *parent;
|
||||
|
||||
current_file = current_file->parent;
|
||||
if (current_file)
|
||||
yylineno = current_file->lineno;
|
||||
|
||||
parent = current_buf->parent;
|
||||
if (parent) {
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -20,10 +20,10 @@
|
||||
|
||||
int cdebug = PRINTD;
|
||||
|
||||
extern int zconflex(void);
|
||||
int yylex(void);
|
||||
static void yyerror(const char *err);
|
||||
static void zconfprint(const char *err, ...);
|
||||
static void zconf_error(const char *err, ...);
|
||||
static void zconferror(const char *err);
|
||||
static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtoken);
|
||||
|
||||
struct symbol *symbol_hash[SYMBOL_HASHSIZE];
|
||||
@ -85,6 +85,7 @@ static struct menu *current_menu, *current_entry;
|
||||
%nonassoc T_NOT
|
||||
|
||||
%type <string> prompt
|
||||
%type <symbol> nonconst_symbol
|
||||
%type <symbol> symbol
|
||||
%type <expr> expr
|
||||
%type <expr> if_expr
|
||||
@ -101,14 +102,34 @@ static struct menu *current_menu, *current_entry;
|
||||
} if_entry menu_entry choice_entry
|
||||
|
||||
%{
|
||||
/* Include zconf.hash.c here so it can see the token constants. */
|
||||
#include "zconf.hash.c"
|
||||
/* Include kconf_id.c here so it can see the token constants. */
|
||||
#include "kconf_id.c"
|
||||
%}
|
||||
|
||||
%%
|
||||
input: nl start | start;
|
||||
|
||||
start: mainmenu_stmt stmt_list | stmt_list;
|
||||
start: mainmenu_stmt stmt_list | no_mainmenu_stmt stmt_list;
|
||||
|
||||
/* mainmenu entry */
|
||||
|
||||
mainmenu_stmt: T_MAINMENU prompt nl
|
||||
{
|
||||
menu_add_prompt(P_MENU, $2, NULL);
|
||||
};
|
||||
|
||||
/* Default main menu, if there's no mainmenu entry */
|
||||
|
||||
no_mainmenu_stmt: /* empty */
|
||||
{
|
||||
/*
|
||||
* Hack: Keep the main menu title on the heap so we can safely free it
|
||||
* later regardless of whether it comes from the 'prompt' in
|
||||
* mainmenu_stmt or here
|
||||
*/
|
||||
menu_add_prompt(P_MENU, xstrdup("Linux Kernel Configuration"), NULL);
|
||||
};
|
||||
|
||||
|
||||
stmt_list:
|
||||
/* empty */
|
||||
@ -119,7 +140,7 @@ stmt_list:
|
||||
| stmt_list T_WORD error T_EOL { zconf_error("unknown statement \"%s\"", $2); }
|
||||
| stmt_list option_name error T_EOL
|
||||
{
|
||||
zconf_error("unexpected option \"%s\"", kconf_id_strings + $2->name);
|
||||
zconf_error("unexpected option \"%s\"", $2->name);
|
||||
}
|
||||
| stmt_list error T_EOL { zconf_error("invalid statement"); }
|
||||
;
|
||||
@ -145,26 +166,23 @@ option_error:
|
||||
|
||||
/* config/menuconfig entry */
|
||||
|
||||
config_entry_start: T_CONFIG T_WORD T_EOL
|
||||
config_entry_start: T_CONFIG nonconst_symbol T_EOL
|
||||
{
|
||||
struct symbol *sym = sym_lookup($2, 0);
|
||||
sym->flags |= SYMBOL_OPTIONAL;
|
||||
menu_add_entry(sym);
|
||||
printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2);
|
||||
$2->flags |= SYMBOL_OPTIONAL;
|
||||
menu_add_entry($2);
|
||||
printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), $2->name);
|
||||
};
|
||||
|
||||
config_stmt: config_entry_start config_option_list
|
||||
{
|
||||
menu_end_entry();
|
||||
printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
|
||||
};
|
||||
|
||||
menuconfig_entry_start: T_MENUCONFIG T_WORD T_EOL
|
||||
menuconfig_entry_start: T_MENUCONFIG nonconst_symbol T_EOL
|
||||
{
|
||||
struct symbol *sym = sym_lookup($2, 0);
|
||||
sym->flags |= SYMBOL_OPTIONAL;
|
||||
menu_add_entry(sym);
|
||||
printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), $2);
|
||||
$2->flags |= SYMBOL_OPTIONAL;
|
||||
menu_add_entry($2);
|
||||
printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), $2->name);
|
||||
};
|
||||
|
||||
menuconfig_stmt: menuconfig_entry_start config_option_list
|
||||
@ -173,7 +191,6 @@ menuconfig_stmt: menuconfig_entry_start config_option_list
|
||||
current_entry->prompt->type = P_MENU;
|
||||
else
|
||||
zconfprint("warning: menuconfig statement without prompt");
|
||||
menu_end_entry();
|
||||
printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
|
||||
};
|
||||
|
||||
@ -211,15 +228,15 @@ config_option: T_DEFAULT expr if_expr T_EOL
|
||||
$1->stype);
|
||||
};
|
||||
|
||||
config_option: T_SELECT T_WORD if_expr T_EOL
|
||||
config_option: T_SELECT nonconst_symbol if_expr T_EOL
|
||||
{
|
||||
menu_add_symbol(P_SELECT, sym_lookup($2, 0), $3);
|
||||
menu_add_symbol(P_SELECT, $2, $3);
|
||||
printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno());
|
||||
};
|
||||
|
||||
config_option: T_IMPLY T_WORD if_expr T_EOL
|
||||
config_option: T_IMPLY nonconst_symbol if_expr T_EOL
|
||||
{
|
||||
menu_add_symbol(P_IMPLY, sym_lookup($2, 0), $3);
|
||||
menu_add_symbol(P_IMPLY, $2, $3);
|
||||
printd(DEBUG_PARSE, "%s:%d:imply\n", zconf_curname(), zconf_lineno());
|
||||
};
|
||||
|
||||
@ -237,8 +254,10 @@ symbol_option_list:
|
||||
| symbol_option_list T_WORD symbol_option_arg
|
||||
{
|
||||
const struct kconf_id *id = kconf_id_lookup($2, strlen($2));
|
||||
if (id && id->flags & TF_OPTION)
|
||||
if (id && id->flags & TF_OPTION) {
|
||||
menu_add_option(id->token, $3);
|
||||
free($3);
|
||||
}
|
||||
else
|
||||
zconfprint("warning: ignoring unknown option %s", $2);
|
||||
free($2);
|
||||
@ -257,6 +276,7 @@ choice: T_CHOICE word_opt T_EOL
|
||||
sym->flags |= SYMBOL_AUTO;
|
||||
menu_add_entry(sym);
|
||||
menu_add_expr(P_CHOICE, NULL, NULL);
|
||||
free($2);
|
||||
printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
|
||||
};
|
||||
|
||||
@ -308,10 +328,10 @@ choice_option: T_OPTIONAL T_EOL
|
||||
printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno());
|
||||
};
|
||||
|
||||
choice_option: T_DEFAULT T_WORD if_expr T_EOL
|
||||
choice_option: T_DEFAULT nonconst_symbol if_expr T_EOL
|
||||
{
|
||||
if ($1->stype == S_UNKNOWN) {
|
||||
menu_add_symbol(P_DEFAULT, sym_lookup($2, 0), $3);
|
||||
menu_add_symbol(P_DEFAULT, $2, $3);
|
||||
printd(DEBUG_PARSE, "%s:%d:default\n",
|
||||
zconf_curname(), zconf_lineno());
|
||||
} else
|
||||
@ -351,13 +371,6 @@ if_block:
|
||||
| if_block choice_stmt
|
||||
;
|
||||
|
||||
/* mainmenu entry */
|
||||
|
||||
mainmenu_stmt: T_MAINMENU prompt nl
|
||||
{
|
||||
menu_add_prompt(P_MENU, $2, NULL);
|
||||
};
|
||||
|
||||
/* menu entry */
|
||||
|
||||
menu: T_MENU prompt T_EOL
|
||||
@ -394,6 +407,7 @@ source_stmt: T_SOURCE prompt T_EOL
|
||||
{
|
||||
printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2);
|
||||
zconf_nextfile($2);
|
||||
free($2);
|
||||
};
|
||||
|
||||
/* comment entry */
|
||||
@ -406,9 +420,7 @@ comment: T_COMMENT prompt T_EOL
|
||||
};
|
||||
|
||||
comment_stmt: comment depends_list
|
||||
{
|
||||
menu_end_entry();
|
||||
};
|
||||
;
|
||||
|
||||
/* help option */
|
||||
|
||||
@ -420,6 +432,17 @@ help_start: T_HELP T_EOL
|
||||
|
||||
help: help_start T_HELPTEXT
|
||||
{
|
||||
if (current_entry->help) {
|
||||
free(current_entry->help);
|
||||
zconfprint("warning: '%s' defined with more than one help text -- only the last one will be used",
|
||||
current_entry->sym->name ?: "<choice>");
|
||||
}
|
||||
|
||||
/* Is the help text empty or all whitespace? */
|
||||
if ($2[strspn($2, " \f\n\r\t\v")] == '\0')
|
||||
zconfprint("warning: '%s' defined with blank help text",
|
||||
current_entry->sym->name ?: "<choice>");
|
||||
|
||||
current_entry->help = $2;
|
||||
};
|
||||
|
||||
@ -491,7 +514,10 @@ expr: symbol { $$ = expr_alloc_symbol($1); }
|
||||
| expr T_AND expr { $$ = expr_alloc_two(E_AND, $1, $3); }
|
||||
;
|
||||
|
||||
symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); }
|
||||
/* For symbol definitions, selects, etc., where quotes are not accepted */
|
||||
nonconst_symbol: T_WORD { $$ = sym_lookup($1, 0); free($1); };
|
||||
|
||||
symbol: nonconst_symbol
|
||||
| T_WORD_QUOTE { $$ = sym_lookup($1, SYMBOL_CONST); free($1); }
|
||||
;
|
||||
|
||||
@ -502,6 +528,7 @@ word_opt: /* empty */ { $$ = NULL; }
|
||||
|
||||
void conf_parse(const char *name)
|
||||
{
|
||||
const char *tmp;
|
||||
struct symbol *sym;
|
||||
int i;
|
||||
|
||||
@ -509,25 +536,26 @@ void conf_parse(const char *name)
|
||||
|
||||
sym_init();
|
||||
_menu_init();
|
||||
rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
|
||||
|
||||
if (getenv("ZCONF_DEBUG"))
|
||||
zconfdebug = 1;
|
||||
zconfparse();
|
||||
if (zconfnerrs)
|
||||
yydebug = 1;
|
||||
yyparse();
|
||||
if (yynerrs)
|
||||
exit(1);
|
||||
if (!modules_sym)
|
||||
modules_sym = sym_find( "n" );
|
||||
|
||||
tmp = rootmenu.prompt->text;
|
||||
rootmenu.prompt->text = _(rootmenu.prompt->text);
|
||||
rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text);
|
||||
free((char*)tmp);
|
||||
|
||||
menu_finalize(&rootmenu);
|
||||
for_all_symbols(i, sym) {
|
||||
if (sym_check_deps(sym))
|
||||
zconfnerrs++;
|
||||
yynerrs++;
|
||||
}
|
||||
if (zconfnerrs)
|
||||
if (yynerrs)
|
||||
exit(1);
|
||||
sym_set_change_count(1);
|
||||
}
|
||||
@ -551,17 +579,17 @@ static bool zconf_endtoken(const struct kconf_id *id, int starttoken, int endtok
|
||||
{
|
||||
if (id->token != endtoken) {
|
||||
zconf_error("unexpected '%s' within %s block",
|
||||
kconf_id_strings + id->name, zconf_tokenname(starttoken));
|
||||
zconfnerrs++;
|
||||
id->name, zconf_tokenname(starttoken));
|
||||
yynerrs++;
|
||||
return false;
|
||||
}
|
||||
if (current_menu->file != current_file) {
|
||||
zconf_error("'%s' in different file than '%s'",
|
||||
kconf_id_strings + id->name, zconf_tokenname(starttoken));
|
||||
id->name, zconf_tokenname(starttoken));
|
||||
fprintf(stderr, "%s:%d: location of the '%s'\n",
|
||||
current_menu->file->name, current_menu->lineno,
|
||||
zconf_tokenname(starttoken));
|
||||
zconfnerrs++;
|
||||
yynerrs++;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -582,7 +610,7 @@ static void zconf_error(const char *err, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
zconfnerrs++;
|
||||
yynerrs++;
|
||||
fprintf(stderr, "%s:%d: ", zconf_curname(), zconf_lineno());
|
||||
va_start(ap, err);
|
||||
vfprintf(stderr, err, ap);
|
||||
@ -590,7 +618,7 @@ static void zconf_error(const char *err, ...)
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
static void zconferror(const char *err)
|
||||
static void yyerror(const char *err)
|
||||
{
|
||||
fprintf(stderr, "%s:%d: %s\n", zconf_curname(), zconf_lineno() + 1, err);
|
||||
}
|
||||
@ -623,7 +651,7 @@ static void print_symbol(FILE *out, struct menu *menu)
|
||||
fprintf(out, "\nconfig %s\n", sym->name);
|
||||
switch (sym->type) {
|
||||
case S_BOOLEAN:
|
||||
fputs(" boolean\n", out);
|
||||
fputs(" bool\n", out);
|
||||
break;
|
||||
case S_TRISTATE:
|
||||
fputs(" tristate\n", out);
|
||||
|
Loading…
Reference in New Issue
Block a user