Rewrite sbox to use a textproto manifest
In preparation for more complicated sandboxing that copies tools and/or inputs into the sandbox directory, make sbox use a textproto input that describes the commands to be run and the files to copy in or out of the sandbox. Bug: 124313442 Test: m checkbuild Test: rule_builder_test.go Test: genrule_test.go Change-Id: I3b918a6643cea77199fd39577ef71e34cdeacdb1
This commit is contained in:
@@ -417,18 +417,23 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
}
|
||||
g.rawCommands = append(g.rawCommands, rawCommand)
|
||||
|
||||
// Pick a unique rule name and the user-visible description.
|
||||
// Pick a unique path outside the task.genDir for the sbox manifest textproto,
|
||||
// a unique rule name, and the user-visible description.
|
||||
manifestName := g.subDir + "genrule.sbox.textproto"
|
||||
desc := "generate"
|
||||
name := "generator"
|
||||
if task.shards > 0 {
|
||||
manifestName = g.subDir + "genrule_" + strconv.Itoa(task.shard) + ".sbox.textproto"
|
||||
desc += " " + strconv.Itoa(task.shard)
|
||||
name += strconv.Itoa(task.shard)
|
||||
} else if len(task.out) == 1 {
|
||||
desc += " " + task.out[0].Base()
|
||||
}
|
||||
|
||||
manifestPath := android.PathForModuleOut(ctx, manifestName)
|
||||
|
||||
// Use a RuleBuilder to create a rule that runs the command inside an sbox sandbox.
|
||||
rule := android.NewRuleBuilder().Sbox(task.genDir)
|
||||
rule := android.NewRuleBuilder().Sbox(task.genDir, manifestPath)
|
||||
cmd := rule.Command()
|
||||
cmd.Text(rawCommand)
|
||||
cmd.ImplicitOutputs(task.out)
|
||||
|
Reference in New Issue
Block a user