Export proto deps from reused libraries too

The deps have to be exported alongside the headers to make sure
the headers are in place when a module that depends on the shared
library builds.

Bug: 37555583
Test: use protos in a cc_library
Change-Id: I8f5b8d7937868458c1cf02b990a348aa395634da
diff --git a/cc/library.go b/cc/library.go
index 1a5de61..12a866b 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -202,6 +202,7 @@
 	// For reusing static library objects for shared library
 	reuseObjects       Objects
 	reuseExportedFlags []string
+	reuseExportedDeps  android.Paths
 
 	// table-of-contents file to optimize out relinking when possible
 	tocFile android.OptionalPath
@@ -364,7 +365,7 @@
 	getWholeStaticMissingDeps() []string
 	static() bool
 	objs() Objects
-	reuseObjs() (Objects, []string)
+	reuseObjs() (Objects, []string, android.Paths)
 	toc() android.OptionalPath
 
 	// Returns true if the build options for the module have selected a static or shared build
@@ -623,6 +624,7 @@
 			library.reexportFlags(flags)
 			library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
 			library.reexportDeps(library.baseCompiler.deps) // TODO: restrict to aidl deps
+			library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.deps...)
 		}
 	}
 
@@ -635,6 +637,7 @@
 			library.reexportFlags(flags)
 			library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
 			library.reexportDeps(library.baseCompiler.deps) // TODO: restrict to proto deps
+			library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.deps...)
 		}
 	}
 
@@ -659,8 +662,8 @@
 	return library.objects
 }
 
-func (library *libraryDecorator) reuseObjs() (Objects, []string) {
-	return library.reuseObjects, library.reuseExportedFlags
+func (library *libraryDecorator) reuseObjs() (Objects, []string, android.Paths) {
+	return library.reuseObjects, library.reuseExportedFlags, library.reuseExportedDeps
 }
 
 func (library *libraryDecorator) toc() android.OptionalPath {