Merge "androidbp: Defer local path printing" into master-soong

This commit is contained in:
Dan Willemsen
2015-06-19 19:34:58 +00:00
committed by Gerrit Code Review

View File

@@ -21,6 +21,8 @@ type androidMkWriter struct {
blueprint *bpparser.File blueprint *bpparser.File
path string path string
printedLocalPath bool
mapScope map[string][]*bpparser.Property mapScope map[string][]*bpparser.Property
} }
@@ -286,6 +288,11 @@ func (w *androidMkWriter) iter() <-chan interface{} {
} }
func (w *androidMkWriter) handleLocalPath() error { func (w *androidMkWriter) handleLocalPath() error {
if w.printedLocalPath {
return nil
}
w.printedLocalPath = true
localPath, err := filepath.Abs(w.path) localPath, err := filepath.Abs(w.path)
if err != nil { if err != nil {
return err return err
@@ -317,15 +324,17 @@ func (w *androidMkWriter) write(androidMk string) error {
w.Writer = bufio.NewWriter(f) w.Writer = bufio.NewWriter(f)
if err := w.handleLocalPath(); err != nil {
return err
}
for block := range w.iter() { for block := range w.iter() {
switch block := block.(type) { switch block := block.(type) {
case *bpparser.Module: case *bpparser.Module:
if err := w.handleLocalPath(); err != nil {
return err
}
w.handleModule(block) w.handleModule(block)
case *bpparser.Assignment: case *bpparser.Assignment:
if err := w.handleLocalPath(); err != nil {
return err
}
w.handleAssignment(block) w.handleAssignment(block)
case bpparser.Comment: case bpparser.Comment:
w.handleComment(&block) w.handleComment(&block)