Skip to contentSkip to conversation

kconfig: split menu.c out of parser.y

PATCH In review Masahiro Yamada 2 participants 3 messages Apr 13, 2021 – Apr 15, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kconfig: split menu.c out of parser.y

Compile menu.c as an independent compilation unit.

---

 scripts/kconfig/Makefile   | 4 ++--
 scripts/kconfig/internal.h | 9 +++++++++
 scripts/kconfig/menu.c     | 1 +
 scripts/kconfig/parser.y   | 5 ++---
 4 files changed, 14 insertions(+), 5 deletions(-)
 create mode 100644 scripts/kconfig/internal.h
scripts/kconfig/Makefile +2 -2
index 1d1a7f83ee8d..5a215880b268 100644
@@ -143,8 +143,8 @@ help:
 
 # ===========================================================================
 # object files used by all kconfig flavours
-common-objs	:= confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o \
-		   symbol.o util.o
+common-objs	:= confdata.o expr.o lexer.lex.o menu.o parser.tab.o \
+		   preprocess.o symbol.o util.o
 
 $(obj)/lexer.lex.o: $(obj)/parser.tab.h
 HOSTCFLAGS_lexer.lex.o	:= -I $(srctree)/$(src)
scripts/kconfig/internal.h new file +9 -0
new file mode 100644
index 000000000000..2f7298c21b64
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef INTERNAL_H
+#define INTERNAL_H
+
+struct menu;
+
+extern struct menu *current_menu, *current_entry;
+
+#endif /* INTERNAL_H */
scripts/kconfig/menu.c +1 -0
index 8b2108b74821..606ba8a63c24 100644
@@ -9,6 +9,7 @@
 #include <string.h>
 
 #include "lkc.h"
+#include "internal.h"
 
 static const char nohelp_text[] = "There is no help available for this option.";
 
scripts/kconfig/parser.y +2 -3
index e90889edf5b3..2af7ce4e1531 100644
@@ -12,6 +12,7 @@
 #include <stdbool.h>
 
 #include "lkc.h"
+#include "internal.h"
 
 #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt)
 
@@ -28,7 +29,7 @@ static bool zconf_endtoken(const char *tokenname,
 
 struct symbol *symbol_hash[SYMBOL_HASHSIZE];
 
-static struct menu *current_menu, *current_entry;
+struct menu *current_menu, *current_entry;
 
 %}
 
@@ -713,5 +714,3 @@ void zconfdump(FILE *out)
 		}
 	}
 }
-
-#include "menu.c"
Signature · 1 line
2.27.0
#1 lore raw

scripts/kconfig/internal.h line 9

Quoted 12 lines · Masahiro Yamada
scripts/kconfig/internal.h new file +9 -0
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef INTERNAL_H
+#define INTERNAL_H
+
+struct menu;
+
+extern struct menu *current_menu, *current_entry;
+
+#endif /* INTERNAL_H */

Maybe call it menu.h instead of internal.h? Unless you have plans to put other "internal" stuff in there.

scripts/kconfig/parser.y static bool zconf_endtoken(const char *tokenname, · line 32

Quoted 8 lines
scripts/kconfig/parser.y +1 -1
@@ -28,7 +29,7 @@ static bool zconf_endtoken(const char *tokenname,
 
 struct symbol *symbol_hash[SYMBOL_HASHSIZE];
 
-static struct menu *current_menu, *current_entry;
+struct menu *current_menu, *current_entry;

Why not put these in menu.c?

#2 lore raw
Quoted 18 lines · Boris Kolpackov

scripts/kconfig/internal.h line 9

Quoted 12 lines · Masahiro Yamada
scripts/kconfig/internal.h new file +9 -0
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef INTERNAL_H
+#define INTERNAL_H
+
+struct menu;
+
+extern struct menu *current_menu, *current_entry;
+
+#endif /* INTERNAL_H */

Maybe call it menu.h instead of internal.h? Unless you have plans to put other "internal" stuff in there.

Yes, I will use this header for further cleanups
of headers.

Quoted 11 lines

scripts/kconfig/parser.y static bool zconf_endtoken(const char *tokenname, · line 32

Quoted 9 lines
scripts/kconfig/parser.y +1 -1
@@ -28,7 +29,7 @@ static bool zconf_endtoken(const char *tokenname,
 
 struct symbol *symbol_hash[SYMBOL_HASHSIZE];
 
-static struct menu *current_menu, *current_entry;
+struct menu *current_menu, *current_entry;

Why not put these in menu.c?

These variables are defined here
before I started to maintain Kconfig.

For now, I am just removing the 'static' directive.

Signature · 2 lines
Best Regards
Masahiro Yamada