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