util/kconfig: Add pre-built parser

It avoids the dependency on bison/flex, minimally speeds up the build
and also works around weird race conditions in some versions of bison
that need more investigation.

The issue this avoids manifests as a build error when creating
parser.tab.c:

    input in flex scanner failed
    make: *** [util/kconfig/Makefile.inc:66: build/util/kconfig/parser.tab.c] Error 2

Since the error happens within bison the alternative would be to make
bison part of our crossgcc environment to ensure that no broken OS
build is used.

BUG=b:197515860
TEST=things build with bison not installed

Change-Id: Ib35dfb7beafc0a09dc333e962b1e3f33df46a854
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/57409
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Raul Rangel <rrangel@chromium.org>
This commit is contained in:
Patrick Georgi 2021-09-06 16:59:56 +02:00
parent 116b144930
commit 615cdfcdb9
5 changed files with 6466 additions and 1 deletions

View File

@ -112,7 +112,7 @@ config FMD_GENPARSER
Otherwise, say N to use the provided pregenerated scanner/parser. Otherwise, say N to use the provided pregenerated scanner/parser.
config UTIL_GENPARSER config UTIL_GENPARSER
bool "Generate SCONFIG & BINCFG parser using flex and bison" bool "Generate parsers for bincfg, sconfig and kconfig locally"
default n default n
help help
Enable this option if you are working on the sconfig device tree Enable this option if you are working on the sconfig device tree

View File

@ -60,12 +60,25 @@ endef
$(foreach prog,$(hostprogs),$(eval $(call hostprogs_template,$(prog)))) $(foreach prog,$(hostprogs),$(eval $(call hostprogs_template,$(prog))))
# This might be a bit of a chicken & egg problem, using a kconfig flag when
# building kconfig, but if you're messing with the parser you probably know
# what you're doing: make CONFIG_UTIL_GENPARSER=y
ifeq ($(CONFIG_UTIL_GENPARSER),y)
$(objk)/%.tab.c $(objk)/%.tab.h: $(srck)/%.y $(objk)/%.tab.c $(objk)/%.tab.h: $(srck)/%.y
bison -t -l --defines -b $(objk)/$* $< bison -t -l --defines -b $(objk)/$* $<
$(objk)/%.lex.c: $(srck)/%.l $(objk)/%.lex.c: $(srck)/%.l
flex -L -o$@ $< flex -L -o$@ $<
else # !CONFIG_UTIL_GENPARSER
$(objk)/parser.tab.c: | $(objk)/parser.tab.h
$(objk)/%: $(srck)/%_shipped
cp $< $@
endif
# Support mingw by shipping our own regex implementation # Support mingw by shipping our own regex implementation
_OS=$(shell uname -s |cut -c-7) _OS=$(shell uname -s |cut -c-7)
regex-objs= regex-objs=

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,132 @@
/* A Bison parser, made by GNU Bison 3.7.6. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
especially those whose name start with YY_ or yy_. They are
private implementation details that can be changed or removed. */
#ifndef YY_YY_PARSER_TAB_H_INCLUDED
# define YY_YY_PARSER_TAB_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 1
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Token kinds. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype
{
YYEMPTY = -2,
YYEOF = 0, /* "end of file" */
YYerror = 256, /* error */
YYUNDEF = 257, /* "invalid token" */
T_HELPTEXT = 258, /* T_HELPTEXT */
T_WORD = 259, /* T_WORD */
T_WORD_QUOTE = 260, /* T_WORD_QUOTE */
T_BOOL = 261, /* T_BOOL */
T_CHOICE = 262, /* T_CHOICE */
T_CLOSE_PAREN = 263, /* T_CLOSE_PAREN */
T_COLON_EQUAL = 264, /* T_COLON_EQUAL */
T_COMMENT = 265, /* T_COMMENT */
T_CONFIG = 266, /* T_CONFIG */
T_DEFAULT = 267, /* T_DEFAULT */
T_DEF_BOOL = 268, /* T_DEF_BOOL */
T_DEF_TRISTATE = 269, /* T_DEF_TRISTATE */
T_DEPENDS = 270, /* T_DEPENDS */
T_ENDCHOICE = 271, /* T_ENDCHOICE */
T_ENDIF = 272, /* T_ENDIF */
T_ENDMENU = 273, /* T_ENDMENU */
T_HELP = 274, /* T_HELP */
T_HEX = 275, /* T_HEX */
T_IF = 276, /* T_IF */
T_IMPLY = 277, /* T_IMPLY */
T_INT = 278, /* T_INT */
T_MAINMENU = 279, /* T_MAINMENU */
T_MENU = 280, /* T_MENU */
T_MENUCONFIG = 281, /* T_MENUCONFIG */
T_MODULES = 282, /* T_MODULES */
T_ON = 283, /* T_ON */
T_OPEN_PAREN = 284, /* T_OPEN_PAREN */
T_OPTIONAL = 285, /* T_OPTIONAL */
T_PLUS_EQUAL = 286, /* T_PLUS_EQUAL */
T_PROMPT = 287, /* T_PROMPT */
T_RANGE = 288, /* T_RANGE */
T_SELECT = 289, /* T_SELECT */
T_SOURCE = 290, /* T_SOURCE */
T_STRING = 291, /* T_STRING */
T_TRISTATE = 292, /* T_TRISTATE */
T_VISIBLE = 293, /* T_VISIBLE */
T_EOL = 294, /* T_EOL */
T_ASSIGN_VAL = 295, /* T_ASSIGN_VAL */
T_OR = 296, /* T_OR */
T_AND = 297, /* T_AND */
T_EQUAL = 298, /* T_EQUAL */
T_UNEQUAL = 299, /* T_UNEQUAL */
T_LESS = 300, /* T_LESS */
T_LESS_EQUAL = 301, /* T_LESS_EQUAL */
T_GREATER = 302, /* T_GREATER */
T_GREATER_EQUAL = 303, /* T_GREATER_EQUAL */
T_NOT = 304 /* T_NOT */
};
typedef enum yytokentype yytoken_kind_t;
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
char *string;
struct symbol *symbol;
struct expr *expr;
struct menu *menu;
enum symbol_type type;
enum variable_flavor flavor;
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE yylval;
int yyparse (void);
#endif /* !YY_YY_PARSER_TAB_H_INCLUDED */