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
diff --git a/cmd/soong_glob/soong_glob.go b/cmd/soong_glob/soong_glob.go
index 227d7b0..6f56bb9 100644
--- a/cmd/soong_glob/soong_glob.go
+++ b/cmd/soong_glob/soong_glob.go
@@ -28,8 +28,29 @@
 
 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 @@
 		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)