Move common test_options properties into the android package
Multiple modules (e.g. java, cc, python, rust) define the `test_options`
field. Extract the common properties in test_options to share across
different test rules.
Bug: 240928948
Test: `refreshmod` and diff with original module-info.json
Change-Id: I404a7a157b4ccaa53d800ee2217559ff695bd825
diff --git a/android/module.go b/android/module.go
index 450dba9..a75a3cc 100644
--- a/android/module.go
+++ b/android/module.go
@@ -936,6 +936,20 @@
Dists []Dist `android:"arch_variant"`
}
+// CommonTestOptions represents the common `test_options` properties in
+// Android.bp.
+type CommonTestOptions struct {
+ // If the test is a hostside (no device required) unittest that shall be run
+ // during presubmit check.
+ Unit_test *bool
+}
+
+// SetAndroidMkEntries sets AndroidMkEntries according to the value of base
+// `test_options`.
+func (t *CommonTestOptions) SetAndroidMkEntries(entries *AndroidMkEntries) {
+ entries.SetBoolIfTrue("LOCAL_IS_UNIT_TEST", Bool(t.Unit_test))
+}
+
// The key to use in TaggedDistFiles when a Dist structure does not specify a
// tag property. This intentionally does not use "" as the default because that
// would mean that an empty tag would have a different meaning when used in a dist
@@ -1095,7 +1109,7 @@
// property structs for architecture-specific versions of generic properties tagged with
// `android:"arch_variant"`.
//
-// InitAndroidModule should not be called if InitAndroidArchModule was called.
+// InitAndroidModule should not be called if InitAndroidArchModule was called.
func InitAndroidArchModule(m Module, hod HostOrDeviceSupported, defaultMultilib Multilib) {
InitAndroidModule(m)
@@ -1336,30 +1350,30 @@
//
// For example:
//
-// import (
-// "android/soong/android"
-// )
+// import (
+// "android/soong/android"
+// )
//
-// type myModule struct {
-// android.ModuleBase
-// properties struct {
-// MyProperty string
-// }
-// }
+// type myModule struct {
+// android.ModuleBase
+// properties struct {
+// MyProperty string
+// }
+// }
//
-// func NewMyModule() android.Module {
-// m := &myModule{}
-// m.AddProperties(&m.properties)
-// android.InitAndroidModule(m)
-// return m
-// }
+// func NewMyModule() android.Module {
+// m := &myModule{}
+// m.AddProperties(&m.properties)
+// android.InitAndroidModule(m)
+// return m
+// }
//
-// func (m *myModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
-// // Get the CPU architecture for the current build variant.
-// variantArch := ctx.Arch()
+// func (m *myModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+// // Get the CPU architecture for the current build variant.
+// variantArch := ctx.Arch()
//
-// // ...
-// }
+// // ...
+// }
type ModuleBase struct {
// Putting the curiously recurring thing pointing to the thing that contains
// the thing pattern to good use.