Check reused source files in hasSrcExt

hasSrcExt is used to determine extra flags and dependencies when
generated files are used.  If the generated files are being handled
in a static library whose objects are reused in a shared library,
the flags and dependencies still need to apply.  Instead of clearing
the source files in the shared library, move them to an OriginalSrcs
property, and check that in hasSrcExt along with the Srcs property.

Also pass extra exported include directories from the static
library to the shared library.

Bug: 37555583
Test: use protos in a cc_library
Change-Id: I709779ec03b66b220b7bd58a1f6f0b9b5067d955
diff --git a/cc/compiler.go b/cc/compiler.go
index eb30767..8afd1bd 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -125,6 +125,9 @@
 			Exclude_srcs []string
 		}
 	}
+
+	// Stores the original list of source files before being cleared by library reuse
+	OriginalSrcs []string `blueprint:"mutated"`
 }
 
 func NewBaseCompiler() *baseCompiler {
@@ -427,6 +430,11 @@
 			return true
 		}
 	}
+	for _, src := range compiler.Properties.OriginalSrcs {
+		if filepath.Ext(src) == ext {
+			return true
+		}
+	}
 
 	return false
 }