Add exclude_* and remove arch_subtract / "-file"

To align with the current make build system, add exclude_srcs and
exclude_java_resource_dirs. These replace the functionality of
arch_subtract and glob exclusions that use "-file" to exclude a file.

Change-Id: I91c23d5e3c9409f2d9f7921f950153a03a68ad61
diff --git a/common/arch.go b/common/arch.go
index ba1f671..60a17e4 100644
--- a/common/arch.go
+++ b/common/arch.go
@@ -628,12 +628,7 @@
 				dstFieldValue, srcFieldValue,
 				newRecursePrefix)
 		case reflect.Slice:
-			val, err := archCombineSlices(dstFieldValue, srcFieldValue, tags["arch_subtract"])
-			if err != nil {
-				ctx.PropertyErrorf(propertyName, err.Error())
-				continue
-			}
-			dstFieldValue.Set(val)
+			dstFieldValue.Set(reflect.AppendSlice(dstFieldValue, srcFieldValue))
 		case reflect.Ptr, reflect.Interface:
 			// Recursively extend the pointed-to struct's fields.
 			if dstFieldValue.IsNil() != srcFieldValue.IsNil() {
@@ -654,38 +649,3 @@
 		}
 	}
 }
-
-func archCombineSlices(general, arch reflect.Value, canSubtract bool) (reflect.Value, error) {
-	if !canSubtract {
-		// Append the extension slice.
-		return reflect.AppendSlice(general, arch), nil
-	}
-
-	// Support -val in arch list to subtract a value from original list
-	l := general.Interface().([]string)
-	for archIndex := 0; archIndex < arch.Len(); archIndex++ {
-		archString := arch.Index(archIndex).String()
-		if strings.HasPrefix(archString, "-") {
-			generalIndex := findStringInSlice(archString[1:], l)
-			if generalIndex == -1 {
-				return reflect.Value{},
-					fmt.Errorf("can't find %q to subtract from general properties", archString[1:])
-			}
-			l = append(l[:generalIndex], l[generalIndex+1:]...)
-		} else {
-			l = append(l, archString)
-		}
-	}
-
-	return reflect.ValueOf(l), nil
-}
-
-func findStringInSlice(str string, slice []string) int {
-	for i, s := range slice {
-		if s == str {
-			return i
-		}
-	}
-
-	return -1
-}
diff --git a/common/module.go b/common/module.go
index 77e0295..1d17de1 100644
--- a/common/module.go
+++ b/common/module.go
@@ -53,7 +53,7 @@
 	blueprint.ModuleContext
 	androidBaseContext
 
-	ExpandSources(srcFiles []string) []string
+	ExpandSources(srcFiles, excludes []string) []string
 	Glob(globPattern string, excludes []string) []string
 
 	InstallFile(installPath, srcPath string, deps ...string) string
@@ -472,32 +472,37 @@
 	return ok
 }
 
-func (ctx *androidModuleContext) ExpandSources(srcFiles []string) []string {
-	prefix := ModuleSrcDir(ctx)
-	for i, srcFile := range srcFiles {
-		if srcFile[0] == '-' {
-			srcFiles[i] = "-" + filepath.Join(prefix, srcFile[1:])
-		} else {
-			srcFiles[i] = filepath.Join(prefix, srcFile)
+func findStringInSlice(str string, slice []string) int {
+	for i, s := range slice {
+		if s == str {
+			return i
 		}
 	}
+	return -1
+}
+
+func (ctx *androidModuleContext) ExpandSources(srcFiles, excludes []string) []string {
+	prefix := ModuleSrcDir(ctx)
+	for i, e := range excludes {
+		j := findStringInSlice(e, srcFiles)
+		if j != -1 {
+			srcFiles = append(srcFiles[:j], srcFiles[j+1:]...)
+		}
+
+		excludes[i] = filepath.Join(prefix, e)
+	}
+
+	for i, srcFile := range srcFiles {
+		srcFiles[i] = filepath.Join(prefix, srcFile)
+	}
 
 	if !hasGlob(srcFiles) {
 		return srcFiles
 	}
 
-	var excludes []string
-	for _, s := range srcFiles {
-		if s[0] == '-' {
-			excludes = append(excludes, s[1:])
-		}
-	}
-
 	globbedSrcFiles := make([]string, 0, len(srcFiles))
 	for _, s := range srcFiles {
-		if s[0] == '-' {
-			continue
-		} else if glob.IsGlob(s) {
+		if glob.IsGlob(s) {
 			globbedSrcFiles = append(globbedSrcFiles, ctx.Glob(s, excludes)...)
 		} else {
 			globbedSrcFiles = append(globbedSrcFiles, s)