Convert java.Dependency to JavaInfo provider
Export information about java dependencies through a Provider
instead of accessing the module directly.
Test: java_test.go
Test: no changes to build.ninja
Change-Id: Ifc5d566bf6f6ebc0ad399e948effaa1ef6a22876
diff --git a/android/paths.go b/android/paths.go
index 44221be..c3fa61a 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -1949,3 +1949,28 @@
// The install path of the data file, relative to the install root.
RelativeInstallPath string
}
+
+// PathsIfNonNil returns a Paths containing only the non-nil input arguments.
+func PathsIfNonNil(paths ...Path) Paths {
+ if len(paths) == 0 {
+ // Fast path for empty argument list
+ return nil
+ } else if len(paths) == 1 {
+ // Fast path for a single argument
+ if paths[0] != nil {
+ return paths
+ } else {
+ return nil
+ }
+ }
+ ret := make(Paths, 0, len(paths))
+ for _, path := range paths {
+ if path != nil {
+ ret = append(ret, path)
+ }
+ }
+ if len(ret) == 0 {
+ return nil
+ }
+ return ret
+}