aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2018-05-28 05:21:53 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-05-28 14:31:19 -0400
commit1d6272e6fe43bc45c7ee58170d91d7242a71296b (patch)
treec40376111aea35ff2a575ed24ad786d3c554fc10
parent82bc8bd82e5c4e6e53d4ba20bb89cec6a91d8702 (diff)
kconfig: add 'info', 'warning-if', and 'error-if' built-in functions
Syntax: $(info,<text>) $(warning-if,<condition>,<text>) $(error-if,<condition>,<text) The 'info' function prints a message to stdout as in Make. The 'warning-if' and 'error-if' are similar to 'warning' and 'error' in Make, but take the condition parameter. They are effective only when the <condition> part is y. Kconfig does not implement the lazy expansion as used in the 'if' 'and, 'or' functions in Make. In other words, Kconfig does not support conditional expansion. The unconditional 'error' function would always terminate the parsing, hence would be useless in Kconfig. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Kees Cook <keescook@chromium.org>
-rw-r--r--scripts/kconfig/preprocess.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c
index 56aa1f0bad04..5ee58eeb9a7d 100644
--- a/scripts/kconfig/preprocess.c
+++ b/scripts/kconfig/preprocess.c
@@ -106,6 +106,21 @@ struct function {
106 char *(*func)(int argc, char *argv[]); 106 char *(*func)(int argc, char *argv[]);
107}; 107};
108 108
109static char *do_error_if(int argc, char *argv[])
110{
111 if (!strcmp(argv[0], "y"))
112 pperror("%s", argv[1]);
113
114 return NULL;
115}
116
117static char *do_info(int argc, char *argv[])
118{
119 printf("%s\n", argv[0]);
120
121 return xstrdup("");
122}
123
109static char *do_shell(int argc, char *argv[]) 124static char *do_shell(int argc, char *argv[])
110{ 125{
111 FILE *p; 126 FILE *p;
@@ -146,9 +161,21 @@ static char *do_shell(int argc, char *argv[])
146 return xstrdup(buf); 161 return xstrdup(buf);
147} 162}
148 163
164static char *do_warning_if(int argc, char *argv[])
165{
166 if (!strcmp(argv[0], "y"))
167 fprintf(stderr, "%s:%d: %s\n",
168 current_file->name, yylineno, argv[1]);
169
170 return xstrdup("");
171}
172
149static const struct function function_table[] = { 173static const struct function function_table[] = {
150 /* Name MIN MAX Function */ 174 /* Name MIN MAX Function */
175 { "error-if", 2, 2, do_error_if },
176 { "info", 1, 1, do_info },
151 { "shell", 1, 1, do_shell }, 177 { "shell", 1, 1, do_shell },
178 { "warning-if", 2, 2, do_warning_if },
152}; 179};
153 180
154#define FUNCTION_MAX_ARGS 16 181#define FUNCTION_MAX_ARGS 16