Product config makefiles to Starlark converter
Test: treehugger; internal tests in mk2rbc_test.go Bug: 172923994 Change-Id: I43120b9c181ef2b8d9453e743233811b0fec268b
This commit is contained in:
@@ -278,6 +278,15 @@ func (ms *MakeString) ReplaceLiteral(input string, output string) {
|
||||
}
|
||||
}
|
||||
|
||||
// If MakeString is $(var) after trimming, returns var
|
||||
func (ms *MakeString) SingleVariable() (*MakeString, bool) {
|
||||
if len(ms.Strings) != 2 || strings.TrimSpace(ms.Strings[0]) != "" ||
|
||||
strings.TrimSpace(ms.Strings[1]) != "" {
|
||||
return nil, false
|
||||
}
|
||||
return ms.Variables[0].Name, true
|
||||
}
|
||||
|
||||
func splitAnyN(s, sep string, n int) []string {
|
||||
ret := []string{}
|
||||
for n == -1 || n > 1 {
|
||||
|
@@ -216,13 +216,14 @@ func (p *parser) parseDirective() bool {
|
||||
// Nothing
|
||||
case "else":
|
||||
p.ignoreSpaces()
|
||||
if p.tok != '\n' {
|
||||
if p.tok != '\n' && p.tok != '#' {
|
||||
d = p.scanner.TokenText()
|
||||
p.accept(scanner.Ident)
|
||||
if d == "ifdef" || d == "ifndef" || d == "ifeq" || d == "ifneq" {
|
||||
d = "el" + d
|
||||
p.ignoreSpaces()
|
||||
expression = p.parseExpression()
|
||||
expression.TrimRightSpaces()
|
||||
} else {
|
||||
p.errorf("expected ifdef/ifndef/ifeq/ifneq, found %s", d)
|
||||
}
|
||||
|
Reference in New Issue
Block a user