Split vndk_libraries_txt into multiple module types
Replace the vndk_libraries_txt module type with llndk_libraries_txt, etc. in preparation for making it a new SingletonModule, which will only work with a single instance of the module type. Bug: 176904285 Test: m checkbuild Change-Id: Ie010a9eeee8f5849201aa4ab4eb9b2e7a9cd7d5b
This commit is contained in:
@@ -250,7 +250,7 @@ func testApexContext(_ *testing.T, bp string, handlers ...testCustomizer) (*andr
|
|||||||
|
|
||||||
ctx.RegisterModuleType("cc_test", cc.TestFactory)
|
ctx.RegisterModuleType("cc_test", cc.TestFactory)
|
||||||
ctx.RegisterModuleType("vndk_prebuilt_shared", cc.VndkPrebuiltSharedFactory)
|
ctx.RegisterModuleType("vndk_prebuilt_shared", cc.VndkPrebuiltSharedFactory)
|
||||||
ctx.RegisterModuleType("vndk_libraries_txt", cc.VndkLibrariesTxtFactory)
|
cc.RegisterVndkLibraryTxtTypes(ctx)
|
||||||
prebuilt_etc.RegisterPrebuiltEtcBuildComponents(ctx)
|
prebuilt_etc.RegisterPrebuiltEtcBuildComponents(ctx)
|
||||||
ctx.RegisterModuleType("platform_compat_config", java.PlatformCompatConfigFactory)
|
ctx.RegisterModuleType("platform_compat_config", java.PlatformCompatConfigFactory)
|
||||||
ctx.RegisterModuleType("sh_binary", sh.ShBinaryFactory)
|
ctx.RegisterModuleType("sh_binary", sh.ShBinaryFactory)
|
||||||
@@ -3219,7 +3219,7 @@ func vndkLibrariesTxtFiles(vers ...string) (result string) {
|
|||||||
if v == "current" {
|
if v == "current" {
|
||||||
for _, txt := range []string{"llndk", "vndkcore", "vndksp", "vndkprivate", "vndkproduct"} {
|
for _, txt := range []string{"llndk", "vndkcore", "vndksp", "vndkprivate", "vndkproduct"} {
|
||||||
result += `
|
result += `
|
||||||
vndk_libraries_txt {
|
` + txt + `_libraries_txt {
|
||||||
name: "` + txt + `.libraries.txt",
|
name: "` + txt + `.libraries.txt",
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
@@ -418,23 +418,24 @@ func TestVndk(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
vndk_libraries_txt {
|
llndk_libraries_txt {
|
||||||
name: "llndk.libraries.txt",
|
name: "llndk.libraries.txt",
|
||||||
}
|
}
|
||||||
vndk_libraries_txt {
|
vndkcore_libraries_txt {
|
||||||
name: "vndkcore.libraries.txt",
|
name: "vndkcore.libraries.txt",
|
||||||
}
|
}
|
||||||
vndk_libraries_txt {
|
vndksp_libraries_txt {
|
||||||
name: "vndksp.libraries.txt",
|
name: "vndksp.libraries.txt",
|
||||||
}
|
}
|
||||||
vndk_libraries_txt {
|
vndkprivate_libraries_txt {
|
||||||
name: "vndkprivate.libraries.txt",
|
name: "vndkprivate.libraries.txt",
|
||||||
}
|
}
|
||||||
vndk_libraries_txt {
|
vndkproduct_libraries_txt {
|
||||||
name: "vndkproduct.libraries.txt",
|
name: "vndkproduct.libraries.txt",
|
||||||
}
|
}
|
||||||
vndk_libraries_txt {
|
vndkcorevariant_libraries_txt {
|
||||||
name: "vndkcorevariant.libraries.txt",
|
name: "vndkcorevariant.libraries.txt",
|
||||||
|
insert_vndk_version: false,
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -546,7 +547,7 @@ func TestVndkWithHostSupported(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vndk_libraries_txt {
|
vndkcore_libraries_txt {
|
||||||
name: "vndkcore.libraries.txt",
|
name: "vndkcore.libraries.txt",
|
||||||
}
|
}
|
||||||
`)
|
`)
|
||||||
@@ -556,8 +557,9 @@ func TestVndkWithHostSupported(t *testing.T) {
|
|||||||
|
|
||||||
func TestVndkLibrariesTxtAndroidMk(t *testing.T) {
|
func TestVndkLibrariesTxtAndroidMk(t *testing.T) {
|
||||||
bp := `
|
bp := `
|
||||||
vndk_libraries_txt {
|
llndk_libraries_txt {
|
||||||
name: "llndk.libraries.txt",
|
name: "llndk.libraries.txt",
|
||||||
|
insert_vndk_version: true,
|
||||||
}`
|
}`
|
||||||
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
config := TestConfig(buildDir, android.Android, nil, bp, nil)
|
||||||
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
|
||||||
@@ -603,8 +605,9 @@ func TestVndkUsingCoreVariant(t *testing.T) {
|
|||||||
nocrt: true,
|
nocrt: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
vndk_libraries_txt {
|
vndkcorevariant_libraries_txt {
|
||||||
name: "vndkcorevariant.libraries.txt",
|
name: "vndkcorevariant.libraries.txt",
|
||||||
|
insert_vndk_version: false,
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
@@ -568,10 +568,10 @@ func CreateTestContext(config android.Config) *android.TestContext {
|
|||||||
ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
|
ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
|
||||||
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
||||||
ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
|
ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
|
||||||
ctx.RegisterModuleType("vndk_libraries_txt", VndkLibrariesTxtFactory)
|
|
||||||
ctx.RegisterModuleType("vendor_snapshot_shared", VendorSnapshotSharedFactory)
|
ctx.RegisterModuleType("vendor_snapshot_shared", VendorSnapshotSharedFactory)
|
||||||
ctx.RegisterModuleType("vendor_snapshot_static", VendorSnapshotStaticFactory)
|
ctx.RegisterModuleType("vendor_snapshot_static", VendorSnapshotStaticFactory)
|
||||||
ctx.RegisterModuleType("vendor_snapshot_binary", VendorSnapshotBinaryFactory)
|
ctx.RegisterModuleType("vendor_snapshot_binary", VendorSnapshotBinaryFactory)
|
||||||
|
RegisterVndkLibraryTxtTypes(ctx)
|
||||||
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
||||||
android.RegisterPrebuiltMutators(ctx)
|
android.RegisterPrebuiltMutators(ctx)
|
||||||
RegisterRequiredBuildComponentsForTest(ctx)
|
RegisterRequiredBuildComponentsForTest(ctx)
|
||||||
|
66
cc/vndk.go
66
cc/vndk.go
@@ -449,15 +449,32 @@ func VndkMutator(mctx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
android.RegisterModuleType("vndk_libraries_txt", VndkLibrariesTxtFactory)
|
RegisterVndkLibraryTxtTypes(android.InitRegistrationContext)
|
||||||
android.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
|
android.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RegisterVndkLibraryTxtTypes(ctx android.RegistrationContext) {
|
||||||
|
ctx.RegisterModuleType("llndk_libraries_txt", VndkLibrariesTxtFactory(libclangRTRemover(llndkLibraries)))
|
||||||
|
ctx.RegisterModuleType("vndksp_libraries_txt", VndkLibrariesTxtFactory(vndkSpLibraries))
|
||||||
|
ctx.RegisterModuleType("vndkcore_libraries_txt", VndkLibrariesTxtFactory(vndkCoreLibraries))
|
||||||
|
ctx.RegisterModuleType("vndkprivate_libraries_txt", VndkLibrariesTxtFactory(vndkPrivateLibraries))
|
||||||
|
ctx.RegisterModuleType("vndkproduct_libraries_txt", VndkLibrariesTxtFactory(vndkProductLibraries))
|
||||||
|
ctx.RegisterModuleType("vndkcorevariant_libraries_txt", VndkLibrariesTxtFactory(vndkUsingCoreVariantLibraries))
|
||||||
|
}
|
||||||
|
|
||||||
type vndkLibrariesTxt struct {
|
type vndkLibrariesTxt struct {
|
||||||
android.ModuleBase
|
android.ModuleBase
|
||||||
|
|
||||||
|
lister func(android.Config) map[string]string
|
||||||
|
properties VndkLibrariesTxtProperties
|
||||||
|
|
||||||
outputFile android.OutputPath
|
outputFile android.OutputPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type VndkLibrariesTxtProperties struct {
|
||||||
|
Insert_vndk_version *bool
|
||||||
|
}
|
||||||
|
|
||||||
var _ etc.PrebuiltEtcModule = &vndkLibrariesTxt{}
|
var _ etc.PrebuiltEtcModule = &vndkLibrariesTxt{}
|
||||||
var _ android.OutputFileProducer = &vndkLibrariesTxt{}
|
var _ android.OutputFileProducer = &vndkLibrariesTxt{}
|
||||||
|
|
||||||
@@ -471,10 +488,15 @@ var _ android.OutputFileProducer = &vndkLibrariesTxt{}
|
|||||||
// A module behaves like a prebuilt_etc but its content is generated by soong.
|
// A module behaves like a prebuilt_etc but its content is generated by soong.
|
||||||
// By being a soong module, these files can be referenced by other soong modules.
|
// By being a soong module, these files can be referenced by other soong modules.
|
||||||
// For example, apex_vndk can depend on these files as prebuilt.
|
// For example, apex_vndk can depend on these files as prebuilt.
|
||||||
func VndkLibrariesTxtFactory() android.Module {
|
func VndkLibrariesTxtFactory(lister func(android.Config) map[string]string) android.ModuleFactory {
|
||||||
m := &vndkLibrariesTxt{}
|
return func() android.Module {
|
||||||
android.InitAndroidModule(m)
|
m := &vndkLibrariesTxt{
|
||||||
return m
|
lister: lister,
|
||||||
|
}
|
||||||
|
m.AddProperties(&m.properties)
|
||||||
|
android.InitAndroidModule(m)
|
||||||
|
return m
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func insertVndkVersion(filename string, vndkVersion string) string {
|
func insertVndkVersion(filename string, vndkVersion string) string {
|
||||||
@@ -484,33 +506,25 @@ func insertVndkVersion(filename string, vndkVersion string) string {
|
|||||||
return filename
|
return filename
|
||||||
}
|
}
|
||||||
|
|
||||||
func (txt *vndkLibrariesTxt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func libclangRTRemover(lister func(android.Config) map[string]string) func(android.Config) map[string]string {
|
||||||
var list []string
|
return func(config android.Config) map[string]string {
|
||||||
switch txt.Name() {
|
libs := lister(config)
|
||||||
case llndkLibrariesTxt:
|
filteredLibs := make(map[string]string, len(libs))
|
||||||
for _, filename := range android.SortedStringMapValues(llndkLibraries(ctx.Config())) {
|
for lib, v := range libs {
|
||||||
if strings.HasPrefix(filename, "libclang_rt.hwasan-") {
|
if strings.HasPrefix(lib, "libclang_rt.hwasan-") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
list = append(list, filename)
|
filteredLibs[lib] = v
|
||||||
}
|
}
|
||||||
case vndkCoreLibrariesTxt:
|
return filteredLibs
|
||||||
list = android.SortedStringMapValues(vndkCoreLibraries(ctx.Config()))
|
|
||||||
case vndkSpLibrariesTxt:
|
|
||||||
list = android.SortedStringMapValues(vndkSpLibraries(ctx.Config()))
|
|
||||||
case vndkPrivateLibrariesTxt:
|
|
||||||
list = android.SortedStringMapValues(vndkPrivateLibraries(ctx.Config()))
|
|
||||||
case vndkProductLibrariesTxt:
|
|
||||||
list = android.SortedStringMapValues(vndkProductLibraries(ctx.Config()))
|
|
||||||
case vndkUsingCoreVariantLibrariesTxt:
|
|
||||||
list = android.SortedStringMapValues(vndkUsingCoreVariantLibraries(ctx.Config()))
|
|
||||||
default:
|
|
||||||
ctx.ModuleErrorf("name(%s) is unknown.", txt.Name())
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (txt *vndkLibrariesTxt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
|
list := android.SortedStringMapValues(txt.lister(ctx.Config()))
|
||||||
|
|
||||||
var filename string
|
var filename string
|
||||||
if txt.Name() != vndkUsingCoreVariantLibrariesTxt {
|
if BoolDefault(txt.properties.Insert_vndk_version, true) {
|
||||||
filename = insertVndkVersion(txt.Name(), ctx.DeviceConfig().PlatformVndkVersion())
|
filename = insertVndkVersion(txt.Name(), ctx.DeviceConfig().PlatformVndkVersion())
|
||||||
} else {
|
} else {
|
||||||
filename = txt.Name()
|
filename = txt.Name()
|
||||||
|
Reference in New Issue
Block a user