lkml.org 
[lkml]   [2018]   [May]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v4 15/31] kconfig: add 'info', 'warning', and 'error' built-in functions
Date
Add 'info', 'warning', and 'error' functions as in Make.

They print messages during parsing Kconfig files. 'error' will be
useful to terminate the parsing immediately in fatal cases.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

Changes in v4:
- Add 'error' function

Changes in v3: None
Changes in v2: None

scripts/kconfig/preprocess.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c
index 47b32dc..591bcf7 100644
--- a/scripts/kconfig/preprocess.c
+++ b/scripts/kconfig/preprocess.c
@@ -104,6 +104,20 @@ struct function {
char *(*func)(int argc, char *argv[], int old_argc, char *old_argv[]);
};

+static char *do_error(int argc, char *argv[], int old_argc, char *old_argv[])
+{
+ pperror("%s", argv[0]);
+
+ return NULL;
+}
+
+static char *do_info(int argc, char *argv[], int old_argc, char *old_argv[])
+{
+ printf("%s\n", argv[0]);
+
+ return xstrdup("");
+}
+
static char *do_shell(int argc, char *argv[], int old_argc, char *old_argv[])
{
FILE *p;
@@ -144,9 +158,19 @@ static char *do_shell(int argc, char *argv[], int old_argc, char *old_argv[])
return xstrdup(buf);
}

+static char *do_warning(int argc, char *argv[], int old_argc, char *old_argv[])
+{
+ fprintf(stderr, "%s:%d: %s\n", current_file->name, yylineno, argv[0]);
+
+ return xstrdup("");
+}
+
static const struct function function_table[] = {
/* Name MIN MAX EXP? Function */
+ { "error", 1, 1, true, do_error },
+ { "info", 1, 1, true, do_info },
{ "shell", 1, 1, true, do_shell },
+ { "warning", 1, 1, true, do_warning },
};

#define FUNCTION_MAX_ARGS 16
--
2.7.4
\
 
 \ /
  Last update: 2018-05-17 08:24    [W:0.093 / U:7.132 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site