bpfmt: Process all blueprint files when a directory is specified
Currently when a directory path is specified bpfmt only processes files named "Blueprints" so change this to also process files with a `.bp` suffix. Test: Manual + bpfmt -d frameworks/base/services shows differences Change-Id: I5a6356f387892934ee8e83362db13cda6156ed51 Signed-off-by: Rashid Zaman <rashidz@meta.com>
This commit is contained in:
parent
7c2ebdef75
commit
a29ee638ea
1 changed files with 7 additions and 1 deletions
|
@ -14,6 +14,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint/parser"
|
"github.com/google/blueprint/parser"
|
||||||
)
|
)
|
||||||
|
@ -110,9 +111,14 @@ func processReader(filename string, in io.Reader, out io.Writer) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isBlueprintFile(f os.FileInfo) bool {
|
||||||
|
name := f.Name()
|
||||||
|
return !f.IsDir() && (name == "Blueprints" || (!strings.HasPrefix(name, ".") && strings.HasSuffix(name, ".bp")))
|
||||||
|
}
|
||||||
|
|
||||||
func walkDir(path string) {
|
func walkDir(path string) {
|
||||||
visitFile := func(path string, f os.FileInfo, err error) error {
|
visitFile := func(path string, f os.FileInfo, err error) error {
|
||||||
if err == nil && f.Name() == "Blueprints" {
|
if err == nil && isBlueprintFile(f) {
|
||||||
err = processFile(path, os.Stdout)
|
err = processFile(path, os.Stdout)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue