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:
66
cc/vndk.go
66
cc/vndk.go
@@ -449,15 +449,32 @@ func VndkMutator(mctx android.BottomUpMutatorContext) {
|
||||
}
|
||||
|
||||
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 @@ var _ android.OutputFileProducer = &vndkLibrariesTxt{}
|
||||
// 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 @@ func insertVndkVersion(filename string, vndkVersion string) string {
|
||||
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()
|
||||
|
Reference in New Issue
Block a user