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
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 2d02a6a..71c6b70 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -418,23 +418,24 @@
},
}
- vndk_libraries_txt {
+ llndk_libraries_txt {
name: "llndk.libraries.txt",
}
- vndk_libraries_txt {
+ vndkcore_libraries_txt {
name: "vndkcore.libraries.txt",
}
- vndk_libraries_txt {
+ vndksp_libraries_txt {
name: "vndksp.libraries.txt",
}
- vndk_libraries_txt {
+ vndkprivate_libraries_txt {
name: "vndkprivate.libraries.txt",
}
- vndk_libraries_txt {
+ vndkproduct_libraries_txt {
name: "vndkproduct.libraries.txt",
}
- vndk_libraries_txt {
+ vndkcorevariant_libraries_txt {
name: "vndkcorevariant.libraries.txt",
+ insert_vndk_version: false,
}
`
@@ -546,7 +547,7 @@
}
}
- vndk_libraries_txt {
+ vndkcore_libraries_txt {
name: "vndkcore.libraries.txt",
}
`)
@@ -556,8 +557,9 @@
func TestVndkLibrariesTxtAndroidMk(t *testing.T) {
bp := `
- vndk_libraries_txt {
+ llndk_libraries_txt {
name: "llndk.libraries.txt",
+ insert_vndk_version: true,
}`
config := TestConfig(buildDir, android.Android, nil, bp, nil)
config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
@@ -603,8 +605,9 @@
nocrt: true,
}
- vndk_libraries_txt {
+ vndkcorevariant_libraries_txt {
name: "vndkcorevariant.libraries.txt",
+ insert_vndk_version: false,
}
`
diff --git a/cc/testing.go b/cc/testing.go
index fc5b030..f834205 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -568,10 +568,10 @@
ctx.RegisterModuleType("vendor_public_library", vendorPublicLibraryFactory)
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
- ctx.RegisterModuleType("vndk_libraries_txt", VndkLibrariesTxtFactory)
ctx.RegisterModuleType("vendor_snapshot_shared", VendorSnapshotSharedFactory)
ctx.RegisterModuleType("vendor_snapshot_static", VendorSnapshotStaticFactory)
ctx.RegisterModuleType("vendor_snapshot_binary", VendorSnapshotBinaryFactory)
+ RegisterVndkLibraryTxtTypes(ctx)
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
android.RegisterPrebuiltMutators(ctx)
RegisterRequiredBuildComponentsForTest(ctx)
diff --git a/cc/vndk.go b/cc/vndk.go
index 2071a03..31c7787 100644
--- a/cc/vndk.go
+++ b/cc/vndk.go
@@ -449,15 +449,32 @@
}
func init() {
- android.RegisterModuleType("vndk_libraries_txt", VndkLibrariesTxtFactory)
+ RegisterVndkLibraryTxtTypes(android.InitRegistrationContext)
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 {
android.ModuleBase
+
+ lister func(android.Config) map[string]string
+ properties VndkLibrariesTxtProperties
+
outputFile android.OutputPath
}
+type VndkLibrariesTxtProperties struct {
+ Insert_vndk_version *bool
+}
+
var _ etc.PrebuiltEtcModule = &vndkLibrariesTxt{}
var _ android.OutputFileProducer = &vndkLibrariesTxt{}
@@ -471,10 +488,15 @@
// 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.
// For example, apex_vndk can depend on these files as prebuilt.
-func VndkLibrariesTxtFactory() android.Module {
- m := &vndkLibrariesTxt{}
- android.InitAndroidModule(m)
- return m
+func VndkLibrariesTxtFactory(lister func(android.Config) map[string]string) android.ModuleFactory {
+ return func() android.Module {
+ m := &vndkLibrariesTxt{
+ lister: lister,
+ }
+ m.AddProperties(&m.properties)
+ android.InitAndroidModule(m)
+ return m
+ }
}
func insertVndkVersion(filename string, vndkVersion string) string {
@@ -484,33 +506,25 @@
return filename
}
-func (txt *vndkLibrariesTxt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
- var list []string
- switch txt.Name() {
- case llndkLibrariesTxt:
- for _, filename := range android.SortedStringMapValues(llndkLibraries(ctx.Config())) {
- if strings.HasPrefix(filename, "libclang_rt.hwasan-") {
+func libclangRTRemover(lister func(android.Config) map[string]string) func(android.Config) map[string]string {
+ return func(config android.Config) map[string]string {
+ libs := lister(config)
+ filteredLibs := make(map[string]string, len(libs))
+ for lib, v := range libs {
+ if strings.HasPrefix(lib, "libclang_rt.hwasan-") {
continue
}
- list = append(list, filename)
+ filteredLibs[lib] = v
}
- case vndkCoreLibrariesTxt:
- 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
+ return filteredLibs
}
+}
+
+func (txt *vndkLibrariesTxt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ list := android.SortedStringMapValues(txt.lister(ctx.Config()))
var filename string
- if txt.Name() != vndkUsingCoreVariantLibrariesTxt {
+ if BoolDefault(txt.properties.Insert_vndk_version, true) {
filename = insertVndkVersion(txt.Name(), ctx.DeviceConfig().PlatformVndkVersion())
} else {
filename = txt.Name()