Merge "Add support for Metalava implicit dependencies for remote execution."
This commit is contained in:
@@ -376,6 +376,7 @@ type Javadoc struct {
|
|||||||
srcFiles android.Paths
|
srcFiles android.Paths
|
||||||
sourcepaths android.Paths
|
sourcepaths android.Paths
|
||||||
argFiles android.Paths
|
argFiles android.Paths
|
||||||
|
implicits android.Paths
|
||||||
|
|
||||||
args string
|
args string
|
||||||
|
|
||||||
@@ -575,6 +576,7 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
// do not pass exclude_srcs directly when expanding srcFiles since exclude_srcs
|
// do not pass exclude_srcs directly when expanding srcFiles since exclude_srcs
|
||||||
// may contain filegroup or genrule.
|
// may contain filegroup or genrule.
|
||||||
srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
|
srcFiles := android.PathsForModuleSrcExcludes(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
|
||||||
|
j.implicits = append(j.implicits, srcFiles...)
|
||||||
|
|
||||||
filterByPackage := func(srcs []android.Path, filterPackages []string) []android.Path {
|
filterByPackage := func(srcs []android.Path, filterPackages []string) []android.Path {
|
||||||
if filterPackages == nil {
|
if filterPackages == nil {
|
||||||
@@ -600,6 +602,24 @@ func (j *Javadoc) collectDeps(ctx android.ModuleContext) deps {
|
|||||||
}
|
}
|
||||||
srcFiles = filterByPackage(srcFiles, j.properties.Filter_packages)
|
srcFiles = filterByPackage(srcFiles, j.properties.Filter_packages)
|
||||||
|
|
||||||
|
// While metalava needs package html files, it does not need them to be explicit on the command
|
||||||
|
// line. More importantly, the metalava rsp file is also used by the subsequent jdiff action if
|
||||||
|
// jdiff_enabled=true. javadoc complains if it receives html files on the command line. The filter
|
||||||
|
// below excludes html files from the rsp file for both metalava and jdiff. Note that the html
|
||||||
|
// files are still included as implicit inputs for successful remote execution and correct
|
||||||
|
// incremental builds.
|
||||||
|
filterHtml := func(srcs []android.Path) []android.Path {
|
||||||
|
filtered := []android.Path{}
|
||||||
|
for _, src := range srcs {
|
||||||
|
if src.Ext() == ".html" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
filtered = append(filtered, src)
|
||||||
|
}
|
||||||
|
return filtered
|
||||||
|
}
|
||||||
|
srcFiles = filterHtml(srcFiles)
|
||||||
|
|
||||||
flags := j.collectAidlFlags(ctx, deps)
|
flags := j.collectAidlFlags(ctx, deps)
|
||||||
srcFiles = j.genSources(ctx, srcFiles, flags)
|
srcFiles = j.genSources(ctx, srcFiles, flags)
|
||||||
|
|
||||||
@@ -1402,10 +1422,26 @@ func (d *Droidstubs) apiToXmlFlags(ctx android.ModuleContext, cmd *android.RuleB
|
|||||||
}
|
}
|
||||||
|
|
||||||
func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersion javaVersion, srcs android.Paths,
|
func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersion javaVersion, srcs android.Paths,
|
||||||
srcJarList android.Path, bootclasspath, classpath classpath, sourcepaths android.Paths) *android.RuleBuilderCommand {
|
srcJarList android.Path, bootclasspath, classpath classpath, sourcepaths android.Paths, implicits android.Paths) *android.RuleBuilderCommand {
|
||||||
// Metalava uses lots of memory, restrict the number of metalava jobs that can run in parallel.
|
// Metalava uses lots of memory, restrict the number of metalava jobs that can run in parallel.
|
||||||
rule.HighMem()
|
rule.HighMem()
|
||||||
cmd := rule.Command()
|
cmd := rule.Command()
|
||||||
|
|
||||||
|
rspFile := ""
|
||||||
|
if len(implicits) > 0 {
|
||||||
|
implicitsRsp := android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"implicits.rsp")
|
||||||
|
rspFile = implicitsRsp.String()
|
||||||
|
impRule := android.NewRuleBuilder()
|
||||||
|
impCmd := impRule.Command()
|
||||||
|
// A dummy action that copies the ninja generated rsp file to a new location. This allows us to
|
||||||
|
// add a large number of inputs to a file without exceeding bash command length limits (which
|
||||||
|
// would happen if we use the WriteFile rule). The cp is needed because RuleBuilder sets the
|
||||||
|
// rsp file to be ${output}.rsp.
|
||||||
|
impCmd.Text("cp").FlagWithRspFileInputList("", implicits).Output(implicitsRsp)
|
||||||
|
impRule.Build(pctx, ctx, "implicitsGen", "implicits generation")
|
||||||
|
cmd.Implicits(implicits)
|
||||||
|
cmd.Implicit(implicitsRsp)
|
||||||
|
}
|
||||||
if ctx.Config().IsEnvTrue("RBE_METALAVA") {
|
if ctx.Config().IsEnvTrue("RBE_METALAVA") {
|
||||||
rule.Remoteable(android.RemoteRuleSupports{RBE: true})
|
rule.Remoteable(android.RemoteRuleSupports{RBE: true})
|
||||||
execStrategy := remoteexec.LocalExecStrategy
|
execStrategy := remoteexec.LocalExecStrategy
|
||||||
@@ -1417,7 +1453,6 @@ func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersi
|
|||||||
pool = v
|
pool = v
|
||||||
}
|
}
|
||||||
inputs := []string{android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "framework", "metalava.jar").String()}
|
inputs := []string{android.PathForOutput(ctx, "host", ctx.Config().PrebuiltOS(), "framework", "metalava.jar").String()}
|
||||||
inputs = append(inputs, sourcepaths.Strings()...)
|
|
||||||
if v := ctx.Config().Getenv("RBE_METALAVA_INPUTS"); v != "" {
|
if v := ctx.Config().Getenv("RBE_METALAVA_INPUTS"); v != "" {
|
||||||
inputs = append(inputs, strings.Split(v, ",")...)
|
inputs = append(inputs, strings.Split(v, ",")...)
|
||||||
}
|
}
|
||||||
@@ -1425,6 +1460,7 @@ func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersi
|
|||||||
Labels: map[string]string{"type": "compile", "lang": "java", "compiler": "metalava"},
|
Labels: map[string]string{"type": "compile", "lang": "java", "compiler": "metalava"},
|
||||||
ExecStrategy: execStrategy,
|
ExecStrategy: execStrategy,
|
||||||
Inputs: inputs,
|
Inputs: inputs,
|
||||||
|
RSPFile: rspFile,
|
||||||
ToolchainInputs: []string{config.JavaCmd(ctx).String()},
|
ToolchainInputs: []string{config.JavaCmd(ctx).String()},
|
||||||
Platform: map[string]string{remoteexec.PoolKey: pool},
|
Platform: map[string]string{remoteexec.PoolKey: pool},
|
||||||
}).NoVarTemplate(ctx.Config()))
|
}).NoVarTemplate(ctx.Config()))
|
||||||
@@ -1482,7 +1518,7 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||||||
srcJarList := zipSyncCmd(ctx, rule, srcJarDir, d.Javadoc.srcJars)
|
srcJarList := zipSyncCmd(ctx, rule, srcJarDir, d.Javadoc.srcJars)
|
||||||
|
|
||||||
cmd := metalavaCmd(ctx, rule, javaVersion, d.Javadoc.srcFiles, srcJarList,
|
cmd := metalavaCmd(ctx, rule, javaVersion, d.Javadoc.srcFiles, srcJarList,
|
||||||
deps.bootClasspath, deps.classpath, d.Javadoc.sourcepaths)
|
deps.bootClasspath, deps.classpath, d.Javadoc.sourcepaths, d.Javadoc.implicits)
|
||||||
|
|
||||||
d.stubsFlags(ctx, cmd, stubsDir)
|
d.stubsFlags(ctx, cmd, stubsDir)
|
||||||
|
|
||||||
|
@@ -1038,7 +1038,7 @@ func checkSystemModulesUseByDroidstubs(t *testing.T, ctx *android.TestContext, m
|
|||||||
for _, i := range metalavaRule.Implicits {
|
for _, i := range metalavaRule.Implicits {
|
||||||
systemJars = append(systemJars, i.Base())
|
systemJars = append(systemJars, i.Base())
|
||||||
}
|
}
|
||||||
if len(systemJars) != 1 || systemJars[0] != systemJar {
|
if len(systemJars) < 1 || systemJars[0] != systemJar {
|
||||||
t.Errorf("inputs of %q must be []string{%q}, but was %#v.", moduleName, systemJar, systemJars)
|
t.Errorf("inputs of %q must be []string{%q}, but was %#v.", moduleName, systemJar, systemJars)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -75,8 +75,8 @@ type REParams struct {
|
|||||||
// OutputFiles is a list of output file paths or ninja variables as placeholders for rule
|
// OutputFiles is a list of output file paths or ninja variables as placeholders for rule
|
||||||
// outputs.
|
// outputs.
|
||||||
OutputFiles []string
|
OutputFiles []string
|
||||||
// OutputDirectories is a list of output directory paths or ninja variables as placeholders
|
// OutputDirectories is a list of output directories or ninja variables as placeholders for
|
||||||
// for rule outputs.
|
// rule output directories.
|
||||||
OutputDirectories []string
|
OutputDirectories []string
|
||||||
// ToolchainInputs is a list of paths or ninja variables pointing to the location of
|
// ToolchainInputs is a list of paths or ninja variables pointing to the location of
|
||||||
// toolchain binaries used by the rule.
|
// toolchain binaries used by the rule.
|
||||||
@@ -102,7 +102,7 @@ func (r *REParams) Template() string {
|
|||||||
return "${remoteexec.Wrapper}" + r.wrapperArgs()
|
return "${remoteexec.Wrapper}" + r.wrapperArgs()
|
||||||
}
|
}
|
||||||
|
|
||||||
// NoVarTemplate generate the remote execution wrapper template without variables, to be used in
|
// NoVarTemplate generates the remote execution wrapper template without variables, to be used in
|
||||||
// RuleBuilder.
|
// RuleBuilder.
|
||||||
func (r *REParams) NoVarTemplate(cfg android.Config) string {
|
func (r *REParams) NoVarTemplate(cfg android.Config) string {
|
||||||
return wrapper(cfg) + r.wrapperArgs()
|
return wrapper(cfg) + r.wrapperArgs()
|
||||||
|
Reference in New Issue
Block a user