Merge "androidbp: Defer local path printing" into master-soong
diff --git a/androidbp/cmd/androidbp.go b/androidbp/cmd/androidbp.go
index 6e0bc7f..58afe77 100644
--- a/androidbp/cmd/androidbp.go
+++ b/androidbp/cmd/androidbp.go
@@ -21,6 +21,8 @@
blueprint *bpparser.File
path string
+ printedLocalPath bool
+
mapScope map[string][]*bpparser.Property
}
@@ -286,6 +288,11 @@
}
func (w *androidMkWriter) handleLocalPath() error {
+ if w.printedLocalPath {
+ return nil
+ }
+ w.printedLocalPath = true
+
localPath, err := filepath.Abs(w.path)
if err != nil {
return err
@@ -317,15 +324,17 @@
w.Writer = bufio.NewWriter(f)
- if err := w.handleLocalPath(); err != nil {
- return err
- }
-
for block := range w.iter() {
switch block := block.(type) {
case *bpparser.Module:
+ if err := w.handleLocalPath(); err != nil {
+ return err
+ }
w.handleModule(block)
case *bpparser.Assignment:
+ if err := w.handleLocalPath(); err != nil {
+ return err
+ }
w.handleAssignment(block)
case bpparser.Comment:
w.handleComment(&block)