Create one rule per one corpus/data files

To avoid MAX_ARG_STRLEN hardlimit.

Test: build and check intermediate directory
Change-Id: I44db1ed14cae4de6ace5b25a392d394d0f9f617a
This commit is contained in:
Inseob Kim 2023-07-11 13:31:36 +09:00
parent 921a465919
commit 3b24406dda
4 changed files with 16 additions and 11 deletions

View file

@ -42,6 +42,7 @@ import (
func init() {
RegisterCCBuildComponents(android.InitRegistrationContext)
pctx.Import("android/soong/android")
pctx.Import("android/soong/cc/config")
}

View file

@ -258,25 +258,29 @@ func (fuzzBin *fuzzBinary) install(ctx ModuleContext, file android.Path) {
func PackageFuzzModule(ctx android.ModuleContext, fuzzPackagedModule fuzz.FuzzPackagedModule, pctx android.PackageContext) fuzz.FuzzPackagedModule {
fuzzPackagedModule.Corpus = android.PathsForModuleSrc(ctx, fuzzPackagedModule.FuzzProperties.Corpus)
builder := android.NewRuleBuilder(pctx, ctx)
intermediateDir := android.PathForModuleOut(ctx, "corpus")
// Create one rule per file to avoid MAX_ARG_STRLEN hardlimit.
for _, entry := range fuzzPackagedModule.Corpus {
builder.Command().Text("cp").
Input(entry).
Output(intermediateDir.Join(ctx, entry.Base()))
ctx.Build(pctx, android.BuildParams{
Rule: android.Cp,
Output: intermediateDir.Join(ctx, entry.Base()),
Input: entry,
})
}
builder.Build("copy_corpus", "copy corpus")
fuzzPackagedModule.CorpusIntermediateDir = intermediateDir
fuzzPackagedModule.Data = android.PathsForModuleSrc(ctx, fuzzPackagedModule.FuzzProperties.Data)
builder = android.NewRuleBuilder(pctx, ctx)
intermediateDir = android.PathForModuleOut(ctx, "data")
// Create one rule per file to avoid MAX_ARG_STRLEN hardlimit.
for _, entry := range fuzzPackagedModule.Data {
builder.Command().Text("cp").
Input(entry).
Output(intermediateDir.Join(ctx, entry.Rel()))
ctx.Build(pctx, android.BuildParams{
Rule: android.Cp,
Output: intermediateDir.Join(ctx, entry.Rel()),
Input: entry,
})
}
builder.Build("copy_data", "copy data")
fuzzPackagedModule.DataIntermediateDir = intermediateDir
if fuzzPackagedModule.FuzzProperties.Dictionary != nil {

View file

@ -58,7 +58,6 @@ import (
func init() {
RegisterNdkModuleTypes(android.InitRegistrationContext)
pctx.Import("android/soong/android")
}
func RegisterNdkModuleTypes(ctx android.RegistrationContext) {

View file

@ -43,6 +43,7 @@ func init() {
android.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("rust_sanitizers", rustSanitizerRuntimeMutator).Parallel()
})
pctx.Import("android/soong/android")
pctx.Import("android/soong/rust/config")
pctx.ImportAs("cc_config", "android/soong/cc/config")
android.InitRegistrationContext.RegisterParallelSingletonType("kythe_rust_extract", kytheExtractRustFactory)