Add defaults for sh_ rules.
I was helping someone who wanted to use the same set of dependencies in
multiple sh_test rules and we realized that there are no defaults on
sh_test, sh_binary, etc. (see vts_ltp_test*)
Bug: 277261121 # Related to this bug
Change-Id: I81084771432e22e3de230511bdaba1b79a171406
Test: go test ./
diff --git a/sh/sh_binary.go b/sh/sh_binary.go
index 9c0db73..853f3d3 100644
--- a/sh/sh_binary.go
+++ b/sh/sh_binary.go
@@ -45,6 +45,7 @@
ctx.RegisterModuleType("sh_binary_host", ShBinaryHostFactory)
ctx.RegisterModuleType("sh_test", ShTestFactory)
ctx.RegisterModuleType("sh_test_host", ShTestHostFactory)
+ ctx.RegisterModuleType("sh_defaults", ShDefaultsFactory)
}
// Test fixture preparer that will register most sh build components.
@@ -167,6 +168,7 @@
type ShBinary struct {
android.ModuleBase
+ android.DefaultableModuleBase
properties shBinaryProperties
@@ -548,6 +550,7 @@
module := &ShBinary{}
initShBinaryModule(module)
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibFirst)
+ android.InitDefaultableModule(module)
return module
}
@@ -557,6 +560,7 @@
module := &ShBinary{}
initShBinaryModule(module)
android.InitAndroidArchModule(module, android.HostSupported, android.MultilibFirst)
+ android.InitDefaultableModule(module)
return module
}
@@ -567,6 +571,7 @@
module.AddProperties(&module.testProperties)
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibFirst)
+ android.InitDefaultableModule(module)
return module
}
@@ -581,6 +586,21 @@
}
android.InitAndroidArchModule(module, android.HostSupported, android.MultilibFirst)
+ android.InitDefaultableModule(module)
+ return module
+}
+
+type ShDefaults struct {
+ android.ModuleBase
+ android.DefaultsModuleBase
+}
+
+func ShDefaultsFactory() android.Module {
+ module := &ShDefaults{}
+
+ module.AddProperties(&shBinaryProperties{}, &TestProperties{})
+ android.InitDefaultsModule(module)
+
return module
}