bpfmt: Process all blueprint files when a directory is specified am: a29ee638ea am: c72a75269d am: 177f5bfe6f am: fedab1373c

Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/2694306

Change-Id: Icfbfc2c60bf5722547d6d33c89fc3b6af5985788
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Rashid Zaman 2023-08-23 02:41:07 +00:00 committed by Automerger Merge Worker
commit 103c1e5b8c

View file

@ -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 {