Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93449082 authored by Roman Zippel's avatar Roman Zippel Committed by Sam Ravnborg
Browse files

kconfig: environment symbol support



Add the possibility to import a value from the environment into kconfig
via the option syntax. Beside flexibility this has the advantage
providing proper dependencies.
Documented the options syntax.

Signed-off-by: default avatarRoman Zippel <zippel@linux-m68k.org>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
parent 7a962923
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -127,6 +127,27 @@ applicable everywhere (see syntax).
  used to help visually separate configuration logic from help within
  the file as an aid to developers.

- misc options: "option" <symbol>[=<value>]
  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
    enables the third modular state for all config symbols.

  - "env"=<value>
    This imports the environment variable into Kconfig. It behaves like
    a default, except that the value comes from the environment, this
    also means that the behaviour when mixing it with normal defaults is
    undefined at this point. The symbol is currently not exported back
    to the build environment (if this is desired, it can be done via
    another symbol).

Menu dependencies
-----------------
+2 −1
Original line number Diff line number Diff line
@@ -106,7 +106,8 @@ struct symbol {
#define SYMBOL_HASHMASK		0xff

enum prop_type {
	P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE, P_SELECT, P_RANGE
	P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE,
	P_SELECT, P_RANGE, P_ENV
};

struct property {
+5 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ extern "C" {

#define T_OPT_MODULES		1
#define T_OPT_DEFCONFIG_LIST	2
#define T_OPT_ENV		3

struct kconf_id {
	int name;
@@ -74,6 +75,7 @@ void kconfig_load(void);

/* menu.c */
void menu_init(void);
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);
@@ -103,6 +105,8 @@ void str_printf(struct gstr *gs, const char *fmt, ...);
const char *str_get(struct gstr *gs);

/* symbol.c */
extern struct expr *sym_env_list;

void sym_init(void);
void sym_clear_all_valid(void);
void sym_set_all_changed(void);
@@ -110,6 +114,7 @@ void sym_set_changed(struct symbol *sym);
struct symbol *sym_check_deps(struct symbol *sym);
struct property *prop_alloc(enum prop_type type, struct symbol *sym);
struct symbol *prop_get_symbol(struct property *prop);
struct property *sym_get_env_prop(struct symbol *sym);

static inline tristate sym_get_tristate_value(struct symbol *sym)
{
+4 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ static struct menu **last_entry_ptr;
struct file *file_list;
struct file *current_file;

static void menu_warn(struct menu *menu, const char *fmt, ...)
void menu_warn(struct menu *menu, const char *fmt, ...)
{
	va_list ap;
	va_start(ap, fmt);
@@ -172,6 +172,9 @@ void menu_add_option(int token, char *arg)
		else if (sym_defconfig_list != current_entry->sym)
			zconf_error("trying to redefine defconfig symbol");
		break;
	case T_OPT_ENV:
		prop_add_env(arg);
		break;
	}
}

+5 −11
Original line number Diff line number Diff line
@@ -1088,7 +1088,11 @@ QString ConfigInfoView::debug_info(struct symbol *sym)
			debug += "</a><br>";
			break;
		case P_DEFAULT:
			debug += "default: ";
		case P_SELECT:
		case P_RANGE:
		case P_ENV:
			debug += prop_get_type_name(prop->type);
			debug += ": ";
			expr_print(prop->expr, expr_print_help, &debug, E_NONE);
			debug += "<br>";
			break;
@@ -1099,16 +1103,6 @@ QString ConfigInfoView::debug_info(struct symbol *sym)
				debug += "<br>";
			}
			break;
		case P_SELECT:
			debug += "select: ";
			expr_print(prop->expr, expr_print_help, &debug, E_NONE);
			debug += "<br>";
			break;
		case P_RANGE:
			debug += "range: ";
			expr_print(prop->expr, expr_print_help, &debug, E_NONE);
			debug += "<br>";
			break;
		default:
			debug += "unknown property: ";
			debug += prop_get_type_name(prop->type);
Loading