diff options
Diffstat (limited to 'apex/apex.go')
-rw-r--r-- | apex/apex.go | 313 |
1 files changed, 85 insertions, 228 deletions
diff --git a/apex/apex.go b/apex/apex.go index 46aaa8b5f..5a56185e8 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -18,6 +18,7 @@ import ( "fmt" "path" "path/filepath" + "regexp" "sort" "strconv" "strings" @@ -94,27 +95,9 @@ func makeApexAvailableWhitelist() map[string][]string { // Module separator // m["com.android.adbd"] = []string{ - "adbd", - "bcm_object", - "fmtlib", - "libadbconnection_server", - "libadbd", "libadbd_auth", - "libadbd_core", - "libadbd_services", - "libasyncio", - "libbacktrace_headers", - "libbase", - "libbase_headers", "libbuildversion", - "libc++", "libcap", - "libcrypto", - "libcrypto_utils", - "libcutils", - "libcutils_headers", - "libdiagnose_usb", - "liblog_headers", "libmdnssd", "libminijail", "libminijail_gen_constants", @@ -125,9 +108,6 @@ func makeApexAvailableWhitelist() map[string][]string { "libpackagelistparser", "libpcre2", "libprocessgroup_headers", - "libqemu_pipe", - "libsystem_headers", - "libutils_headers", } // // Module separator @@ -136,7 +116,6 @@ func makeApexAvailableWhitelist() map[string][]string { "art_cmdlineparser_headers", "art_disassembler_headers", "art_libartbase_headers", - "bcm_object", "bionic_libc_platform_headers", "core-repackaged-icu4j", "cpp-define-generator-asm-support", @@ -148,9 +127,7 @@ func makeApexAvailableWhitelist() map[string][]string { "conscrypt.module.intra.core.api.stubs", "dex2oat_headers", "dt_fd_forward_export", - "fmtlib", "icu4c_extra_headers", - "jacocoagent", "javavm_headers", "jni_platform_headers", "libPlatformProperties", @@ -160,15 +137,6 @@ func makeApexAvailableWhitelist() map[string][]string { "libart_runtime_headers_ndk", "libartd-disassembler", "libasync_safe", - "libbacktrace", - "libbase", - "libbase_headers", - "libc++", - "libc++_static", - "libc++abi", - "libc++demangle", - "libc_headers", - "libcrypto", "libdexfile_all_headers", "libdexfile_external_headers", "libdexfile_support", @@ -181,7 +149,6 @@ func makeApexAvailableWhitelist() map[string][]string { "libicuuc_headers", "libicuuc_stubdata", "libjdwp_headers", - "liblog_headers", "liblz4", "liblzma", "libmeminfo", @@ -192,7 +159,6 @@ func makeApexAvailableWhitelist() map[string][]string { "libopenjdkjvmti_headers", "libperfetto_client_experimental", "libprocinfo", - "libprotobuf-cpp-lite", "libunwind_llvm", "libunwindstack", "libv8", @@ -229,13 +195,10 @@ func makeApexAvailableWhitelist() map[string][]string { "android.hidl.token@1.0-utils", "avrcp-target-service", "avrcp_headers", - "bcm_object", "bluetooth-protos-lite", "bluetooth.mapsapi", "com.android.vcard", "dnsresolver_aidl_interface-V2-java", - "fmtlib", - "guava", "ipmemorystore-aidl-interfaces-V5-java", "ipmemorystore-aidl-interfaces-java", "internal_include_headers", @@ -245,9 +208,6 @@ func makeApexAvailableWhitelist() map[string][]string { "libFraunhoferAAC", "libaudio-a2dp-hw-utils", "libaudio-hearing-aid-hw-utils", - "libbacktrace_headers", - "libbase", - "libbase_headers", "libbinder_headers", "libbluetooth", "libbluetooth-types", @@ -269,38 +229,23 @@ func makeApexAvailableWhitelist() map[string][]string { "libbtdevice", "libbte", "libbtif", - "libc++", "libchrome", - "libcrypto", - "libcutils", - "libcutils_headers", "libevent", "libfmq", "libg722codec", "libgtest_prod", "libgui_headers", - "libhidlbase", - "libhidlbase-impl-internal", - "libhidltransport-impl-internal", - "libhwbinder-impl-internal", - "libjsoncpp", - "liblog_headers", "libmedia_headers", "libmodpb64", "libosi", "libprocessgroup", "libprocessgroup_headers", - "libprotobuf-cpp-lite", - "libprotobuf-java-lite", - "libprotobuf-java-micro", "libstagefright_foundation_headers", "libstagefright_headers", "libstatslog", "libstatssocket", - "libsystem_headers", "libtinyxml2", "libudrv-uipc", - "libutils_headers", "libz", "media_plugin_headers", "net-utils-services-common", @@ -320,12 +265,8 @@ func makeApexAvailableWhitelist() map[string][]string { // Module separator // m["com.android.conscrypt"] = []string{ - "bcm_object", "boringssl_self_test", - "libc++", - "libcrypto", "libnativehelper_header_only", - "libssl", "unsupportedappusage", } // @@ -365,28 +306,11 @@ func makeApexAvailableWhitelist() map[string][]string { "android.hidl.memory.token@1.0", "android.hidl.memory@1.0", "android.hidl.safe_union@1.0", - "bcm_object", - "fmtlib", "gemmlowp_headers", "libarect", - "libbacktrace_headers", - "libbase", - "libbase_headers", "libbuildversion", - "libc++", - "libcrypto", - "libcrypto_static", - "libcutils", - "libcutils_headers", "libeigen", "libfmq", - "libhidlbase", - "libhidlbase-impl-internal", - "libhidlmemory", - "libhidltransport-impl-internal", - "libhwbinder-impl-internal", - "libjsoncpp", - "liblog_headers", "libmath", "libneuralnetworks_common", "libneuralnetworks_headers", @@ -394,12 +318,10 @@ func makeApexAvailableWhitelist() map[string][]string { "libprocessgroup_headers", "libprocpartition", "libsync", - "libsystem_headers", "libtextclassifier_hash", "libtextclassifier_hash_headers", "libtextclassifier_hash_static", "libtflite_kernel_utils", - "libutils_headers", "philox_random", "philox_random_headers", "tensorflow_headers", @@ -431,9 +353,7 @@ func makeApexAvailableWhitelist() map[string][]string { "android.hidl.memory@1.0", "android.hidl.token@1.0", "android.hidl.token@1.0-utils", - "bcm_object", "bionic_libc_platform_headers", - "fmtlib", "gl_headers", "libEGL", "libEGL_blobCache", @@ -455,23 +375,14 @@ func makeApexAvailableWhitelist() map[string][]string { "libaudiopolicy", "libaudioutils", "libaudioutils_fixedfft", - "libbacktrace", - "libbacktrace_headers", - "libbase", - "libbase_headers", "libbinder_headers", "libbluetooth-types-header", "libbufferhub", "libbufferhub_headers", "libbufferhubqueue", - "libc++", - "libc_headers", "libc_malloc_debug_backtrace", "libcamera_client", "libcamera_metadata", - "libcrypto", - "libcutils", - "libcutils_headers", "libdexfile_external_headers", "libdexfile_support", "libdvr_headers", @@ -483,14 +394,7 @@ func makeApexAvailableWhitelist() map[string][]string { "libgui", "libgui_headers", "libhardware_headers", - "libhidlbase", - "libhidlbase-impl-internal", - "libhidlmemory", - "libhidltransport-impl-internal", - "libhwbinder-impl-internal", "libinput", - "libjsoncpp", - "liblog_headers", "liblzma", "libmath", "libmedia", @@ -538,11 +442,9 @@ func makeApexAvailableWhitelist() map[string][]string { "libstagefright_mpeg2extractor", "libstagefright_mpeg2support", "libsync", - "libsystem_headers", "libui", "libui_headers", "libunwindstack", - "libutils_headers", "libvibrator", "libvorbisidec", "libwavextractor", @@ -582,7 +484,6 @@ func makeApexAvailableWhitelist() map[string][]string { "android.hidl.safe_union@1.0", "android.hidl.token@1.0", "android.hidl.token@1.0-utils", - "fmtlib", "libEGL", "libFLAC", "libFLAC-config", @@ -599,15 +500,10 @@ func makeApexAvailableWhitelist() map[string][]string { "libavcenc", "libavservices_minijail", "libavservices_minijail", - "libbacktrace", - "libbacktrace_headers", - "libbase", - "libbase_headers", "libbinder_headers", "libbinderthreadstateutils", "libbluetooth-types-header", "libbufferhub_headers", - "libc++", "libc_scudo", "libcap", "libcodec2", @@ -647,8 +543,6 @@ func makeApexAvailableWhitelist() map[string][]string { "libcodec2_soft_vp9dec", "libcodec2_soft_vp9enc", "libcodec2_vndk", - "libcutils", - "libcutils_headers", "libdexfile_support", "libdvr_headers", "libfmq", @@ -664,15 +558,8 @@ func makeApexAvailableWhitelist() map[string][]string { "libhardware_headers", "libhevcdec", "libhevcenc", - "libhidlbase", - "libhidlbase-impl-internal", - "libhidlmemory", - "libhidltransport-impl-internal", - "libhwbinder-impl-internal", "libion", "libjpeg", - "libjsoncpp", - "liblog_headers", "liblzma", "libmath", "libmedia_codecserviceregistrant", @@ -710,11 +597,9 @@ func makeApexAvailableWhitelist() map[string][]string { "libstagefright_m4vh263enc", "libstagefright_mp3dec", "libsync", - "libsystem_headers", "libui", "libui_headers", "libunwindstack", - "libutils_headers", "libvorbisidec", "libvpx", "libyuv", @@ -730,7 +615,6 @@ func makeApexAvailableWhitelist() map[string][]string { "MediaProvider", "MediaProviderGoogle", "fmtlib_ndk", - "guava", "libbase_ndk", "libfuse", "libfuse_jni", @@ -754,7 +638,6 @@ func makeApexAvailableWhitelist() map[string][]string { "kotlinx-coroutines-android-nodeps", "kotlinx-coroutines-core", "kotlinx-coroutines-core-nodeps", - "libprotobuf-java-lite", "permissioncontroller-statsd", } // @@ -762,14 +645,9 @@ func makeApexAvailableWhitelist() map[string][]string { // m["com.android.runtime"] = []string{ "bionic_libc_platform_headers", - "fmtlib", "libarm-optimized-routines-math", "libasync_safe", "libasync_safe_headers", - "libbacktrace_headers", - "libbase", - "libbase_headers", - "libc++", "libc_aeabi", "libc_bionic", "libc_bionic_ndk", @@ -783,7 +661,6 @@ func makeApexAvailableWhitelist() map[string][]string { "libc_freebsd", "libc_freebsd_large_stack", "libc_gdtoa", - "libc_headers", "libc_init_dynamic", "libc_init_static", "libc_jemalloc_wrapper", @@ -798,8 +675,6 @@ func makeApexAvailableWhitelist() map[string][]string { "libc_syscalls", "libc_tzcode", "libc_unwind_static", - "libcutils", - "libcutils_headers", "libdebuggerd", "libdebuggerd_common_headers", "libdebuggerd_handler_core", @@ -812,7 +687,6 @@ func makeApexAvailableWhitelist() map[string][]string { "libjemalloc5", "liblinker_main", "liblinker_malloc", - "liblog_headers", "liblz4", "liblzma", "libprocessgroup_headers", @@ -820,11 +694,9 @@ func makeApexAvailableWhitelist() map[string][]string { "libpropertyinfoparser", "libscudo", "libstdc++", - "libsystem_headers", "libsystemproperties", "libtombstoned_client_static", "libunwindstack", - "libutils_headers", "libz", "libziparchive", } @@ -832,34 +704,19 @@ func makeApexAvailableWhitelist() map[string][]string { // Module separator // m["com.android.resolv"] = []string{ - "bcm_object", "dnsresolver_aidl_interface-unstable-ndk_platform", - "fmtlib", - "libbacktrace_headers", - "libbase", - "libbase_headers", - "libc++", - "libcrypto", - "libcutils", - "libcutils_headers", "libgtest_prod", - "libjsoncpp", - "liblog_headers", "libnativehelper_header_only", "libnetd_client_headers", "libnetd_resolv", "libnetdutils", "libprocessgroup", "libprocessgroup_headers", - "libprotobuf-cpp-lite", - "libssl", "libstatslog_resolv", "libstatspush_compat", "libstatssocket", "libstatssocket_headers", - "libsystem_headers", "libsysutils", - "libutils_headers", "netd_event_listener_interface-ndk_platform", "server_configurable_flags", "stats_proto", @@ -868,28 +725,13 @@ func makeApexAvailableWhitelist() map[string][]string { // Module separator // m["com.android.tethering"] = []string{ - "libbase", - "libc++", "libnativehelper_compat_libc++", "android.hardware.tetheroffload.config@1.0", - "fmtlib", - "libbacktrace_headers", - "libbase_headers", "libcgrouprc", "libcgrouprc_format", - "libcutils", - "libcutils_headers", - "libhidlbase", - "libhidlbase-impl-internal", - "libhidltransport-impl-internal", - "libhwbinder-impl-internal", - "libjsoncpp", - "liblog_headers", "libprocessgroup", "libprocessgroup_headers", - "libsystem_headers", "libtetherutilsjni", - "libutils_headers", "libvndksupport", "tethering-aidl-interfaces-java", } @@ -925,20 +767,9 @@ func makeApexAvailableWhitelist() map[string][]string { "ipmemorystore-aidl-interfaces-V3-java", "ipmemorystore-aidl-interfaces-java", "ksoap2", - "libbacktrace_headers", - "libbase", - "libbase_headers", - "libc++", - "libcutils", - "libcutils_headers", - "liblog_headers", "libnanohttpd", "libprocessgroup", "libprocessgroup_headers", - "libprotobuf-java-lite", - "libprotobuf-java-nano", - "libsystem_headers", - "libutils_headers", "libwifi-jni", "net-utils-services-common", "netd_aidl_interface-V2-java", @@ -966,34 +797,14 @@ func makeApexAvailableWhitelist() map[string][]string { // Module separator // m["com.android.os.statsd"] = []string{ - "libbacktrace_headers", - "libbase_headers", - "libc++", - "libcutils", - "libcutils_headers", - "liblog_headers", "libprocessgroup_headers", "libstatssocket", - "libsystem_headers", - "libutils_headers", } // // Module separator // m[android.AvailableToAnyApex] = []string{ - "crtbegin_dynamic", - "crtbegin_dynamic1", - "crtbegin_so", - "crtbegin_so1", - "crtbegin_static", - "crtbrand", - "crtend_android", - "crtend_so", "libatomic", - "libc++_static", - "libc++abi", - "libc++demangle", - "libc_headers", "libclang_rt", "libgcc_stripped", "libprofile-clang-extras", @@ -1001,22 +812,6 @@ func makeApexAvailableWhitelist() map[string][]string { "libprofile-extras", "libprofile-extras_ndk", "libunwind_llvm", - "ndk_crtbegin_dynamic.27", - "ndk_crtbegin_so.16", - "ndk_crtbegin_so.19", - "ndk_crtbegin_so.21", - "ndk_crtbegin_so.24", - "ndk_crtbegin_so.27", - "ndk_crtend_android.27", - "ndk_crtend_so.16", - "ndk_crtend_so.19", - "ndk_crtend_so.21", - "ndk_crtend_so.24", - "ndk_crtend_so.27", - "ndk_libandroid_support", - "ndk_libc++_static", - "ndk_libc++abi", - "ndk_libunwind", } return m } @@ -1071,20 +866,28 @@ func apexDepsMutator(mctx android.TopDownMutatorContext) { return } - cur := mctx.Module().(interface { - DepIsInSameApex(android.BaseModuleContext, android.Module) bool - }) + cur := mctx.Module().(android.DepIsInSameApex) mctx.VisitDirectDeps(func(child android.Module) { depName := mctx.OtherModuleName(child) if am, ok := child.(android.ApexModule); ok && am.CanHaveApexVariants() && - cur.DepIsInSameApex(mctx, child) { + (cur.DepIsInSameApex(mctx, child) || inAnySdk(child)) { android.UpdateApexDependency(apexBundles, depName, directDep) am.BuildForApexes(apexBundles) } }) } +// If a module in an APEX depends on a module from an SDK then it needs an APEX +// specific variant created for it. Refer to sdk.sdkDepsReplaceMutator. +func inAnySdk(module android.Module) bool { + if sa, ok := module.(android.SdkAware); ok { + return sa.IsInAnySdk() + } + + return false +} + // Create apex variations if a module is included in APEX(s). func apexMutator(mctx android.BottomUpMutatorContext) { if am, ok := mctx.Module().(android.ApexModule); ok && am.CanHaveApexVariants() { @@ -1973,10 +1776,14 @@ func (c *flattenedApexContext) InstallBypassMake() bool { return true } +// Function called while walking an APEX's payload dependencies. +// +// Return true if the `to` module should be visited, false otherwise. +type payloadDepsCallback func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool + // Visit dependencies that contributes to the payload of this APEX -func (a *apexBundle) walkPayloadDeps(ctx android.ModuleContext, - do func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool)) { - ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool { +func (a *apexBundle) walkPayloadDeps(ctx android.ModuleContext, do payloadDepsCallback) { + ctx.WalkDeps(func(child, parent android.Module) bool { am, ok := child.(android.ApexModule) if !ok || !am.CanHaveApexVariants() { return false @@ -1985,22 +1792,18 @@ func (a *apexBundle) walkPayloadDeps(ctx android.ModuleContext, // Check for the direct dependencies that contribute to the payload if dt, ok := ctx.OtherModuleDependencyTag(child).(dependencyTag); ok { if dt.payload { - do(ctx, parent, am, false /* externalDep */) - return true + return do(ctx, parent, am, false /* externalDep */) } + // As soon as the dependency graph crosses the APEX boundary, don't go further. return false } // Check for the indirect dependencies if it is considered as part of the APEX if am.ApexName() != "" { - do(ctx, parent, am, false /* externalDep */) - return true + return do(ctx, parent, am, false /* externalDep */) } - do(ctx, parent, am, true /* externalDep */) - - // As soon as the dependency graph crosses the APEX boundary, don't go further. - return false + return do(ctx, parent, am, true /* externalDep */) }) } @@ -2016,6 +1819,24 @@ func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) int { return android.FutureApiLevel } +// A regexp for removing boilerplate from BaseDependencyTag from the string representation of +// a dependency tag. +var tagCleaner = regexp.MustCompile(`\QBaseDependencyTag:blueprint.BaseDependencyTag{}\E(, )?`) + +func PrettyPrintTag(tag blueprint.DependencyTag) string { + // Use tag's custom String() method if available. + if stringer, ok := tag.(fmt.Stringer); ok { + return stringer.String() + } + + // Otherwise, get a default string representation of the tag's struct. + tagString := fmt.Sprintf("%#v", tag) + + // Remove the boilerplate from BaseDependencyTag as it adds no value. + tagString = tagCleaner.ReplaceAllString(tagString, "") + return tagString +} + // Ensures that the dependencies are marked as available for this APEX func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) { // Let's be practical. Availability for test, host, and the VNDK apex isn't important @@ -2023,24 +1844,54 @@ func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) { return } - a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) { + // Coverage build adds additional dependencies for the coverage-only runtime libraries. + // Requiring them and their transitive depencies with apex_available is not right + // because they just add noise. + if ctx.Config().IsEnvTrue("EMMA_INSTRUMENT") || a.IsNativeCoverageNeeded(ctx) { + return + } + + a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool { + if externalDep { + // As soon as the dependency graph crosses the APEX boundary, don't go further. + return false + } + apexName := ctx.ModuleName() fromName := ctx.OtherModuleName(from) toName := ctx.OtherModuleName(to) - if externalDep || to.AvailableFor(apexName) || whitelistedApexAvailable(apexName, toName) { - return + + // If `to` is not actually in the same APEX as `from` then it does not need apex_available and neither + // do any of its dependencies. + if am, ok := from.(android.DepIsInSameApex); ok && !am.DepIsInSameApex(ctx, to) { + // As soon as the dependency graph crosses the APEX boundary, don't go further. + return false } - ctx.ModuleErrorf("%q requires %q that is not available for the APEX.", fromName, toName) + + if to.AvailableFor(apexName) || whitelistedApexAvailable(apexName, toName) { + return true + } + message := "" + tagPath := ctx.GetTagPath() + // Skip the first module as that will be added at the start of the error message by ctx.ModuleErrorf(). + walkPath := ctx.GetWalkPath()[1:] + for i, m := range walkPath { + message = fmt.Sprintf("%s\n via tag %s\n -> %s", message, PrettyPrintTag(tagPath[i]), m.String()) + } + ctx.ModuleErrorf("%q requires %q that is not available for the APEX. Dependency path:%s", fromName, toName, message) + // Visit this module's dependencies to check and report any issues with their availability. + return true }) } // Collects the list of module names that directly or indirectly contributes to the payload of this APEX func (a *apexBundle) collectDepsInfo(ctx android.ModuleContext) { a.depInfos = make(map[string]depInfo) - a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) { + a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool { if from.Name() == to.Name() { // This can happen for cc.reuseObjTag. We are not interested in tracking this. - return + // As soon as the dependency graph crosses the APEX boundary, don't go further. + return !externalDep } if info, exists := a.depInfos[to.Name()]; exists { @@ -2056,6 +1907,9 @@ func (a *apexBundle) collectDepsInfo(ctx android.ModuleContext) { isExternal: externalDep, } } + + // As soon as the dependency graph crosses the APEX boundary, don't go further. + return !externalDep }) } @@ -2132,6 +1986,9 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { // TODO(jiyong) do this using walkPayloadDeps ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool { depTag := ctx.OtherModuleDependencyTag(child) + if _, ok := depTag.(android.ExcludeFromApexContentsTag); ok { + return false + } depName := ctx.OtherModuleName(child) if _, isDirectDep := parent.(*apexBundle); isDirectDep { switch depTag { @@ -2300,7 +2157,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { filesInfo = append(filesInfo, apexFileForPrebuiltEtc(ctx, prebuilt, depName)) } } else if am.CanHaveApexVariants() && am.IsInstallableToApex() { - ctx.ModuleErrorf("unexpected tag %q for indirect dependency %q", depTag, depName) + ctx.ModuleErrorf("unexpected tag %s for indirect dependency %q", PrettyPrintTag(depTag), depName) } } } |