aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorRoman Zippel <zippel@linux-m68k.org>2008-01-13 22:50:54 -0500
committerSam Ravnborg <sam@ravnborg.org>2008-01-28 17:14:39 -0500
commit93449082e905ce73d0346d617dd67c4b668b58af (patch)
treeeba7030f32ce18fa71562224ee2e0d8ddda33421 /scripts
parent7a962923359768e04137125bd479fd0dfa6117d3 (diff)
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: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/kconfig/expr.h3
-rw-r--r--scripts/kconfig/lkc.h5
-rw-r--r--scripts/kconfig/menu.c5
-rw-r--r--scripts/kconfig/qconf.cc16
-rw-r--r--scripts/kconfig/symbol.c45
-rw-r--r--scripts/kconfig/util.c23
-rw-r--r--scripts/kconfig/zconf.gperf1
-rw-r--r--scripts/kconfig/zconf.hash.c_shipped45
8 files changed, 108 insertions, 35 deletions
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index b6f922c77e0b..9d4cba1c001d 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -106,7 +106,8 @@ struct symbol {
106#define SYMBOL_HASHMASK 0xff 106#define SYMBOL_HASHMASK 0xff
107 107
108enum prop_type { 108enum prop_type {
109 P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE, P_SELECT, P_RANGE 109 P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE,
110 P_SELECT, P_RANGE, P_ENV
110}; 111};
111 112
112struct property { 113struct property {
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index 8a07ee4f6bd4..4bc68f20a73c 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -44,6 +44,7 @@ extern "C" {
44 44
45#define T_OPT_MODULES 1 45#define T_OPT_MODULES 1
46#define T_OPT_DEFCONFIG_LIST 2 46#define T_OPT_DEFCONFIG_LIST 2
47#define T_OPT_ENV 3
47 48
48struct kconf_id { 49struct kconf_id {
49 int name; 50 int name;
@@ -74,6 +75,7 @@ void kconfig_load(void);
74 75
75/* menu.c */ 76/* menu.c */
76void menu_init(void); 77void menu_init(void);
78void menu_warn(struct menu *menu, const char *fmt, ...);
77struct menu *menu_add_menu(void); 79struct menu *menu_add_menu(void);
78void menu_end_menu(void); 80void menu_end_menu(void);
79void menu_add_entry(struct symbol *sym); 81void menu_add_entry(struct symbol *sym);
@@ -103,6 +105,8 @@ void str_printf(struct gstr *gs, const char *fmt, ...);
103const char *str_get(struct gstr *gs); 105const char *str_get(struct gstr *gs);
104 106
105/* symbol.c */ 107/* symbol.c */
108extern struct expr *sym_env_list;
109
106void sym_init(void); 110void sym_init(void);
107void sym_clear_all_valid(void); 111void sym_clear_all_valid(void);
108void sym_set_all_changed(void); 112void sym_set_all_changed(void);
@@ -110,6 +114,7 @@ void sym_set_changed(struct symbol *sym);
110struct symbol *sym_check_deps(struct symbol *sym); 114struct symbol *sym_check_deps(struct symbol *sym);
111struct property *prop_alloc(enum prop_type type, struct symbol *sym); 115struct property *prop_alloc(enum prop_type type, struct symbol *sym);
112struct symbol *prop_get_symbol(struct property *prop); 116struct symbol *prop_get_symbol(struct property *prop);
117struct property *sym_get_env_prop(struct symbol *sym);
113 118
114static inline tristate sym_get_tristate_value(struct symbol *sym) 119static inline tristate sym_get_tristate_value(struct symbol *sym)
115{ 120{
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 3637d1057e13..e6ef171e5b14 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -15,7 +15,7 @@ static struct menu **last_entry_ptr;
15struct file *file_list; 15struct file *file_list;
16struct file *current_file; 16struct file *current_file;
17 17
18static void menu_warn(struct menu *menu, const char *fmt, ...) 18void menu_warn(struct menu *menu, const char *fmt, ...)
19{ 19{
20 va_list ap; 20 va_list ap;
21 va_start(ap, fmt); 21 va_start(ap, fmt);
@@ -172,6 +172,9 @@ void menu_add_option(int token, char *arg)
172 else if (sym_defconfig_list != current_entry->sym) 172 else if (sym_defconfig_list != current_entry->sym)
173 zconf_error("trying to redefine defconfig symbol"); 173 zconf_error("trying to redefine defconfig symbol");
174 break; 174 break;
175 case T_OPT_ENV:
176 prop_add_env(arg);
177 break;
175 } 178 }
176} 179}
177 180
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 9fe27ca8a192..5d0fd38b089b 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1088,7 +1088,11 @@ QString ConfigInfoView::debug_info(struct symbol *sym)
1088 debug += "</a><br>"; 1088 debug += "</a><br>";
1089 break; 1089 break;
1090 case P_DEFAULT: 1090 case P_DEFAULT:
1091 debug += "default: "; 1091 case P_SELECT:
1092 case P_RANGE:
1093 case P_ENV:
1094 debug += prop_get_type_name(prop->type);
1095 debug += ": ";
1092 expr_print(prop->expr, expr_print_help, &debug, E_NONE); 1096 expr_print(prop->expr, expr_print_help, &debug, E_NONE);
1093 debug += "<br>"; 1097 debug += "<br>";
1094 break; 1098 break;
@@ -1099,16 +1103,6 @@ QString ConfigInfoView::debug_info(struct symbol *sym)
1099 debug += "<br>"; 1103 debug += "<br>";
1100 } 1104 }
1101 break; 1105 break;
1102 case P_SELECT:
1103 debug += "select: ";
1104 expr_print(prop->expr, expr_print_help, &debug, E_NONE);
1105 debug += "<br>";
1106 break;
1107 case P_RANGE:
1108 debug += "range: ";
1109 expr_print(prop->expr, expr_print_help, &debug, E_NONE);
1110 debug += "<br>";
1111 break;
1112 default: 1106 default:
1113 debug += "unknown property: "; 1107 debug += "unknown property: ";
1114 debug += prop_get_type_name(prop->type); 1108 debug += prop_get_type_name(prop->type);
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;
34struct symbol *modules_sym; 34struct symbol *modules_sym;
35tristate modules_val; 35tristate modules_val;
36 36
37struct expr *sym_env_list;
38
37void sym_add_default(struct symbol *sym, const char *def) 39void 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
122struct 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
120struct property *sym_get_default_prop(struct symbol *sym) 131struct 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
897void prop_add_env(const char *env)
898{
899 struct symbol *sym, *sym2;
900