Skip to content

Commit

Permalink
kconfig: split some C files out of zconf.y
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
masahir0y committed Dec 28, 2018
1 parent 0c87410 commit 558e78e
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 15 deletions.
19 changes: 9 additions & 10 deletions scripts/kconfig/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,23 +142,22 @@ help:
@echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)'

# ===========================================================================
# Shared Makefile for the various kconfig executables:
# conf: Used for defconfig, oldconfig and related targets
# object files used by all kconfig flavours

conf-objs := conf.o zconf.tab.o

hostprogs-y := conf
common-objs := confdata.o expr.o symbol.o preprocess.o zconf.tab.o

targets += zconf.lex.c

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

# conf: Used for defconfig, oldconfig and related targets
hostprogs-y += conf
conf-objs := conf.o $(common-objs)

# nconf: Used for the nconfig target based on ncurses
hostprogs-y += nconf
nconf-objs := nconf.o zconf.tab.o nconf.gui.o
nconf-objs := nconf.o nconf.gui.o $(common-objs)

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

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

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

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

HOSTLDLIBS_gconf = $(shell . $(obj)/.gconf-cfg && echo $$libs)
HOSTCFLAGS_gconf.o = $(shell . $(obj)/.gconf-cfg && echo $$cflags)
Expand Down
1 change: 1 addition & 0 deletions scripts/kconfig/confdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down
2 changes: 2 additions & 0 deletions scripts/kconfig/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
* Copyright (C) 2002 Roman Zippel <[email protected]>
*/

#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down
1 change: 1 addition & 0 deletions scripts/kconfig/lkc.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const char *str_get(struct gstr *gs);
/* symbol.c */
void sym_clear_all_valid(void);
struct symbol *sym_choice_default(struct symbol *sym);
struct property *sym_get_range_prop(struct symbol *sym);
const char *sym_get_string_default(struct symbol *sym);
struct symbol *sym_check_deps(struct symbol *sym);
struct property *prop_alloc(enum prop_type type, struct symbol *sym);
Expand Down
2 changes: 2 additions & 0 deletions scripts/kconfig/preprocess.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
//
// Copyright (C) 2018 Masahiro Yamada <[email protected]>

#include <ctype.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "list.h"
#include "lkc.h"

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

Expand Down
2 changes: 1 addition & 1 deletion scripts/kconfig/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ static struct property *sym_get_default_prop(struct symbol *sym)
return NULL;
}

static struct property *sym_get_range_prop(struct symbol *sym)
struct property *sym_get_range_prop(struct symbol *sym)
{
struct property *prop;

Expand Down
4 changes: 0 additions & 4 deletions scripts/kconfig/zconf.y
Original file line number Diff line number Diff line change
Expand Up @@ -731,8 +731,4 @@ void zconfdump(FILE *out)

#include "zconf.lex.c"
#include "util.c"
#include "confdata.c"
#include "expr.c"
#include "symbol.c"
#include "menu.c"
#include "preprocess.c"

0 comments on commit 558e78e

Please sign in to comment.