From 3e8ec07787180c043d1f82bb7ef98d5d8c3d370c Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Tue, 31 Mar 2015 16:40:23 -0700 Subject: Support excludes in globs Java resource support requires globbing directories while ignoring specific filenames. Add support for multiple -e options to soong_glob to specify filenames to exclude, and split out Glob into GlobRule to insert a rule to generate a glob file list. Change-Id: Ia911dd68bd1638452881d18378572d015fd4e31a --- cmd/soong_glob/soong_glob.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'cmd/soong_glob') diff --git a/cmd/soong_glob/soong_glob.go b/cmd/soong_glob/soong_glob.go index 227d7b01..6f56bb98 100644 --- a/cmd/soong_glob/soong_glob.go +++ b/cmd/soong_glob/soong_glob.go @@ -28,8 +28,29 @@ import ( var ( out = flag.String("o", "", "file to write list of files that match glob") + + excludes multiArg ) +func init() { + flag.Var(&excludes, "e", "pattern to exclude from results") +} + +type multiArg []string + +func (m *multiArg) String() string { + return `""` +} + +func (m *multiArg) Set(s string) error { + *m = append(*m, s) + return nil +} + +func (m *multiArg) Get() interface{} { + return m +} + func usage() { fmt.Fprintf(os.Stderr, "usage: soong_glob -o out glob\n") flag.PrintDefaults() @@ -48,7 +69,7 @@ func main() { usage() } - _, err := glob.GlobWithDepFile(flag.Arg(0), *out, *out+".d") + _, err := glob.GlobWithDepFile(flag.Arg(0), *out, *out+".d", excludes) if err != nil { fmt.Fprintf(os.Stderr, "error: %s\n", err.Error()) os.Exit(1) -- cgit v1.2.3