Have bpfix not remove empty lists
Since in some cases they're not the default value.
Test: echo "cc_defaults{ system_shared_libs:[] }" | bpfix | grep system_shared_libs > /dev/null && echo ok
Bug: 66979076
Change-Id: I760b34f980281b955972819676bd62154a6c73f5
diff --git a/bpfix/bpfix/bpfix.go b/bpfix/bpfix/bpfix.go
index 1249494..fcd4fec 100644
--- a/bpfix/bpfix/bpfix.go
+++ b/bpfix/bpfix/bpfix.go
@@ -19,6 +19,7 @@
import (
"bytes"
"fmt"
+
"github.com/google/blueprint/parser"
)
@@ -26,7 +27,6 @@
// A FixRequest doesn't specify whether to do a dry run or where to write the results; that's in cmd/bpfix.go
type FixRequest struct {
simplifyKnownRedundantVariables bool
- removeEmptyLists bool
}
func NewFixRequest() FixRequest {
@@ -36,7 +36,6 @@
func (r FixRequest) AddAll() (result FixRequest) {
result = r
result.simplifyKnownRedundantVariables = true
- result.removeEmptyLists = true
return result
}
@@ -89,12 +88,6 @@
return nil, err
}
}
- if config.removeEmptyLists {
- tree, err = removePropertiesHavingTheirDefaultValues(tree)
- if err != nil {
- return nil, err
- }
- }
return tree, err
}
@@ -154,32 +147,3 @@
}
return tree, nil
}
-
-func removePropertiesHavingTheirDefaultValues(tree *parser.File) (fixed *parser.File, err error) {
- for _, def := range tree.Defs {
- mod, ok := def.(*parser.Module)
- if !ok {
- continue
- }
- writeIndex := 0
- for _, prop := range mod.Properties {
- val := prop.Value
- keep := true
- switch val := val.(type) {
- case *parser.List:
- if len(val.Values) == 0 {
- keep = false
- }
- break
- default:
- keep = true
- }
- if keep {
- mod.Properties[writeIndex] = prop
- writeIndex++
- }
- }
- mod.Properties = mod.Properties[:writeIndex]
- }
- return tree, nil
-}