aboutsummaryrefslogtreecommitdiff
path: root/tradefed/autogen.go
diff options
context:
space:
mode:
Diffstat (limited to 'tradefed/autogen.go')
-rw-r--r--tradefed/autogen.go172
1 files changed, 36 insertions, 136 deletions
diff --git a/tradefed/autogen.go b/tradefed/autogen.go
index c2429ab7a..e93bac3ed 100644
--- a/tradefed/autogen.go
+++ b/tradefed/autogen.go
@@ -107,15 +107,10 @@ func (ob Object) Config() string {
}
-func autogenTemplate(ctx android.ModuleContext, output android.WritablePath, template string, configs []Config, testInstallBase string) {
- autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), output, template, configs, "", testInstallBase)
-}
-
-func autogenTemplateWithName(ctx android.ModuleContext, name string, output android.WritablePath, template string, configs []Config, testInstallBase string) {
- autogenTemplateWithNameAndOutputFile(ctx, name, output, template, configs, "", testInstallBase)
-}
-
-func autogenTemplateWithNameAndOutputFile(ctx android.ModuleContext, name string, output android.WritablePath, template string, configs []Config, outputFileName string, testInstallBase string) {
+func autogenTemplate(ctx android.ModuleContext, name string, output android.WritablePath, template string, configs []Config, outputFileName string, testInstallBase string) {
+ if template == "" {
+ ctx.ModuleErrorf("Empty template")
+ }
var configStrings []string
for _, config := range configs {
configStrings = append(configStrings, config.Config())
@@ -137,144 +132,49 @@ func autogenTemplateWithNameAndOutputFile(ctx android.ModuleContext, name string
})
}
-func AutoGenNativeTestConfig(ctx android.ModuleContext, testConfigProp *string,
- testConfigTemplateProp *string, testSuites []string, config []Config, autoGenConfig *bool, testInstallBase string) android.Path {
-
- path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig, testConfigTemplateProp)
+// AutoGenTestConfigOptions is used so that we can supply many optional
+// arguments to the AutoGenTestConfig function.
+type AutoGenTestConfigOptions struct {
+ Name string
+ OutputFileName string
+ TestConfigProp *string
+ TestConfigTemplateProp *string
+ TestSuites []string
+ Config []Config
+ OptionsForAutogenerated []Option
+ AutoGenConfig *bool
+ UnitTest *bool
+ TestInstallBase string
+ DeviceTemplate string
+ HostTemplate string
+ HostUnitTestTemplate string
+}
+
+func AutoGenTestConfig(ctx android.ModuleContext, options AutoGenTestConfigOptions) android.Path {
+ configs := append([]Config{}, options.Config...)
+ for _, c := range options.OptionsForAutogenerated {
+ configs = append(configs, c)
+ }
+ path, autogenPath := testConfigPath(ctx, options.TestConfigProp, options.TestSuites, options.AutoGenConfig, options.TestConfigTemplateProp)
if autogenPath != nil {
- templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
+ templatePath := getTestConfigTemplate(ctx, options.TestConfigTemplateProp)
if templatePath.Valid() {
- autogenTemplate(ctx, autogenPath, templatePath.String(), config, testInstallBase)
+ autogenTemplate(ctx, options.Name, autogenPath, templatePath.String(), configs, options.OutputFileName, options.TestInstallBase)
} else {
if ctx.Device() {
- autogenTemplate(ctx, autogenPath, "${NativeTestConfigTemplate}", config, testInstallBase)
+ autogenTemplate(ctx, options.Name, autogenPath, options.DeviceTemplate, configs, options.OutputFileName, options.TestInstallBase)
} else {
- autogenTemplate(ctx, autogenPath, "${NativeHostTestConfigTemplate}", config, testInstallBase)
- }
- }
- return autogenPath
- }
- return path
-}
-
-func AutoGenShellTestConfig(ctx android.ModuleContext, testConfigProp *string,
- testConfigTemplateProp *string, testSuites []string, config []Config, autoGenConfig *bool, outputFileName string) android.Path {
- path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig, testConfigTemplateProp)
- if autogenPath != nil {
- templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
- if templatePath.Valid() {
- autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), autogenPath, templatePath.String(), config, outputFileName, "")
- } else {
- autogenTemplateWithNameAndOutputFile(ctx, ctx.ModuleName(), autogenPath, "${ShellTestConfigTemplate}", config, outputFileName, "")
- }
- return autogenPath
- }
- return path
-}
-
-func AutoGenNativeBenchmarkTestConfig(ctx android.ModuleContext, testConfigProp *string,
- testConfigTemplateProp *string, testSuites []string, configs []Config, autoGenConfig *bool) android.Path {
- path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig, testConfigTemplateProp)
- if autogenPath != nil {
- templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
- if templatePath.Valid() {
- autogenTemplate(ctx, autogenPath, templatePath.String(), configs, "")
- } else {
- autogenTemplate(ctx, autogenPath, "${NativeBenchmarkTestConfigTemplate}", configs, "")
- }
- return autogenPath
- }
- return path
-}
-
-func AutoGenJavaTestConfig(ctx android.ModuleContext, testConfigProp *string, testConfigTemplateProp *string,
- testSuites []string, config []Config, autoGenConfig *bool, unitTest *bool) android.Path {
- path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig, testConfigTemplateProp)
- if autogenPath != nil {
- templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
- if templatePath.Valid() {
- autogenTemplate(ctx, autogenPath, templatePath.String(), config, "")
- } else {
- if ctx.Device() {
- autogenTemplate(ctx, autogenPath, "${JavaTestConfigTemplate}", config, "")
- } else {
- if Bool(unitTest) {
- autogenTemplate(ctx, autogenPath, "${JavaHostUnitTestConfigTemplate}", config, "")
+ if Bool(options.UnitTest) {
+ autogenTemplate(ctx, options.Name, autogenPath, options.HostUnitTestTemplate, configs, options.OutputFileName, options.TestInstallBase)
} else {
- autogenTemplate(ctx, autogenPath, "${JavaHostTestConfigTemplate}", config, "")
+ autogenTemplate(ctx, options.Name, autogenPath, options.HostTemplate, configs, options.OutputFileName, options.TestInstallBase)
}
}
}
return autogenPath
}
- return path
-}
-
-func AutoGenPythonBinaryHostTestConfig(ctx android.ModuleContext, testConfigProp *string,
- testConfigTemplateProp *string, testSuites []string, autoGenConfig *bool) android.Path {
-
- path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig, testConfigTemplateProp)
- if autogenPath != nil {
- templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
- if templatePath.Valid() {
- autogenTemplate(ctx, autogenPath, templatePath.String(), nil, "")
- } else {
- autogenTemplate(ctx, autogenPath, "${PythonBinaryHostTestConfigTemplate}", nil, "")
- }
- return autogenPath
- }
- return path
-}
-
-func AutoGenRustTestConfig(ctx android.ModuleContext, testConfigProp *string,
- testConfigTemplateProp *string, testSuites []string, config []Config, autoGenConfig *bool, testInstallBase string) android.Path {
- path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig, testConfigTemplateProp)
- if autogenPath != nil {
- templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
- if templatePath.Valid() {
- autogenTemplate(ctx, autogenPath, templatePath.String(), config, testInstallBase)
- } else {
- if ctx.Device() {
- autogenTemplate(ctx, autogenPath, "${RustDeviceTestConfigTemplate}", config, testInstallBase)
- } else {
- autogenTemplate(ctx, autogenPath, "${RustHostTestConfigTemplate}", config, testInstallBase)
- }
- }
- return autogenPath
- }
- return path
-}
-
-func AutoGenRustBenchmarkConfig(ctx android.ModuleContext, testConfigProp *string,
- testConfigTemplateProp *string, testSuites []string, config []Config, autoGenConfig *bool) android.Path {
- path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig, testConfigTemplateProp)
- if autogenPath != nil {
- templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
- if templatePath.Valid() {
- autogenTemplate(ctx, autogenPath, templatePath.String(), config, "")
- } else {
- if ctx.Device() {
- autogenTemplate(ctx, autogenPath, "${RustDeviceBenchmarkConfigTemplate}", config, "")
- } else {
- autogenTemplate(ctx, autogenPath, "${RustHostBenchmarkConfigTemplate}", config, "")
- }
- }
- return autogenPath
- }
- return path
-}
-
-func AutoGenRobolectricTestConfig(ctx android.ModuleContext, testConfigProp *string, testConfigTemplateProp *string,
- testSuites []string, autoGenConfig *bool) android.Path {
- path, autogenPath := testConfigPath(ctx, testConfigProp, testSuites, autoGenConfig, testConfigTemplateProp)
- if autogenPath != nil {
- templatePath := getTestConfigTemplate(ctx, testConfigTemplateProp)
- if templatePath.Valid() {
- autogenTemplate(ctx, autogenPath, templatePath.String(), nil, "")
- } else {
- autogenTemplate(ctx, autogenPath, "${RobolectricTestConfigTemplate}", nil, "")
- }
- return autogenPath
+ if len(options.OptionsForAutogenerated) > 0 {
+ ctx.ModuleErrorf("Extra tradefed configurations were provided for an autogenerated xml file, but the autogenerated xml file was not used.")
}
return path
}