From: Masahiro Yamada Date: Mon, 28 May 2018 09:21:53 +0000 (+0900) Subject: kconfig: add 'info', 'warning-if', and 'error-if' built-in functions X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=715ca322b4f23a2b15adb34d0d829ae34c04dede;p=carl9170fw.git kconfig: add 'info', 'warning-if', and 'error-if' built-in functions Syntax: $(info,) $(warning-if,,) $(error-if,, 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 Reviewed-by: Kees Cook Signed-off-by: Christian Lamparter --- diff --git a/config/preprocess.c b/config/preprocess.c index 56aa1f0..5ee58ee 100644 --- a/config/preprocess.c +++ b/config/preprocess.c @@ -106,6 +106,21 @@ struct function { char *(*func)(int argc, char *argv[]); }; +static char *do_error_if(int argc, char *argv[]) +{ + if (!strcmp(argv[0], "y")) + pperror("%s", argv[1]); + + return NULL; +} + +static char *do_info(int argc, char *argv[]) +{ + printf("%s\n", argv[0]); + + return xstrdup(""); +} + static char *do_shell(int argc, char *argv[]) { FILE *p; @@ -146,9 +161,21 @@ static char *do_shell(int argc, char *argv[]) return xstrdup(buf); } +static char *do_warning_if(int argc, char *argv[]) +{ + if (!strcmp(argv[0], "y")) + fprintf(stderr, "%s:%d: %s\n", + current_file->name, yylineno, argv[1]); + + return xstrdup(""); +} + static const struct function function_table[] = { /* Name MIN MAX Function */ + { "error-if", 2, 2, do_error_if }, + { "info", 1, 1, do_info }, { "shell", 1, 1, do_shell }, + { "warning-if", 2, 2, do_warning_if }, }; #define FUNCTION_MAX_ARGS 16