1package testing 2 3import ( 4 "android/soong/android" 5) 6 7const fileContainingCodeMetadataFilePaths = "all_code_metadata_paths.rsp" 8const allCodeMetadataFile = "all_code_metadata.pb" 9 10func AllCodeMetadataFactory() android.Singleton { 11 return &allCodeMetadataSingleton{} 12} 13 14type allCodeMetadataSingleton struct { 15 // Path where the collected metadata is stored after successful validation. 16 outputPath android.OutputPath 17} 18 19func (this *allCodeMetadataSingleton) GenerateBuildActions(ctx android.SingletonContext) { 20 var intermediateMetadataPaths android.Paths 21 22 ctx.VisitAllModules( 23 func(module android.Module) { 24 if metadata, ok := android.SingletonModuleProvider(ctx, module, CodeMetadataProviderKey); ok { 25 intermediateMetadataPaths = append(intermediateMetadataPaths, metadata.IntermediatePath) 26 } 27 }, 28 ) 29 30 rspFile := android.PathForOutput(ctx, fileContainingCodeMetadataFilePaths) 31 this.outputPath = android.PathForOutput(ctx, ownershipDirectory, allCodeMetadataFile) 32 33 rule := android.NewRuleBuilder(pctx, ctx) 34 cmd := rule.Command(). 35 BuiltTool("metadata"). 36 FlagWithArg("-rule ", "code_metadata"). 37 FlagWithRspFileInputList("-inputFile ", rspFile, intermediateMetadataPaths) 38 cmd.FlagWithOutput("-outputFile ", this.outputPath) 39 rule.Build("all_code_metadata_rule", "Generate all code metadata") 40 41 ctx.Phony("all_code_metadata", this.outputPath) 42} 43 44func (this *allCodeMetadataSingleton) MakeVars(ctx android.MakeVarsContext) { 45 ctx.DistForGoal("code_metadata", this.outputPath) 46} 47