diff options
Diffstat (limited to 'scripts/kconfig/symbol.c')
-rw-r--r-- | scripts/kconfig/symbol.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index a7dfc82fc858..99e3d02d1cfc 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c | |||
@@ -34,6 +34,8 @@ struct symbol *sym_defconfig_list; | |||
34 | struct symbol *modules_sym; | 34 | struct symbol *modules_sym; |
35 | tristate modules_val; | 35 | tristate modules_val; |
36 | 36 | ||
37 | struct expr *sym_env_list; | ||
38 | |||
37 | void sym_add_default(struct symbol *sym, const char *def) | 39 | void sym_add_default(struct symbol *sym, const char *def) |
38 | { | 40 | { |
39 | struct property *prop = prop_alloc(P_DEFAULT, sym); | 41 | struct property *prop = prop_alloc(P_DEFAULT, sym); |
@@ -117,6 +119,15 @@ struct property *sym_get_choice_prop(struct symbol *sym) | |||
117 | return NULL; | 119 | return NULL; |
118 | } | 120 | } |
119 | 121 | ||
122 | struct property *sym_get_env_prop(struct symbol *sym) | ||
123 | { | ||
124 | struct property *prop; | ||
125 | |||
126 | for_all_properties(sym, prop, P_ENV) | ||
127 | return prop; | ||
128 | return NULL; | ||
129 | } | ||
130 | |||
120 | struct property *sym_get_default_prop(struct symbol *sym) | 131 | struct property *sym_get_default_prop(struct symbol *sym) |
121 | { | 132 | { |
122 | struct property *prop; | 133 | struct property *prop; |
@@ -346,6 +357,9 @@ void sym_calc_value(struct symbol *sym) | |||
346 | ; | 357 | ; |
347 | } | 358 | } |
348 | 359 | ||
360 | if (sym->flags & SYMBOL_AUTO) | ||
361 | sym->flags &= ~SYMBOL_WRITE; | ||
362 | |||
349 | sym->curr = newval; | 363 | sym->curr = newval; |
350 | if (sym_is_choice(sym) && newval.tri == yes) | 364 | if (sym_is_choice(sym) && newval.tri == yes) |
351 | sym->curr.val = sym_calc_choice(sym); | 365 | sym->curr.val = sym_calc_choice(sym); |
@@ -860,6 +874,8 @@ const char *prop_get_type_name(enum prop_type type) | |||
860 | switch (type) { | 874 | switch (type) { |
861 | case P_PROMPT: | 875 | case P_PROMPT: |
862 | return "prompt"; | 876 | return "prompt"; |
877 | case P_ENV: | ||
878 | return "env"; | ||
863 | case P_COMMENT: | 879 | case P_COMMENT: |
864 | return "comment"; | 880 | return "comment"; |
865 | case P_MENU: | 881 | case P_MENU: |
@@ -877,3 +893,32 @@ const char *prop_get_type_name(enum prop_type type) | |||
877 | } | 893 | } |
878 | return "unknown"; | 894 | return "unknown"; |
879 | } | 895 | } |
896 | |||
897 | void prop_add_env(const char *env) | ||
898 | { | ||
899 | struct symbol *sym, *sym2; | ||
900 | struct property *prop; | ||
901 | char *p; | ||
902 | |||
903 | sym = current_entry->sym; | ||
904 | sym->flags |= SYMBOL_AUTO; | ||
905 | for_all_properties(sym, prop, P_ENV) { | ||
906 | sym2 = prop_get_symbol(prop); | ||
907 | if (strcmp(sym2->name, env)) | ||
908 | menu_warn(current_entry, "redefining environment symbol from %s", | ||
909 | sym2->name); | ||
910 | return; | ||
911 | } | ||
912 | |||
913 | prop = prop_alloc(P_ENV, sym); | ||
914 | prop->expr = expr_alloc_symbol(sym_lookup(env, 1)); | ||
915 | |||
916 | sym_env_list = expr_alloc_one(E_LIST, sym_env_list); | ||
917 | sym_env_list->right.sym = sym; | ||
918 | |||
919 | p = getenv(env); | ||
920 | if (p) | ||
921 | sym_add_default(sym, p); | ||
922 | else | ||
923 | menu_warn(current_entry, "environment variable %s undefined", env); | ||
924 | } | ||