Skip to content

Commit 558e78e

Browse files
committed
kconfig: split some C files out of zconf.y
I want to compile each C file independently instead of including all of them from zconf.y. Split out confdata.c, expr.c, symbol.c, and preprocess.c . These are low-hanging fruits. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
1 parent 0c87410 commit 558e78e

7 files changed

Lines changed: 16 additions & 15 deletions

File tree

‎scripts/kconfig/Makefile‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,23 +142,22 @@ help:
142142
@echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)'
143143

144144
# ===========================================================================
145-
# Shared Makefile for the various kconfig executables:
146-
# conf: Used for defconfig, oldconfig and related targets
147145
# object files used by all kconfig flavours
148-
149-
conf-objs := conf.o zconf.tab.o
150-
151-
hostprogs-y := conf
146+
common-objs := confdata.o expr.o symbol.o preprocess.o zconf.tab.o
152147

153148
targets += zconf.lex.c
154149

155150
# generated files seem to need this to find local include files
156151
HOSTCFLAGS_zconf.lex.o := -I$(src)
157152
HOSTCFLAGS_zconf.tab.o := -I$(src)
158153

154+
# conf: Used for defconfig, oldconfig and related targets
155+
hostprogs-y += conf
156+
conf-objs := conf.o $(common-objs)
157+
159158
# nconf: Used for the nconfig target based on ncurses
160159
hostprogs-y += nconf
161-
nconf-objs := nconf.o zconf.tab.o nconf.gui.o
160+
nconf-objs := nconf.o nconf.gui.o $(common-objs)
162161

163162
HOSTLDLIBS_nconf = $(shell . $(obj)/.nconf-cfg && echo $$libs)
164163
HOSTCFLAGS_nconf.o = $(shell . $(obj)/.nconf-cfg && echo $$cflags)
@@ -169,7 +168,7 @@ $(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/.nconf-cfg
169168
# mconf: Used for the menuconfig target based on lxdialog
170169
hostprogs-y += mconf
171170
lxdialog := checklist.o inputbox.o menubox.o textbox.o util.o yesno.o
172-
mconf-objs := mconf.o zconf.tab.o $(addprefix lxdialog/, $(lxdialog))
171+
mconf-objs := mconf.o $(addprefix lxdialog/, $(lxdialog)) $(common-objs)
173172

174173
HOSTLDLIBS_mconf = $(shell . $(obj)/.mconf-cfg && echo $$libs)
175174
$(foreach f, mconf.o $(lxdialog), \
@@ -181,7 +180,7 @@ $(addprefix $(obj)/lxdialog/, $(lxdialog)): $(obj)/.mconf-cfg
181180
# qconf: Used for the xconfig target based on Qt
182181
hostprogs-y += qconf
183182
qconf-cxxobjs := qconf.o
184-
qconf-objs := zconf.tab.o
183+
qconf-objs := $(common-objs)
185184

186185
HOSTLDLIBS_qconf = $(shell . $(obj)/.qconf-cfg && echo $$libs)
187186
HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/.qconf-cfg && echo $$cflags)
@@ -196,7 +195,7 @@ $(obj)/%.moc: $(src)/%.h $(obj)/.qconf-cfg
196195

197196
# gconf: Used for the gconfig target based on GTK+
198197
hostprogs-y += gconf
199-
gconf-objs := gconf.o zconf.tab.o
198+
gconf-objs := gconf.o $(common-objs)
200199

201200
HOSTLDLIBS_gconf = $(shell . $(obj)/.gconf-cfg && echo $$libs)
202201
HOSTCFLAGS_gconf.o = $(shell . $(obj)/.gconf-cfg && echo $$cflags)

‎scripts/kconfig/confdata.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <ctype.h>
88
#include <errno.h>
99
#include <fcntl.h>
10+
#include <limits.h>
1011
#include <stdarg.h>
1112
#include <stdio.h>
1213
#include <stdlib.h>

‎scripts/kconfig/expr.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
44
*/
55

6+
#include <ctype.h>
7+
#include <errno.h>
68
#include <stdio.h>
79
#include <stdlib.h>
810
#include <string.h>

‎scripts/kconfig/lkc.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ const char *str_get(struct gstr *gs);
108108
/* symbol.c */
109109
void sym_clear_all_valid(void);
110110
struct symbol *sym_choice_default(struct symbol *sym);
111+
struct property *sym_get_range_prop(struct symbol *sym);
111112
const char *sym_get_string_default(struct symbol *sym);
112113
struct symbol *sym_check_deps(struct symbol *sym);
113114
struct property *prop_alloc(enum prop_type type, struct symbol *sym);

‎scripts/kconfig/preprocess.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
//
33
// Copyright (C) 2018 Masahiro Yamada <yamada.masahiro@socionext.com>
44

5+
#include <ctype.h>
56
#include <stdarg.h>
67
#include <stdbool.h>
78
#include <stdio.h>
89
#include <stdlib.h>
910
#include <string.h>
1011

1112
#include "list.h"
13+
#include "lkc.h"
1214

1315
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
1416

‎scripts/kconfig/symbol.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ static struct property *sym_get_default_prop(struct symbol *sym)
8686
return NULL;
8787
}
8888

89-
static struct property *sym_get_range_prop(struct symbol *sym)
89+
struct property *sym_get_range_prop(struct symbol *sym)
9090
{
9191
struct property *prop;
9292

‎scripts/kconfig/zconf.y‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,4 @@ void zconfdump(FILE *out)
731731

732732
#include "zconf.lex.c"
733733
#include "util.c"
734-
#include "confdata.c"
735-
#include "expr.c"
736-
#include "symbol.c"
737734
#include "menu.c"
738-
#include "preprocess.c"

0 commit comments

Comments
 (0)