From a02cf8b55bd7864e7d40abada7caaf4ac5b784f9 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 15 Apr 2021 20:15:04 +0200 Subject: pkg/kconfig: relax parsing for older kernels An older kernel uses source directive w/o quotes, option with a quoted value and $SRCDIR without parens. --- pkg/kconfig/kconfig.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'pkg/kconfig') diff --git a/pkg/kconfig/kconfig.go b/pkg/kconfig/kconfig.go index af367a8a0..080f1d932 100644 --- a/pkg/kconfig/kconfig.go +++ b/pkg/kconfig/kconfig.go @@ -202,7 +202,11 @@ func (kp *kconfigParser) parseLine() { func (kp *kconfigParser) parseMenu(cmd string) { switch cmd { case "source": - kp.includeSource(kp.QuotedString()) + file, ok := kp.TryQuotedString() + if !ok { + file = kp.ConsumeLine() + } + kp.includeSource(file) case "mainmenu": kp.pushCurrent(&Menu{ Kind: MenuConfig, @@ -294,7 +298,8 @@ func (kp *kconfigParser) parseProperty(prop string) { _ = kp.parseExpr() } case "option": - _ = kp.Ident() + // It can be 'option foo', or 'option bar="BAZ"'. + kp.ConsumeLine() case "modules": case "optional": case "default": @@ -409,5 +414,7 @@ func (kp *kconfigParser) parseDefaultValue() { } func (kp *kconfigParser) expandString(str string) string { - return strings.Replace(str, "$(SRCARCH)", kp.target.KernelHeaderArch, -1) + str = strings.Replace(str, "$(SRCARCH)", kp.target.KernelHeaderArch, -1) + str = strings.Replace(str, "$SRCARCH", kp.target.KernelHeaderArch, -1) + return str } -- cgit mrf-deployment