mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 12:42:02 +00:00
104daea149
To get access to environment variables, Kconfig needs to define a symbol using "option env=" syntax. It is tedious to add a symbol entry for each environment variable given that we need to define much more such as 'CC', 'AS', 'srctree' etc. to evaluate the compiler capability in Kconfig. Adding '$' for symbol references is grammatically inconsistent. Looking at the code, the symbols prefixed with 'S' are expanded by: - conf_expand_value() This is used to expand 'arch/$ARCH/defconfig' and 'defconfig_list' - sym_expand_string_value() This is used to expand strings in 'source' and 'mainmenu' All of them are fixed values independent of user configuration. So, they can be changed into the direct expansion instead of symbols. This change makes the code much cleaner. The bounce symbols 'SRCARCH', 'ARCH', 'SUBARCH', 'KERNELVERSION' are gone. sym_init() hard-coding 'UNAME_RELEASE' is also gone. 'UNAME_RELEASE' should be replaced with an environment variable. ARCH_DEFCONFIG is a normal symbol, so it should be simply referenced without '$' prefix. The new syntax is addicted by Make. The variable reference needs parentheses, like $(FOO), but you can omit them for single-letter variables, like $F. Yet, in Makefiles, people tend to use the parenthetical form for consistency / clarification. At this moment, only the environment variable is supported, but I will extend the concept of 'variable' later on. The variables are expanded in the lexer so we can simplify the token handling on the parser side. For example, the following code works. [Example code] config MY_TOOLCHAIN_LIST string default "My tools: CC=$(CC), AS=$(AS), CPP=$(CPP)" [Result] $ make -s alldefconfig && tail -n 1 .config CONFIG_MY_TOOLCHAIN_LIST="My tools: CC=gcc, AS=as, CPP=gcc -E" Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Kees Cook <keescook@chromium.org>
53 lines
1.8 KiB
C
53 lines
1.8 KiB
C
|
|
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 },
|
|
{ "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;
|
|
}
|