Remove more duplicated flags and dependencies

All the stats below are for a hikey960-eng build on AOSP master.

Number of order-only inputs in out/soong/build.ninja:
Before: 2847162
After:   606508

Size of:                       Before  After
out/soong/build.ninja          572MB   233MB  -59%
out/soong/Android-hikey960.mk   15MB     9MB  -40%
out/build-hikey960.ninja       367MB   358MB   -2%

Ninja time in `m nothing`:
Before: 6.9s
After:  5.0s

Soong generation time:
Before: 11.6s
After:   6.6s

Test: m nothing
Test: wrote script that counted inputs, only duplicates were removed
Test: treehugger
Change-Id: I6b7c5ef5b1395014b7bf5fd0b8112d42bee127bf
diff --git a/android/paths.go b/android/paths.go
index b5b4730..9c8e93a 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -283,6 +283,23 @@
 	return ret
 }
 
+// FirstUniqueElements returns all unique elements of a slice, keeping the first copy of each
+// modifies the slice contents in place, and returns a subslice of the original slice
+func FirstUniquePaths(list Paths) Paths {
+	k := 0
+outer:
+	for i := 0; i < len(list); i++ {
+		for j := 0; j < k; j++ {
+			if list[i] == list[j] {
+				continue outer
+			}
+		}
+		list[k] = list[i]
+		k++
+	}
+	return list[:k]
+}
+
 // WritablePaths is a slice of WritablePaths, used for multiple outputs.
 type WritablePaths []WritablePath