Merge "Only depend on a single file for generated headers"
diff --git a/cc/cc.go b/cc/cc.go
index f65441f..05a1579 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1138,13 +1138,13 @@
 			case genHeaderDepTag, genHeaderExportDepTag:
 				if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
 					depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders,
-						genRule.GeneratedSourceFiles()...)
+						genRule.GeneratedDeps()...)
 					flags := includeDirsToFlags(genRule.GeneratedHeaderDirs())
 					depPaths.Flags = append(depPaths.Flags, flags)
 					if depTag == genHeaderExportDepTag {
 						depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags)
 						depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps,
-							genRule.GeneratedSourceFiles()...)
+							genRule.GeneratedDeps()...)
 						// Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library.
 						c.sabi.Properties.ReexportedIncludeFlags = append(c.sabi.Properties.ReexportedIncludeFlags, flags)
 
diff --git a/genrule/genrule.go b/genrule/genrule.go
index e423ebc..0cd110c 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -43,6 +43,7 @@
 type SourceFileGenerator interface {
 	GeneratedSourceFiles() android.Paths
 	GeneratedHeaderDirs() android.Paths
+	GeneratedDeps() android.Paths
 }
 
 type HostToolProvider interface {
@@ -107,6 +108,7 @@
 	exportedIncludeDirs android.Paths
 
 	outputFiles android.Paths
+	outputDeps  android.Paths
 }
 
 type taskFunc func(ctx android.ModuleContext, rawCommand string, srcFiles android.Paths) generateTask
@@ -130,6 +132,10 @@
 	return g.exportedIncludeDirs
 }
 
+func (g *Module) GeneratedDeps() android.Paths {
+	return g.outputDeps
+}
+
 func (g *Module) DepsMutator(ctx android.BottomUpMutatorContext) {
 	android.ExtractSourcesDeps(ctx, g.properties.Srcs)
 	android.ExtractSourcesDeps(ctx, g.properties.Tool_files)
@@ -334,6 +340,7 @@
 	for _, outputFile := range task.out {
 		g.outputFiles = append(g.outputFiles, outputFile)
 	}
+	g.outputDeps = append(g.outputDeps, task.out[0])
 }
 
 func generatorFactory(taskGenerator taskFunc, props ...interface{}) *Module {