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
This commit is contained in:
Colin Cross
2015-03-31 16:40:23 -07:00
parent c77f9d1404
commit 3e8ec07787
3 changed files with 56 additions and 12 deletions

View File

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