Mark generated renderscript header files as implicit outputs

If a generated renderscript header is referenced by a cpp file
clang will insert a depsfile dependency on the header.  If the
generator rule does not include the header as an output, ninja
will not consider the cpp file dirty after the generator runs,
and not rebuild it.  On the next build, it will see that the
timestamp of the generated header is new and consider the cpp
file dirty.

Mark the header files as implicit outputs of the generator.

Bug: 75982985
Test: m libstagefright_mediafilter
      touch frameworks/av/media/libstagefright/filters/saturationARGB.rs
      m libstagefright_mediafilter
      m libstagefright_mediafilter

Change-Id: I3ac899322fe9cae2a6e4171092740339ef844494
This commit is contained in:
Colin Cross 2018-03-19 22:44:29 -07:00
parent 4d693a7a27
commit 80e6054eab
1 changed files with 13 additions and 6 deletions

View File

@ -49,6 +49,11 @@ func rsGeneratedCppFile(ctx android.ModuleContext, rsFile android.Path) android.
return android.PathForModuleGen(ctx, "rs", "ScriptC_"+fileName+".cpp") return android.PathForModuleGen(ctx, "rs", "ScriptC_"+fileName+".cpp")
} }
func rsGeneratedHFile(ctx android.ModuleContext, rsFile android.Path) android.WritablePath {
fileName := strings.TrimSuffix(rsFile.Base(), rsFile.Ext())
return android.PathForModuleGen(ctx, "rs", "ScriptC_"+fileName+".h")
}
func rsGeneratedDepFile(ctx android.ModuleContext, rsFile android.Path) android.WritablePath { func rsGeneratedDepFile(ctx android.ModuleContext, rsFile android.Path) android.WritablePath {
fileName := strings.TrimSuffix(rsFile.Base(), rsFile.Ext()) fileName := strings.TrimSuffix(rsFile.Base(), rsFile.Ext())
return android.PathForModuleGen(ctx, "rs", fileName+".d") return android.PathForModuleGen(ctx, "rs", fileName+".d")
@ -56,18 +61,20 @@ func rsGeneratedDepFile(ctx android.ModuleContext, rsFile android.Path) android.
func rsGenerateCpp(ctx android.ModuleContext, rsFiles android.Paths, rsFlags string) android.Paths { func rsGenerateCpp(ctx android.ModuleContext, rsFiles android.Paths, rsFlags string) android.Paths {
stampFile := android.PathForModuleGen(ctx, "rs", "rs.stamp") stampFile := android.PathForModuleGen(ctx, "rs", "rs.stamp")
depFiles := make(android.WritablePaths, len(rsFiles)) depFiles := make(android.WritablePaths, 0, len(rsFiles))
cppFiles := make(android.WritablePaths, len(rsFiles)) genFiles := make(android.WritablePaths, 0, 2*len(rsFiles))
for i, rsFile := range rsFiles { for _, rsFile := range rsFiles {
depFiles[i] = rsGeneratedDepFile(ctx, rsFile) depFiles = append(depFiles, rsGeneratedDepFile(ctx, rsFile))
cppFiles[i] = rsGeneratedCppFile(ctx, rsFile) genFiles = append(genFiles,
rsGeneratedCppFile(ctx, rsFile),
rsGeneratedHFile(ctx, rsFile))
} }
ctx.Build(pctx, android.BuildParams{ ctx.Build(pctx, android.BuildParams{
Rule: rsCpp, Rule: rsCpp,
Description: "llvm-rs-cc", Description: "llvm-rs-cc",
Output: stampFile, Output: stampFile,
ImplicitOutputs: cppFiles, ImplicitOutputs: genFiles,
Inputs: rsFiles, Inputs: rsFiles,
Args: map[string]string{ Args: map[string]string{
"rsFlags": rsFlags, "rsFlags": rsFlags,