Pass pctx and ctx to NewRuleBuilder
Enable the RuleBuilder and RuleBuilderCommand methods to access the BuilderContext by passing it to NewRuleBuilder instead of RuleBuilder.Build. Test: genrule_test.go Test: rule_builder_test.go Test: m checkbuild Change-Id: I63e6597e19167393876dc2259d6f521363b7dabc
This commit is contained in:
24
cc/fuzz.go
24
cc/fuzz.go
@@ -246,25 +246,25 @@ func (fuzz *fuzzBinary) install(ctx ModuleContext, file android.Path) {
|
||||
fuzz.binaryDecorator.baseInstaller.install(ctx, file)
|
||||
|
||||
fuzz.corpus = android.PathsForModuleSrc(ctx, fuzz.Properties.Corpus)
|
||||
builder := android.NewRuleBuilder()
|
||||
builder := android.NewRuleBuilder(pctx, ctx)
|
||||
intermediateDir := android.PathForModuleOut(ctx, "corpus")
|
||||
for _, entry := range fuzz.corpus {
|
||||
builder.Command().Text("cp").
|
||||
Input(entry).
|
||||
Output(intermediateDir.Join(ctx, entry.Base()))
|
||||
}
|
||||
builder.Build(pctx, ctx, "copy_corpus", "copy corpus")
|
||||
builder.Build("copy_corpus", "copy corpus")
|
||||
fuzz.corpusIntermediateDir = intermediateDir
|
||||
|
||||
fuzz.data = android.PathsForModuleSrc(ctx, fuzz.Properties.Data)
|
||||
builder = android.NewRuleBuilder()
|
||||
builder = android.NewRuleBuilder(pctx, ctx)
|
||||
intermediateDir = android.PathForModuleOut(ctx, "data")
|
||||
for _, entry := range fuzz.data {
|
||||
builder.Command().Text("cp").
|
||||
Input(entry).
|
||||
Output(intermediateDir.Join(ctx, entry.Rel()))
|
||||
}
|
||||
builder.Build(pctx, ctx, "copy_data", "copy data")
|
||||
builder.Build("copy_data", "copy data")
|
||||
fuzz.dataIntermediateDir = intermediateDir
|
||||
|
||||
if fuzz.Properties.Dictionary != nil {
|
||||
@@ -419,12 +419,12 @@ func (s *fuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
|
||||
sharedLibraries := collectAllSharedDependencies(ctx, module)
|
||||
|
||||
var files []fileToZip
|
||||
builder := android.NewRuleBuilder()
|
||||
builder := android.NewRuleBuilder(pctx, ctx)
|
||||
|
||||
// Package the corpora into a zipfile.
|
||||
if fuzzModule.corpus != nil {
|
||||
corpusZip := archDir.Join(ctx, module.Name()+"_seed_corpus.zip")
|
||||
command := builder.Command().BuiltTool(ctx, "soong_zip").
|
||||
command := builder.Command().BuiltTool("soong_zip").
|
||||
Flag("-j").
|
||||
FlagWithOutput("-o ", corpusZip)
|
||||
command.FlagWithRspFileInputList("-r ", fuzzModule.corpus)
|
||||
@@ -434,7 +434,7 @@ func (s *fuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
|
||||
// Package the data into a zipfile.
|
||||
if fuzzModule.data != nil {
|
||||
dataZip := archDir.Join(ctx, module.Name()+"_data.zip")
|
||||
command := builder.Command().BuiltTool(ctx, "soong_zip").
|
||||
command := builder.Command().BuiltTool("soong_zip").
|
||||
FlagWithOutput("-o ", dataZip)
|
||||
for _, f := range fuzzModule.data {
|
||||
intermediateDir := strings.TrimSuffix(f.String(), f.Rel())
|
||||
@@ -492,7 +492,7 @@ func (s *fuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
|
||||
}
|
||||
|
||||
fuzzZip := archDir.Join(ctx, module.Name()+".zip")
|
||||
command := builder.Command().BuiltTool(ctx, "soong_zip").
|
||||
command := builder.Command().BuiltTool("soong_zip").
|
||||
Flag("-j").
|
||||
FlagWithOutput("-o ", fuzzZip)
|
||||
for _, file := range files {
|
||||
@@ -504,7 +504,7 @@ func (s *fuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
|
||||
command.FlagWithInput("-f ", file.SourceFilePath)
|
||||
}
|
||||
|
||||
builder.Build(pctx, ctx, "create-"+fuzzZip.String(),
|
||||
builder.Build("create-"+fuzzZip.String(),
|
||||
"Package "+module.Name()+" for "+archString+"-"+hostOrTargetString)
|
||||
|
||||
// Don't add modules to 'make haiku' that are set to not be exported to the
|
||||
@@ -531,11 +531,11 @@ func (s *fuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
|
||||
filesToZip := archDirs[archOs]
|
||||
arch := archOs.arch
|
||||
hostOrTarget := archOs.hostOrTarget
|
||||
builder := android.NewRuleBuilder()
|
||||
builder := android.NewRuleBuilder(pctx, ctx)
|
||||
outputFile := android.PathForOutput(ctx, "fuzz-"+hostOrTarget+"-"+arch+".zip")
|
||||
s.packages = append(s.packages, outputFile)
|
||||
|
||||
command := builder.Command().BuiltTool(ctx, "soong_zip").
|
||||
command := builder.Command().BuiltTool("soong_zip").
|
||||
Flag("-j").
|
||||
FlagWithOutput("-o ", outputFile).
|
||||
Flag("-L 0") // No need to try and re-compress the zipfiles.
|
||||
@@ -549,7 +549,7 @@ func (s *fuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
|
||||
command.FlagWithInput("-f ", fileToZip.SourceFilePath)
|
||||
}
|
||||
|
||||
builder.Build(pctx, ctx, "create-fuzz-package-"+arch+"-"+hostOrTarget,
|
||||
builder.Build("create-fuzz-package-"+arch+"-"+hostOrTarget,
|
||||
"Create fuzz target packages for "+arch+"-"+hostOrTarget)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user