Merge "Generate the known NDK libraries list." am: 2e1b8baeda

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1353447

Change-Id: I05725fdfbbd34ee839ac63ff5534a7c40643a122
This commit is contained in:
Treehugger Robot 2020-07-01 21:57:23 +00:00 committed by Automerger Merge Worker
commit 5f33df625a
4 changed files with 32 additions and 63 deletions

View file

@ -873,7 +873,7 @@ func (c *Module) isCoverageVariant() bool {
} }
func (c *Module) IsNdk() bool { func (c *Module) IsNdk() bool {
return inList(c.Name(), ndkMigratedLibs) return inList(c.Name(), ndkKnownLibs)
} }
func (c *Module) isLlndk(config android.Config) bool { func (c *Module) isLlndk(config android.Config) bool {
@ -1759,8 +1759,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
variantNdkLibs := []string{} variantNdkLibs := []string{}
variantLateNdkLibs := []string{} variantLateNdkLibs := []string{}
if ctx.Os() == android.Android { if ctx.Os() == android.Android {
version := ctx.sdkVersion()
// rewriteLibs takes a list of names of shared libraries and scans it for three types // rewriteLibs takes a list of names of shared libraries and scans it for three types
// of names: // of names:
// //
@ -1802,12 +1800,8 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
for _, entry := range list { for _, entry := range list {
// strip #version suffix out // strip #version suffix out
name, _ := StubsLibNameAndVersion(entry) name, _ := StubsLibNameAndVersion(entry)
if ctx.useSdk() && inList(name, ndkPrebuiltSharedLibraries) { if ctx.useSdk() && inList(name, ndkKnownLibs) {
if !inList(name, ndkMigratedLibs) { variantLibs = append(variantLibs, name+ndkLibrarySuffix)
nonvariantLibs = append(nonvariantLibs, name+".ndk."+version)
} else {
variantLibs = append(variantLibs, name+ndkLibrarySuffix)
}
} else if ctx.useVndk() { } else if ctx.useVndk() {
nonvariantLibs = append(nonvariantLibs, rewriteVendorLibs(entry)) nonvariantLibs = append(nonvariantLibs, rewriteVendorLibs(entry))
} else if (ctx.Platform() || ctx.ProductSpecific()) && inList(name, *vendorPublicLibraries) { } else if (ctx.Platform() || ctx.ProductSpecific()) && inList(name, *vendorPublicLibraries) {

View file

@ -97,7 +97,12 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
ctx.Strict("CLANG_EXTERNAL_CFLAGS", "${config.ClangExternalCflags}") ctx.Strict("CLANG_EXTERNAL_CFLAGS", "${config.ClangExternalCflags}")
ctx.Strict("GLOBAL_CLANG_CFLAGS_NO_OVERRIDE", "${config.NoOverrideClangGlobalCflags}") ctx.Strict("GLOBAL_CLANG_CFLAGS_NO_OVERRIDE", "${config.NoOverrideClangGlobalCflags}")
ctx.Strict("GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE", "") ctx.Strict("GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE", "")
ctx.Strict("NDK_PREBUILT_SHARED_LIBRARIES", strings.Join(ndkPrebuiltSharedLibs, " ")) ndkLibNames := []string{}
for _, lib := range ndkKnownLibs {
ndkLibNames = append(ndkLibNames, strings.TrimPrefix(lib, "lib"))
}
sort.Strings(ndkLibNames)
ctx.Strict("NDK_PREBUILT_SHARED_LIBRARIES", strings.Join(ndkLibNames, " "))
ctx.Strict("BOARD_VNDK_VERSION", ctx.DeviceConfig().VndkVersion()) ctx.Strict("BOARD_VNDK_VERSION", ctx.DeviceConfig().VndkVersion())
@ -174,8 +179,8 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
ctx.StrictRaw("SRC_HEADERS", strings.Join(includes, " ")) ctx.StrictRaw("SRC_HEADERS", strings.Join(includes, " "))
ctx.StrictRaw("SRC_SYSTEM_HEADERS", strings.Join(systemIncludes, " ")) ctx.StrictRaw("SRC_SYSTEM_HEADERS", strings.Join(systemIncludes, " "))
sort.Strings(ndkMigratedLibs) sort.Strings(ndkKnownLibs)
ctx.Strict("NDK_MIGRATED_LIBS", strings.Join(ndkMigratedLibs, " ")) ctx.Strict("NDK_MIGRATED_LIBS", strings.Join(ndkKnownLibs, " "))
hostTargets := ctx.Config().Targets[android.BuildOs] hostTargets := ctx.Config().Targets[android.BuildOs]
makeVarsToolchain(ctx, "", hostTargets[0]) makeVarsToolchain(ctx, "", hostTargets[0])

View file

@ -47,37 +47,10 @@ var (
ndkLibrarySuffix = ".ndk" ndkLibrarySuffix = ".ndk"
ndkPrebuiltSharedLibs = []string{ // Added as a variation dependency via depsMutator.
"aaudio", ndkKnownLibs = []string{}
"amidi", // protects ndkKnownLibs writes during parallel BeginMutator.
"android", ndkKnownLibsLock sync.Mutex
"binder_ndk",
"c",
"camera2ndk",
"dl",
"EGL",
"GLESv1_CM",
"GLESv2",
"GLESv3",
"jnigraphics",
"log",
"mediandk",
"nativewindow",
"m",
"neuralnetworks",
"OpenMAXAL",
"OpenSLES",
"stdc++",
"sync",
"vulkan",
"z",
}
ndkPrebuiltSharedLibraries = addPrefix(append([]string(nil), ndkPrebuiltSharedLibs...), "lib")
// These libraries have migrated over to the new ndk_library, which is added
// as a variation dependency via depsMutator.
ndkMigratedLibs = []string{}
ndkMigratedLibsLock sync.Mutex // protects ndkMigratedLibs writes during parallel BeginMutator
) )
// Creates a stub shared library based on the provided version file. // Creates a stub shared library based on the provided version file.
@ -257,14 +230,14 @@ func (c *stubDecorator) compilerInit(ctx BaseModuleContext) {
ctx.PropertyErrorf("name", "Do not append %q manually, just use the base name", ndkLibrarySuffix) ctx.PropertyErrorf("name", "Do not append %q manually, just use the base name", ndkLibrarySuffix)
} }
ndkMigratedLibsLock.Lock() ndkKnownLibsLock.Lock()
defer ndkMigratedLibsLock.Unlock() defer ndkKnownLibsLock.Unlock()
for _, lib := range ndkMigratedLibs { for _, lib := range ndkKnownLibs {
if lib == name { if lib == name {
return return
} }
} }
ndkMigratedLibs = append(ndkMigratedLibs, name) ndkKnownLibs = append(ndkKnownLibs, name)
} }
func addStubLibraryCompilerFlags(flags Flags) Flags { func addStubLibraryCompilerFlags(flags Flags) Flags {

View file

@ -32,6 +32,7 @@ func RegisterRequiredBuildComponentsForTest(ctx android.RegistrationContext) {
ctx.RegisterModuleType("cc_object", ObjectFactory) ctx.RegisterModuleType("cc_object", ObjectFactory)
ctx.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory) ctx.RegisterModuleType("ndk_prebuilt_shared_stl", NdkPrebuiltSharedStlFactory)
ctx.RegisterModuleType("ndk_prebuilt_object", NdkPrebuiltObjectFactory) ctx.RegisterModuleType("ndk_prebuilt_object", NdkPrebuiltObjectFactory)
ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
} }
func GatherRequiredDepsForTest(oses ...android.OsType) string { func GatherRequiredDepsForTest(oses ...android.OsType) string {
@ -393,25 +394,22 @@ func GatherRequiredDepsForTest(oses ...android.OsType) string {
system_shared_libs: [], system_shared_libs: [],
} }
cc_library { ndk_library {
name: "libc.ndk.current", name: "libc",
sdk_version: "current", first_version: "minimum",
stl: "none", symbol_file: "libc.map.txt",
system_shared_libs: [],
} }
cc_library { ndk_library {
name: "libm.ndk.current", name: "libm",
sdk_version: "current", first_version: "minimum",
stl: "none", symbol_file: "libm.map.txt",
system_shared_libs: [],
} }
cc_library { ndk_library {
name: "libdl.ndk.current", name: "libdl",
sdk_version: "current", first_version: "minimum",
stl: "none", symbol_file: "libdl.map.txt",
system_shared_libs: [],
} }
ndk_prebuilt_object { ndk_prebuilt_object {
@ -503,7 +501,6 @@ func CreateTestContext() *android.TestContext {
ctx.RegisterModuleType("cc_fuzz", FuzzFactory) ctx.RegisterModuleType("cc_fuzz", FuzzFactory)
ctx.RegisterModuleType("cc_test", TestFactory) ctx.RegisterModuleType("cc_test", TestFactory)
ctx.RegisterModuleType("llndk_headers", llndkHeadersFactory) ctx.RegisterModuleType("llndk_headers", llndkHeadersFactory)
ctx.RegisterModuleType("ndk_library", NdkLibraryFactory)
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)