Merge "Move LLNDK related logic to llndk_library" into main
This commit is contained in:
1
cc/cc.go
1
cc/cc.go
@@ -50,6 +50,7 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) {
|
||||
ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
|
||||
ctx.BottomUp("sdk", sdkMutator).Parallel()
|
||||
ctx.BottomUp("vndk", VndkMutator).Parallel()
|
||||
ctx.BottomUp("llndk", llndkMutator).Parallel()
|
||||
ctx.BottomUp("link", LinkageMutator).Parallel()
|
||||
ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
|
||||
ctx.BottomUp("version", versionMutator).Parallel()
|
||||
|
@@ -16,12 +16,12 @@ package cc
|
||||
|
||||
import (
|
||||
"android/soong/android"
|
||||
"android/soong/etc"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
llndkLibrarySuffix = ".llndk"
|
||||
llndkHeadersSuffix = ".llndk"
|
||||
)
|
||||
|
||||
// Holds properties to describe a stub shared library based on the provided version file.
|
||||
@@ -78,3 +78,138 @@ func makeLlndkVars(ctx android.MakeVarsContext) {
|
||||
ctx.Strict("LLNDK_MOVED_TO_APEX_LIBRARIES",
|
||||
strings.Join(android.SortedKeys(movedToApexLlndkLibraries), " "))
|
||||
}
|
||||
|
||||
func init() {
|
||||
RegisterLlndkLibraryTxtType(android.InitRegistrationContext)
|
||||
}
|
||||
|
||||
func RegisterLlndkLibraryTxtType(ctx android.RegistrationContext) {
|
||||
ctx.RegisterParallelSingletonModuleType("llndk_libraries_txt", llndkLibrariesTxtFactory)
|
||||
}
|
||||
|
||||
type llndkLibrariesTxtModule struct {
|
||||
android.SingletonModuleBase
|
||||
|
||||
outputFile android.OutputPath
|
||||
moduleNames []string
|
||||
fileNames []string
|
||||
}
|
||||
|
||||
var _ etc.PrebuiltEtcModule = &llndkLibrariesTxtModule{}
|
||||
var _ android.OutputFileProducer = &llndkLibrariesTxtModule{}
|
||||
|
||||
// llndk_libraries_txt is a singleton module whose content is a list of LLNDK libraries
|
||||
// generated by Soong but can be referenced by other modules.
|
||||
// For example, apex_vndk can depend on these files as prebuilt.
|
||||
// Make uses LLNDK_LIBRARIES to determine which libraries to install.
|
||||
// HWASAN is only part of the LL-NDK in builds in which libc depends on HWASAN.
|
||||
// Therefore, by removing the library here, we cause it to only be installed if libc
|
||||
// depends on it.
|
||||
func llndkLibrariesTxtFactory() android.SingletonModule {
|
||||
m := &llndkLibrariesTxtModule{}
|
||||
android.InitAndroidArchModule(m, android.DeviceSupported, android.MultilibCommon)
|
||||
return m
|
||||
}
|
||||
|
||||
func (txt *llndkLibrariesTxtModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
filename := txt.Name()
|
||||
|
||||
txt.outputFile = android.PathForModuleOut(ctx, filename).OutputPath
|
||||
|
||||
installPath := android.PathForModuleInstall(ctx, "etc")
|
||||
ctx.InstallFile(installPath, filename, txt.outputFile)
|
||||
}
|
||||
|
||||
func (txt *llndkLibrariesTxtModule) GenerateSingletonBuildActions(ctx android.SingletonContext) {
|
||||
ctx.VisitAllModules(func(m android.Module) {
|
||||
if c, ok := m.(*Module); ok && c.VendorProperties.IsLLNDK && !c.Header() && !c.IsVndkPrebuiltLibrary() {
|
||||
filename, err := getVndkFileName(c)
|
||||
if err != nil {
|
||||
ctx.ModuleErrorf(m, "%s", err)
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(ctx.ModuleName(m), "libclang_rt.hwasan") {
|
||||
txt.moduleNames = append(txt.moduleNames, ctx.ModuleName(m))
|
||||
}
|
||||
txt.fileNames = append(txt.fileNames, filename)
|
||||
}
|
||||
})
|
||||
txt.moduleNames = android.SortedUniqueStrings(txt.moduleNames)
|
||||
txt.fileNames = android.SortedUniqueStrings(txt.fileNames)
|
||||
|
||||
android.WriteFileRule(ctx, txt.outputFile, strings.Join(txt.fileNames, "\n"))
|
||||
}
|
||||
|
||||
func (txt *llndkLibrariesTxtModule) AndroidMkEntries() []android.AndroidMkEntries {
|
||||
return []android.AndroidMkEntries{{
|
||||
Class: "ETC",
|
||||
OutputFile: android.OptionalPathForPath(txt.outputFile),
|
||||
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
||||
func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
|
||||
entries.SetString("LOCAL_MODULE_STEM", txt.outputFile.Base())
|
||||
},
|
||||
},
|
||||
}}
|
||||
}
|
||||
|
||||
func (txt *llndkLibrariesTxtModule) MakeVars(ctx android.MakeVarsContext) {
|
||||
ctx.Strict("LLNDK_LIBRARIES", strings.Join(txt.moduleNames, " "))
|
||||
}
|
||||
|
||||
// PrebuiltEtcModule interface
|
||||
func (txt *llndkLibrariesTxtModule) OutputFile() android.OutputPath {
|
||||
return txt.outputFile
|
||||
}
|
||||
|
||||
// PrebuiltEtcModule interface
|
||||
func (txt *llndkLibrariesTxtModule) BaseDir() string {
|
||||
return "etc"
|
||||
}
|
||||
|
||||
// PrebuiltEtcModule interface
|
||||
func (txt *llndkLibrariesTxtModule) SubDir() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (txt *llndkLibrariesTxtModule) OutputFiles(tag string) (android.Paths, error) {
|
||||
return android.Paths{txt.outputFile}, nil
|
||||
}
|
||||
|
||||
func llndkMutator(mctx android.BottomUpMutatorContext) {
|
||||
m, ok := mctx.Module().(*Module)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
if shouldSkipLlndkMutator(m) {
|
||||
return
|
||||
}
|
||||
|
||||
lib, isLib := m.linker.(*libraryDecorator)
|
||||
prebuiltLib, isPrebuiltLib := m.linker.(*prebuiltLibraryLinker)
|
||||
|
||||
if m.InVendorOrProduct() && isLib && lib.hasLLNDKStubs() {
|
||||
m.VendorProperties.IsLLNDK = true
|
||||
}
|
||||
if m.InVendorOrProduct() && isPrebuiltLib && prebuiltLib.hasLLNDKStubs() {
|
||||
m.VendorProperties.IsLLNDK = true
|
||||
}
|
||||
|
||||
if m.IsVndkPrebuiltLibrary() && !m.IsVndk() {
|
||||
m.VendorProperties.IsLLNDK = true
|
||||
}
|
||||
}
|
||||
|
||||
// Check for modules that mustn't be LLNDK
|
||||
func shouldSkipLlndkMutator(m *Module) bool {
|
||||
if !m.Enabled() {
|
||||
return true
|
||||
}
|
||||
if !m.Device() {
|
||||
return true
|
||||
}
|
||||
if m.Target().NativeBridge == android.NativeBridgeEnabled {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
@@ -554,6 +554,7 @@ var PrepareForTestWithCcBuildComponents = android.GroupFixturePreparers(
|
||||
ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
|
||||
|
||||
RegisterVndkLibraryTxtTypes(ctx)
|
||||
RegisterLlndkLibraryTxtType(ctx)
|
||||
}),
|
||||
|
||||
// Additional files needed in tests that disallow non-existent source files.
|
||||
@@ -570,17 +571,17 @@ var PrepareForTestWithCcDefaultModules = android.GroupFixturePreparers(
|
||||
|
||||
// Additional files needed in tests that disallow non-existent source.
|
||||
android.MockFS{
|
||||
"defaults/cc/common/libc.map.txt": nil,
|
||||
"defaults/cc/common/libdl.map.txt": nil,
|
||||
"defaults/cc/common/libft2.map.txt": nil,
|
||||
"defaults/cc/common/libm.map.txt": nil,
|
||||
"defaults/cc/common/ndk_libc++_shared": nil,
|
||||
"defaults/cc/common/crtbegin_so.c": nil,
|
||||
"defaults/cc/common/crtbegin.c": nil,
|
||||
"defaults/cc/common/crtend_so.c": nil,
|
||||
"defaults/cc/common/crtend.c": nil,
|
||||
"defaults/cc/common/crtbrand.c": nil,
|
||||
"external/compiler-rt/lib/cfi/cfi_blocklist.txt": nil,
|
||||
"defaults/cc/common/libc.map.txt": nil,
|
||||
"defaults/cc/common/libdl.map.txt": nil,
|
||||
"defaults/cc/common/libft2.map.txt": nil,
|
||||
"defaults/cc/common/libm.map.txt": nil,
|
||||
"defaults/cc/common/ndk_libc++_shared": nil,
|
||||
"defaults/cc/common/crtbegin_so.c": nil,
|
||||
"defaults/cc/common/crtbegin.c": nil,
|
||||
"defaults/cc/common/crtend_so.c": nil,
|
||||
"defaults/cc/common/crtend.c": nil,
|
||||
"defaults/cc/common/crtbrand.c": nil,
|
||||
"external/compiler-rt/lib/cfi/cfi_blocklist.txt": nil,
|
||||
|
||||
"defaults/cc/common/libclang_rt.ubsan_minimal.android_arm64.a": nil,
|
||||
"defaults/cc/common/libclang_rt.ubsan_minimal.android_arm.a": nil,
|
||||
@@ -702,6 +703,7 @@ func CreateTestContext(config android.Config) *android.TestContext {
|
||||
ctx.RegisterModuleType("vndk_prebuilt_shared", VndkPrebuiltSharedFactory)
|
||||
|
||||
RegisterVndkLibraryTxtTypes(ctx)
|
||||
RegisterLlndkLibraryTxtType(ctx)
|
||||
|
||||
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
||||
android.RegisterPrebuiltMutators(ctx)
|
||||
|
29
cc/vndk.go
29
cc/vndk.go
@@ -219,7 +219,6 @@ func vndkIsVndkDepAllowed(from *vndkdep, to *vndkdep) error {
|
||||
type moduleListerFunc func(ctx android.SingletonContext) (moduleNames, fileNames []string)
|
||||
|
||||
var (
|
||||
llndkLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsLLNDK && !m.Header() })
|
||||
vndkSPLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKSP })
|
||||
vndkCoreLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKCore })
|
||||
vndkPrivateLibraries = vndkModuleLister(func(m *Module) bool { return m.VendorProperties.IsVNDKPrivate })
|
||||
@@ -378,19 +377,12 @@ func VndkMutator(mctx android.BottomUpMutatorContext) {
|
||||
prebuiltLib, isPrebuiltLib := m.linker.(*prebuiltLibraryLinker)
|
||||
|
||||
if m.InVendorOrProduct() && isLib && lib.hasLLNDKStubs() {
|
||||
m.VendorProperties.IsLLNDK = true
|
||||
m.VendorProperties.IsVNDKPrivate = Bool(lib.Properties.Llndk.Private)
|
||||
}
|
||||
if m.InVendorOrProduct() && isPrebuiltLib && prebuiltLib.hasLLNDKStubs() {
|
||||
m.VendorProperties.IsLLNDK = true
|
||||
m.VendorProperties.IsVNDKPrivate = Bool(prebuiltLib.Properties.Llndk.Private)
|
||||
}
|
||||
|
||||
if m.IsVndkPrebuiltLibrary() && !m.IsVndk() {
|
||||
m.VendorProperties.IsLLNDK = true
|
||||
// TODO(b/280697209): copy "llndk.private" flag to vndk_prebuilt_shared
|
||||
}
|
||||
|
||||
if (isLib && lib.buildShared()) || (isPrebuiltLib && prebuiltLib.buildShared()) {
|
||||
if m.vndkdep != nil && m.vndkdep.isVndk() && !m.vndkdep.isVndkExt() {
|
||||
processVndkLibrary(mctx, m)
|
||||
@@ -404,8 +396,6 @@ func init() {
|
||||
}
|
||||
|
||||
func RegisterVndkLibraryTxtTypes(ctx android.RegistrationContext) {
|
||||
ctx.RegisterParallelSingletonModuleType("llndk_libraries_txt", llndkLibrariesTxtFactory)
|
||||
ctx.RegisterParallelSingletonModuleType("llndk_libraries_txt_for_apex", llndkLibrariesTxtApexOnlyFactory)
|
||||
ctx.RegisterParallelSingletonModuleType("vndksp_libraries_txt", vndkSPLibrariesTxtFactory)
|
||||
ctx.RegisterParallelSingletonModuleType("vndkcore_libraries_txt", vndkCoreLibrariesTxtFactory)
|
||||
ctx.RegisterParallelSingletonModuleType("vndkprivate_libraries_txt", vndkPrivateLibrariesTxtFactory)
|
||||
@@ -435,25 +425,6 @@ type VndkLibrariesTxtProperties struct {
|
||||
var _ etc.PrebuiltEtcModule = &vndkLibrariesTxt{}
|
||||
var _ android.OutputFileProducer = &vndkLibrariesTxt{}
|
||||
|
||||
// llndk_libraries_txt is a singleton module whose content is a list of LLNDK libraries
|
||||
// generated by Soong.
|
||||
// Make uses LLNDK_LIBRARIES to determine which libraries to install.
|
||||
// HWASAN is only part of the LLNDK in builds in which libc depends on HWASAN.
|
||||
// Therefore, by removing the library here, we cause it to only be installed if libc
|
||||
// depends on it.
|
||||
func llndkLibrariesTxtFactory() android.SingletonModule {
|
||||
return newVndkLibrariesWithMakeVarFilter(llndkLibraries, "LLNDK_LIBRARIES", "libclang_rt.hwasan")
|
||||
}
|
||||
|
||||
// llndk_libraries_txt_for_apex is a singleton module that provide the same LLNDK libraries list
|
||||
// with the llndk_libraries_txt, but skips setting make variable LLNDK_LIBRARIES. So, it must not
|
||||
// be used without installing llndk_libraries_txt singleton.
|
||||
// We include llndk_libraries_txt by default to install the llndk.libraries.txt file to system/etc.
|
||||
// This singleton module is to install the llndk.libraries.<ver>.txt file to vndk apex.
|
||||
func llndkLibrariesTxtApexOnlyFactory() android.SingletonModule {
|
||||
return newVndkLibrariesWithMakeVarFilter(llndkLibraries, "", "libclang_rt.hwasan")
|
||||
}
|
||||
|
||||
// vndksp_libraries_txt is a singleton module whose content is a list of VNDKSP libraries
|
||||
// generated by Soong but can be referenced by other modules.
|
||||
// For example, apex_vndk can depend on these files as prebuilt.
|
||||
|
Reference in New Issue
Block a user