[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH v3 12/23] kconfig: Support glob in kconfig
Hi Sharan, This patch looks ok. -- Felipe Reviewed-by: Felipe Huici <felipe.huici@xxxxxxxxx> On 19.09.19, 11:17, "Minios-devel on behalf of Sharan Santhanam" <minios-devel-bounces@xxxxxxxxxxxxxxxxxxxx on behalf of Sharan.Santhanam@xxxxxxxxx> wrote: Add support for glob on kconfig. Taken from coreboot implementation. URL: https://github.com/coreboot/coreboot commit-id: 91ba80dd798b Signed-off-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx> --- support/kconfig.new/lexer.l | 27 +++++++++ support/kconfig.new/lkc.h | 1 + support/kconfig.new/parser.y | 2 +- .../kconfig.new/patches/09-support-glob-in-kconfig | 70 ++++++++++++++++++++++ 4 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 support/kconfig.new/patches/09-support-glob-in-kconfig diff --git a/support/kconfig.new/lexer.l b/support/kconfig.new/lexer.l index 6354c90..c5acb32 100644 --- a/support/kconfig.new/lexer.l +++ b/support/kconfig.new/lexer.l @@ -8,6 +8,7 @@ %{ #include <assert.h> +#include <glob.h> #include <limits.h> #include <stdio.h> #include <stdlib.h> @@ -442,6 +443,32 @@ void zconf_nextfile(const char *name) current_file = file; } +void zconf_nextfiles(const char *wildcard) +{ + glob_t g = {0}; + char **w; + int i; + + if (glob(wildcard, 0, NULL, &g) != 0) { + return; + } + if (g.gl_pathv == NULL) { + globfree(&g); + return; + } + + /* working through files backwards, since + * we're first pushing them on a stack + * before actually handling them. + */ + for (i = g.gl_pathc; i > 0; i--) { + w = &g.gl_pathv[i - 1]; + zconf_nextfile(*w); + } + + globfree(&g); +} + static void zconf_endfile(void) { struct buffer *parent; diff --git a/support/kconfig.new/lkc.h b/support/kconfig.new/lkc.h index cbc7658..69d2c77 100644 --- a/support/kconfig.new/lkc.h +++ b/support/kconfig.new/lkc.h @@ -44,6 +44,7 @@ void zconf_starthelp(void); FILE *zconf_fopen(const char *name); void zconf_initscan(const char *name); void zconf_nextfile(const char *name); +void zconf_nextfiles(const char *name); int zconf_lineno(void); const char *zconf_curname(void); diff --git a/support/kconfig.new/parser.y b/support/kconfig.new/parser.y index 60936c7..95700f8 100644 --- a/support/kconfig.new/parser.y +++ b/support/kconfig.new/parser.y @@ -366,7 +366,7 @@ menu_option_list: source_stmt: T_SOURCE prompt T_EOL { printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2); - zconf_nextfile($2); + zconf_nextfiles($2); free($2); }; diff --git a/support/kconfig.new/patches/09-support-glob-in-kconfig b/support/kconfig.new/patches/09-support-glob-in-kconfig new file mode 100644 index 0000000..0357c22 --- /dev/null +++ b/support/kconfig.new/patches/09-support-glob-in-kconfig @@ -0,0 +1,70 @@ +diff --git a/support/kconfig.new/lexer.l b/support/kconfig.new/lexer.l +index 6354c90..c5acb32 100644 +--- a/support/kconfig.new/lexer.l ++++ b/support/kconfig.new/lexer.l +@@ -8,6 +8,7 @@ + %{ + + #include <assert.h> ++#include <glob.h> + #include <limits.h> + #include <stdio.h> + #include <stdlib.h> +@@ -442,6 +443,32 @@ void zconf_nextfile(const char *name) + current_file = file; + } + ++void zconf_nextfiles(const char *wildcard) ++{ ++ glob_t g = {0}; ++ char **w; ++ int i; ++ ++ if (glob(wildcard, 0, NULL, &g) != 0) { ++ return; ++ } ++ if (g.gl_pathv == NULL) { ++ globfree(&g); ++ return; ++ } ++ ++ /* working through files backwards, since ++ * we're first pushing them on a stack ++ * before actually handling them. ++ */ ++ for (i = g.gl_pathc; i > 0; i--) { ++ w = &g.gl_pathv[i - 1]; ++ zconf_nextfile(*w); ++ } ++ ++ globfree(&g); ++} ++ + static void zconf_endfile(void) + { + struct buffer *parent; +diff --git a/support/kconfig.new/lkc.h b/support/kconfig.new/lkc.h +index cbc7658..69d2c77 100644 +--- a/support/kconfig.new/lkc.h ++++ b/support/kconfig.new/lkc.h +@@ -44,6 +44,7 @@ void zconf_starthelp(void); + FILE *zconf_fopen(const char *name); + void zconf_initscan(const char *name); + void zconf_nextfile(const char *name); ++void zconf_nextfiles(const char *name); + int zconf_lineno(void); + const char *zconf_curname(void); + +diff --git a/support/kconfig.new/parser.y b/support/kconfig.new/parser.y +index 60936c7..95700f8 100644 +--- a/support/kconfig.new/parser.y ++++ b/support/kconfig.new/parser.y +@@ -366,7 +366,7 @@ menu_option_list: + source_stmt: T_SOURCE prompt T_EOL + { + printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), $2); +- zconf_nextfile($2); ++ zconf_nextfiles($2); + free($2); + }; + -- 2.7.4 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |