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) { |
Colin Cross | 5a37718 | 2023-12-14 14:46:23 -0800 | [diff] [blame] | 24 | if metadata, ok := android.SingletonModuleProvider(ctx, module, CodeMetadataProviderKey); ok { |
| 25 | intermediateMetadataPaths = append(intermediateMetadataPaths, metadata.IntermediatePath) |
Aditya Choudhary | 8094b6b | 2023-10-12 19:40:17 +0000 | [diff] [blame] | 26 | } |
Aditya Choudhary | 8094b6b | 2023-10-12 19:40:17 +0000 | [diff] [blame] | 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 | |
| 44 | func (this *allCodeMetadataSingleton) MakeVars(ctx android.MakeVarsContext) { |
| 45 | ctx.DistForGoal("code_metadata", this.outputPath) |
| 46 | } |