diff options
| -rw-r--r-- | android/apex.go | 12 | ||||
| -rw-r--r-- | android/soong_config_modules.go | 1 | ||||
| -rw-r--r-- | android/soong_config_modules_test.go | 6 | ||||
| -rw-r--r-- | apex/androidmk.go | 25 | ||||
| -rw-r--r-- | apex/apex.go | 845 | ||||
| -rw-r--r-- | apex/apex_test.go | 62 | ||||
| -rw-r--r-- | cc/cc.go | 26 | ||||
| -rw-r--r-- | cc/config/vndk.go | 66 | ||||
| -rw-r--r-- | cc/linkable.go | 5 | ||||
| -rwxr-xr-x | java/app.go | 7 | ||||
| -rw-r--r-- | java/java.go | 29 | ||||
| -rw-r--r-- | java/sdk.go | 8 | ||||
| -rw-r--r-- | java/sdk_test.go | 9 | ||||
| -rw-r--r-- | java/testing.go | 1 | ||||
| -rw-r--r-- | sdk/java_sdk_test.go | 20 |
15 files changed, 967 insertions, 155 deletions
diff --git a/android/apex.go b/android/apex.go index a4b695608..9195388bf 100644 --- a/android/apex.go +++ b/android/apex.go @@ -180,20 +180,20 @@ func (m *ApexModuleBase) checkApexAvailableProperty(mctx BaseModuleContext) { func (m *ApexModuleBase) CreateApexVariations(mctx BottomUpMutatorContext) []Module { if len(m.apexVariations) > 0 { m.checkApexAvailableProperty(mctx) + sort.Strings(m.apexVariations) variations := []string{} - availableForPlatform := mctx.Module().(ApexModule).AvailableFor(AvailableToPlatform) || mctx.Host() - if availableForPlatform { - variations = append(variations, "") // Original variation for platform - } + variations = append(variations, "") // Original variation for platform variations = append(variations, m.apexVariations...) defaultVariation := "" mctx.SetDefaultDependencyVariation(&defaultVariation) + modules := mctx.CreateVariations(variations...) for i, m := range modules { - if availableForPlatform && i == 0 { - continue + platformVariation := i == 0 + if platformVariation && !mctx.Host() && !m.(ApexModule).AvailableFor(AvailableToPlatform) { + m.SkipInstall() } m.(ApexModule).setApexName(variations[i]) } diff --git a/android/soong_config_modules.go b/android/soong_config_modules.go index f54e774f8..198108d65 100644 --- a/android/soong_config_modules.go +++ b/android/soong_config_modules.go @@ -303,6 +303,7 @@ func loadSoongConfigModuleTypeDefinition(ctx LoadHookContext, from string) map[s } return ctx.Config().Once(key, func() interface{} { + ctx.AddNinjaFileDeps(from) r, err := ctx.Config().fs.Open(from) if err != nil { ctx.PropertyErrorf("from", "failed to open %q: %s", from, err) diff --git a/android/soong_config_modules_test.go b/android/soong_config_modules_test.go index 66feba801..6ad88a2ee 100644 --- a/android/soong_config_modules_test.go +++ b/android/soong_config_modules_test.go @@ -43,7 +43,7 @@ func TestSoongConfigModule(t *testing.T) { name: "acme_test_defaults", module_type: "test_defaults", config_namespace: "acme", - variables: ["board", "feature1", "feature2", "feature3"], + variables: ["board", "feature1", "feature2", "FEATURE3"], properties: ["cflags", "srcs"], } @@ -61,7 +61,7 @@ func TestSoongConfigModule(t *testing.T) { } soong_config_bool_variable { - name: "feature3", + name: "FEATURE3", } ` @@ -91,7 +91,7 @@ func TestSoongConfigModule(t *testing.T) { feature2: { cflags: ["-DFEATURE2"], }, - feature3: { + FEATURE3: { cflags: ["-DFEATURE3"], }, }, diff --git a/apex/androidmk.go b/apex/androidmk.go index 89299105c..714045fc2 100644 --- a/apex/androidmk.go +++ b/apex/androidmk.go @@ -42,7 +42,11 @@ func (a *apexBundle) AndroidMk() android.AndroidMkData { }} } -func (a *apexBundle) androidMkForFiles(w io.Writer, apexName, moduleDir string) []string { +func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, moduleDir string) []string { + // apexBundleName comes from the 'name' property; apexName comes from 'apex_name' property. + // An apex is installed to /system/apex/<apexBundleName> and is activated at /apex/<apexName> + // In many cases, the two names are the same, but could be different in general. + moduleNames := []string{} apexType := a.properties.ApexType // To avoid creating duplicate build rules, run this function only when primaryApexType is true @@ -52,12 +56,21 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexName, moduleDir string) return moduleNames } + // b/140136207. When there are overriding APEXes for a VNDK APEX, the symbols file for the overridden + // APEX and the overriding APEX will have the same installation paths at /apex/com.android.vndk.v<ver> + // as their apexName will be the same. To avoid the path conflicts, skip installing the symbol files + // for the overriding VNDK APEXes. + symbolFilesNotNeeded := a.vndkApex && len(a.overridableProperties.Overrides) > 0 + if symbolFilesNotNeeded && apexType != flattenedApex { + return moduleNames + } + var postInstallCommands []string for _, fi := range a.filesInfo { if a.linkToSystemLib && fi.transitiveDep && fi.AvailableToPlatform() { // TODO(jiyong): pathOnDevice should come from fi.module, not being calculated here linkTarget := filepath.Join("/system", fi.Path()) - linkPath := filepath.Join(a.installDir.ToMakePath().String(), apexName, fi.Path()) + linkPath := filepath.Join(a.installDir.ToMakePath().String(), apexBundleName, fi.Path()) mkdirCmd := "mkdir -p " + filepath.Dir(linkPath) linkCmd := "ln -sfn " + linkTarget + " " + linkPath postInstallCommands = append(postInstallCommands, mkdirCmd, linkCmd) @@ -75,7 +88,7 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexName, moduleDir string) if linkToSystemLib { moduleName = fi.moduleName } else { - moduleName = fi.moduleName + "." + apexName + a.suffix + moduleName = fi.moduleName + "." + apexBundleName + a.suffix } if !android.InList(moduleName, moduleNames) { @@ -99,8 +112,8 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexName, moduleDir string) if apexType == flattenedApex { // /system/apex/<name>/{lib|framework|...} fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", filepath.Join(a.installDir.ToMakePath().String(), - apexName, fi.installDir)) - if a.primaryApexType { + apexBundleName, fi.installDir)) + if a.primaryApexType && !symbolFilesNotNeeded { fmt.Fprintln(w, "LOCAL_SOONG_SYMBOL_PATH :=", pathWhenActivated) } if len(fi.symlinks) > 0 { @@ -236,7 +249,7 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData { apexType := a.properties.ApexType if a.installable() { apexName := proptools.StringDefault(a.properties.Apex_name, name) - moduleNames = a.androidMkForFiles(w, apexName, moduleDir) + moduleNames = a.androidMkForFiles(w, name, apexName, moduleDir) } if apexType == flattenedApex { diff --git a/apex/apex.go b/apex/apex.go index 53bdc1249..f42bed089 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -45,18 +45,21 @@ const ( type dependencyTag struct { blueprint.BaseDependencyTag name string + + // determines if the dependent will be part of the APEX payload + payload bool } var ( - sharedLibTag = dependencyTag{name: "sharedLib"} - executableTag = dependencyTag{name: "executable"} - javaLibTag = dependencyTag{name: "javaLib"} - prebuiltTag = dependencyTag{name: "prebuilt"} - testTag = dependencyTag{name: "test"} + sharedLibTag = dependencyTag{name: "sharedLib", payload: true} + executableTag = dependencyTag{name: "executable", payload: true} + javaLibTag = dependencyTag{name: "javaLib", payload: true} + prebuiltTag = dependencyTag{name: "prebuilt", payload: true} + testTag = dependencyTag{name: "test", payload: true} keyTag = dependencyTag{name: "key"} certificateTag = dependencyTag{name: "certificate"} usesTag = dependencyTag{name: "uses"} - androidAppTag = dependencyTag{name: "androidApp"} + androidAppTag = dependencyTag{name: "androidApp", payload: true} apexAvailWl = makeApexAvailableWhitelist() ) @@ -70,97 +73,466 @@ func makeApexAvailableWhitelist() map[string][]string { // // Module separator // - m["com.android.adbd"] = []string{"adbd", "libcrypto"} + 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", + "liblog_headers", + "libmdnssd", + "libminijail", + "libminijail_gen_constants", + "libminijail_gen_constants_obj", + "libminijail_gen_syscall", + "libminijail_gen_syscall_obj", + "libminijail_generated", + "libpackagelistparser", + "libpcre2", + "libprocessgroup_headers", + "libqemu_pipe", + "libselinux", + "libsystem_headers", + "libutils_headers", + } + // + // Module separator + // + m["com.android.appsearch"] = []string{ + "icing-java-proto-lite", + "libprotobuf-java-lite", + } // // Module separator // m["com.android.art"] = []string{ + "art_cmdlineparser_headers", + "art_disassembler_headers", + "art_libartbase_headers", + "bcm_object", + "bionic_libc_platform_headers", + "core-repackaged-icu4j", + "cpp-define-generator-asm-support", + "cpp-define-generator-definitions", + "crtbegin_dynamic", + "crtbegin_dynamic1", + "crtbegin_so1", + "crtbrand", + "conscrypt.module.intra.core.api.stubs", + "dex2oat_headers", + "dt_fd_forward_export", + "fmtlib", + "icu4c_extra_headers", "jacocoagent", + "javavm_headers", + "jni_platform_headers", + "libPlatformProperties", + "libadbconnection_client", "libadbconnection_server", + "libandroidicuinit", + "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", + "libdmabufinfo", "libexpat", + "libfdlibm", + "libgtest_prod", + "libicui18n_headers", "libicuuc", + "libicuuc_headers", + "libicuuc_stubdata", + "libjdwp_headers", + "liblog", + "liblog_headers", + "liblz4", "liblzma", "libmeminfo", + "libnativebridge-headers", + "libnativehelper_header_only", + "libnativeloader-headers", + "libnpt_headers", + "libopenjdkjvmti_headers", + "libperfetto_client_experimental", "libprocinfo", + "libprotobuf-cpp-lite", + "libunwind_llvm", "libunwindstack", + "libv8", + "libv8base", + "libv8gen", + "libv8platform", + "libv8sampler", + "libv8src", "libvixl", "libvixld", "libz", "libziparchive", - "prebuilt_libclang_rt", + "perfetto_trace_protos", } // // Module separator // m["com.android.bluetooth.updatable"] = []string{ "android.hardware.audio.common@5.0", - "android.hardware.bluetooth@1.0", - "android.hardware.bluetooth@1.1", "android.hardware.bluetooth.a2dp@1.0", "android.hardware.bluetooth.audio@2.0", + "android.hardware.bluetooth@1.0", + "android.hardware.bluetooth@1.1", + "android.hardware.graphics.bufferqueue@1.0", + "android.hardware.graphics.bufferqueue@2.0", + "android.hardware.graphics.common@1.0", + "android.hardware.graphics.common@1.1", + "android.hardware.graphics.common@1.2", + "android.hardware.media@1.0", "android.hidl.safe_union@1.0", + "android.hidl.token@1.0", + "android.hidl.token@1.0-utils", + "avrcp-target-service", + "avrcp_headers", + "bcm_object", + "bluetooth-protos-lite", + "bluetooth.mapsapi", + "com.android.vcard", + "fmtlib", + "guava", + "internal_include_headers", + "lib-bt-packets", + "lib-bt-packets-avrcp", + "lib-bt-packets-base", + "libFraunhoferAAC", + "libaudio-a2dp-hw-utils", + "libaudio-hearing-aid-hw-utils", + "libbacktrace_headers", "libbase", + "libbase_headers", + "libbinder_headers", "libbinderthreadstate", "libbluetooth", + "libbluetooth-types", + "libbluetooth-types-header", + "libbluetooth_gd", + "libbluetooth_headers", "libbluetooth_jni", + "libbt-audio-hal-interface", + "libbt-bta", + "libbt-common", + "libbt-hci", + "libbt-platform-protos-lite", + "libbt-protos-lite", + "libbt-sbc-decoder", + "libbt-sbc-encoder", + "libbt-stack", + "libbt-utils", + "libbtcore", + "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", + "libutils_headers", "libz", + "media_plugin_headers", + "sap-api-java-static", + "services.net", } // // Module separator // - m["com.android.conscrypt"] = []string{"boringssl_self_test", "libc++", "libcrypto", "libssl"} + m["com.android.cellbroadcast"] = []string{"CellBroadcastApp", "CellBroadcastServiceModule"} + // + // Module separator + // + m["com.android.conscrypt"] = []string{ + "bcm_object", + "boringssl_self_test", + "libc++", + "libcrypto", + "libnativehelper_header_only", + "libssl", + } // // Module separator // - m["com.android.cronet"] = []string{"org.chromium.net.cronet", "prebuilt_libcronet.80.0.3986.0"} + m["com.android.extservices"] = []string{ + "flatbuffer_headers", + "liblua", + "libtextclassifier", + "libtextclassifier_hash_static", + "libtflite_static", + "libutf", + "libz_current", + "tensorflow_headers", + } + // + // Module separator + // + m["com.android.cronet"] = []string{ + "cronet_impl_common_java", + "cronet_impl_native_java", + "cronet_impl_platform_java", + "libcronet.80.0.3986.0", + "org.chromium.net.cronet", + "prebuilt_libcronet.80.0.3986.0", + } + // + // Module separator + // + m["com.android.neuralnetworks"] = []string{ + "android.hardware.neuralnetworks@1.0", + "android.hardware.neuralnetworks@1.1", + "android.hardware.neuralnetworks@1.2", + "android.hardware.neuralnetworks@1.3", + "android.hidl.allocator@1.0", + "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", + "libbinderthreadstate", + "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", + "libprocessgroup", + "libprocessgroup_headers", + "libprocpartition", + "libsync", + "libsystem_headers", + "libtextclassifier_hash", + "libtextclassifier_hash_headers", + "libtextclassifier_hash_static", + "libtflite_kernel_utils", + "libutils", + "libutils_headers", + "philox_random", + "philox_random_headers", + "tensorflow_headers", + } // // Module separator // m["com.android.media"] = []string{ - "android.hardware.cas@1.0", + "android.frameworks.bufferhub@1.0", "android.hardware.cas.native@1.0", + "android.hardware.cas@1.0", + "android.hardware.configstore-utils", + "android.hardware.configstore@1.0", + "android.hardware.configstore@1.1", + "android.hardware.graphics.allocator@2.0", + "android.hardware.graphics.allocator@3.0", + "android.hardware.graphics.bufferqueue@1.0", + "android.hardware.graphics.bufferqueue@2.0", + "android.hardware.graphics.common@1.0", + "android.hardware.graphics.common@1.1", + "android.hardware.graphics.common@1.2", + "android.hardware.graphics.mapper@2.0", + "android.hardware.graphics.mapper@2.1", + "android.hardware.graphics.mapper@3.0", + "android.hardware.media.omx@1.0", + "android.hardware.media@1.0", "android.hidl.allocator@1.0", - "android.hidl.memory@1.0", "android.hidl.memory.token@1.0", + "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", + "libEGL_getProcAddress", + "libFLAC", + "libFLAC-config", + "libFLAC-headers", + "libGLESv2", "libaacextractor", "libamrextractor", + "libarect", + "libasync_safe", + "libaudio_system_headers", + "libaudioclient", + "libaudioclient_headers", + "libaudiofoundation", + "libaudiofoundation_headers", + "libaudiomanager", + "libaudiopolicy", + "libaudioutils", + "libaudioutils_fixedfft", + "libbacktrace", + "libbacktrace_headers", "libbase", + "libbase_headers", + "libbinder_headers", "libbinderthreadstate", + "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", + "libexpat", + "libfifo", "libflacextractor", + "libgrallocusage", + "libgraphicsenv", + "libgui", + "libgui_headers", + "libhardware_headers", "libhidlbase", + "libhidlbase-impl-internal", "libhidlmemory", + "libhidltransport-impl-internal", + "libhwbinder-impl-internal", + "libinput", + "libjsoncpp", + "liblog_headers", + "liblzma", + "libmath", + "libmedia", + "libmedia_codeclist", + "libmedia_headers", + "libmedia_helper", + "libmedia_helper_headers", + "libmedia_midiiowrapper", + "libmedia_omx", + "libmediautils", "libmidiextractor", "libmkvextractor", "libmp3extractor", "libmp4extractor", "libmpeg2extractor", + "libnativebase_headers", + "libnativebridge-headers", + "libnativebridge_lazy", + "libnativeloader-headers", + "libnativeloader_lazy", + "libnativewindow_headers", + "libnblog", "liboggextractor", + "libpackagelistparser", + "libpcre2", + "libpdx", + "libpdx_default_transport", + "libpdx_headers", + "libpdx_uds", "libprocessgroup", + "libprocessgroup_headers", + "libprocinfo", + "libselinux", + "libsonivox", + "libspeexresampler", + "libspeexresampler", + "libstagefright_esds", + "libstagefright_flacdec", + "libstagefright_flacdec", + "libstagefright_foundation", + "libstagefright_foundation_headers", + "libstagefright_foundation_without_imemory", + "libstagefright_headers", + "libstagefright_id3", + "libstagefright_metadatautils", + "libstagefright_mpeg2extractor", + "libstagefright_mpeg2support", + "libsync", + "libsystem_headers", + "libui", + "libui_headers", + "libunwindstack", "libutils", + "libutils_headers", + "libvibrator", + "libvorbisidec", "libwavextractor", + "libwebm", + "media_ndk_headers", + "media_plugin_headers", "updatable-media", } // @@ -168,36 +540,64 @@ func makeApexAvailableWhitelist() map[string][]string { // m["com.android.media.swcodec"] = []string{ "android.frameworks.bufferhub@1.0", + "android.hardware.common-ndk_platform", + "android.hardware.configstore-utils", "android.hardware.configstore@1.0", "android.hardware.configstore@1.1", - "android.hardware.configstore-utils", "android.hardware.graphics.allocator@2.0", "android.hardware.graphics.allocator@3.0", "android.hardware.graphics.bufferqueue@1.0", "android.hardware.graphics.bufferqueue@2.0", + "android.hardware.graphics.common-ndk_platform", "android.hardware.graphics.common@1.0", "android.hardware.graphics.common@1.1", "android.hardware.graphics.common@1.2", "android.hardware.graphics.mapper@2.0", "android.hardware.graphics.mapper@2.1", "android.hardware.graphics.mapper@3.0", - "android.hardware.media@1.0", + "android.hardware.graphics.mapper@4.0", "android.hardware.media.bufferpool@2.0", "android.hardware.media.c2@1.0", "android.hardware.media.omx@1.0", - "android.hidl.memory@1.0", + "android.hardware.media@1.0", + "android.hardware.media@1.0", "android.hidl.memory.token@1.0", + "android.hidl.memory@1.0", "android.hidl.safe_union@1.0", "android.hidl.token@1.0", "android.hidl.token@1.0-utils", + "fmtlib", + "libEGL", + "libFLAC", + "libFLAC-config", + "libFLAC-headers", + "libFraunhoferAAC", + "libarect", + "libasync_safe", + "libaudio_system_headers", + "libaudioutils", + "libaudioutils", + "libaudioutils_fixedfft", + "libavcdec", + "libavcenc", + "libavservices_minijail", "libavservices_minijail", "libbacktrace", + "libbacktrace_headers", "libbase", + "libbase_headers", + "libbinder_headers", "libbinderthreadstate", + "libbluetooth-types-header", + "libbufferhub_headers", "libc++", + "libc_scudo", "libcap", "libcodec2", + "libcodec2_headers", "libcodec2_hidl@1.0", + "libcodec2_hidl@1.1", + "libcodec2_internal", "libcodec2_soft_aacdec", "libcodec2_soft_aacenc", "libcodec2_soft_amrnbdec", @@ -230,73 +630,381 @@ func makeApexAvailableWhitelist() map[string][]string { "libcodec2_soft_vp9dec", "libcodec2_soft_vp9enc", "libcodec2_vndk", - "libc_scudo", "libcutils", + "libcutils_headers", "libdexfile_support", - "libEGL", + "libdvr_headers", "libfmq", + "libfmq", + "libgav1", + "libgralloctypes", + "libgrallocusage", "libgraphicsenv", + "libgsm", + "libgui_bufferqueue_static", + "libgui_headers", "libhardware", + "libhardware_headers", + "libhevcdec", + "libhevcenc", "libhidlbase", + "libhidlbase-impl-internal", "libhidlmemory", + "libhidltransport-impl-internal", + "libhwbinder-impl-internal", "libion", + "libjpeg", + "libjsoncpp", + "liblog_headers", "liblzma", + "libmath", "libmedia_codecserviceregistrant", + "libmedia_headers", "libminijail", + "libminijail_gen_constants", + "libminijail_gen_constants_obj", + "libminijail_gen_syscall", + "libminijail_gen_syscall_obj", + "libminijail_generated", + "libmpeg2dec", + "libnativebase_headers", "libnativebridge_lazy", "libnativeloader_lazy", + "libnativewindow_headers", "libopus", + "libpdx_headers", "libprocessgroup", + "libprocessgroup_headers", "libscudo_wrapper", "libsfplugin_ccodec_utils", "libstagefright_amrnb_common", + "libstagefright_amrnbdec", + "libstagefright_amrnbenc", + "libstagefright_amrwbdec", + "libstagefright_amrwbenc", "libstagefright_bufferpool@2.0.1", "libstagefright_bufferqueue_helper", "libstagefright_enc_common", "libstagefright_flacdec", "libstagefright_foundation", + "libstagefright_foundation_headers", + "libstagefright_headers", + "libstagefright_m4vh263dec", + "libstagefright_m4vh263enc", + "libstagefright_mp3dec", "libsync", + "libsystem_headers", "libui", + "libui_headers", "libunwindstack", "libutils", + "libutils_headers", "libvorbisidec", "libvpx", + "libyuv", + "libyuv_static", + "media_ndk_headers", + "media_plugin_headers", "mediaswcodec", - "prebuilt_libclang_rt", + } + // + // Module separator + // + m["com.android.mediaprovider"] = []string{ + "MediaProvider", + "MediaProviderGoogle", + "fmtlib_ndk", + "guava", + "libbase_ndk", + "libfuse", + "libfuse_jni", + "libnativehelper_header_only", + } + // + // Module separator + // + m["com.android.permission"] = []string{ + "androidx.annotation_annotation", + "androidx.annotation_annotation-nodeps", + "androidx.lifecycle_lifecycle-common", + "androidx.lifecycle_lifecycle-common-java8", + "androidx.lifecycle_lifecycle-common-java8-nodeps", + "androidx.lifecycle_lifecycle-common-nodeps", + "kotlin-annotations", + "kotlin-stdlib", + "kotlin-stdlib-jdk7", + "kotlin-stdlib-jdk8", + "kotlinx-coroutines-android", + "kotlinx-coroutines-android-nodeps", + "kotlinx-coroutines-core", + "kotlinx-coroutines-core-nodeps", + "libprotobuf-java-lite", + "permissioncontroller-statsd", } // // Module separator // 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", + "libc_bootstrap", + "libc_common", + "libc_common_shared", + "libc_common_static", + "libc_dns", + "libc_dynamic_dispatch", + "libc_fortify", + "libc_freebsd", + "libc_freebsd_large_stack", + "libc_gdtoa", + "libc_headers", + "libc_init_dynamic", + "libc_init_static", + "libc_jemalloc_wrapper", + "libc_netbsd", + "libc_nomalloc", + "libc_nopthread", + "libc_openbsd", + "libc_openbsd_large_stack", + "libc_openbsd_ndk", + "libc_pthread", + "libc_static_dispatch", + "libc_syscalls", + "libc_tzcode", + "libc_unwind_static", + "libcutils", + "libcutils_headers", + "libdebuggerd", + "libdebuggerd_common_headers", + "libdebuggerd_handler_core", + "libdebuggerd_handler_fallback", + "libdexfile_external_headers", "libdexfile_support", + "libdexfile_support_static", + "libgtest_prod", + "libjemalloc5", + "liblinker_main", + "liblinker_malloc", + "liblog", + "liblog_headers", + "liblz4", "liblzma", + "libprocessgroup_headers", + "libprocinfo", + "libpropertyinfoparser", + "libscudo", + "libstdc++", + "libsystem_headers", + "libsystemproperties", + "libtombstoned_client_static", "libunwindstack", - "prebuilt_libclang_rt", + "libutils_headers", + "libz", + "libziparchive", } // // Module separator // - m["com.android.resolv"] = []string{"libcrypto", "libnetd_resolv", "libssl"} + 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", + "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", + "libutils_headers", + "netd_event_listener_interface-ndk_platform", + "server_configurable_flags", + "stats_proto", + } // // Module separator // - m["com.android.tethering"] = []string{"libbase", "libc++", "libnativehelper_compat_libc++"} + m["com.android.tethering"] = []string{ + "libbase", + "libc++", + "libnativehelper_compat_libc++", + "android.hardware.tetheroffload.config@1.0", + "fmtlib", + "libbacktrace_headers", + "libbase_headers", + "libbinderthreadstate", + "libcgrouprc", + "libcgrouprc_format", + "libcutils", + "libcutils_headers", + "libhidlbase", + "libhidlbase-impl-internal", + "libhidltransport-impl-internal", + "libhwbinder-impl-internal", + "libjsoncpp", + "liblog", + "liblog_headers", + "libprocessgroup", + "libprocessgroup_headers", + "libsystem_headers", + "libtetherutilsjni", + "libutils", + "libutils_headers", + "libvndksupport", + "tethering-aidl-interfaces-java", + } // // Module separator // - m["com.android.vndk"] = []string{ - "libbacktrace", - "libbinderthreadstate", - "libblas", - "libcompiler_rt", - "libgui", - "libunwind", + m["com.android.wifi"] = []string{ + "PlatformProperties", + "android.hardware.wifi-V1.0-java", + "android.hardware.wifi-V1.1-java", + "android.hardware.wifi-V1.2-java", + "android.hardware.wifi-V1.3-java", + "android.hardware.wifi-V1.4-java", + "android.hardware.wifi.hostapd-V1.0-java", + "android.hardware.wifi.hostapd-V1.1-java", + "android.hardware.wifi.hostapd-V1.2-java", + "android.hardware.wifi.supplicant-V1.0-java", + "android.hardware.wifi.supplicant-V1.1-java", + "android.hardware.wifi.supplicant-V1.2-java", + "android.hardware.wifi.supplicant-V1.3-java", + "android.hidl.base-V1.0-java", + "android.hidl.manager-V1.0-java", + "android.hidl.manager-V1.1-java", + "android.hidl.manager-V1.2-java", + "androidx.annotation_annotation", + "androidx.annotation_annotation-nodeps", + "bouncycastle-unbundled", + "dnsresolver_aidl_interface-V2-java", + "error_prone_annotations", + "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", + "libutils_headers", + "libwifi-jni", + "net-utils-services-common", + "netd_aidl_interface-V2-java", + "netd_aidl_interface-unstable-java", + "netd_event_listener_interface-java", + "netlink-client", + "networkstack-aidl-interfaces-unstable-java", + "networkstack-client", + "services.net", + "wifi-lite-protos", + "wifi-nano-protos", + "wifi-service-pre-jarjar", + "wifi-service-resources", + "prebuilt_androidx.annotation_annotation-nodeps", + } + // + // Module separator + // + m["com.android.sdkext"] = []string{ + "fmtlib_ndk", + "libbase_ndk", + "libprotobuf-cpp-lite-ndk", } // // 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["//any"] = []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", + "libprofile-clang-extras_ndk", + "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 } @@ -1228,6 +1936,47 @@ func (c *flattenedApexContext) InstallBypassMake() bool { return true } +// 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 + if ctx.Host() || a.testApex || a.vndkApex { + return + } + + checkDep := func(ctx android.ModuleContext, am android.ApexModule) { + apexName := ctx.ModuleName() + if am.AvailableFor(apexName) || whitelistedApexAvailable(apexName, am) { + return + } + ctx.ModuleErrorf("requires %q that is not available for the APEX.", am.Name()) + } + + ctx.WalkDepsBlueprint(func(child, parent blueprint.Module) bool { + am, ok := child.(android.ApexModule) + if !ok || !am.CanHaveApexVariants() { + return false + } + + // Check for the direct dependencies that contribute to the payload + if dt, ok := ctx.OtherModuleDependencyTag(child).(dependencyTag); ok { + if dt.payload { + checkDep(ctx, am) + return true + } + return false + } + + // Check for the indirect dependencies if it is considered as part of the APEX + if am.DepIsInSameApex(ctx, am) { + checkDep(ctx, am) + return true + } + + // As soon as the dependency graph crosses the APEX boundary, don't go further. + return false + }) +} + func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild() switch a.properties.ApexType { @@ -1263,6 +2012,8 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { return } + a.checkApexAvailability(ctx) + handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case) // native lib dependencies @@ -1520,23 +2271,6 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { return filesInfo[i].builtFile.String() < filesInfo[j].builtFile.String() }) - // check apex_available requirements - if !ctx.Host() && !a.testApex { - for _, fi := range filesInfo { - if am, ok := fi.module.(android.ApexModule); ok { - // vndk {enabled:true} implies visibility to the vndk apex - if ccm, ok := fi.module.(*cc.Module); ok && ccm.IsVndk() && a.vndkApex { - continue - } - - if !am.AvailableFor(ctx.ModuleName()) && !whitelistedApexAvailable(ctx.ModuleName(), a.vndkApex, fi.module) { - ctx.ModuleErrorf("requires %q that is not available for the APEX", fi.module.Name()) - // don't stop so that we can report other violations in the same run - } - } - } - } - a.installDir = android.PathForModuleInstall(ctx, "apex") a.filesInfo = filesInfo @@ -1580,18 +2314,27 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.buildApexDependencyInfo(ctx) } -func whitelistedApexAvailable(apex string, is_vndk bool, module android.Module) bool { +func whitelistedApexAvailable(apex string, module android.Module) bool { key := apex key = strings.Replace(key, "test_", "", 1) key = strings.Replace(key, "com.android.art.debug", "com.android.art", 1) key = strings.Replace(key, "com.android.art.release", "com.android.art", 1) moduleName := module.Name() - if strings.Contains(moduleName, "prebuilt_libclang_rt") { - // This module has variants that depend on the product being built. - moduleName = "prebuilt_libclang_rt" + // Prebuilt modules (e.g. java_import, etc.) have "prebuilt_" prefix added by the build + // system. Trim the prefix for the check since they are confusing + moduleName = strings.TrimPrefix(moduleName, "prebuilt_") + if strings.HasPrefix(moduleName, "libclang_rt.") { + // This module has many arch variants that depend on the product being built. + // We don't want to list them all + moduleName = "libclang_rt" + } + + if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) { + return true } + key = "//any" if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) { return true } diff --git a/apex/apex_test.go b/apex/apex_test.go index 22f0f6f7d..c5b89e6de 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -469,6 +469,11 @@ func TestBasicApex(t *testing.T) { sdk_version: "none", system_modules: "none", compile_dex: true, + // TODO: remove //apex_available:platform + apex_available: [ + "//apex_available:platform", + "myapex", + ], } java_library { @@ -760,7 +765,7 @@ func TestApexWithStubs(t *testing.T) { ensureNotContains(t, mylibLdFlags, "mylib3/android_arm64_armv8-a_shared_12_myapex/mylib3.so") // Ensure that stubs libs are built without -include flags - mylib2Cflags := ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_static_myapex").Rule("cc").Args["cFlags"] + mylib2Cflags := ctx.ModuleForTests("mylib2", "android_arm64_armv8-a_static").Rule("cc").Args["cFlags"] ensureNotContains(t, mylib2Cflags, "-include ") // Ensure that genstub is invoked with --apex @@ -886,6 +891,7 @@ func TestApexWithRuntimeLibsDependency(t *testing.T) { stubs: { versions: ["10", "20", "30"], }, + apex_available: [ "myapex" ], } cc_library { @@ -1573,6 +1579,7 @@ func TestHeaderLibsDependency(t *testing.T) { export_include_dirs: ["my_include"], system_shared_libs: [], stl: "none", + apex_available: [ "myapex" ], } cc_library { @@ -2210,11 +2217,12 @@ func TestDependenciesInApexManifest(t *testing.T) { } func TestApexName(t *testing.T) { - ctx, _ := testApex(t, ` + ctx, config := testApex(t, ` apex { name: "myapex", key: "myapex.key", apex_name: "com.android.myapex", + native_shared_libs: ["mylib"], } apex_key { @@ -2222,6 +2230,17 @@ func TestApexName(t *testing.T) { public_key: "testkey.avbpubkey", private_key: "testkey.pem", } + + cc_library { + name: "mylib", + srcs: ["mylib.cpp"], + system_shared_libs: [], + stl: "none", + apex_available: [ + "//apex_available:platform", + "myapex", + ], + } `) module := ctx.ModuleForTests("myapex", "android_common_myapex_image") @@ -2229,6 +2248,16 @@ func TestApexName(t *testing.T) { ensureContains(t, apexManifestRule.Args["opt"], "-v name com.android.myapex") apexRule := module.Rule("apexRule") ensureContains(t, apexRule.Args["opt_flags"], "--do_not_check_keyname") + + apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle) + data := android.AndroidMkDataForTest(t, config, "", apexBundle) + name := apexBundle.BaseModuleName() + prefix := "TARGET_" + var builder strings.Builder + data.Custom(&builder, name, prefix, "", data) + androidMk := builder.String() + ensureContains(t, androidMk, "LOCAL_MODULE := mylib.myapex\n") + ensureNotContains(t, androidMk, "LOCAL_MODULE := mylib.com.android.myapex\n") } func TestNonTestApex(t *testing.T) { @@ -3004,6 +3033,7 @@ func TestApexWithApps(t *testing.T) { srcs: ["mylib.cpp"], stl: "none", system_shared_libs: [], + apex_available: [ "myapex" ], } `) @@ -3259,10 +3289,15 @@ func TestApexAvailable(t *testing.T) { }`) // check that libfoo and libbar are created only for myapex, but not for the platform - ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared_myapex") - ensureListNotContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared") - ensureListContains(t, ctx.ModuleVariantsForTests("libbar"), "android_arm64_armv8-a_shared_myapex") - ensureListNotContains(t, ctx.ModuleVariantsForTests("libbar"), "android_arm64_armv8-a_shared") + // TODO(jiyong) the checks for the platform variant are removed because we now create + // the platform variant regardless of the apex_availability. Instead, we will make sure that + // the platform variants are not used from other platform modules. When that is done, + // these checks will be replaced by expecting a specific error message that will be + // emitted when the platform variant is used. + // ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared_myapex") + // ensureListNotContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared") + // ensureListContains(t, ctx.ModuleVariantsForTests("libbar"), "android_arm64_armv8-a_shared_myapex") + // ensureListNotContains(t, ctx.ModuleVariantsForTests("libbar"), "android_arm64_armv8-a_shared") ctx, _ = testApex(t, ` apex { @@ -3311,11 +3346,16 @@ func TestApexAvailable(t *testing.T) { }`) // shared variant of libfoo is only available to myapex - ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared_myapex") - ensureListNotContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared") - // but the static variant is available to both myapex and the platform - ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_static_myapex") - ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_static") + // TODO(jiyong) the checks for the platform variant are removed because we now create + // the platform variant regardless of the apex_availability. Instead, we will make sure that + // the platform variants are not used from other platform modules. When that is done, + // these checks will be replaced by expecting a specific error message that will be + // emitted when the platform variant is used. + // ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared_myapex") + // ensureListNotContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_shared") + // // but the static variant is available to both myapex and the platform + // ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_static_myapex") + // ensureListContains(t, ctx.ModuleVariantsForTests("libfoo"), "android_arm64_armv8-a_static") } func TestOverrideApex(t *testing.T) { @@ -1266,8 +1266,11 @@ func orderStaticModuleDeps(module LinkableInterface, staticDeps []LinkableInterf allTransitiveDeps := make(map[android.Path][]android.Path, len(staticDeps)) staticDepFiles := []android.Path{} for _, dep := range staticDeps { - allTransitiveDeps[dep.OutputFile().Path()] = dep.GetDepsInLinkOrder() - staticDepFiles = append(staticDepFiles, dep.OutputFile().Path()) + // The OutputFile may not be valid for a variant not present, and the AllowMissingDependencies flag is set. + if dep.OutputFile().Valid() { + allTransitiveDeps[dep.OutputFile().Path()] = dep.GetDepsInLinkOrder() + staticDepFiles = append(staticDepFiles, dep.OutputFile().Path()) + } } sharedDepFiles := []android.Path{} for _, sharedDep := range sharedDeps { @@ -1777,6 +1780,9 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) { for _, lib := range deps.SharedLibs { depTag := SharedDepTag + if c.static() { + depTag = SharedFromStaticDepTag + } if inList(lib, deps.ReexportSharedLibHeaders) { depTag = sharedExportDepTag } @@ -2194,7 +2200,7 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { depFile := android.OptionalPath{} switch depTag { - case ndkStubDepTag, SharedDepTag, sharedExportDepTag: + case ndkStubDepTag, SharedDepTag, SharedFromStaticDepTag, sharedExportDepTag: ptr = &depPaths.SharedLibs depPtr = &depPaths.SharedLibsDeps depFile = ccDep.Toc() @@ -2547,9 +2553,17 @@ func (c *Module) AndroidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Write func (c *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { if depTag, ok := ctx.OtherModuleDependencyTag(dep).(DependencyTag); ok { - if cc, ok := dep.(*Module); ok && cc.IsStubs() && depTag.Shared { - // dynamic dep to a stubs lib crosses APEX boundary - return false + if cc, ok := dep.(*Module); ok { + if cc.HasStubsVariants() && depTag.Shared && depTag.Library { + // dynamic dep to a stubs lib crosses APEX boundary + return false + } + if depTag.FromStatic { + // shared_lib dependency from a static lib is considered as crossing + // the APEX boundary because the dependency doesn't actually is + // linked; the dependency is used only during the compilation phase. + return false + } } } return true diff --git a/cc/config/vndk.go b/cc/config/vndk.go index 52bd9f0d0..7b8c3350f 100644 --- a/cc/config/vndk.go +++ b/cc/config/vndk.go @@ -18,48 +18,10 @@ package config // For these libraries, the vendor variants must be installed even if the device // has VndkUseCoreVariant set. var VndkMustUseVendorVariantList = []string{ - "android.hardware.automotive.evs@1.0", - "android.hardware.automotive.vehicle@2.0", - "android.hardware.broadcastradio@2.0", - "android.hardware.camera.device@1.0", - "android.hardware.camera.device@3.2", - "android.hardware.camera.device@3.3", - "android.hardware.camera.device@3.4", - "android.hardware.camera.provider@2.4", - "android.hardware.fastboot@1.0", - "android.hardware.media.bufferpool@1.0", - "android.hardware.neuralnetworks@1.0", - "android.hardware.neuralnetworks@1.1", - "android.hardware.neuralnetworks@1.2", - "android.hardware.neuralnetworks@1.3", "android.hardware.nfc@1.2", - "android.hardware.oemlock@1.0", - "android.hardware.power.stats@1.0", "android.hardware.power-ndk_platform", - "android.hardware.power@1.0", - "android.hardware.power@1.1", - "android.hardware.radio@1.4", - "android.hardware.secure_element@1.0", - "android.hardware.sensors@1.0", - "android.hardware.soundtrigger@2.0", - "android.hardware.soundtrigger@2.0-core", - "android.hardware.soundtrigger@2.1", - "android.hardware.tetheroffload.config@1.0", - "android.hardware.tetheroffload.control@1.0", "android.hardware.vibrator-ndk_platform", - "android.hardware.weaver@1.0", - "android.hardware.wifi.hostapd@1.0", - "android.hardware.wifi.offload@1.0", - "android.hardware.wifi.supplicant@1.0", - "android.hardware.wifi.supplicant@1.1", - "android.hardware.wifi@1.1", - "android.hardware.wifi@1.2", - "android.hardwareundtrigger@2.0", - "android.hardwareundtrigger@2.0-core", - "android.hardwareundtrigger@2.1", - "libaudioroute", "libbinder", - "libcamera_metadata", "libcrypto", "libexpat", "libgatekeeper", @@ -68,45 +30,17 @@ var VndkMustUseVendorVariantList = []string{ "libkeymaster_messages", "libkeymaster_portable", "libmedia_omx", - "libprotobuf-cpp-full", - "libprotobuf-cpp-lite", "libpuresoftkeymasterdevice", "libselinux", "libsoftkeymasterdevice", "libsqlite", "libssl", - "libstagefright_amrnb_common", "libstagefright_bufferpool@2.0", "libstagefright_bufferqueue_helper", - "libstagefright_enc_common", - "libstagefright_flacdec", "libstagefright_foundation", "libstagefright_omx", "libstagefright_omx_utils", - "libstagefright_soft_aacdec", - "libstagefright_soft_aacenc", - "libstagefright_soft_amrdec", - "libstagefright_soft_amrnbenc", - "libstagefright_soft_amrwbenc", - "libstagefright_soft_avcdec", - "libstagefright_soft_avcenc", - "libstagefright_soft_flacdec", - "libstagefright_soft_flacenc", - "libstagefright_soft_g711dec", - "libstagefright_soft_gsmdec", - "libstagefright_soft_hevcdec", - "libstagefright_soft_mp3dec", - "libstagefright_soft_mpeg2dec", - "libstagefright_soft_mpeg4dec", - "libstagefright_soft_mpeg4enc", - "libstagefright_soft_opusdec", - "libstagefright_soft_rawdec", - "libstagefright_soft_vorbisdec", - "libstagefright_soft_vpxdec", - "libstagefright_soft_vpxenc", "libstagefright_xmlparser", "libui", - "libvorbisidec", "libxml2", - "libyuv", } diff --git a/cc/linkable.go b/cc/linkable.go index 3c46d9dd9..2abb11264 100644 --- a/cc/linkable.go +++ b/cc/linkable.go @@ -67,12 +67,17 @@ type DependencyTag struct { ReexportFlags bool ExplicitlyVersioned bool + + FromStatic bool } var ( SharedDepTag = DependencyTag{Name: "shared", Library: true, Shared: true} StaticDepTag = DependencyTag{Name: "static", Library: true} + // Same as SharedDepTag, but from a static lib + SharedFromStaticDepTag = DependencyTag{Name: "shared from static", Library: true, Shared: true, FromStatic: true} + CrtBeginDepTag = DependencyTag{Name: "crtbegin"} CrtEndDepTag = DependencyTag{Name: "crtend"} ) diff --git a/java/app.go b/java/app.go index 6e0ffeb67..9503ec455 100755 --- a/java/app.go +++ b/java/app.go @@ -583,6 +583,13 @@ func (a *AndroidApp) getCertString(ctx android.BaseModuleContext) string { return String(a.overridableAppProperties.Certificate) } +func (a *AndroidApp) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { + if IsJniDepTag(ctx.OtherModuleDependencyTag(dep)) { + return true + } + return a.Library.DepIsInSameApex(ctx, dep) +} + // For OutputFileProducer interface func (a *AndroidApp) OutputFiles(tag string) (android.Paths, error) { switch tag { diff --git a/java/java.go b/java/java.go index ed3dca9e0..c94ea8293 100644 --- a/java/java.go +++ b/java/java.go @@ -757,9 +757,12 @@ func checkProducesJars(ctx android.ModuleContext, dep android.SourceFileProducer type linkType int const ( + // TODO(jiyong) rename these for better readability. Make the allowed + // and disallowed link types explicit javaCore linkType = iota javaSdk javaSystem + javaModule javaPlatform ) @@ -789,6 +792,10 @@ func (m *Module) getLinkType(name string) (ret linkType, stubs bool) { return javaSdk, true case ver.kind == sdkPublic: return javaSdk, false + case name == "android_module_lib_stubs_current": + return javaModule, true + case ver.kind == sdkModule: + return javaModule, false case ver.kind == sdkPrivate || ver.kind == sdkNone || ver.kind == sdkCorePlatform: return javaPlatform, false case !ver.valid(): @@ -824,11 +831,17 @@ func checkLinkType(ctx android.ModuleContext, from *Module, to linkTypeContext, } break case javaSystem: - if otherLinkType == javaPlatform { + if otherLinkType == javaPlatform || otherLinkType == javaModule { ctx.ModuleErrorf("compiles against system API, but dependency %q is compiling against private API."+commonMessage, ctx.OtherModuleName(to)) } break + case javaModule: + if otherLinkType == javaPlatform { + ctx.ModuleErrorf("compiles against module API, but dependency %q is compiling against private API."+commonMessage, + ctx.OtherModuleName(to)) + } + break case javaPlatform: // no restriction on link-type break @@ -1704,8 +1717,10 @@ func (j *Module) hasCode(ctx android.ModuleContext) bool { func (j *Module) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { depTag := ctx.OtherModuleDependencyTag(dep) - // dependencies other than the static linkage are all considered crossing APEX boundary - return depTag == staticLibTag + // Dependencies other than the static linkage are all considered crossing APEX boundary + // Also, a dependency to an sdk member is also considered as such. This is required because + // sdk members should be mutated into APEXes. Refer to sdk.sdkDepsReplaceMutator. + return depTag == staticLibTag || j.IsInAnySdk() } func (j *Module) Stem() string { @@ -2393,6 +2408,14 @@ func (j *Import) SrcJarArgs() ([]string, android.Paths) { return nil, nil } +func (j *Import) DepIsInSameApex(ctx android.BaseModuleContext, dep android.Module) bool { + depTag := ctx.OtherModuleDependencyTag(dep) + // dependencies other than the static linkage are all considered crossing APEX boundary + // Also, a dependency to an sdk member is also considered as such. This is required because + // sdk members should be mutated into APEXes. Refer to sdk.sdkDepsReplaceMutator. + return depTag == staticLibTag || j.IsInAnySdk() +} + // Add compile time check for interface implementation var _ android.IDEInfo = (*Import)(nil) var _ android.IDECustomizedModuleName = (*Import)(nil) diff --git a/java/sdk.go b/java/sdk.go index f388358e5..1c047a353 100644 --- a/java/sdk.go +++ b/java/sdk.go @@ -71,6 +71,7 @@ const ( sdkPublic sdkSystem sdkTest + sdkModule sdkPrivate ) @@ -91,6 +92,8 @@ func (k sdkKind) String() string { return "core" case sdkCorePlatform: return "core_platform" + case sdkModule: + return "module" default: return "invalid" } @@ -256,6 +259,8 @@ func sdkSpecFrom(str string) sdkSpec { kind = sdkSystem case "test": kind = sdkTest + case "module": + kind = sdkModule default: return sdkSpec{sdkInvalid, sdkVersionNone, str} } @@ -382,6 +387,9 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep return toModule("android_test_stubs_current", "framework-res", sdkFrameworkAidlPath(ctx)) case sdkCore: return toModule("core.current.stubs", "", nil) + case sdkModule: + // TODO(146757305): provide .apk and .aidl that have more APIs for modules + return toModule("android_module_lib_stubs_current", "framework-res", sdkFrameworkAidlPath(ctx)) default: panic(fmt.Errorf("invalid sdk %q", sdkVersion.raw)) } diff --git a/java/sdk_test.go b/java/sdk_test.go index 9cabd7772..c815fe3c1 100644 --- a/java/sdk_test.go +++ b/java/sdk_test.go @@ -211,6 +211,15 @@ func TestClasspath(t *testing.T) { java8classpath: []string{"prebuilts/sdk/29/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"}, aidl: "-pprebuilts/sdk/29/public/framework.aidl", }, + { + + name: "module_current", + properties: `sdk_version: "module_current",`, + bootclasspath: []string{"android_module_lib_stubs_current", "core-lambda-stubs"}, + system: "core-current-stubs-system-modules", + java9classpath: []string{"android_module_lib_stubs_current"}, + aidl: "-p" + buildDir + "/framework.aidl", + }, } for _, testcase := range classpathTestcases { diff --git a/java/testing.go b/java/testing.go index c409a46eb..8f979c73e 100644 --- a/java/testing.go +++ b/java/testing.go @@ -146,6 +146,7 @@ func GatherRequiredDepsForTest() string { "android_stubs_current", "android_system_stubs_current", "android_test_stubs_current", + "android_module_lib_stubs_current", "core.current.stubs", "core.platform.api.stubs", "kotlin-stdlib", diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go index 692c2051e..cc893b9ef 100644 --- a/sdk/java_sdk_test.go +++ b/sdk/java_sdk_test.go @@ -34,7 +34,7 @@ func TestBasicSdkWithJavaLibrary(t *testing.T) { result := testSdkWithJava(t, ` sdk { name: "mysdk", - java_header_libs: ["myjavalib"], + java_header_libs: ["sdkmember"], } sdk_snapshot { @@ -47,22 +47,36 @@ func TestBasicSdkWithJavaLibrary(t *testing.T) { java_header_libs: ["sdkmember_mysdk_2"], } - java_import { + java_library { name: "sdkmember", - prefer: false, + srcs: ["Test.java"], + system_modules: "none", + sdk_version: "none", host_supported: true, + apex_available: [ + "//apex_available:platform", + "//apex_available:anyapex", + ], } java_import { name: "sdkmember_mysdk_1", sdk_member_name: "sdkmember", host_supported: true, + apex_available: [ + "//apex_available:platform", + "//apex_available:anyapex", + ], } java_import { name: "sdkmember_mysdk_2", sdk_member_name: "sdkmember", host_supported: true, + apex_available: [ + "//apex_available:platform", + "//apex_available:anyapex", + ], } java_library { |