aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2021-04-15 20:15:04 +0200
committerDmitry Vyukov <dvyukov@google.com>2021-04-16 13:57:41 +0200
commita02cf8b55bd7864e7d40abada7caaf4ac5b784f9 (patch)
treec82299d69c16c57abd7ee4fbd817d78926e82875
parentc59079a693ad1d89c782f7db14b9f1c5629e2abc (diff)
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.
-rw-r--r--pkg/kconfig/kconfig.go13
1 files changed, 10 insertions, 3 deletions
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
}