diff options
author | 2018-02-21 02:10:29 -0800 | |
---|---|---|
committer | 2018-05-07 16:21:59 -0700 | |
commit | 4339853a20bc300968d0389f4f9307ec415d540d (patch) | |
tree | 3258e9b29d26cafc74123ad21cc557f28cf0c9b1 /androidmk/parser/parser.go | |
parent | 470969df19079ad1c2eeb94fcc984ca2ce5e68ab (diff) |
Add a dependency fixer for proto deps
protoc dependency files, at least for C++ outputs, uses the form of:
a/b.c \
a/b.h: <dep1> <dep2>...
Ninja will fail the command when it parses a dep file and there's more
than one output file (even though it doesn't care what the output file
name is). So this tool will parse the original file, and output a
version with only a single output file.
Bug: 67329638
Test: NINJA_ARGS="-t deps ...pb.c" m
Test: NINJA_ARGS="-t deps ...srcjar" m
Test: NINJA_ARGS="-t deps ...srcszip" m
Test: Run dep_fixer across all of taimen's dep files, no failures.
Test: Run dep_fixer against the processed files, no changes.
Test: Run androidmk across all of our Android.mk files, inspect the diffs
Change-Id: I4263b7d5faea37285afa6b24dedf5964aa7d19dc
Diffstat (limited to 'androidmk/parser/parser.go')
-rw-r--r-- | androidmk/parser/parser.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/androidmk/parser/parser.go b/androidmk/parser/parser.go index 89ee308f7..89c1af904 100644 --- a/androidmk/parser/parser.go +++ b/androidmk/parser/parser.go @@ -35,6 +35,10 @@ func (e *ParseError) Error() string { return fmt.Sprintf("%s: %s", e.Pos, e.Err) } +const builtinDollar = "__builtin_dollar" + +var builtinDollarName = SimpleMakeString(builtinDollar, NoPos) + func (p *parser) Parse() ([]Node, []error) { defer func() { if r := recover(); r != nil { @@ -326,7 +330,11 @@ loop: case '$': var variable Variable variable = p.parseVariable() - value.appendVariable(variable) + if variable.Name == builtinDollarName { + value.appendString("$") + } else { + value.appendVariable(variable) + } case scanner.EOF: break loop case '(': @@ -357,7 +365,8 @@ func (p *parser) parseVariable() Variable { case '{': return p.parseBracketedVariable('{', '}', pos) case '$': - name = SimpleMakeString("__builtin_dollar", NoPos) + name = builtinDollarName + p.accept(p.tok) case scanner.EOF: p.errorf("expected variable name, found %s", scanner.TokenString(p.tok)) @@ -457,6 +466,8 @@ func (p *parser) parseRulePrerequisites(target *MakeString) (*MakeString, bool) case '=': p.parseAssignment("=", target, prerequisites) return nil, true + case scanner.EOF: + // do nothing default: p.errorf("unexpected token %s after rule prerequisites", scanner.TokenString(p.tok)) } |