Remove support for unsandboxed metalava
Everything is running in the sandbox, remove the unsandboxed support. Bug: 153703940 Test: m checkbuild Change-Id: I811b8a0ad37143518c120367dd20b2b6aa011570
This commit is contained in:
parent
d47f4ac828
commit
8095c29597
3 changed files with 21 additions and 84 deletions
|
@ -98,10 +98,6 @@ type JavadocProperties struct {
|
|||
|
||||
// names of the output files used in args that will be generated
|
||||
Out []string
|
||||
|
||||
// If set, metalava is sandboxed to only read files explicitly specified on the command
|
||||
// line. Defaults to false.
|
||||
Sandbox *bool
|
||||
}
|
||||
|
||||
type ApiToCheck struct {
|
||||
|
|
|
@ -383,7 +383,7 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a
|
|||
|
||||
func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersion javaVersion, srcs android.Paths,
|
||||
srcJarList android.Path, bootclasspath, classpath classpath, sourcepaths android.Paths,
|
||||
implicitsRsp, homeDir android.WritablePath, sandbox bool) *android.RuleBuilderCommand {
|
||||
homeDir android.WritablePath) *android.RuleBuilderCommand {
|
||||
rule.Command().Text("rm -rf").Flag(homeDir.String())
|
||||
rule.Command().Text("mkdir -p").Flag(homeDir.String())
|
||||
|
||||
|
@ -392,39 +392,16 @@ func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersi
|
|||
|
||||
if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_METALAVA") {
|
||||
rule.Remoteable(android.RemoteRuleSupports{RBE: true})
|
||||
if sandbox {
|
||||
execStrategy := ctx.Config().GetenvWithDefault("RBE_METALAVA_EXEC_STRATEGY", remoteexec.LocalExecStrategy)
|
||||
labels := map[string]string{"type": "tool", "name": "metalava"}
|
||||
// TODO: metalava pool rejects these jobs
|
||||
pool := ctx.Config().GetenvWithDefault("RBE_METALAVA_POOL", "java16")
|
||||
rule.Rewrapper(&remoteexec.REParams{
|
||||
Labels: labels,
|
||||
ExecStrategy: execStrategy,
|
||||
ToolchainInputs: []string{config.JavaCmd(ctx).String()},
|
||||
Platform: map[string]string{remoteexec.PoolKey: pool},
|
||||
})
|
||||
} else {
|
||||
execStrategy := remoteexec.LocalExecStrategy
|
||||
labels := map[string]string{"type": "compile", "lang": "java", "compiler": "metalava", "shallow": "true"}
|
||||
pool := ctx.Config().GetenvWithDefault("RBE_METALAVA_POOL", "metalava")
|
||||
|
||||
inputs := []string{
|
||||
ctx.Config().HostJavaToolPath(ctx, "metalava").String(),
|
||||
homeDir.String(),
|
||||
}
|
||||
if v := ctx.Config().Getenv("RBE_METALAVA_INPUTS"); v != "" {
|
||||
inputs = append(inputs, strings.Split(v, ",")...)
|
||||
}
|
||||
cmd.Text((&remoteexec.REParams{
|
||||
Labels: labels,
|
||||
ExecStrategy: execStrategy,
|
||||
Inputs: inputs,
|
||||
RSPFiles: []string{implicitsRsp.String()},
|
||||
ToolchainInputs: []string{config.JavaCmd(ctx).String()},
|
||||
Platform: map[string]string{remoteexec.PoolKey: pool},
|
||||
EnvironmentVariables: []string{"ANDROID_PREFS_ROOT"},
|
||||
}).NoVarTemplate(ctx.Config().RBEWrapper()))
|
||||
}
|
||||
execStrategy := ctx.Config().GetenvWithDefault("RBE_METALAVA_EXEC_STRATEGY", remoteexec.LocalExecStrategy)
|
||||
labels := map[string]string{"type": "tool", "name": "metalava"}
|
||||
// TODO: metalava pool rejects these jobs
|
||||
pool := ctx.Config().GetenvWithDefault("RBE_METALAVA_POOL", "java16")
|
||||
rule.Rewrapper(&remoteexec.REParams{
|
||||
Labels: labels,
|
||||
ExecStrategy: execStrategy,
|
||||
ToolchainInputs: []string{config.JavaCmd(ctx).String()},
|
||||
Platform: map[string]string{remoteexec.PoolKey: pool},
|
||||
})
|
||||
}
|
||||
|
||||
cmd.BuiltTool("metalava").ImplicitTool(ctx.Config().HostJavaToolPath(ctx, "metalava.jar")).
|
||||
|
@ -435,18 +412,6 @@ func metalavaCmd(ctx android.ModuleContext, rule *android.RuleBuilder, javaVersi
|
|||
FlagWithRspFileInputList("@", android.PathForModuleOut(ctx, "metalava.rsp"), srcs).
|
||||
FlagWithInput("@", srcJarList)
|
||||
|
||||
if !sandbox {
|
||||
if javaHome := ctx.Config().Getenv("ANDROID_JAVA_HOME"); javaHome != "" {
|
||||
cmd.Implicit(android.PathForSource(ctx, javaHome))
|
||||
}
|
||||
|
||||
cmd.FlagWithOutput("--strict-input-files:warn ", android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"violations.txt"))
|
||||
|
||||
if implicitsRsp != nil {
|
||||
cmd.FlagWithArg("--strict-input-files-exempt ", "@"+implicitsRsp.String())
|
||||
}
|
||||
}
|
||||
|
||||
if len(bootclasspath) > 0 {
|
||||
cmd.FlagWithInputList("-bootclasspath ", bootclasspath.Paths(), ":")
|
||||
}
|
||||
|
@ -482,12 +447,9 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
|
||||
rule := android.NewRuleBuilder(pctx, ctx)
|
||||
|
||||
sandbox := proptools.BoolDefault(d.Javadoc.properties.Sandbox, true)
|
||||
if sandbox {
|
||||
rule.Sbox(android.PathForModuleOut(ctx, "metalava"),
|
||||
android.PathForModuleOut(ctx, "metalava.sbox.textproto")).
|
||||
SandboxInputs()
|
||||
}
|
||||
rule.Sbox(android.PathForModuleOut(ctx, "metalava"),
|
||||
android.PathForModuleOut(ctx, "metalava.sbox.textproto")).
|
||||
SandboxInputs()
|
||||
|
||||
if BoolDefault(d.properties.High_mem, false) {
|
||||
// This metalava run uses lots of memory, restrict the number of metalava jobs that can run in parallel.
|
||||
|
@ -505,11 +467,9 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
|
||||
srcJarList := zipSyncCmd(ctx, rule, srcJarDir, d.Javadoc.srcJars)
|
||||
|
||||
implicitsRsp := android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"implicits.rsp")
|
||||
homeDir := android.PathForModuleOut(ctx, "metalava", "home")
|
||||
cmd := metalavaCmd(ctx, rule, javaVersion, d.Javadoc.srcFiles, srcJarList,
|
||||
deps.bootClasspath, deps.classpath, d.Javadoc.sourcepaths, implicitsRsp, homeDir,
|
||||
sandbox)
|
||||
deps.bootClasspath, deps.classpath, d.Javadoc.sourcepaths, homeDir)
|
||||
cmd.Implicits(d.Javadoc.implicits)
|
||||
|
||||
d.stubsFlags(ctx, cmd, stubsDir)
|
||||
|
@ -628,22 +588,6 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
cmd.FlagWithArg("--error-message:compatibility:released ", msg)
|
||||
}
|
||||
|
||||
if !sandbox {
|
||||
// When sandboxing is enabled RuleBuilder tracks all the inputs needed for remote execution.
|
||||
// Without it we have to do it manually.
|
||||
impRule := android.NewRuleBuilder(pctx, ctx)
|
||||
impCmd := impRule.Command()
|
||||
// An 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("", android.PathForModuleOut(ctx, "metalava-implicits.rsp"), cmd.GetImplicits()).
|
||||
Output(implicitsRsp)
|
||||
impRule.Build("implicitsGen", "implicits generation")
|
||||
cmd.Implicit(implicitsRsp)
|
||||
}
|
||||
|
||||
if generateStubs {
|
||||
rule.Command().
|
||||
BuiltTool("soong_zip").
|
||||
|
@ -675,9 +619,7 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
}
|
||||
|
||||
// TODO(b/183630617): rewrapper doesn't support restat rules
|
||||
if !sandbox {
|
||||
rule.Restat()
|
||||
}
|
||||
// rule.Restat()
|
||||
|
||||
zipSyncCleanupCmd(rule, srcJarDir)
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ func TestDroidstubs(t *testing.T) {
|
|||
srcs: ["bar-doc/a.java"],
|
||||
api_levels_annotations_dirs: ["droiddoc-templates-sdk"],
|
||||
api_levels_annotations_enabled: true,
|
||||
sandbox: false,
|
||||
}
|
||||
|
||||
droidstubs {
|
||||
|
@ -44,7 +43,6 @@ func TestDroidstubs(t *testing.T) {
|
|||
api_levels_annotations_dirs: ["droiddoc-templates-sdk"],
|
||||
api_levels_annotations_enabled: true,
|
||||
api_levels_jar_filename: "android.other.jar",
|
||||
sandbox: false,
|
||||
}
|
||||
`,
|
||||
map[string][]byte{
|
||||
|
@ -68,13 +66,15 @@ func TestDroidstubs(t *testing.T) {
|
|||
}
|
||||
for _, c := range testcases {
|
||||
m := ctx.ModuleForTests(c.moduleName, "android_common")
|
||||
metalava := m.Rule("metalava")
|
||||
rp := metalava.RuleParams
|
||||
manifest := m.Output("metalava.sbox.textproto")
|
||||
sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest)
|
||||
expected := "--android-jar-pattern ./%/public/" + c.expectedJarFilename
|
||||
if actual := rp.Command; !strings.Contains(actual, expected) {
|
||||
if actual := String(sboxProto.Commands[0].Command); !strings.Contains(actual, expected) {
|
||||
t.Errorf("For %q, expected metalava argument %q, but was not found %q", c.moduleName, expected, actual)
|
||||
}
|
||||
|
||||
metalava := m.Rule("metalava")
|
||||
rp := metalava.RuleParams
|
||||
if actual := rp.Pool != nil && strings.Contains(rp.Pool.String(), "highmem"); actual != c.high_mem {
|
||||
t.Errorf("Expected %q high_mem to be %v, was %v", c.moduleName, c.high_mem, actual)
|
||||
}
|
||||
|
@ -92,7 +92,6 @@ func TestDroidstubsSandbox(t *testing.T) {
|
|||
droidstubs {
|
||||
name: "bar-stubs",
|
||||
srcs: ["bar-doc/a.java"],
|
||||
sandbox: true,
|
||||
|
||||
args: "--reference $(location :foo)",
|
||||
arg_files: [":foo"],
|
||||
|
|
Loading…
Reference in a new issue