Merge tag 'kconfig-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kconfig updates from Masahiro Yamada: - Change 'option defconfig' to the environment variable KCONFIG_DEFCONFIG_LIST - Refactor tinyconfig without using allnoconfig_y - Remove 'option allnoconfig_y' syntax - Change 'option modules' to 'modules' - Do not use /boot/config-* etc. as base config for cross-compilation - Fix a search bug in nconf - Various code cleanups * tag 'kconfig-v5.13' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (34 commits) kconfig: refactor .gitignore kconfig: highlight xconfig 'comment' lines with '***' kconfig: highlight gconfig 'comment' lines with '***' kconfig: gconf: remove unused code kconfig: remove unused PACKAGE definition kconfig: nconf: stop endless search loops kconfig: split menu.c out of parser.y kconfig: nconf: refactor in print_in_middle() kconfig: nconf: remove meaningless wattrset() call from show_menu() kconfig: nconf: change set_config_filename() to void function kconfig: nconf: refactor attributes setup code kconfig: nconf: remove unneeded default for menu prompt kconfig: nconf: get rid of (void) casts from wattrset() calls kconfig: nconf: fix NORMAL attributes kconfig: mconf,nconf: remove unneeded '\0' termination after snprintf() kconfig: use /boot/config-* etc. as DEFCONFIG_LIST only for native build kconfig: change sym_change_count to a boolean flag kconfig: nconf: fix core dump when searching in empty menu kconfig: lxdialog: A spello fix and a punctuation added kconfig: streamline_config.pl: Couple of typo fixes ...
This commit is contained in:
@@ -223,26 +223,11 @@ applicable everywhere (see syntax).
|
|||||||
the indentation level, this means it ends at the first line which has
|
the indentation level, this means it ends at the first line which has
|
||||||
a smaller indentation than the first line of the help text.
|
a smaller indentation than the first line of the help text.
|
||||||
|
|
||||||
- misc options: "option" <symbol>[=<value>]
|
- module attribute: "modules"
|
||||||
|
|
||||||
Various less common options can be defined via this option syntax,
|
|
||||||
which can modify the behaviour of the menu entry and its config
|
|
||||||
symbol. These options are currently possible:
|
|
||||||
|
|
||||||
- "defconfig_list"
|
|
||||||
This declares a list of default entries which can be used when
|
|
||||||
looking for the default configuration (which is used when the main
|
|
||||||
.config doesn't exists yet.)
|
|
||||||
|
|
||||||
- "modules"
|
|
||||||
This declares the symbol to be used as the MODULES symbol, which
|
This declares the symbol to be used as the MODULES symbol, which
|
||||||
enables the third modular state for all config symbols.
|
enables the third modular state for all config symbols.
|
||||||
At most one symbol may have the "modules" option set.
|
At most one symbol may have the "modules" option set.
|
||||||
|
|
||||||
- "allnoconfig_y"
|
|
||||||
This declares the symbol as one that should have the value y when
|
|
||||||
using "allnoconfig". Used for symbols that hide other symbols.
|
|
||||||
|
|
||||||
Menu dependencies
|
Menu dependencies
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,14 @@ KCONFIG_CONFIG
|
|||||||
This environment variable can be used to specify a default kernel config
|
This environment variable can be used to specify a default kernel config
|
||||||
file name to override the default name of ".config".
|
file name to override the default name of ".config".
|
||||||
|
|
||||||
|
KCONFIG_DEFCONFIG_LIST
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
This environment variable specifies a list of config files which can be used
|
||||||
|
as a base configuration in case the .config does not exist yet. Entries in
|
||||||
|
the list are separated with whitespaces to each other, and the first one
|
||||||
|
that exists is used.
|
||||||
|
|
||||||
KCONFIG_OVERWRITECONFIG
|
KCONFIG_OVERWRITECONFIG
|
||||||
-----------------------
|
-----------------------
|
||||||
If you set KCONFIG_OVERWRITECONFIG in the environment, Kconfig will not
|
If you set KCONFIG_OVERWRITECONFIG in the environment, Kconfig will not
|
||||||
|
|||||||
8
Makefile
8
Makefile
@@ -404,12 +404,14 @@ ifeq ($(ARCH),sh64)
|
|||||||
SRCARCH := sh
|
SRCARCH := sh
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
export cross_compiling :=
|
||||||
|
ifneq ($(SRCARCH),$(SUBARCH))
|
||||||
|
cross_compiling := 1
|
||||||
|
endif
|
||||||
|
|
||||||
KCONFIG_CONFIG ?= .config
|
KCONFIG_CONFIG ?= .config
|
||||||
export KCONFIG_CONFIG
|
export KCONFIG_CONFIG
|
||||||
|
|
||||||
# Default file for 'make defconfig'. This may be overridden by arch-Makefile.
|
|
||||||
export KBUILD_DEFCONFIG := defconfig
|
|
||||||
|
|
||||||
# SHELL used by kbuild
|
# SHELL used by kbuild
|
||||||
CONFIG_SHELL := sh
|
CONFIG_SHELL := sh
|
||||||
|
|
||||||
|
|||||||
12
init/Kconfig
12
init/Kconfig
@@ -1,13 +1,4 @@
|
|||||||
# SPDX-License-Identifier: GPL-2.0-only
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
config DEFCONFIG_LIST
|
|
||||||
string
|
|
||||||
depends on !UML
|
|
||||||
option defconfig_list
|
|
||||||
default "/lib/modules/$(shell,uname -r)/.config"
|
|
||||||
default "/etc/kernel-config"
|
|
||||||
default "/boot/config-$(shell,uname -r)"
|
|
||||||
default "arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)"
|
|
||||||
|
|
||||||
config CC_VERSION_TEXT
|
config CC_VERSION_TEXT
|
||||||
string
|
string
|
||||||
default "$(CC_VERSION_TEXT)"
|
default "$(CC_VERSION_TEXT)"
|
||||||
@@ -1805,7 +1796,6 @@ config DEBUG_RSEQ
|
|||||||
|
|
||||||
config EMBEDDED
|
config EMBEDDED
|
||||||
bool "Embedded system"
|
bool "Embedded system"
|
||||||
option allnoconfig_y
|
|
||||||
select EXPERT
|
select EXPERT
|
||||||
help
|
help
|
||||||
This option should be enabled if compiling the kernel for
|
This option should be enabled if compiling the kernel for
|
||||||
@@ -2080,7 +2070,7 @@ config MODULE_SIG_FORMAT
|
|||||||
|
|
||||||
menuconfig MODULES
|
menuconfig MODULES
|
||||||
bool "Enable loadable module support"
|
bool "Enable loadable module support"
|
||||||
option modules
|
modules
|
||||||
help
|
help
|
||||||
Kernel modules are small pieces of compiled code which can
|
Kernel modules are small pieces of compiled code which can
|
||||||
be inserted in the running kernel, rather than being
|
be inserted in the running kernel, rather than being
|
||||||
|
|||||||
1
kernel/configs/tiny-base.config
Normal file
1
kernel/configs/tiny-base.config
Normal file
@@ -0,0 +1 @@
|
|||||||
|
CONFIG_EMBEDDED=y
|
||||||
13
scripts/kconfig/.gitignore
vendored
13
scripts/kconfig/.gitignore
vendored
@@ -1,12 +1,5 @@
|
|||||||
# SPDX-License-Identifier: GPL-2.0-only
|
# SPDX-License-Identifier: GPL-2.0-only
|
||||||
|
/conf
|
||||||
|
/[gmnq]conf
|
||||||
|
/[gmnq]conf-cfg
|
||||||
/qconf-moc.cc
|
/qconf-moc.cc
|
||||||
*conf-cfg
|
|
||||||
|
|
||||||
#
|
|
||||||
# configuration programs
|
|
||||||
#
|
|
||||||
conf
|
|
||||||
mconf
|
|
||||||
nconf
|
|
||||||
qconf
|
|
||||||
gconf
|
|
||||||
|
|||||||
@@ -9,10 +9,24 @@ else
|
|||||||
Kconfig := Kconfig
|
Kconfig := Kconfig
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifndef KBUILD_DEFCONFIG
|
||||||
|
KBUILD_DEFCONFIG := defconfig
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(quiet),silent_)
|
ifeq ($(quiet),silent_)
|
||||||
silent := -s
|
silent := -s
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
export KCONFIG_DEFCONFIG_LIST :=
|
||||||
|
ifndef cross_compiling
|
||||||
|
kernel-release := $(shell uname -r)
|
||||||
|
KCONFIG_DEFCONFIG_LIST += \
|
||||||
|
/lib/modules/$(kernel-release)/.config \
|
||||||
|
/etc/kernel-config \
|
||||||
|
/boot/config-$(kernel-release)
|
||||||
|
endif
|
||||||
|
KCONFIG_DEFCONFIG_LIST += arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG)
|
||||||
|
|
||||||
# We need this, in case the user has it in its environment
|
# We need this, in case the user has it in its environment
|
||||||
unexport CONFIG_
|
unexport CONFIG_
|
||||||
|
|
||||||
@@ -88,7 +102,8 @@ configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/c
|
|||||||
|
|
||||||
PHONY += tinyconfig
|
PHONY += tinyconfig
|
||||||
tinyconfig:
|
tinyconfig:
|
||||||
$(Q)$(MAKE) -f $(srctree)/Makefile allnoconfig tiny.config
|
$(Q)KCONFIG_ALLCONFIG=kernel/configs/tiny-base.config $(MAKE) -f $(srctree)/Makefile allnoconfig
|
||||||
|
$(Q)$(MAKE) -f $(srctree)/Makefile tiny.config
|
||||||
|
|
||||||
# CHECK: -o cache_dir=<path> working?
|
# CHECK: -o cache_dir=<path> working?
|
||||||
PHONY += testconfig
|
PHONY += testconfig
|
||||||
@@ -128,8 +143,8 @@ help:
|
|||||||
|
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
# object files used by all kconfig flavours
|
# object files used by all kconfig flavours
|
||||||
common-objs := confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o \
|
common-objs := confdata.o expr.o lexer.lex.o menu.o parser.tab.o \
|
||||||
symbol.o util.o
|
preprocess.o symbol.o util.o
|
||||||
|
|
||||||
$(obj)/lexer.lex.o: $(obj)/parser.tab.h
|
$(obj)/lexer.lex.o: $(obj)/parser.tab.h
|
||||||
HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src)
|
HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ enum input_mode {
|
|||||||
mod2yesconfig,
|
mod2yesconfig,
|
||||||
};
|
};
|
||||||
static enum input_mode input_mode = oldaskconfig;
|
static enum input_mode input_mode = oldaskconfig;
|
||||||
|
static int input_mode_opt;
|
||||||
static int indent = 1;
|
static int indent = 1;
|
||||||
static int tty_stdio;
|
static int tty_stdio;
|
||||||
static int sync_kconfig;
|
static int sync_kconfig;
|
||||||
@@ -82,6 +82,241 @@ static void xfgets(char *str, int size, FILE *in)
|
|||||||
printf("%s", str);
|
printf("%s", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void set_randconfig_seed(void)
|
||||||
|
{
|
||||||
|
unsigned int seed;
|
||||||
|
char *env;
|
||||||
|
bool seed_set = false;
|
||||||
|
|
||||||
|
env = getenv("KCONFIG_SEED");
|
||||||
|
if (env && *env) {
|
||||||
|
char *endp;
|
||||||
|
|
||||||
|
seed = strtol(env, &endp, 0);
|
||||||
|
if (*endp == '\0')
|
||||||
|
seed_set = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!seed_set) {
|
||||||
|
struct timeval now;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Use microseconds derived seed, compensate for systems where it may
|
||||||
|
* be zero.
|
||||||
|
*/
|
||||||
|
gettimeofday(&now, NULL);
|
||||||
|
seed = (now.tv_sec + 1) * (now.tv_usec + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("KCONFIG_SEED=0x%X\n", seed);
|
||||||
|
srand(seed);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool randomize_choice_values(struct symbol *csym)
|
||||||
|
{
|
||||||
|
struct property *prop;
|
||||||
|
struct symbol *sym;
|
||||||
|
struct expr *e;
|
||||||
|
int cnt, def;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If choice is mod then we may have more items selected
|
||||||
|
* and if no then no-one.
|
||||||
|
* In both cases stop.
|
||||||
|
*/
|
||||||
|
if (csym->curr.tri != yes)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
prop = sym_get_choice_prop(csym);
|
||||||
|
|
||||||
|
/* count entries in choice block */
|
||||||
|
cnt = 0;
|
||||||
|
expr_list_for_each_sym(prop->expr, e, sym)
|
||||||
|
cnt++;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* find a random value and set it to yes,
|
||||||
|
* set the rest to no so we have only one set
|
||||||
|
*/
|
||||||
|
def = rand() % cnt;
|
||||||
|
|
||||||
|
cnt = 0;
|
||||||
|
expr_list_for_each_sym(prop->expr, e, sym) {
|
||||||
|
if (def == cnt++) {
|
||||||
|
sym->def[S_DEF_USER].tri = yes;
|
||||||
|
csym->def[S_DEF_USER].val = sym;
|
||||||
|
} else {
|
||||||
|
sym->def[S_DEF_USER].tri = no;
|
||||||
|
}
|
||||||
|
sym->flags |= SYMBOL_DEF_USER;
|
||||||
|
/* clear VALID to get value calculated */
|
||||||
|
sym->flags &= ~SYMBOL_VALID;
|
||||||
|
}
|
||||||
|
csym->flags |= SYMBOL_DEF_USER;
|
||||||
|
/* clear VALID to get value calculated */
|
||||||
|
csym->flags &= ~SYMBOL_VALID;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum conf_def_mode {
|
||||||
|
def_default,
|
||||||
|
def_yes,
|
||||||
|
def_mod,
|
||||||
|
def_y2m,
|
||||||
|
def_m2y,
|
||||||
|
def_no,
|
||||||
|
def_random
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool conf_set_all_new_symbols(enum conf_def_mode mode)
|
||||||
|
{
|
||||||
|
struct symbol *sym, *csym;
|
||||||
|
int i, cnt;
|
||||||
|
/*
|
||||||
|
* can't go as the default in switch-case below, otherwise gcc whines
|
||||||
|
* about -Wmaybe-uninitialized
|
||||||
|
*/
|
||||||
|
int pby = 50; /* probability of bool = y */
|
||||||
|
int pty = 33; /* probability of tristate = y */
|
||||||
|
int ptm = 33; /* probability of tristate = m */
|
||||||
|
bool has_changed = false;
|
||||||
|
|
||||||
|
if (mode == def_random) {
|
||||||
|
int n, p[3];
|
||||||
|
char *env = getenv("KCONFIG_PROBABILITY");
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
while (env && *env) {
|
||||||
|
char *endp;
|
||||||
|
int tmp = strtol(env, &endp, 10);
|
||||||
|
|
||||||
|
if (tmp >= 0 && tmp <= 100) {
|
||||||
|
p[n++] = tmp;
|
||||||
|
} else {
|
||||||
|
errno = ERANGE;
|
||||||
|
perror("KCONFIG_PROBABILITY");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
env = (*endp == ':') ? endp + 1 : endp;
|
||||||
|
if (n >= 3)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch (n) {
|
||||||
|
case 1:
|
||||||
|
pby = p[0];
|
||||||
|
ptm = pby / 2;
|
||||||
|
pty = pby - ptm;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
pty = p[0];
|
||||||
|
ptm = p[1];
|
||||||
|
pby = pty + ptm;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
pby = p[0];
|
||||||
|
pty = p[1];
|
||||||
|
ptm = p[2];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pty + ptm > 100) {
|
||||||
|
errno = ERANGE;
|
||||||
|
perror("KCONFIG_PROBABILITY");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for_all_symbols(i, sym) {
|
||||||
|
if (sym_has_value(sym) || sym->flags & SYMBOL_VALID)
|
||||||
|
continue;
|
||||||
|
switch (sym_get_type(sym)) {
|
||||||
|
case S_BOOLEAN:
|
||||||
|
case S_TRISTATE:
|
||||||
|
has_changed = true;
|
||||||
|
switch (mode) {
|
||||||
|
case def_yes:
|
||||||
|
sym->def[S_DEF_USER].tri = yes;
|
||||||
|
break;
|
||||||
|
case def_mod:
|
||||||
|
sym->def[S_DEF_USER].tri = mod;
|
||||||
|
break;
|
||||||
|
case def_no:
|
||||||
|
sym->def[S_DEF_USER].tri = no;
|
||||||
|
break;
|
||||||
|
case def_random:
|
||||||
|
sym->def[S_DEF_USER].tri = no;
|
||||||
|
cnt = rand() % 100;
|
||||||
|
if (sym->type == S_TRISTATE) {
|
||||||
|
if (cnt < pty)
|
||||||
|
sym->def[S_DEF_USER].tri = yes;
|
||||||
|
else if (cnt < pty + ptm)
|
||||||
|
sym->def[S_DEF_USER].tri = mod;
|
||||||
|
} else if (cnt < pby)
|
||||||
|
sym->def[S_DEF_USER].tri = yes;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!(sym_is_choice(sym) && mode == def_random))
|
||||||
|
sym->flags |= SYMBOL_DEF_USER;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sym_clear_all_valid();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We have different type of choice blocks.
|
||||||
|
* If curr.tri equals to mod then we can select several
|
||||||
|
* choice symbols in one block.
|
||||||
|
* In this case we do nothing.
|
||||||
|
* If curr.tri equals yes then only one symbol can be
|
||||||
|
* selected in a choice block and we set it to yes,
|
||||||
|
* and the rest to no.
|
||||||
|
*/
|
||||||
|
if (mode != def_random) {
|
||||||
|
for_all_symbols(i, csym) {
|
||||||
|
if ((sym_is_choice(csym) && !sym_has_value(csym)) ||
|
||||||
|
sym_is_choice_value(csym))
|
||||||
|
csym->flags |= SYMBOL_NEED_SET_CHOICE_VALUES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for_all_symbols(i, csym) {
|
||||||
|
if (sym_has_value(csym) || !sym_is_choice(csym))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
sym_calc_value(csym);
|
||||||
|
if (mode == def_random)
|
||||||
|
has_changed |= randomize_choice_values(csym);
|
||||||
|
else {
|
||||||
|
set_all_choice_values(csym);
|
||||||
|
has_changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return has_changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void conf_rewrite_mod_or_yes(enum conf_def_mode mode)
|
||||||
|
{
|
||||||
|
struct symbol *sym;
|
||||||
|
int i;
|
||||||
|
tristate old_val = (mode == def_y2m) ? yes : mod;
|
||||||
|
tristate new_val = (mode == def_y2m) ? mod : yes;
|
||||||
|
|
||||||
|
for_all_symbols(i, sym) {
|
||||||
|
if (sym_get_type(sym) == S_TRISTATE &&
|
||||||
|
sym->def[S_DEF_USER].tri == old_val)
|
||||||
|
sym->def[S_DEF_USER].tri = new_val;
|
||||||
|
}
|
||||||
|
sym_clear_all_valid();
|
||||||
|
}
|
||||||
|
|
||||||
static int conf_askvalue(struct symbol *sym, const char *def)
|
static int conf_askvalue(struct symbol *sym, const char *def)
|
||||||
{
|
{
|
||||||
if (!sym_has_value(sym))
|
if (!sym_has_value(sym))
|
||||||
@@ -444,29 +679,35 @@ static void check_conf(struct menu *menu)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct option long_opts[] = {
|
static struct option long_opts[] = {
|
||||||
{"oldaskconfig", no_argument, NULL, oldaskconfig},
|
{"help", no_argument, NULL, 'h'},
|
||||||
{"oldconfig", no_argument, NULL, oldconfig},
|
{"silent", no_argument, NULL, 's'},
|
||||||
{"syncconfig", no_argument, NULL, syncconfig},
|
{"oldaskconfig", no_argument, &input_mode_opt, oldaskconfig},
|
||||||
{"defconfig", required_argument, NULL, defconfig},
|
{"oldconfig", no_argument, &input_mode_opt, oldconfig},
|
||||||
{"savedefconfig", required_argument, NULL, savedefconfig},
|
{"syncconfig", no_argument, &input_mode_opt, syncconfig},
|
||||||
{"allnoconfig", no_argument, NULL, allnoconfig},
|
{"defconfig", required_argument, &input_mode_opt, defconfig},
|
||||||
{"allyesconfig", no_argument, NULL, allyesconfig},
|
{"savedefconfig", required_argument, &input_mode_opt, savedefconfig},
|
||||||
{"allmodconfig", no_argument, NULL, allmodconfig},
|
{"allnoconfig", no_argument, &input_mode_opt, allnoconfig},
|
||||||
{"alldefconfig", no_argument, NULL, alldefconfig},
|
{"allyesconfig", no_argument, &input_mode_opt, allyesconfig},
|
||||||
{"randconfig", no_argument, NULL, randconfig},
|
{"allmodconfig", no_argument, &input_mode_opt, allmodconfig},
|
||||||
{"listnewconfig", no_argument, NULL, listnewconfig},
|
{"alldefconfig", no_argument, &input_mode_opt, alldefconfig},
|
||||||
{"helpnewconfig", no_argument, NULL, helpnewconfig},
|
{"randconfig", no_argument, &input_mode_opt, randconfig},
|
||||||
{"olddefconfig", no_argument, NULL, olddefconfig},
|
{"listnewconfig", no_argument, &input_mode_opt, listnewconfig},
|
||||||
{"yes2modconfig", no_argument, NULL, yes2modconfig},
|
{"helpnewconfig", no_argument, &input_mode_opt, helpnewconfig},
|
||||||
{"mod2yesconfig", no_argument, NULL, mod2yesconfig},
|
{"olddefconfig", no_argument, &input_mode_opt, olddefconfig},
|
||||||
|
{"yes2modconfig", no_argument, &input_mode_opt, yes2modconfig},
|
||||||
|
{"mod2yesconfig", no_argument, &input_mode_opt, mod2yesconfig},
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void conf_usage(const char *progname)
|
static void conf_usage(const char *progname)
|
||||||
{
|
{
|
||||||
|
printf("Usage: %s [options] <kconfig-file>\n", progname);
|
||||||
printf("Usage: %s [-s] [option] <kconfig-file>\n", progname);
|
printf("\n");
|
||||||
printf("[option] is _one_ of the following:\n");
|
printf("Generic options:\n");
|
||||||
|
printf(" -h, --help Print this message and exit.\n");
|
||||||
|
printf(" -s, --silent Do not print log.\n");
|
||||||
|
printf("\n");
|
||||||
|
printf("Mode options:\n");
|
||||||
printf(" --listnewconfig List new options\n");
|
printf(" --listnewconfig List new options\n");
|
||||||
printf(" --helpnewconfig List new options and help text\n");
|
printf(" --helpnewconfig List new options and help text\n");
|
||||||
printf(" --oldaskconfig Start a new configuration using a line-oriented program\n");
|
printf(" --oldaskconfig Start a new configuration using a line-oriented program\n");
|
||||||
@@ -496,16 +737,22 @@ int main(int ac, char **av)
|
|||||||
tty_stdio = isatty(0) && isatty(1);
|
tty_stdio = isatty(0) && isatty(1);
|
||||||
|
|
||||||
while ((opt = getopt_long(ac, av, "hs", long_opts, NULL)) != -1) {
|
while ((opt = getopt_long(ac, av, "hs", long_opts, NULL)) != -1) {
|
||||||
if (opt == 's') {
|
|
||||||
conf_set_message_callback(NULL);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
input_mode = (enum input_mode)opt;
|
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
case 'h':
|
||||||
|
conf_usage(progname);
|
||||||
|
exit(1);
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
conf_set_message_callback(NULL);
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
input_mode = input_mode_opt;
|
||||||
|
switch (input_mode) {
|
||||||
case syncconfig:
|
case syncconfig:
|
||||||
/*
|
/*
|
||||||
* syncconfig is invoked during the build stage.
|
* syncconfig is invoked during the build stage.
|
||||||
* Suppress distracting "configuration written to ..."
|
* Suppress distracting
|
||||||
|
* "configuration written to ..."
|
||||||
*/
|
*/
|
||||||
conf_set_message_callback(NULL);
|
conf_set_message_callback(NULL);
|
||||||
sync_kconfig = 1;
|
sync_kconfig = 1;
|
||||||
@@ -515,45 +762,12 @@ int main(int ac, char **av)
|
|||||||
defconfig_file = optarg;
|
defconfig_file = optarg;
|
||||||
break;
|
break;
|
||||||
case randconfig:
|
case randconfig:
|
||||||
{
|
set_randconfig_seed();
|
||||||
struct timeval now;
|
break;
|
||||||
unsigned int seed;
|
default:
|
||||||
char *seed_env;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Use microseconds derived seed,
|
|
||||||
* compensate for systems where it may be zero
|
|
||||||
*/
|
|
||||||
gettimeofday(&now, NULL);
|
|
||||||
seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1));
|
|
||||||
|
|
||||||
seed_env = getenv("KCONFIG_SEED");
|
|
||||||
if( seed_env && *seed_env ) {
|
|
||||||
char *endp;
|
|
||||||
int tmp = (int)strtol(seed_env, &endp, 0);
|
|
||||||
if (*endp == '\0') {
|
|
||||||
seed = tmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fprintf( stderr, "KCONFIG_SEED=0x%X\n", seed );
|
|
||||||
srand(seed);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case oldaskconfig:
|
default:
|
||||||
case oldconfig:
|
|
||||||
case allnoconfig:
|
|
||||||
case allyesconfig:
|
|
||||||
case allmodconfig:
|
|
||||||
case alldefconfig:
|
|
||||||
case listnewconfig:
|
|
||||||
case helpnewconfig:
|
|
||||||
case olddefconfig:
|
|
||||||
case yes2modconfig:
|
|
||||||
case mod2yesconfig:
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
conf_usage(progname);
|
|
||||||
exit(1);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -562,8 +776,7 @@ int main(int ac, char **av)
|
|||||||
conf_usage(progname);
|
conf_usage(progname);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
name = av[optind];
|
conf_parse(av[optind]);
|
||||||
conf_parse(name);
|
|
||||||
//zconfdump(stdout);
|
//zconfdump(stdout);
|
||||||
|
|
||||||
switch (input_mode) {
|
switch (input_mode) {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ static bool is_dir(const char *path)
|
|||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
if (stat(path, &st))
|
if (stat(path, &st))
|
||||||
return 0;
|
return false;
|
||||||
|
|
||||||
return S_ISDIR(st.st_mode);
|
return S_ISDIR(st.st_mode);
|
||||||
}
|
}
|
||||||
@@ -355,28 +355,46 @@ int conf_read_simple(const char *name, int def)
|
|||||||
if (name) {
|
if (name) {
|
||||||
in = zconf_fopen(name);
|
in = zconf_fopen(name);
|
||||||
} else {
|
} else {
|
||||||
struct property *prop;
|
char *env;
|
||||||
|
|
||||||
name = conf_get_configname();
|
name = conf_get_configname();
|
||||||
in = zconf_fopen(name);
|
in = zconf_fopen(name);
|
||||||
if (in)
|
if (in)
|
||||||
goto load;
|
goto load;
|
||||||
sym_add_change_count(1);
|
conf_set_changed(true);
|
||||||
if (!sym_defconfig_list)
|
|
||||||
|
env = getenv("KCONFIG_DEFCONFIG_LIST");
|
||||||
|
if (!env)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for_all_defaults(sym_defconfig_list, prop) {
|
while (1) {
|
||||||
if (expr_calc_value(prop->visible.expr) == no ||
|
bool is_last;
|
||||||
prop->expr->type != E_SYMBOL)
|
|
||||||
continue;
|
while (isspace(*env))
|
||||||
sym_calc_value(prop->expr->left.sym);
|
env++;
|
||||||
name = sym_get_string_value(prop->expr->left.sym);
|
|
||||||
in = zconf_fopen(name);
|
if (!*env)
|
||||||
|
break;
|
||||||
|
|
||||||
|
p = env;
|
||||||
|
while (*p && !isspace(*p))
|
||||||
|
p++;
|
||||||
|
|
||||||
|
is_last = (*p == '\0');
|
||||||
|
|
||||||
|
*p = '\0';
|
||||||
|
|
||||||
|
in = zconf_fopen(env);
|
||||||
if (in) {
|
if (in) {
|
||||||
conf_message("using defaults found in %s",
|
conf_message("using defaults found in %s",
|
||||||
name);
|
env);
|
||||||
goto load;
|
goto load;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_last)
|
||||||
|
break;
|
||||||
|
|
||||||
|
env = p + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!in)
|
if (!in)
|
||||||
@@ -421,7 +439,7 @@ load:
|
|||||||
if (def == S_DEF_USER) {
|
if (def == S_DEF_USER) {
|
||||||
sym = sym_find(line + 2 + strlen(CONFIG_));
|
sym = sym_find(line + 2 + strlen(CONFIG_));
|
||||||
if (!sym) {
|
if (!sym) {
|
||||||
sym_add_change_count(1);
|
conf_set_changed(true);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -464,7 +482,7 @@ load:
|
|||||||
*/
|
*/
|
||||||
conf_touch_dep(line + strlen(CONFIG_));
|
conf_touch_dep(line + strlen(CONFIG_));
|
||||||
else
|
else
|
||||||
sym_add_change_count(1);
|
conf_set_changed(true);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -512,7 +530,7 @@ int conf_read(const char *name)
|
|||||||
int conf_unsaved = 0;
|
int conf_unsaved = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
sym_set_change_count(0);
|
conf_set_changed(false);
|
||||||
|
|
||||||
if (conf_read_simple(name, S_DEF_USER)) {
|
if (conf_read_simple(name, S_DEF_USER)) {
|
||||||
sym_calc_value(modules_sym);
|
sym_calc_value(modules_sym);
|
||||||
@@ -570,7 +588,8 @@ int conf_read(const char *name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sym_add_change_count(conf_warnings || conf_unsaved);
|
if (conf_warnings || conf_unsaved)
|
||||||
|
conf_set_changed(true);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -915,7 +934,7 @@ next:
|
|||||||
if (is_same(name, tmpname)) {
|
if (is_same(name, tmpname)) {
|
||||||
conf_message("No change to %s", name);
|
conf_message("No change to %s", name);
|
||||||
unlink(tmpname);
|
unlink(tmpname);
|
||||||
sym_set_change_count(0);
|
conf_set_changed(false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -927,7 +946,7 @@ next:
|
|||||||
|
|
||||||
conf_message("configuration written to %s", name);
|
conf_message("configuration written to %s", name);
|
||||||
|
|
||||||
sym_set_change_count(0);
|
conf_set_changed(false);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1095,26 +1114,20 @@ int conf_write_autoconf(int overwrite)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sym_change_count;
|
static bool conf_changed;
|
||||||
static void (*conf_changed_callback)(void);
|
static void (*conf_changed_callback)(void);
|
||||||
|
|
||||||
void sym_set_change_count(int count)
|
void conf_set_changed(bool val)
|
||||||
{
|
{
|
||||||
int _sym_change_count = sym_change_count;
|
if (conf_changed_callback && conf_changed != val)
|
||||||
sym_change_count = count;
|
|
||||||
if (conf_changed_callback &&
|
|
||||||
(bool)_sym_change_count != (bool)count)
|
|
||||||
conf_changed_callback();
|
conf_changed_callback();
|
||||||
}
|
|
||||||
|
|
||||||
void sym_add_change_count(int count)
|
conf_changed = val;
|
||||||
{
|
|
||||||
sym_set_change_count(count + sym_change_count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool conf_get_changed(void)
|
bool conf_get_changed(void)
|
||||||
{
|
{
|
||||||
return sym_change_count;
|
return conf_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void conf_set_changed_callback(void (*fn)(void))
|
void conf_set_changed_callback(void (*fn)(void))
|
||||||
@@ -1122,54 +1135,6 @@ void conf_set_changed_callback(void (*fn)(void))
|
|||||||
conf_changed_callback = fn;
|
conf_changed_callback = fn;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool randomize_choice_values(struct symbol *csym)
|
|
||||||
{
|
|
||||||
struct property *prop;
|
|
||||||
struct symbol *sym;
|
|
||||||
struct expr *e;
|
|
||||||
int cnt, def;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If choice is mod then we may have more items selected
|
|
||||||
* and if no then no-one.
|
|
||||||
* In both cases stop.
|
|
||||||
*/
|
|
||||||
if (csym->curr.tri != yes)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
prop = sym_get_choice_prop(csym);
|
|
||||||
|
|
||||||
/* count entries in choice block */
|
|
||||||
cnt = 0;
|
|
||||||
expr_list_for_each_sym(prop->expr, e, sym)
|
|
||||||
cnt++;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* find a random value and set it to yes,
|
|
||||||
* set the rest to no so we have only one set
|
|
||||||
*/
|
|
||||||
def = (rand() % cnt);
|
|
||||||
|
|
||||||
cnt = 0;
|
|
||||||
expr_list_for_each_sym(prop->expr, e, sym) {
|
|
||||||
if (def == cnt++) {
|
|
||||||
sym->def[S_DEF_USER].tri = yes;
|
|
||||||
csym->def[S_DEF_USER].val = sym;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sym->def[S_DEF_USER].tri = no;
|
|
||||||
}
|
|
||||||
sym->flags |= SYMBOL_DEF_USER;
|
|
||||||
/* clear VALID to get value calculated */
|
|
||||||
sym->flags &= ~SYMBOL_VALID;
|
|
||||||
}
|
|
||||||
csym->flags |= SYMBOL_DEF_USER;
|
|
||||||
/* clear VALID to get value calculated */
|
|
||||||
csym->flags &= ~(SYMBOL_VALID);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_all_choice_values(struct symbol *csym)
|
void set_all_choice_values(struct symbol *csym)
|
||||||
{
|
{
|
||||||
struct property *prop;
|
struct property *prop;
|
||||||
@@ -1189,146 +1154,3 @@ void set_all_choice_values(struct symbol *csym)
|
|||||||
/* clear VALID to get value calculated */
|
/* clear VALID to get value calculated */
|
||||||
csym->flags &= ~(SYMBOL_VALID | SYMBOL_NEED_SET_CHOICE_VALUES);
|
csym->flags &= ~(SYMBOL_VALID | SYMBOL_NEED_SET_CHOICE_VALUES);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool conf_set_all_new_symbols(enum conf_def_mode mode)
|
|
||||||
{
|
|
||||||
struct symbol *sym, *csym;
|
|
||||||
int i, cnt, pby, pty, ptm; /* pby: probability of bool = y
|
|
||||||
* pty: probability of tristate = y
|
|
||||||
* ptm: probability of tristate = m
|
|
||||||
*/
|
|
||||||
|
|
||||||
pby = 50; pty = ptm = 33; /* can't go as the default in switch-case
|
|
||||||
* below, otherwise gcc whines about
|
|
||||||
* -Wmaybe-uninitialized */
|
|
||||||
if (mode == def_random) {
|
|
||||||
int n, p[3];
|
|
||||||
char *env = getenv("KCONFIG_PROBABILITY");
|
|
||||||
n = 0;
|
|
||||||
while( env && *env ) {
|
|
||||||
char *endp;
|
|
||||||
int tmp = strtol( env, &endp, 10 );
|
|
||||||
if( tmp >= 0 && tmp <= 100 ) {
|
|
||||||
p[n++] = tmp;
|
|
||||||
} else {
|
|
||||||
errno = ERANGE;
|
|
||||||
perror( "KCONFIG_PROBABILITY" );
|
|
||||||
exit( 1 );
|
|
||||||
}
|
|
||||||
env = (*endp == ':') ? endp+1 : endp;
|
|
||||||
if( n >=3 ) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
switch( n ) {
|
|
||||||
case 1:
|
|
||||||
pby = p[0]; ptm = pby/2; pty = pby-ptm;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
pty = p[0]; ptm = p[1]; pby = pty + ptm;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
pby = p[0]; pty = p[1]; ptm = p[2];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( pty+ptm > 100 ) {
|
|
||||||
errno = ERANGE;
|
|
||||||
perror( "KCONFIG_PROBABILITY" );
|
|
||||||
exit( 1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool has_changed = false;
|
|
||||||
|
|
||||||
for_all_symbols(i, sym) {
|
|
||||||
if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID))
|
|
||||||
continue;
|
|
||||||
switch (sym_get_type(sym)) {
|
|
||||||
case S_BOOLEAN:
|
|
||||||
case S_TRISTATE:
|
|
||||||
has_changed = true;
|
|
||||||
switch (mode) {
|
|
||||||
case def_yes:
|
|
||||||
sym->def[S_DEF_USER].tri = yes;
|
|
||||||
break;
|
|
||||||
case def_mod:
|
|
||||||
sym->def[S_DEF_USER].tri = mod;
|
|
||||||
break;
|
|
||||||
case def_no:
|
|
||||||
if (sym->flags & SYMBOL_ALLNOCONFIG_Y)
|
|
||||||
sym->def[S_DEF_USER].tri = yes;
|
|
||||||
else
|
|
||||||
sym->def[S_DEF_USER].tri = no;
|
|
||||||
break;
|
|
||||||
case def_random:
|
|
||||||
sym->def[S_DEF_USER].tri = no;
|
|
||||||
cnt = rand() % 100;
|
|
||||||
if (sym->type == S_TRISTATE) {
|
|
||||||
if (cnt < pty)
|
|
||||||
sym->def[S_DEF_USER].tri = yes;
|
|
||||||
else if (cnt < (pty+ptm))
|
|
||||||
sym->def[S_DEF_USER].tri = mod;
|
|
||||||
} else if (cnt < pby)
|
|
||||||
sym->def[S_DEF_USER].tri = yes;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!(sym_is_choice(sym) && mode == def_random))
|
|
||||||
sym->flags |= SYMBOL_DEF_USER;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
sym_clear_all_valid();
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We have different type of choice blocks.
|
|
||||||
* If curr.tri equals to mod then we can select several
|
|
||||||
* choice symbols in one block.
|
|
||||||
* In this case we do nothing.
|
|
||||||
* If curr.tri equals yes then only one symbol can be
|
|
||||||
* selected in a choice block and we set it to yes,
|
|
||||||
* and the rest to no.
|
|
||||||
*/
|
|
||||||
if (mode != def_random) {
|
|
||||||
for_all_symbols(i, csym) {
|
|
||||||
if ((sym_is_choice(csym) && !sym_has_value(csym)) ||
|
|
||||||
sym_is_choice_value(csym))
|
|
||||||
csym->flags |= SYMBOL_NEED_SET_CHOICE_VALUES;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for_all_symbols(i, csym) {
|
|
||||||
if (sym_has_value(csym) || !sym_is_choice(csym))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
sym_calc_value(csym);
|
|
||||||
if (mode == def_random)
|
|
||||||
has_changed |= randomize_choice_values(csym);
|
|
||||||
else {
|
|
||||||
set_all_choice_values(csym);
|
|
||||||
has_changed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return has_changed;
|
|
||||||
}
|
|
||||||
|
|
||||||
void conf_rewrite_mod_or_yes(enum conf_def_mode mode)
|
|
||||||
{
|
|
||||||
struct symbol *sym;
|
|
||||||
int i;
|
|
||||||
tristate old_val = (mode == def_y2m) ? yes : mod;
|
|
||||||
tristate new_val = (mode == def_y2m) ? mod : yes;
|
|
||||||
|
|
||||||
for_all_symbols(i, sym) {
|
|
||||||
if (sym_get_type(sym) == S_TRISTATE &&
|
|
||||||
sym->def[S_DEF_USER].tri == old_val)
|
|
||||||
sym->def[S_DEF_USER].tri = new_val;
|
|
||||||
}
|
|
||||||
sym_clear_all_valid();
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -156,9 +156,6 @@ struct symbol {
|
|||||||
/* choice values need to be set before calculating this symbol value */
|
/* choice values need to be set before calculating this symbol value */
|
||||||
#define SYMBOL_NEED_SET_CHOICE_VALUES 0x100000
|
#define SYMBOL_NEED_SET_CHOICE_VALUES 0x100000
|
||||||
|
|
||||||
/* Set symbol to y if allnoconfig; used for symbols that hide others */
|
|
||||||
#define SYMBOL_ALLNOCONFIG_Y 0x200000
|
|
||||||
|
|
||||||
#define SYMBOL_MAXLENGTH 256
|
#define SYMBOL_MAXLENGTH 256
|
||||||
#define SYMBOL_HASHSIZE 9973
|
#define SYMBOL_HASHSIZE 9973
|
||||||
|
|
||||||
@@ -281,15 +278,12 @@ struct jump_key {
|
|||||||
int index;
|
int index;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define JUMP_NB 9
|
|
||||||
|
|
||||||
extern struct file *file_list;
|
extern struct file *file_list;
|
||||||
extern struct file *current_file;
|
extern struct file *current_file;
|
||||||
struct file *lookup_file(const char *name);
|
struct file *lookup_file(const char *name);
|
||||||
|
|
||||||
extern struct symbol symbol_yes, symbol_no, symbol_mod;
|
extern struct symbol symbol_yes, symbol_no, symbol_mod;
|
||||||
extern struct symbol *modules_sym;
|
extern struct symbol *modules_sym;
|
||||||
extern struct symbol *sym_defconfig_list;
|
|
||||||
extern int cdebug;
|
extern int cdebug;
|
||||||
struct expr *expr_alloc_symbol(struct symbol *sym);
|
struct expr *expr_alloc_symbol(struct symbol *sym);
|
||||||
struct expr *expr_alloc_one(enum expr_type type, struct expr *ce);
|
struct expr *expr_alloc_one(enum expr_type type, struct expr *ce);
|
||||||
|
|||||||
@@ -3,10 +3,6 @@
|
|||||||
* Copyright (C) 2002-2003 Romain Lievin <roms@tilp.info>
|
* Copyright (C) 2002-2003 Romain Lievin <roms@tilp.info>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
|
||||||
# include <config.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "lkc.h"
|
#include "lkc.h"
|
||||||
#include "images.h"
|
#include "images.h"
|
||||||
@@ -1048,8 +1044,13 @@ static gchar **fill_row(struct menu *menu)
|
|||||||
g_free(row[i]);
|
g_free(row[i]);
|
||||||
bzero(row, sizeof(row));
|
bzero(row, sizeof(row));
|
||||||
|
|
||||||
|
ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
|
||||||
|
|
||||||
row[COL_OPTION] =
|
row[COL_OPTION] =
|
||||||
g_strdup_printf("%s %s", menu_get_prompt(menu),
|
g_strdup_printf("%s %s %s %s",
|
||||||
|
ptype == P_COMMENT ? "***" : "",
|
||||||
|
menu_get_prompt(menu),
|
||||||
|
ptype == P_COMMENT ? "***" : "",
|
||||||
sym && !sym_has_value(sym) ? "(NEW)" : "");
|
sym && !sym_has_value(sym) ? "(NEW)" : "");
|
||||||
|
|
||||||
if (opt_mode == OPT_ALL && !menu_is_visible(menu))
|
if (opt_mode == OPT_ALL && !menu_is_visible(menu))
|
||||||
@@ -1060,7 +1061,6 @@ static gchar **fill_row(struct menu *menu)
|
|||||||
else
|
else
|
||||||
row[COL_COLOR] = g_strdup("Black");
|
row[COL_COLOR] = g_strdup("Black");
|
||||||
|
|
||||||
ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
|
|
||||||
switch (ptype) {
|
switch (ptype) {
|
||||||
case P_MENU:
|
case P_MENU:
|
||||||
row[COL_PIXBUF] = (gchar *) xpm_menu;
|
row[COL_PIXBUF] = (gchar *) xpm_menu;
|
||||||
@@ -1452,9 +1452,6 @@ int main(int ac, char *av[])
|
|||||||
gtk_init(&ac, &av);
|
gtk_init(&ac, &av);
|
||||||
glade_init();
|
glade_init();
|
||||||
|
|
||||||
//add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
|
|
||||||
//add_pixmap_directory (PACKAGE_SOURCE_DIR "/pixmaps");
|
|
||||||
|
|
||||||
/* Determine GUI path */
|
/* Determine GUI path */
|
||||||
env = getenv(SRCTREE);
|
env = getenv(SRCTREE);
|
||||||
if (env)
|
if (env)
|
||||||
|
|||||||
9
scripts/kconfig/internal.h
Normal file
9
scripts/kconfig/internal.h
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||||
|
#ifndef INTERNAL_H
|
||||||
|
#define INTERNAL_H
|
||||||
|
|
||||||
|
struct menu;
|
||||||
|
|
||||||
|
extern struct menu *current_menu, *current_entry;
|
||||||
|
|
||||||
|
#endif /* INTERNAL_H */
|
||||||
@@ -91,7 +91,6 @@ n [A-Za-z0-9_-]
|
|||||||
[ \t]* /* whitespaces */
|
[ \t]* /* whitespaces */
|
||||||
\\\n /* escaped new line */
|
\\\n /* escaped new line */
|
||||||
\n return T_EOL;
|
\n return T_EOL;
|
||||||
"allnoconfig_y" return T_ALLNOCONFIG_Y;
|
|
||||||
"bool" return T_BOOL;
|
"bool" return T_BOOL;
|
||||||
"choice" return T_CHOICE;
|
"choice" return T_CHOICE;
|
||||||
"comment" return T_COMMENT;
|
"comment" return T_COMMENT;
|
||||||
@@ -99,7 +98,6 @@ n [A-Za-z0-9_-]
|
|||||||
"def_bool" return T_DEF_BOOL;
|
"def_bool" return T_DEF_BOOL;
|
||||||
"def_tristate" return T_DEF_TRISTATE;
|
"def_tristate" return T_DEF_TRISTATE;
|
||||||
"default" return T_DEFAULT;
|
"default" return T_DEFAULT;
|
||||||
"defconfig_list" return T_DEFCONFIG_LIST;
|
|
||||||
"depends" return T_DEPENDS;
|
"depends" return T_DEPENDS;
|
||||||
"endchoice" return T_ENDCHOICE;
|
"endchoice" return T_ENDCHOICE;
|
||||||
"endif" return T_ENDIF;
|
"endif" return T_ENDIF;
|
||||||
@@ -114,7 +112,6 @@ n [A-Za-z0-9_-]
|
|||||||
"menuconfig" return T_MENUCONFIG;
|
"menuconfig" return T_MENUCONFIG;
|
||||||
"modules" return T_MODULES;
|
"modules" return T_MODULES;
|
||||||
"on" return T_ON;
|
"on" return T_ON;
|
||||||
"option" return T_OPTION;
|
|
||||||
"optional" return T_OPTIONAL;
|
"optional" return T_OPTIONAL;
|
||||||
"prompt" return T_PROMPT;
|
"prompt" return T_PROMPT;
|
||||||
"range" return T_RANGE;
|
"range" return T_RANGE;
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ extern "C" {
|
|||||||
|
|
||||||
#define SRCTREE "srctree"
|
#define SRCTREE "srctree"
|
||||||
|
|
||||||
#ifndef PACKAGE
|
|
||||||
#define PACKAGE "linux"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CONFIG_
|
#ifndef CONFIG_
|
||||||
#define CONFIG_ "CONFIG_"
|
#define CONFIG_ "CONFIG_"
|
||||||
#endif
|
#endif
|
||||||
@@ -34,16 +30,6 @@ static inline const char *CONFIG_prefix(void)
|
|||||||
#undef CONFIG_
|
#undef CONFIG_
|
||||||
#define CONFIG_ CONFIG_prefix()
|
#define CONFIG_ CONFIG_prefix()
|
||||||
|
|
||||||
enum conf_def_mode {
|
|
||||||
def_default,
|
|
||||||
def_yes,
|
|
||||||
def_mod,
|
|
||||||
def_y2m,
|
|
||||||
def_m2y,
|
|
||||||
def_no,
|
|
||||||
def_random
|
|
||||||
};
|
|
||||||
|
|
||||||
extern int yylineno;
|
extern int yylineno;
|
||||||
void zconfdump(FILE *out);
|
void zconfdump(FILE *out);
|
||||||
void zconf_starthelp(void);
|
void zconf_starthelp(void);
|
||||||
@@ -55,10 +41,6 @@ const char *zconf_curname(void);
|
|||||||
|
|
||||||
/* confdata.c */
|
/* confdata.c */
|
||||||
const char *conf_get_configname(void);
|
const char *conf_get_configname(void);
|
||||||
void sym_set_change_count(int count);
|
|
||||||
void sym_add_change_count(int count);
|
|
||||||
bool conf_set_all_new_symbols(enum conf_def_mode mode);
|
|
||||||
void conf_rewrite_mod_or_yes(enum conf_def_mode mode);
|
|
||||||
void set_all_choice_values(struct symbol *csym);
|
void set_all_choice_values(struct symbol *csym);
|
||||||
|
|
||||||
/* confdata.c and expr.c */
|
/* confdata.c and expr.c */
|
||||||
@@ -107,9 +89,6 @@ void menu_add_visibility(struct expr *dep);
|
|||||||
struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
|
struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep);
|
||||||
void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
|
void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
|
||||||
void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
|
void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
|
||||||
void menu_add_option_modules(void);
|
|
||||||
void menu_add_option_defconfig_list(void);
|
|
||||||
void menu_add_option_allnoconfig_y(void);
|
|
||||||
void menu_finalize(struct menu *parent);
|
void menu_finalize(struct menu *parent);
|
||||||
void menu_set_type(int type);
|
void menu_set_type(int type);
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ int conf_read_simple(const char *name, int);
|
|||||||
int conf_write_defconfig(const char *name);
|
int conf_write_defconfig(const char *name);
|
||||||
int conf_write(const char *name);
|
int conf_write(const char *name);
|
||||||
int conf_write_autoconf(int overwrite);
|
int conf_write_autoconf(int overwrite);
|
||||||
|
void conf_set_changed(bool val);
|
||||||
bool conf_get_changed(void);
|
bool conf_get_changed(void);
|
||||||
void conf_set_changed_callback(void (*fn)(void));
|
void conf_set_changed_callback(void (*fn)(void));
|
||||||
void conf_set_message_callback(void (*fn)(const char *s));
|
void conf_set_message_callback(void (*fn)(const char *s));
|
||||||
|
|||||||
@@ -363,7 +363,7 @@ void print_title(WINDOW *dialog, const char *title, int width)
|
|||||||
/*
|
/*
|
||||||
* Print a string of text in a window, automatically wrap around to the
|
* Print a string of text in a window, automatically wrap around to the
|
||||||
* next line if the string is too long to fit on one line. Newline
|
* next line if the string is too long to fit on one line. Newline
|
||||||
* characters '\n' are propperly processed. We start on a new line
|
* characters '\n' are properly processed. We start on a new line
|
||||||
* if there is no room for at least 4 nonblanks following a double-space.
|
* if there is no room for at least 4 nonblanks following a double-space.
|
||||||
*/
|
*/
|
||||||
void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
|
void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
|
||||||
@@ -541,7 +541,7 @@ int first_alpha(const char *string, const char *exempt)
|
|||||||
* lxdialog suggest <ESC> <ESC> which is correctly translated to two
|
* lxdialog suggest <ESC> <ESC> which is correctly translated to two
|
||||||
* times esc. But then we need to ignore the second esc to avoid stepping
|
* times esc. But then we need to ignore the second esc to avoid stepping
|
||||||
* out one menu too much. Filter away all escaped key sequences since
|
* out one menu too much. Filter away all escaped key sequences since
|
||||||
* keypad(FALSE) turn off ncurses support for escape sequences - and thats
|
* keypad(FALSE) turn off ncurses support for escape sequences - and that's
|
||||||
* needed to make notimeout() do as expected.
|
* needed to make notimeout() do as expected.
|
||||||
*/
|
*/
|
||||||
int on_key_esc(WINDOW *win)
|
int on_key_esc(WINDOW *win)
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
#include "lkc.h"
|
#include "lkc.h"
|
||||||
#include "lxdialog/dialog.h"
|
#include "lxdialog/dialog.h"
|
||||||
|
|
||||||
|
#define JUMP_NB 9
|
||||||
|
|
||||||
static const char mconf_readme[] =
|
static const char mconf_readme[] =
|
||||||
"Overview\n"
|
"Overview\n"
|
||||||
"--------\n"
|
"--------\n"
|
||||||
@@ -297,17 +299,12 @@ static char filename[PATH_MAX+1];
|
|||||||
static void set_config_filename(const char *config_filename)
|
static void set_config_filename(const char *config_filename)
|
||||||
{
|
{
|
||||||
static char menu_backtitle[PATH_MAX+128];
|
static char menu_backtitle[PATH_MAX+128];
|
||||||
int size;
|
|
||||||
|
|
||||||
size = snprintf(menu_backtitle, sizeof(menu_backtitle),
|
snprintf(menu_backtitle, sizeof(menu_backtitle), "%s - %s",
|
||||||
"%s - %s", config_filename, rootmenu.prompt->text);
|
config_filename, rootmenu.prompt->text);
|
||||||
if (size >= sizeof(menu_backtitle))
|
|
||||||
menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
|
|
||||||
set_dialog_backtitle(menu_backtitle);
|
set_dialog_backtitle(menu_backtitle);
|
||||||
|
|
||||||
size = snprintf(filename, sizeof(filename), "%s", config_filename);
|
snprintf(filename, sizeof(filename), "%s", config_filename);
|
||||||
if (size >= sizeof(filename))
|
|
||||||
filename[sizeof(filename)-1] = '\0';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct subtitle_part {
|
struct subtitle_part {
|
||||||
@@ -908,7 +905,7 @@ static void conf_load(void)
|
|||||||
return;
|
return;
|
||||||
if (!conf_read(dialog_input_result)) {
|
if (!conf_read(dialog_input_result)) {
|
||||||
set_config_filename(dialog_input_result);
|
set_config_filename(dialog_input_result);
|
||||||
sym_set_change_count(1);
|
conf_set_changed(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
show_textbox(NULL, "File does not exist!", 5, 38);
|
show_textbox(NULL, "File does not exist!", 5, 38);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "lkc.h"
|
#include "lkc.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
static const char nohelp_text[] = "There is no help available for this option.";
|
static const char nohelp_text[] = "There is no help available for this option.";
|
||||||
|
|
||||||
@@ -211,28 +212,6 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep)
|
|||||||
menu_add_prop(type, expr_alloc_symbol(sym), dep);
|
menu_add_prop(type, expr_alloc_symbol(sym), dep);
|
||||||
}
|
}
|
||||||
|
|
||||||
void menu_add_option_modules(void)
|
|
||||||
{
|
|
||||||
if (modules_sym)
|
|
||||||
zconf_error("symbol '%s' redefines option 'modules' already defined by symbol '%s'",
|
|
||||||
current_entry->sym->name, modules_sym->name);
|
|
||||||
modules_sym = current_entry->sym;
|
|
||||||
}
|
|
||||||
|
|
||||||
void menu_add_option_defconfig_list(void)
|
|
||||||
{
|
|
||||||
if (!sym_defconfig_list)
|
|
||||||
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_NO_WRITE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void menu_add_option_allnoconfig_y(void)
|
|
||||||
{
|
|
||||||
current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int menu_validate_number(struct symbol *sym, struct symbol *sym2)
|
static int menu_validate_number(struct symbol *sym, struct symbol *sym2)
|
||||||
{
|
{
|
||||||
return sym2->type == S_INT || sym2->type == S_HEX ||
|
return sym2->type == S_INT || sym2->type == S_HEX ||
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ static int mwin_max_cols;
|
|||||||
static MENU *curses_menu;
|
static MENU *curses_menu;
|
||||||
static ITEM *curses_menu_items[MAX_MENU_ITEMS];
|
static ITEM *curses_menu_items[MAX_MENU_ITEMS];
|
||||||
static struct mitem k_menu_items[MAX_MENU_ITEMS];
|
static struct mitem k_menu_items[MAX_MENU_ITEMS];
|
||||||
static int items_num;
|
static unsigned int items_num;
|
||||||
static int global_exit;
|
static int global_exit;
|
||||||
/* the currently selected button */
|
/* the currently selected button */
|
||||||
static const char *current_instructions = menu_instructions;
|
static const char *current_instructions = menu_instructions;
|
||||||
@@ -370,18 +370,18 @@ static void print_function_line(void)
|
|||||||
int lines = getmaxy(stdscr);
|
int lines = getmaxy(stdscr);
|
||||||
|
|
||||||
for (i = 0; i < function_keys_num; i++) {
|
for (i = 0; i < function_keys_num; i++) {
|
||||||
(void) wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]);
|
wattrset(main_window, attr_function_highlight);
|
||||||
mvwprintw(main_window, lines-3, offset,
|
mvwprintw(main_window, lines-3, offset,
|
||||||
"%s",
|
"%s",
|
||||||
function_keys[i].key_str);
|
function_keys[i].key_str);
|
||||||
(void) wattrset(main_window, attributes[FUNCTION_TEXT]);
|
wattrset(main_window, attr_function_text);
|
||||||
offset += strlen(function_keys[i].key_str);
|
offset += strlen(function_keys[i].key_str);
|
||||||
mvwprintw(main_window, lines-3,
|
mvwprintw(main_window, lines-3,
|
||||||
offset, "%s",
|
offset, "%s",
|
||||||
function_keys[i].func);
|
function_keys[i].func);
|
||||||
offset += strlen(function_keys[i].func) + skip;
|
offset += strlen(function_keys[i].func) + skip;
|
||||||
}
|
}
|
||||||
(void) wattrset(main_window, attributes[NORMAL]);
|
wattrset(main_window, attr_normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* help */
|
/* help */
|
||||||
@@ -496,16 +496,20 @@ typedef enum {MATCH_TINKER_PATTERN_UP, MATCH_TINKER_PATTERN_DOWN,
|
|||||||
/* return the index of the matched item, or -1 if no such item exists */
|
/* return the index of the matched item, or -1 if no such item exists */
|
||||||
static int get_mext_match(const char *match_str, match_f flag)
|
static int get_mext_match(const char *match_str, match_f flag)
|
||||||
{
|
{
|
||||||
int match_start = item_index(current_item(curses_menu));
|
int match_start, index;
|
||||||
int index;
|
|
||||||
|
/* Do not search if the menu is empty (i.e. items_num == 0) */
|
||||||
|
match_start = item_index(current_item(curses_menu));
|
||||||
|
if (match_start == ERR)
|
||||||
|
return -1;
|
||||||
|
|
||||||
if (flag == FIND_NEXT_MATCH_DOWN)
|
if (flag == FIND_NEXT_MATCH_DOWN)
|
||||||
++match_start;
|
++match_start;
|
||||||
else if (flag == FIND_NEXT_MATCH_UP)
|
else if (flag == FIND_NEXT_MATCH_UP)
|
||||||
--match_start;
|
--match_start;
|
||||||
|
|
||||||
|
match_start = (match_start + items_num) % items_num;
|
||||||
index = match_start;
|
index = match_start;
|
||||||
index = (index + items_num) % items_num;
|
|
||||||
while (true) {
|
while (true) {
|
||||||
char *str = k_menu_items[index].str;
|
char *str = k_menu_items[index].str;
|
||||||
if (strcasestr(str, match_str) != NULL)
|
if (strcasestr(str, match_str) != NULL)
|
||||||
@@ -627,19 +631,12 @@ static int item_is_tag(char tag)
|
|||||||
|
|
||||||
static char filename[PATH_MAX+1];
|
static char filename[PATH_MAX+1];
|
||||||
static char menu_backtitle[PATH_MAX+128];
|
static char menu_backtitle[PATH_MAX+128];
|
||||||
static const char *set_config_filename(const char *config_filename)
|
static void set_config_filename(const char *config_filename)
|
||||||
{
|
{
|
||||||
int size;
|
snprintf(menu_backtitle, sizeof(menu_backtitle), "%s - %s",
|
||||||
|
config_filename, rootmenu.prompt->text);
|
||||||
|
|
||||||
size = snprintf(menu_backtitle, sizeof(menu_backtitle),
|
snprintf(filename, sizeof(filename), "%s", config_filename);
|
||||||
"%s - %s", config_filename, rootmenu.prompt->text);
|
|
||||||
if (size >= sizeof(menu_backtitle))
|
|
||||||
menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
|
|
||||||
|
|
||||||
size = snprintf(filename, sizeof(filename), "%s", config_filename);
|
|
||||||
if (size >= sizeof(filename))
|
|
||||||
filename[sizeof(filename)-1] = '\0';
|
|
||||||
return menu_backtitle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return = 0 means we are successful.
|
/* return = 0 means we are successful.
|
||||||
@@ -956,16 +953,15 @@ static void show_menu(const char *prompt, const char *instructions,
|
|||||||
current_instructions = instructions;
|
current_instructions = instructions;
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
(void) wattrset(main_window, attributes[NORMAL]);
|
print_in_middle(stdscr, 1, getmaxx(stdscr),
|
||||||
print_in_middle(stdscr, 1, 0, getmaxx(stdscr),
|
|
||||||
menu_backtitle,
|
menu_backtitle,
|
||||||
attributes[MAIN_HEADING]);
|
attr_main_heading);
|
||||||
|
|
||||||
(void) wattrset(main_window, attributes[MAIN_MENU_BOX]);
|
wattrset(main_window, attr_main_menu_box);
|
||||||
box(main_window, 0, 0);
|
box(main_window, 0, 0);
|
||||||
(void) wattrset(main_window, attributes[MAIN_MENU_HEADING]);
|
wattrset(main_window, attr_main_menu_heading);
|
||||||
mvwprintw(main_window, 0, 3, " %s ", prompt);
|
mvwprintw(main_window, 0, 3, " %s ", prompt);
|
||||||
(void) wattrset(main_window, attributes[NORMAL]);
|
wattrset(main_window, attr_normal);
|
||||||
|
|
||||||
set_menu_items(curses_menu, curses_menu_items);
|
set_menu_items(curses_menu, curses_menu_items);
|
||||||
|
|
||||||
@@ -1068,7 +1064,6 @@ static int do_match(int key, struct match_state *state, int *ans)
|
|||||||
static void conf(struct menu *menu)
|
static void conf(struct menu *menu)
|
||||||
{
|
{
|
||||||
struct menu *submenu = NULL;
|
struct menu *submenu = NULL;
|
||||||
const char *prompt = menu_get_prompt(menu);
|
|
||||||
struct symbol *sym;
|
struct symbol *sym;
|
||||||
int res;
|
int res;
|
||||||
int current_index = 0;
|
int current_index = 0;
|
||||||
@@ -1086,8 +1081,7 @@ static void conf(struct menu *menu)
|
|||||||
if (!child_count)
|
if (!child_count)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
show_menu(prompt ? prompt : "Main Menu",
|
show_menu(menu_get_prompt(menu), menu_instructions,
|
||||||
menu_instructions,
|
|
||||||
current_index, &last_top_row);
|
current_index, &last_top_row);
|
||||||
keypad((menu_win(curses_menu)), TRUE);
|
keypad((menu_win(curses_menu)), TRUE);
|
||||||
while (!global_exit) {
|
while (!global_exit) {
|
||||||
@@ -1404,7 +1398,7 @@ static void conf_load(void)
|
|||||||
return;
|
return;
|
||||||
if (!conf_read(dialog_input_result)) {
|
if (!conf_read(dialog_input_result)) {
|
||||||
set_config_filename(dialog_input_result);
|
set_config_filename(dialog_input_result);
|
||||||
sym_set_change_count(1);
|
conf_set_changed(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
btn_dialog(main_window, "File does not exist!", 0);
|
btn_dialog(main_window, "File does not exist!", 0);
|
||||||
@@ -1523,9 +1517,9 @@ int main(int ac, char **av)
|
|||||||
menu_opts_on(curses_menu, O_NONCYCLIC);
|
menu_opts_on(curses_menu, O_NONCYCLIC);
|
||||||
menu_opts_on(curses_menu, O_IGNORECASE);
|
menu_opts_on(curses_menu, O_IGNORECASE);
|
||||||
set_menu_mark(curses_menu, " ");
|
set_menu_mark(curses_menu, " ");
|
||||||
set_menu_fore(curses_menu, attributes[MAIN_MENU_FORE]);
|
set_menu_fore(curses_menu, attr_main_menu_fore);
|
||||||
set_menu_back(curses_menu, attributes[MAIN_MENU_BACK]);
|
set_menu_back(curses_menu, attr_main_menu_back);
|
||||||
set_menu_grey(curses_menu, attributes[MAIN_MENU_GREY]);
|
set_menu_grey(curses_menu, attr_main_menu_grey);
|
||||||
|
|
||||||
set_config_filename(conf_get_configname());
|
set_config_filename(conf_get_configname());
|
||||||
setup_windows();
|
setup_windows();
|
||||||
|
|||||||
@@ -7,169 +7,120 @@
|
|||||||
#include "nconf.h"
|
#include "nconf.h"
|
||||||
#include "lkc.h"
|
#include "lkc.h"
|
||||||
|
|
||||||
/* a list of all the different widgets we use */
|
int attr_normal;
|
||||||
attributes_t attributes[ATTR_MAX+1] = {0};
|
int attr_main_heading;
|
||||||
|
int attr_main_menu_box;
|
||||||
|
int attr_main_menu_fore;
|
||||||
|
int attr_main_menu_back;
|
||||||
|
int attr_main_menu_grey;
|
||||||
|
int attr_main_menu_heading;
|
||||||
|
int attr_scrollwin_text;
|
||||||
|
int attr_scrollwin_heading;
|
||||||
|
int attr_scrollwin_box;
|
||||||
|
int attr_dialog_text;
|
||||||
|
int attr_dialog_menu_fore;
|
||||||
|
int attr_dialog_menu_back;
|
||||||
|
int attr_dialog_box;
|
||||||
|
int attr_input_box;
|
||||||
|
int attr_input_heading;
|
||||||
|
int attr_input_text;
|
||||||
|
int attr_input_field;
|
||||||
|
int attr_function_text;
|
||||||
|
int attr_function_highlight;
|
||||||
|
|
||||||
/* available colors:
|
#define COLOR_ATTR(_at, _fg, _bg, _hl) \
|
||||||
COLOR_BLACK 0
|
{ .attr = &(_at), .has_color = true, .color_fg = _fg, .color_bg = _bg, .highlight = _hl }
|
||||||
COLOR_RED 1
|
#define NO_COLOR_ATTR(_at, _hl) \
|
||||||
COLOR_GREEN 2
|
{ .attr = &(_at), .has_color = false, .highlight = _hl }
|
||||||
COLOR_YELLOW 3
|
#define COLOR_DEFAULT -1
|
||||||
COLOR_BLUE 4
|
|
||||||
COLOR_MAGENTA 5
|
|
||||||
COLOR_CYAN 6
|
|
||||||
COLOR_WHITE 7
|
|
||||||
*/
|
|
||||||
static void set_normal_colors(void)
|
|
||||||
{
|
|
||||||
init_pair(NORMAL, -1, -1);
|
|
||||||
init_pair(MAIN_HEADING, COLOR_MAGENTA, -1);
|
|
||||||
|
|
||||||
/* FORE is for the selected item */
|
struct nconf_attr_param {
|
||||||
init_pair(MAIN_MENU_FORE, -1, -1);
|
int *attr;
|
||||||
/* BACK for all the rest */
|
bool has_color;
|
||||||
init_pair(MAIN_MENU_BACK, -1, -1);
|
int color_fg;
|
||||||
init_pair(MAIN_MENU_GREY, -1, -1);
|
int color_bg;
|
||||||
init_pair(MAIN_MENU_HEADING, COLOR_GREEN, -1);
|
int highlight;
|
||||||
init_pair(MAIN_MENU_BOX, COLOR_YELLOW, -1);
|
};
|
||||||
|
|
||||||
init_pair(SCROLLWIN_TEXT, -1, -1);
|
static const struct nconf_attr_param color_theme_params[] = {
|
||||||
init_pair(SCROLLWIN_HEADING, COLOR_GREEN, -1);
|
COLOR_ATTR(attr_normal, COLOR_DEFAULT, COLOR_DEFAULT, A_NORMAL),
|
||||||
init_pair(SCROLLWIN_BOX, COLOR_YELLOW, -1);
|
COLOR_ATTR(attr_main_heading, COLOR_MAGENTA, COLOR_DEFAULT, A_BOLD | A_UNDERLINE),
|
||||||
|
COLOR_ATTR(attr_main_menu_box, COLOR_YELLOW, COLOR_DEFAULT, A_NORMAL),
|
||||||
|
COLOR_ATTR(attr_main_menu_fore, COLOR_DEFAULT, COLOR_DEFAULT, A_REVERSE),
|
||||||
|
COLOR_ATTR(attr_main_menu_back, COLOR_DEFAULT, COLOR_DEFAULT, A_NORMAL),
|
||||||
|
COLOR_ATTR(attr_main_menu_grey, COLOR_DEFAULT, COLOR_DEFAULT, A_NORMAL),
|
||||||
|
COLOR_ATTR(attr_main_menu_heading, COLOR_GREEN, COLOR_DEFAULT, A_BOLD),
|
||||||
|
COLOR_ATTR(attr_scrollwin_text, COLOR_DEFAULT, COLOR_DEFAULT, A_NORMAL),
|
||||||
|
COLOR_ATTR(attr_scrollwin_heading, COLOR_GREEN, COLOR_DEFAULT, A_BOLD),
|
||||||
|
COLOR_ATTR(attr_scrollwin_box, COLOR_YELLOW, COLOR_DEFAULT, A_BOLD),
|
||||||
|
COLOR_ATTR(attr_dialog_text, COLOR_DEFAULT, COLOR_DEFAULT, A_BOLD),
|
||||||
|
COLOR_ATTR(attr_dialog_menu_fore, COLOR_RED, COLOR_DEFAULT, A_STANDOUT),
|
||||||
|
COLOR_ATTR(attr_dialog_menu_back, COLOR_YELLOW, COLOR_DEFAULT, A_NORMAL),
|
||||||
|
COLOR_ATTR(attr_dialog_box, COLOR_YELLOW, COLOR_DEFAULT, A_BOLD),
|
||||||
|
COLOR_ATTR(attr_input_box, COLOR_YELLOW, COLOR_DEFAULT, A_NORMAL),
|
||||||
|
COLOR_ATTR(attr_input_heading, COLOR_GREEN, COLOR_DEFAULT, A_BOLD),
|
||||||
|
COLOR_ATTR(attr_input_text, COLOR_DEFAULT, COLOR_DEFAULT, A_NORMAL),
|
||||||
|
COLOR_ATTR(attr_input_field, COLOR_DEFAULT, COLOR_DEFAULT, A_UNDERLINE),
|
||||||
|
COLOR_ATTR(attr_function_text, COLOR_YELLOW, COLOR_DEFAULT, A_REVERSE),
|
||||||
|
COLOR_ATTR(attr_function_highlight, COLOR_DEFAULT, COLOR_DEFAULT, A_BOLD),
|
||||||
|
{ /* sentinel */ }
|
||||||
|
};
|
||||||
|
|
||||||
init_pair(DIALOG_TEXT, -1, -1);
|
static const struct nconf_attr_param no_color_theme_params[] = {
|
||||||
init_pair(DIALOG_BOX, COLOR_YELLOW, -1);
|
NO_COLOR_ATTR(attr_normal, A_NORMAL),
|
||||||
init_pair(DIALOG_MENU_BACK, COLOR_YELLOW, -1);
|
NO_COLOR_ATTR(attr_main_heading, A_BOLD | A_UNDERLINE),
|
||||||
init_pair(DIALOG_MENU_FORE, COLOR_RED, -1);
|
NO_COLOR_ATTR(attr_main_menu_box, A_NORMAL),
|
||||||
|
NO_COLOR_ATTR(attr_main_menu_fore, A_STANDOUT),
|
||||||
init_pair(INPUT_BOX, COLOR_YELLOW, -1);
|
NO_COLOR_ATTR(attr_main_menu_back, A_NORMAL),
|
||||||
init_pair(INPUT_HEADING, COLOR_GREEN, -1);
|
NO_COLOR_ATTR(attr_main_menu_grey, A_NORMAL),
|
||||||
init_pair(INPUT_TEXT, -1, -1);
|
NO_COLOR_ATTR(attr_main_menu_heading, A_BOLD),
|
||||||
init_pair(INPUT_FIELD, -1, -1);
|
NO_COLOR_ATTR(attr_scrollwin_text, A_NORMAL),
|
||||||
|
NO_COLOR_ATTR(attr_scrollwin_heading, A_BOLD),
|
||||||
init_pair(FUNCTION_HIGHLIGHT, -1, -1);
|
NO_COLOR_ATTR(attr_scrollwin_box, A_BOLD),
|
||||||
init_pair(FUNCTION_TEXT, COLOR_YELLOW, -1);
|
NO_COLOR_ATTR(attr_dialog_text, A_NORMAL),
|
||||||
}
|
NO_COLOR_ATTR(attr_dialog_menu_fore, A_STANDOUT),
|
||||||
|
NO_COLOR_ATTR(attr_dialog_menu_back, A_NORMAL),
|
||||||
/* available attributes:
|
NO_COLOR_ATTR(attr_dialog_box, A_BOLD),
|
||||||
A_NORMAL Normal display (no highlight)
|
NO_COLOR_ATTR(attr_input_box, A_BOLD),
|
||||||
A_STANDOUT Best highlighting mode of the terminal.
|
NO_COLOR_ATTR(attr_input_heading, A_BOLD),
|
||||||
A_UNDERLINE Underlining
|
NO_COLOR_ATTR(attr_input_text, A_NORMAL),
|
||||||
A_REVERSE Reverse video
|
NO_COLOR_ATTR(attr_input_field, A_UNDERLINE),
|
||||||
A_BLINK Blinking
|
NO_COLOR_ATTR(attr_function_text, A_REVERSE),
|
||||||
A_DIM Half bright
|
NO_COLOR_ATTR(attr_function_highlight, A_BOLD),
|
||||||
A_BOLD Extra bright or bold
|
{ /* sentinel */ }
|
||||||
A_PROTECT Protected mode
|
};
|
||||||
A_INVIS Invisible or blank mode
|
|
||||||
A_ALTCHARSET Alternate character set
|
|
||||||
A_CHARTEXT Bit-mask to extract a character
|
|
||||||
COLOR_PAIR(n) Color-pair number n
|
|
||||||
*/
|
|
||||||
static void normal_color_theme(void)
|
|
||||||
{
|
|
||||||
/* automatically add color... */
|
|
||||||
#define mkattr(name, attr) do { \
|
|
||||||
attributes[name] = attr | COLOR_PAIR(name); } while (0)
|
|
||||||
mkattr(NORMAL, NORMAL);
|
|
||||||
mkattr(MAIN_HEADING, A_BOLD | A_UNDERLINE);
|
|
||||||
|
|
||||||
mkattr(MAIN_MENU_FORE, A_REVERSE);
|
|
||||||
mkattr(MAIN_MENU_BACK, A_NORMAL);
|
|
||||||
mkattr(MAIN_MENU_GREY, A_NORMAL);
|
|
||||||
mkattr(MAIN_MENU_HEADING, A_BOLD);
|
|
||||||
mkattr(MAIN_MENU_BOX, A_NORMAL);
|
|
||||||
|
|
||||||
mkattr(SCROLLWIN_TEXT, A_NORMAL);
|
|
||||||
mkattr(SCROLLWIN_HEADING, A_BOLD);
|
|
||||||
mkattr(SCROLLWIN_BOX, A_BOLD);
|
|
||||||
|
|
||||||
mkattr(DIALOG_TEXT, A_BOLD);
|
|
||||||
mkattr(DIALOG_BOX, A_BOLD);
|
|
||||||
mkattr(DIALOG_MENU_FORE, A_STANDOUT);
|
|
||||||
mkattr(DIALOG_MENU_BACK, A_NORMAL);
|
|
||||||
|
|
||||||
mkattr(INPUT_BOX, A_NORMAL);
|
|
||||||
mkattr(INPUT_HEADING, A_BOLD);
|
|
||||||
mkattr(INPUT_TEXT, A_NORMAL);
|
|
||||||
mkattr(INPUT_FIELD, A_UNDERLINE);
|
|
||||||
|
|
||||||
mkattr(FUNCTION_HIGHLIGHT, A_BOLD);
|
|
||||||
mkattr(FUNCTION_TEXT, A_REVERSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void no_colors_theme(void)
|
|
||||||
{
|
|
||||||
/* automatically add highlight, no color */
|
|
||||||
#define mkattrn(name, attr) { attributes[name] = attr; }
|
|
||||||
|
|
||||||
mkattrn(NORMAL, NORMAL);
|
|
||||||
mkattrn(MAIN_HEADING, A_BOLD | A_UNDERLINE);
|
|
||||||
|
|
||||||
mkattrn(MAIN_MENU_FORE, A_STANDOUT);
|
|
||||||
mkattrn(MAIN_MENU_BACK, A_NORMAL);
|
|
||||||
mkattrn(MAIN_MENU_GREY, A_NORMAL);
|
|
||||||
mkattrn(MAIN_MENU_HEADING, A_BOLD);
|
|
||||||
mkattrn(MAIN_MENU_BOX, A_NORMAL);
|
|
||||||
|
|
||||||
mkattrn(SCROLLWIN_TEXT, A_NORMAL);
|
|
||||||
mkattrn(SCROLLWIN_HEADING, A_BOLD);
|
|
||||||
mkattrn(SCROLLWIN_BOX, A_BOLD);
|
|
||||||
|
|
||||||
mkattrn(DIALOG_TEXT, A_NORMAL);
|
|
||||||
mkattrn(DIALOG_BOX, A_BOLD);
|
|
||||||
mkattrn(DIALOG_MENU_FORE, A_STANDOUT);
|
|
||||||
mkattrn(DIALOG_MENU_BACK, A_NORMAL);
|
|
||||||
|
|
||||||
mkattrn(INPUT_BOX, A_BOLD);
|
|
||||||
mkattrn(INPUT_HEADING, A_BOLD);
|
|
||||||
mkattrn(INPUT_TEXT, A_NORMAL);
|
|
||||||
mkattrn(INPUT_FIELD, A_UNDERLINE);
|
|
||||||
|
|
||||||
mkattrn(FUNCTION_HIGHLIGHT, A_BOLD);
|
|
||||||
mkattrn(FUNCTION_TEXT, A_REVERSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_colors(void)
|
void set_colors(void)
|
||||||
{
|
{
|
||||||
|
const struct nconf_attr_param *p;
|
||||||
|
int pair = 0;
|
||||||
|
|
||||||
|
if (has_colors()) {
|
||||||
start_color();
|
start_color();
|
||||||
use_default_colors();
|
use_default_colors();
|
||||||
set_normal_colors();
|
p = color_theme_params;
|
||||||
if (has_colors()) {
|
|
||||||
normal_color_theme();
|
|
||||||
} else {
|
} else {
|
||||||
/* give defaults */
|
p = no_color_theme_params;
|
||||||
no_colors_theme();
|
}
|
||||||
|
|
||||||
|
for (; p->attr; p++) {
|
||||||
|
int attr = p->highlight;
|
||||||
|
|
||||||
|
if (p->has_color) {
|
||||||
|
pair++;
|
||||||
|
init_pair(pair, p->color_fg, p->color_bg);
|
||||||
|
attr |= COLOR_PAIR(pair);
|
||||||
|
}
|
||||||
|
|
||||||
|
*p->attr = attr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* this changes the windows attributes !!! */
|
/* this changes the windows attributes !!! */
|
||||||
void print_in_middle(WINDOW *win,
|
void print_in_middle(WINDOW *win, int y, int width, const char *str, int attrs)
|
||||||
int starty,
|
{
|
||||||
int startx,
|
wattrset(win, attrs);
|
||||||
int width,
|
mvwprintw(win, y, (width - strlen(str)) / 2, "%s", str);
|
||||||
const char *string,
|
|
||||||
chtype color)
|
|
||||||
{ int length, x, y;
|
|
||||||
float temp;
|
|
||||||
|
|
||||||
|
|
||||||
if (win == NULL)
|
|
||||||
win = stdscr;
|
|
||||||
getyx(win, y, x);
|
|
||||||
if (startx != 0)
|
|
||||||
x = startx;
|
|
||||||
if (starty != 0)
|
|
||||||
y = starty;
|
|
||||||
if (width == 0)
|
|
||||||
width = 80;
|
|
||||||
|
|
||||||
length = strlen(string);
|
|
||||||
temp = (width - length) / 2;
|
|
||||||
x = startx + (int)temp;
|
|
||||||
(void) wattrset(win, color);
|
|
||||||
mvwprintw(win, y, x, "%s", string);
|
|
||||||
refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_line_no(const char *text)
|
int get_line_no(const char *text)
|
||||||
@@ -294,14 +245,14 @@ int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...)
|
|||||||
msg_win = derwin(win, win_rows-2, msg_width, 1,
|
msg_win = derwin(win, win_rows-2, msg_width, 1,
|
||||||
1+(total_width+2-msg_width)/2);
|
1+(total_width+2-msg_width)/2);
|
||||||
|
|
||||||
set_menu_fore(menu, attributes[DIALOG_MENU_FORE]);
|
set_menu_fore(menu, attr_dialog_menu_fore);
|
||||||
set_menu_back(menu, attributes[DIALOG_MENU_BACK]);
|
set_menu_back(menu, attr_dialog_menu_back);
|
||||||
|
|
||||||
(void) wattrset(win, attributes[DIALOG_BOX]);
|
wattrset(win, attr_dialog_box);
|
||||||
box(win, 0, 0);
|
box(win, 0, 0);
|
||||||
|
|
||||||
/* print message */
|
/* print message */
|
||||||
(void) wattrset(msg_win, attributes[DIALOG_TEXT]);
|
wattrset(msg_win, attr_dialog_text);
|
||||||
fill_window(msg_win, msg);
|
fill_window(msg_win, msg);
|
||||||
|
|
||||||
set_menu_win(menu, win);
|
set_menu_win(menu, win);
|
||||||
@@ -405,16 +356,16 @@ int dialog_inputbox(WINDOW *main_window,
|
|||||||
form_win = derwin(win, 1, prompt_width, prompt_lines+3, 2);
|
form_win = derwin(win, 1, prompt_width, prompt_lines+3, 2);
|
||||||
keypad(form_win, TRUE);
|
keypad(form_win, TRUE);
|
||||||
|
|
||||||
(void) wattrset(form_win, attributes[INPUT_FIELD]);
|
wattrset(form_win, attr_input_field);
|
||||||
|
|
||||||
(void) wattrset(win, attributes[INPUT_BOX]);
|
wattrset(win, attr_input_box);
|
||||||
box(win, 0, 0);
|
box(win, 0, 0);
|
||||||
(void) wattrset(win, attributes[INPUT_HEADING]);
|
wattrset(win, attr_input_heading);
|
||||||
if (title)
|
if (title)
|
||||||
mvwprintw(win, 0, 3, "%s", title);
|
mvwprintw(win, 0, 3, "%s", title);
|
||||||
|
|
||||||
/* print message */
|
/* print message */
|
||||||
(void) wattrset(prompt_win, attributes[INPUT_TEXT]);
|
wattrset(prompt_win, attr_input_text);
|
||||||
fill_window(prompt_win, prompt);
|
fill_window(prompt_win, prompt);
|
||||||
|
|
||||||
mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
|
mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
|
||||||
@@ -576,7 +527,7 @@ void show_scroll_win(WINDOW *main_window,
|
|||||||
|
|
||||||
/* create the pad */
|
/* create the pad */
|
||||||
pad = newpad(total_lines+10, total_cols+10);
|
pad = newpad(total_lines+10, total_cols+10);
|
||||||
(void) wattrset(pad, attributes[SCROLLWIN_TEXT]);
|
wattrset(pad, attr_scrollwin_text);
|
||||||
fill_window(pad, text);
|
fill_window(pad, text);
|
||||||
|
|
||||||
win_lines = min(total_lines+4, lines-2);
|
win_lines = min(total_lines+4, lines-2);
|
||||||
@@ -591,9 +542,9 @@ void show_scroll_win(WINDOW *main_window,
|
|||||||
win = newwin(win_lines, win_cols, y, x);
|
win = newwin(win_lines, win_cols, y, x);
|
||||||
keypad(win, TRUE);
|
keypad(win, TRUE);
|
||||||
/* show the help in the help window, and show the help panel */
|
/* show the help in the help window, and show the help panel */
|
||||||
(void) wattrset(win, attributes[SCROLLWIN_BOX]);
|
wattrset(win, attr_scrollwin_box);
|
||||||
box(win, 0, 0);
|
box(win, 0, 0);
|
||||||
(void) wattrset(win, attributes[SCROLLWIN_HEADING]);
|
wattrset(win, attr_scrollwin_heading);
|
||||||
mvwprintw(win, 0, 3, " %s ", title);
|
mvwprintw(win, 0, 3, " %s ", title);
|
||||||
panel = new_panel(win);
|
panel = new_panel(win);
|
||||||
|
|
||||||
@@ -604,10 +555,9 @@ void show_scroll_win(WINDOW *main_window,
|
|||||||
text_cols, 0);
|
text_cols, 0);
|
||||||
print_in_middle(win,
|
print_in_middle(win,
|
||||||
text_lines+2,
|
text_lines+2,
|
||||||
0,
|
|
||||||
text_cols,
|
text_cols,
|
||||||
"<OK>",
|
"<OK>",
|
||||||
attributes[DIALOG_MENU_FORE]);
|
attr_dialog_menu_fore);
|
||||||
wrefresh(win);
|
wrefresh(win);
|
||||||
|
|
||||||
res = wgetch(win);
|
res = wgetch(win);
|
||||||
|
|||||||
@@ -32,30 +32,26 @@
|
|||||||
typeof(b) _b = b;\
|
typeof(b) _b = b;\
|
||||||
_a < _b ? _a : _b; })
|
_a < _b ? _a : _b; })
|
||||||
|
|
||||||
typedef enum {
|
extern int attr_normal;
|
||||||
NORMAL = 1,
|
extern int attr_main_heading;
|
||||||
MAIN_HEADING,
|
extern int attr_main_menu_box;
|
||||||
MAIN_MENU_BOX,
|
extern int attr_main_menu_fore;
|
||||||
MAIN_MENU_FORE,
|
extern int attr_main_menu_back;
|
||||||
MAIN_MENU_BACK,
|
extern int attr_main_menu_grey;
|
||||||
MAIN_MENU_GREY,
|
extern int attr_main_menu_heading;
|
||||||
MAIN_MENU_HEADING,
|
extern int attr_scrollwin_text;
|
||||||
SCROLLWIN_TEXT,
|
extern int attr_scrollwin_heading;
|
||||||
SCROLLWIN_HEADING,
|
extern int attr_scrollwin_box;
|
||||||
SCROLLWIN_BOX,
|
extern int attr_dialog_text;
|
||||||
DIALOG_TEXT,
|
extern int attr_dialog_menu_fore;
|
||||||
DIALOG_MENU_FORE,
|
extern int attr_dialog_menu_back;
|
||||||
DIALOG_MENU_BACK,
|
extern int attr_dialog_box;
|
||||||
DIALOG_BOX,
|
extern int attr_input_box;
|
||||||
INPUT_BOX,
|
extern int attr_input_heading;
|
||||||
INPUT_HEADING,
|
extern int attr_input_text;
|
||||||
INPUT_TEXT,
|
extern int attr_input_field;
|
||||||
INPUT_FIELD,
|
extern int attr_function_text;
|
||||||
FUNCTION_TEXT,
|
extern int attr_function_highlight;
|
||||||
FUNCTION_HIGHLIGHT,
|
|
||||||
ATTR_MAX
|
|
||||||
} attributes_t;
|
|
||||||
extern attributes_t attributes[];
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
F_HELP = 1,
|
F_HELP = 1,
|
||||||
@@ -72,12 +68,7 @@ typedef enum {
|
|||||||
void set_colors(void);
|
void set_colors(void);
|
||||||
|
|
||||||
/* this changes the windows attributes !!! */
|
/* this changes the windows attributes !!! */
|
||||||
void print_in_middle(WINDOW *win,
|
void print_in_middle(WINDOW *win, int y, int width, const char *str, int attrs);
|
||||||
int starty,
|
|
||||||
int startx,
|
|
||||||
int width,
|
|
||||||
const char *string,
|
|
||||||
chtype color);
|
|
||||||
int get_line_length(const char *line);
|
int get_line_length(const char *line);
|
||||||
int get_line_no(const char *text);
|
int get_line_no(const char *text);
|
||||||
const char *get_line(const char *text, int line_no);
|
const char *get_line(const char *text, int line_no);
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "lkc.h"
|
#include "lkc.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
|
#define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ static bool zconf_endtoken(const char *tokenname,
|
|||||||
|
|
||||||
struct symbol *symbol_hash[SYMBOL_HASHSIZE];
|
struct symbol *symbol_hash[SYMBOL_HASHSIZE];
|
||||||
|
|
||||||
static struct menu *current_menu, *current_entry;
|
struct menu *current_menu, *current_entry;
|
||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
@@ -45,7 +46,6 @@ static struct menu *current_menu, *current_entry;
|
|||||||
%token <string> T_HELPTEXT
|
%token <string> T_HELPTEXT
|
||||||
%token <string> T_WORD
|
%token <string> T_WORD
|
||||||
%token <string> T_WORD_QUOTE
|
%token <string> T_WORD_QUOTE
|
||||||
%token T_ALLNOCONFIG_Y
|
|
||||||
%token T_BOOL
|
%token T_BOOL
|
||||||
%token T_CHOICE
|
%token T_CHOICE
|
||||||
%token T_CLOSE_PAREN
|
%token T_CLOSE_PAREN
|
||||||
@@ -53,7 +53,6 @@ static struct menu *current_menu, *current_entry;
|
|||||||
%token T_COMMENT
|
%token T_COMMENT
|
||||||
%token T_CONFIG
|
%token T_CONFIG
|
||||||
%token T_DEFAULT
|
%token T_DEFAULT
|
||||||
%token T_DEFCONFIG_LIST
|
|
||||||
%token T_DEF_BOOL
|
%token T_DEF_BOOL
|
||||||
%token T_DEF_TRISTATE
|
%token T_DEF_TRISTATE
|
||||||
%token T_DEPENDS
|
%token T_DEPENDS
|
||||||
@@ -71,7 +70,6 @@ static struct menu *current_menu, *current_entry;
|
|||||||
%token T_MODULES
|
%token T_MODULES
|
||||||
%token T_ON
|
%token T_ON
|
||||||
%token T_OPEN_PAREN
|
%token T_OPEN_PAREN
|
||||||
%token T_OPTION
|
|
||||||
%token T_OPTIONAL
|
%token T_OPTIONAL
|
||||||
%token T_PLUS_EQUAL
|
%token T_PLUS_EQUAL
|
||||||
%token T_PROMPT
|
%token T_PROMPT
|
||||||
@@ -218,19 +216,12 @@ config_option: T_RANGE symbol symbol if_expr T_EOL
|
|||||||
printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno());
|
printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno());
|
||||||
};
|
};
|
||||||
|
|
||||||
config_option: T_OPTION T_MODULES T_EOL
|
config_option: T_MODULES T_EOL
|
||||||
{
|
{
|
||||||
menu_add_option_modules();
|
if (modules_sym)
|
||||||
};
|
zconf_error("symbol '%s' redefines option 'modules' already defined by symbol '%s'",
|
||||||
|
current_entry->sym->name, modules_sym->name);
|
||||||
config_option: T_OPTION T_DEFCONFIG_LIST T_EOL
|
modules_sym = current_entry->sym;
|
||||||
{
|
|
||||||
menu_add_option_defconfig_list();
|
|
||||||
};
|
|
||||||
|
|
||||||
config_option: T_OPTION T_ALLNOCONFIG_Y T_EOL
|
|
||||||
{
|
|
||||||
menu_add_option_allnoconfig_y();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* choice entry */
|
/* choice entry */
|
||||||
@@ -517,7 +508,7 @@ void conf_parse(const char *name)
|
|||||||
}
|
}
|
||||||
if (yynerrs)
|
if (yynerrs)
|
||||||
exit(1);
|
exit(1);
|
||||||
sym_set_change_count(1);
|
conf_set_changed(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool zconf_endtoken(const char *tokenname,
|
static bool zconf_endtoken(const char *tokenname,
|
||||||
@@ -723,5 +714,3 @@ void zconfdump(FILE *out)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "menu.c"
|
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ void ConfigItem::updateMenu(void)
|
|||||||
goto set_prompt;
|
goto set_prompt;
|
||||||
case P_COMMENT:
|
case P_COMMENT:
|
||||||
setIcon(promptColIdx, QIcon());
|
setIcon(promptColIdx, QIcon());
|
||||||
|
prompt = "*** " + prompt + " ***";
|
||||||
goto set_prompt;
|
goto set_prompt;
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
# 1. Boot up the kernel that you want to stream line the config on.
|
# 1. Boot up the kernel that you want to stream line the config on.
|
||||||
# 2. Change directory to the directory holding the source of the
|
# 2. Change directory to the directory holding the source of the
|
||||||
# kernel that you just booted.
|
# kernel that you just booted.
|
||||||
# 3. Copy the configuraton file to this directory as .config
|
# 3. Copy the configuration file to this directory as .config
|
||||||
# 4. Have all your devices that you need modules for connected and
|
# 4. Have all your devices that you need modules for connected and
|
||||||
# operational (make sure that their corresponding modules are loaded)
|
# operational (make sure that their corresponding modules are loaded)
|
||||||
# 5. Run this script redirecting the output to some other file
|
# 5. Run this script redirecting the output to some other file
|
||||||
@@ -481,7 +481,7 @@ sub parse_config_depends
|
|||||||
# The idea is we look at all the configs that select it. If one
|
# The idea is we look at all the configs that select it. If one
|
||||||
# is already in our list of configs to enable, then there's nothing
|
# is already in our list of configs to enable, then there's nothing
|
||||||
# else to do. If there isn't, we pick the first config that was
|
# else to do. If there isn't, we pick the first config that was
|
||||||
# enabled in the orignal config and use that.
|
# enabled in the original config and use that.
|
||||||
sub parse_config_selects
|
sub parse_config_selects
|
||||||
{
|
{
|
||||||
my ($config, $p) = @_;
|
my ($config, $p) = @_;
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ static struct symbol symbol_empty = {
|
|||||||
.flags = SYMBOL_VALID,
|
.flags = SYMBOL_VALID,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct symbol *sym_defconfig_list;
|
|
||||||
struct symbol *modules_sym;
|
struct symbol *modules_sym;
|
||||||
static tristate modules_val;
|
static tristate modules_val;
|
||||||
|
|
||||||
@@ -473,7 +472,7 @@ void sym_clear_all_valid(void)
|
|||||||
|
|
||||||
for_all_symbols(i, sym)
|
for_all_symbols(i, sym)
|
||||||
sym->flags &= ~SYMBOL_VALID;
|
sym->flags &= ~SYMBOL_VALID;
|
||||||
sym_add_change_count(1);
|
conf_set_changed(true);
|
||||||
sym_calc_value(modules_sym);
|
sym_calc_value(modules_sym);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
config MODULES
|
config MODULES
|
||||||
bool "Enable loadable module support"
|
bool "Enable loadable module support"
|
||||||
option modules
|
modules
|
||||||
default y
|
default y
|
||||||
|
|
||||||
choice
|
choice
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
config MODULES
|
config MODULES
|
||||||
def_bool y
|
def_bool y
|
||||||
option modules
|
modules
|
||||||
|
|
||||||
config DEP
|
config DEP
|
||||||
tristate
|
tristate
|
||||||
|
|||||||
@@ -53,6 +53,10 @@ class Conf:
|
|||||||
# Override 'srctree' environment to make the test as the top directory
|
# Override 'srctree' environment to make the test as the top directory
|
||||||
extra_env['srctree'] = self._test_dir
|
extra_env['srctree'] = self._test_dir
|
||||||
|
|
||||||
|
# Clear KCONFIG_DEFCONFIG_LIST to keep unit tests from being affected
|
||||||
|
# by the user's environment.
|
||||||
|
extra_env['KCONFIG_DEFCONFIG_LIST'] = ''
|
||||||
|
|
||||||
# Run Kconfig in a temporary directory.
|
# Run Kconfig in a temporary directory.
|
||||||
# This directory is automatically removed when done.
|
# This directory is automatically removed when done.
|
||||||
with tempfile.TemporaryDirectory() as temp_dir:
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
config MODULES
|
config MODULES
|
||||||
def_bool y
|
def_bool y
|
||||||
option modules
|
modules
|
||||||
|
|
||||||
choice
|
choice
|
||||||
prompt "Choice"
|
prompt "Choice"
|
||||||
|
|||||||
Reference in New Issue
Block a user