add additional fields to cc_fuzz build types

Specifically, this adds:
* Owner
* Disable (stop fuzzer from running in Haiku)
* Bug Component
* Bug Hotlist

The fields are all inside a new 'options' struct.

The values from these fields (if any) are written into a config file as
json.

Bug: 142551000
Test: ran locally with a modified build file and verified output in .zip
Change-Id: I86edf74c2cebe9912ac0ad203f99028be4062c8b
This commit is contained in:
Kris Alder
2019-10-22 10:52:01 -07:00
parent ce6b216c5e
commit f979ee3873
2 changed files with 49 additions and 0 deletions

View File

@@ -15,6 +15,7 @@
package cc
import (
"encoding/json"
"path/filepath"
"strings"
@@ -24,12 +25,35 @@ import (
"android/soong/cc/config"
)
type FuzzConfig struct {
// Email address of people to CC on bugs or contact about this fuzz target.
Cc []string `json:"cc,omitempty"`
// Boolean specifying whether to disable the fuzz target from running
// automatically in continuous fuzzing infrastructure.
Disable *bool `json:"disable,omitempty"`
// Component in Google's bug tracking system that bugs should be filed to.
Componentid *int64 `json:"componentid,omitempty"`
// Hotlists in Google's bug tracking system that bugs should be marked with.
Hotlists []string `json:"hotlists,omitempty"`
}
func (f *FuzzConfig) String() string {
b, err := json.Marshal(f)
if err != nil {
panic(err)
}
return string(b)
}
type FuzzProperties struct {
// Optional list of seed files to be installed to the fuzz target's output
// directory.
Corpus []string `android:"path"`
// Optional dictionary to be installed to the fuzz target's output directory.
Dictionary *string `android:"path"`
// Config for running the target on fuzzing infrastructure.
Fuzz_config *FuzzConfig
}
func init() {
@@ -57,6 +81,7 @@ type fuzzBinary struct {
dictionary android.Path
corpus android.Paths
corpusIntermediateDir android.Path
config android.Path
}
func (fuzz *fuzzBinary) linkerProps() []interface{} {
@@ -122,6 +147,19 @@ func (fuzz *fuzzBinary) install(ctx ModuleContext, file android.Path) {
fuzz.dictionary.String())
}
}
if fuzz.Properties.Fuzz_config != nil {
configPath := android.PathForModuleOut(ctx, "config").Join(ctx, "config.txt")
ctx.Build(pctx, android.BuildParams{
Rule: android.WriteFile,
Description: "fuzzer infrastructure configuration",
Output: configPath,
Args: map[string]string{
"content": fuzz.Properties.Fuzz_config.String(),
},
})
fuzz.config = configPath
}
}
func NewFuzz(hod android.HostOrDeviceSupported) *Module {
@@ -234,6 +272,12 @@ func (s *fuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
archDirs[archDir] = append(archDirs[archDir],
fileToZip{fuzzModule.dictionary, ccModule.Name()})
}
// Additional fuzz config.
if fuzzModule.config != nil {
archDirs[archDir] = append(archDirs[archDir],
fileToZip{fuzzModule.config, ccModule.Name()})
}
})
for archDir, filesToZip := range archDirs {