arch/arm64: Support FEAT_CCIDX
[coreboot2.git] / util / kconfig / patches / 0008-kconfig-Add-wildcard-support-for-source.patch
blob2e6a24f30fb523bba2fa8ad1eac6d40e54bf284f
1 From 5e2355bf017b3347b29126a0eeb866558334f704 Mon Sep 17 00:00:00 2001
2 From: Stefan Reinauer <stefan.reinauer@coreboot.org>
3 Date: Fri, 3 Apr 2015 20:01:38 +0200
4 Subject: [PATCH] kconfig: Add wildcard support for "source"
6 Kconfig's include directive "source" does not support
7 wildcards (e.g. source src/mainboard/*/Kconfig) which
8 makes automatic inclusion of all boards a tedious task
9 and prevents us from implementing "drop in" boards.
11 In our Makefile.mk files we already include mainboard
12 directories per wildcard, so let's add the infrastructure
13 to do the same with Kconfig.
15 v2: change from wordexp to glob for better portability.
17 Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
18 Signed-off-by: Patrick Georgi <pgeorgi@google.com>
19 ---
20 util/kconfig/lexer.l | 27 +++++++++++++++++++++++++++
21 util/kconfig/lkc.h | 1 +
22 util/kconfig/parser.y | 2 +-
23 3 files changed, 29 insertions(+), 1 deletion(-)
25 Index: kconfig/lexer.l
26 ===================================================================
27 --- kconfig.orig/lexer.l
28 +++ kconfig/lexer.l
29 @@ -8,6 +8,7 @@
32 #include <assert.h>
33 +#include <glob.h>
34 #include <limits.h>
35 #include <stdio.h>
36 #include <stdlib.h>
37 @@ -439,6 +440,32 @@ void zconf_nextfile(const char *name)
38 current_file = file;
41 +void zconf_nextfiles(const char *wildcard)
43 + glob_t g;
44 + char **w;
45 + int i;
47 + if (glob(wildcard, 0, NULL, &g) != 0) {
48 + return;
49 + }
50 + if (g.gl_pathv == NULL) {
51 + globfree(&g);
52 + return;
53 + }
55 + /* working through files backwards, since
56 + * we're first pushing them on a stack
57 + * before actually handling them.
58 + */
59 + for (i = g.gl_pathc; i > 0; i--) {
60 + w = &g.gl_pathv[i - 1];
61 + zconf_nextfile(*w);
62 + }
64 + globfree(&g);
67 static void zconf_endfile(void)
69 struct buffer *parent;
70 Index: kconfig/lkc.h
71 ===================================================================
72 --- kconfig.orig/lkc.h
73 +++ kconfig/lkc.h
74 @@ -36,6 +36,7 @@ void zconf_starthelp(void);
75 FILE *zconf_fopen(const char *name);
76 void zconf_initscan(const char *name);
77 void zconf_nextfile(const char *name);
78 +void zconf_nextfiles(const char *name);
79 int zconf_lineno(void);
80 const char *zconf_curname(void);
82 Index: kconfig/parser.y
83 ===================================================================
84 --- kconfig.orig/parser.y
85 +++ kconfig/parser.y
86 @@ -358,7 +358,7 @@ menu_option_list:
87 source_stmt: T_SOURCE T_WORD_QUOTE T_EOL
89 printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2);
90 - zconf_nextfile($2);
91 + zconf_nextfiles($2);
92 free($2);