Incorporate cc_library_headers into mixed builds

Test: go soong tests
Test: bp2build generate & sync; mixed build libc; mixed build su (su is
      an Android.mk target that relies on converted a cc_library_headers)
Bug: 181552740
Change-Id: I9efd587970551fd41f642a208f0aa0a80e8694e0
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 536efa4..8f3a652 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -191,17 +191,31 @@
 }
 
 func (library *libraryDecorator) androidMkWriteExportedFlags(entries *android.AndroidMkEntries) {
-	exportedFlags := library.flagExporter.flags
-	for _, dir := range library.flagExporter.dirs {
+	var exportedFlags []string
+	var includeDirs android.Paths
+	var systemIncludeDirs android.Paths
+	var exportedDeps android.Paths
+
+	if library.flagExporterInfo != nil {
+		exportedFlags = library.flagExporterInfo.Flags
+		includeDirs = library.flagExporterInfo.IncludeDirs
+		systemIncludeDirs = library.flagExporterInfo.SystemIncludeDirs
+		exportedDeps = library.flagExporterInfo.Deps
+	} else {
+		exportedFlags = library.flagExporter.flags
+		includeDirs = library.flagExporter.dirs
+		systemIncludeDirs = library.flagExporter.systemDirs
+		exportedDeps = library.flagExporter.deps
+	}
+	for _, dir := range includeDirs {
 		exportedFlags = append(exportedFlags, "-I"+dir.String())
 	}
-	for _, dir := range library.flagExporter.systemDirs {
+	for _, dir := range systemIncludeDirs {
 		exportedFlags = append(exportedFlags, "-isystem "+dir.String())
 	}
 	if len(exportedFlags) > 0 {
 		entries.AddStrings("LOCAL_EXPORT_CFLAGS", exportedFlags...)
 	}
-	exportedDeps := library.flagExporter.deps
 	if len(exportedDeps) > 0 {
 		entries.AddStrings("LOCAL_EXPORT_C_INCLUDE_DEPS", exportedDeps.Strings()...)
 	}