blob: b035435db2782f6922d9699fb7bb647f7f36101b [file] [log] [blame]
Aditya Choudhary2368e9e2023-11-09 20:07:52 +00001package testing
2
3import (
4 "android/soong/android"
5)
6
7const ownershipDirectory = "ownership"
8const fileContainingFilePaths = "all_test_spec_paths.rsp"
9const allTestSpecsFile = "all_test_specs.pb"
10
11func AllTestSpecsFactory() android.Singleton {
12 return &allTestSpecsSingleton{}
13}
14
15type allTestSpecsSingleton struct {
16 // Path where the collected metadata is stored after successful validation.
17 outputPath android.OutputPath
18}
19
20func (this *allTestSpecsSingleton) GenerateBuildActions(ctx android.SingletonContext) {
21 var intermediateMetadataPaths android.Paths
22
23 ctx.VisitAllModules(func(module android.Module) {
Colin Cross5a377182023-12-14 14:46:23 -080024 if metadata, ok := android.SingletonModuleProvider(ctx, module, TestSpecProviderKey); ok {
25 intermediateMetadataPaths = append(intermediateMetadataPaths, metadata.IntermediatePath)
Aditya Choudhary2368e9e2023-11-09 20:07:52 +000026 }
Aditya Choudhary2368e9e2023-11-09 20:07:52 +000027 })
28
29 rspFile := android.PathForOutput(ctx, fileContainingFilePaths)
30 this.outputPath = android.PathForOutput(ctx, ownershipDirectory, allTestSpecsFile)
31
32 rule := android.NewRuleBuilder(pctx, ctx)
33 cmd := rule.Command().
34 BuiltTool("metadata").
35 FlagWithArg("-rule ", "test_spec").
36 FlagWithRspFileInputList("-inputFile ", rspFile, intermediateMetadataPaths)
37 cmd.FlagWithOutput("-outputFile ", this.outputPath)
38 rule.Build("all_test_specs_rule", "Generate all test specifications")
39 ctx.Phony("all_test_specs", this.outputPath)
40}
41
42func (this *allTestSpecsSingleton) MakeVars(ctx android.MakeVarsContext) {
43 ctx.DistForGoal("test_specs", this.outputPath)
44}