Merge "test_for is available for all cc_* module types" am: 2920d2cec0
am: 2b33ad60aa
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1517638 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: Icb7b66c56d49f6d6731416e9a1ae45e1f5b73d19
This commit is contained in:
commit
d21fb571b8
|
@ -5971,9 +5971,27 @@ func TestTestFor(t *testing.T) {
|
||||||
srcs: ["mylib.cpp"],
|
srcs: ["mylib.cpp"],
|
||||||
system_shared_libs: [],
|
system_shared_libs: [],
|
||||||
stl: "none",
|
stl: "none",
|
||||||
shared_libs: ["mylib", "myprivlib"],
|
shared_libs: ["mylib", "myprivlib", "mytestlib"],
|
||||||
test_for: ["myapex"]
|
test_for: ["myapex"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "mytestlib",
|
||||||
|
srcs: ["mylib.cpp"],
|
||||||
|
system_shared_libs: [],
|
||||||
|
shared_libs: ["mylib", "myprivlib"],
|
||||||
|
stl: "none",
|
||||||
|
test_for: ["myapex"],
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_benchmark {
|
||||||
|
name: "mybench",
|
||||||
|
srcs: ["mylib.cpp"],
|
||||||
|
system_shared_libs: [],
|
||||||
|
shared_libs: ["mylib", "myprivlib"],
|
||||||
|
stl: "none",
|
||||||
|
test_for: ["myapex"],
|
||||||
|
}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
// the test 'mytest' is a test for the apex, therefore is linked to the
|
// the test 'mytest' is a test for the apex, therefore is linked to the
|
||||||
|
@ -5981,6 +5999,16 @@ func TestTestFor(t *testing.T) {
|
||||||
ldFlags := ctx.ModuleForTests("mytest", "android_arm64_armv8-a").Rule("ld").Args["libFlags"]
|
ldFlags := ctx.ModuleForTests("mytest", "android_arm64_armv8-a").Rule("ld").Args["libFlags"]
|
||||||
ensureContains(t, ldFlags, "mylib/android_arm64_armv8-a_shared/mylib.so")
|
ensureContains(t, ldFlags, "mylib/android_arm64_armv8-a_shared/mylib.so")
|
||||||
ensureNotContains(t, ldFlags, "mylib/android_arm64_armv8-a_shared_1/mylib.so")
|
ensureNotContains(t, ldFlags, "mylib/android_arm64_armv8-a_shared_1/mylib.so")
|
||||||
|
|
||||||
|
// The same should be true for cc_library
|
||||||
|
ldFlags = ctx.ModuleForTests("mytestlib", "android_arm64_armv8-a_shared").Rule("ld").Args["libFlags"]
|
||||||
|
ensureContains(t, ldFlags, "mylib/android_arm64_armv8-a_shared/mylib.so")
|
||||||
|
ensureNotContains(t, ldFlags, "mylib/android_arm64_armv8-a_shared_1/mylib.so")
|
||||||
|
|
||||||
|
// ... and for cc_benchmark
|
||||||
|
ldFlags = ctx.ModuleForTests("mybench", "android_arm64_armv8-a").Rule("ld").Args["libFlags"]
|
||||||
|
ensureContains(t, ldFlags, "mylib/android_arm64_armv8-a_shared/mylib.so")
|
||||||
|
ensureNotContains(t, ldFlags, "mylib/android_arm64_armv8-a_shared_1/mylib.so")
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(jungjw): Move this to proptools
|
// TODO(jungjw): Move this to proptools
|
||||||
|
|
13
cc/cc.go
13
cc/cc.go
|
@ -332,6 +332,11 @@ type BaseProperties struct {
|
||||||
// framework module from a snapshot.
|
// framework module from a snapshot.
|
||||||
Exclude_from_vendor_snapshot *bool
|
Exclude_from_vendor_snapshot *bool
|
||||||
Exclude_from_recovery_snapshot *bool
|
Exclude_from_recovery_snapshot *bool
|
||||||
|
|
||||||
|
// List of APEXes that this module has private access to for testing purpose. The module
|
||||||
|
// can depend on libraries that are not exported by the APEXes and use private symbols
|
||||||
|
// from the exported libraries.
|
||||||
|
Test_for []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type VendorProperties struct {
|
type VendorProperties struct {
|
||||||
|
@ -2935,13 +2940,7 @@ func (c *Module) AvailableFor(what string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) TestFor() []string {
|
func (c *Module) TestFor() []string {
|
||||||
if test, ok := c.linker.(interface {
|
return c.Properties.Test_for
|
||||||
testFor() []string
|
|
||||||
}); ok {
|
|
||||||
return test.testFor()
|
|
||||||
} else {
|
|
||||||
return c.ApexModuleBase.TestFor()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) UniqueApexVariations() bool {
|
func (c *Module) UniqueApexVariations() bool {
|
||||||
|
|
|
@ -29,11 +29,6 @@ type TestProperties struct {
|
||||||
|
|
||||||
// if set, use the isolated gtest runner. Defaults to false.
|
// if set, use the isolated gtest runner. Defaults to false.
|
||||||
Isolated *bool
|
Isolated *bool
|
||||||
|
|
||||||
// List of APEXes that this module tests. The module has access to
|
|
||||||
// the private part of the listed APEXes even when it is not included in the
|
|
||||||
// APEXes.
|
|
||||||
Test_for []string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test option struct.
|
// Test option struct.
|
||||||
|
@ -241,10 +236,6 @@ func (test *testDecorator) gtest() bool {
|
||||||
return BoolDefault(test.Properties.Gtest, true)
|
return BoolDefault(test.Properties.Gtest, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (test *testDecorator) testFor() []string {
|
|
||||||
return test.Properties.Test_for
|
|
||||||
}
|
|
||||||
|
|
||||||
func (test *testDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
func (test *testDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
||||||
if !test.gtest() {
|
if !test.gtest() {
|
||||||
return flags
|
return flags
|
||||||
|
|
|
@ -29,6 +29,7 @@ func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
|
||||||
|
|
||||||
ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory)
|
ctx.RegisterModuleType("toolchain_library", ToolchainLibraryFactory)
|
||||||
ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory)
|
ctx.RegisterModuleType("llndk_library", LlndkLibraryFactory)
|
||||||
|
ctx.RegisterModuleType("cc_benchmark", BenchmarkFactory)
|
||||||
ctx.RegisterModuleType("cc_object", ObjectFactory)
|
ctx.RegisterModuleType("cc_object", ObjectFactory)
|
||||||
ctx.RegisterModuleType("cc_genrule", genRuleFactory)
|
ctx.RegisterModuleType("cc_genrule", genRuleFactory)
|
||||||
ctx.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory)
|
ctx.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory)
|
||||||
|
@ -437,6 +438,13 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
|
||||||
ndk_prebuilt_shared_stl {
|
ndk_prebuilt_shared_stl {
|
||||||
name: "ndk_libc++_shared",
|
name: "ndk_libc++_shared",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cc_library_static {
|
||||||
|
name: "libgoogle-benchmark",
|
||||||
|
sdk_version: "current",
|
||||||
|
stl: "none",
|
||||||
|
system_shared_libs: [],
|
||||||
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
supportLinuxBionic := false
|
supportLinuxBionic := false
|
||||||
|
|
Loading…
Reference in New Issue