diff options
author | Colin Cross <ccross@android.com> | 2016-06-10 17:34:07 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2016-06-14 19:04:53 -0700 |
commit | 7b6ba5c7fac1f420ae68cee1ab51d85e73e5900e (patch) | |
tree | 9feb962eaf3bd86f317a1d00e8469dddf0f300ba /androidmk/cmd | |
parent | e538e410cb8931628d210b022513c4368bae49f0 (diff) | |
download | build_soong-7b6ba5c7fac1f420ae68cee1ab51d85e73e5900e.tar.gz build_soong-7b6ba5c7fac1f420ae68cee1ab51d85e73e5900e.tar.bz2 build_soong-7b6ba5c7fac1f420ae68cee1ab51d85e73e5900e.zip |
Add CommentGroups
Follows blueprint change https://github.com/google/blueprint/pull/104/commits/1e73794d421a8017dbbc1d80913d93571d46d1b6
Change-Id: If3539e2d9370a0224a2364608c496a1e4385dbbf
Diffstat (limited to 'androidmk/cmd')
-rw-r--r-- | androidmk/cmd/androidmk/androidmk.go | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/androidmk/cmd/androidmk/androidmk.go b/androidmk/cmd/androidmk/androidmk.go index 75a53815..bc3295a0 100644 --- a/androidmk/cmd/androidmk/androidmk.go +++ b/androidmk/cmd/androidmk/androidmk.go @@ -16,7 +16,7 @@ import ( // TODO: non-expanded variables with expressions type bpFile struct { - comments []bpparser.Comment + comments []*bpparser.CommentGroup defs []bpparser.Definition localAssignments map[string]*bpparser.Property globalAssignments map[string]*bpparser.Expression @@ -29,21 +29,32 @@ type bpFile struct { inModule bool } +func (f *bpFile) insertComment(s string) { + f.comments = append(f.comments, &bpparser.CommentGroup{ + Comments: []*bpparser.Comment{ + &bpparser.Comment{ + Comment: []string{s}, + Slash: f.bpPos, + }, + }, + }) + f.bpPos.Offset += len(s) +} + +func (f *bpFile) insertExtraComment(s string) { + f.insertComment(s) + f.bpPos.Line++ +} + func (f *bpFile) errorf(node mkparser.Node, s string, args ...interface{}) { orig := node.Dump() s = fmt.Sprintf(s, args...) - c := bpparser.Comment{ - Comment: []string{fmt.Sprintf("// ANDROIDMK TRANSLATION ERROR: %s", s)}, - Slash: f.bpPos, - } + f.insertExtraComment(fmt.Sprintf("// ANDROIDMK TRANSLATION ERROR: %s", s)) lines := strings.Split(orig, "\n") for _, l := range lines { - c.Comment = append(c.Comment, "// "+l) + f.insertExtraComment("// " + l) } - f.incBpPos(len(lines)) - - f.comments = append(f.comments, c) } func (f *bpFile) setMkPos(pos, end scanner.Position) { @@ -54,11 +65,6 @@ func (f *bpFile) setMkPos(pos, end scanner.Position) { f.mkPos = end } -// Called when inserting extra lines into the blueprint file -func (f *bpFile) incBpPos(lines int) { - f.bpPos.Line += lines -} - type conditional struct { cond string eq bool @@ -104,10 +110,7 @@ func convertFile(filename string, buffer *bytes.Buffer) (string, []error) { switch x := node.(type) { case *mkparser.Comment: - file.comments = append(file.comments, bpparser.Comment{ - Slash: file.bpPos, - Comment: []string{"//" + x.Comment}, - }) + file.insertComment("//" + x.Comment) case *mkparser.Assignment: handleAssignment(file, x, assignmentCond) case *mkparser.Directive: |