summaryrefslogtreecommitdiff
path: root/apex/apex.go
diff options
context:
space:
mode:
Diffstat (limited to 'apex/apex.go')
-rw-r--r--apex/apex.go245
1 files changed, 127 insertions, 118 deletions
diff --git a/apex/apex.go b/apex/apex.go
index fa71ffa5c..10c16f5b8 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -93,69 +93,6 @@ func makeApexAvailableWhitelist() map[string][]string {
//
// Module separator
//
- artApexContents := []string{
- "art_cmdlineparser_headers",
- "art_disassembler_headers",
- "art_libartbase_headers",
- "bionic_libc_platform_headers",
- "core-repackaged-icu4j",
- "cpp-define-generator-asm-support",
- "cpp-define-generator-definitions",
- "crtbegin_dynamic",
- "crtbegin_dynamic1",
- "crtbegin_so1",
- "crtbrand",
- "dex2oat_headers",
- "dt_fd_forward_export",
- "icu4c_extra_headers",
- "javavm_headers",
- "jni_platform_headers",
- "libPlatformProperties",
- "libadbconnection_client",
- "libadbconnection_server",
- "libandroidicuinit",
- "libart_runtime_headers_ndk",
- "libartd-disassembler",
- "libdexfile_all_headers",
- "libdexfile_external_headers",
- "libdexfile_support",
- "libdmabufinfo",
- "libexpat",
- "libfdlibm",
- "libicui18n_headers",
- "libicuuc",
- "libicuuc_headers",
- "libicuuc_stubdata",
- "libjdwp_headers",
- "liblz4",
- "liblzma",
- "libmeminfo",
- "libnativebridge-headers",
- "libnativehelper_header_only",
- "libnativeloader-headers",
- "libnpt_headers",
- "libopenjdkjvmti_headers",
- "libperfetto_client_experimental",
- "libprocinfo",
- "libunwind_llvm",
- "libunwindstack",
- "libv8",
- "libv8base",
- "libv8gen",
- "libv8platform",
- "libv8sampler",
- "libv8src",
- "libvixl",
- "libvixld",
- "libz",
- "libziparchive",
- "perfetto_trace_protos",
- }
- m["com.android.art.debug"] = artApexContents
- m["com.android.art.release"] = artApexContents
- //
- // Module separator
- //
m["com.android.bluetooth.updatable"] = []string{
"android.hardware.audio.common@5.0",
"android.hardware.bluetooth.a2dp@1.0",
@@ -244,19 +181,6 @@ func makeApexAvailableWhitelist() map[string][]string {
//
// Module separator
//
- m["com.android.extservices"] = []string{
- "flatbuffer_headers",
- "liblua",
- "libtextclassifier",
- "libtextclassifier_hash_static",
- "libtflite_static",
- "libutf",
- "libz_current",
- "tensorflow_headers",
- }
- //
- // Module separator
- //
m["com.android.neuralnetworks"] = []string{
"android.hardware.neuralnetworks@1.0",
"android.hardware.neuralnetworks@1.1",
@@ -300,7 +224,10 @@ func makeApexAvailableWhitelist() map[string][]string {
"android.hidl.token@1.0",
"android.hidl.token@1.0-utils",
"bionic_libc_platform_headers",
+ "exoplayer2-extractor",
+ "exoplayer2-extractor-annotation-stubs",
"gl_headers",
+ "jsr305",
"libEGL",
"libEGL_blobCache",
"libEGL_getProcAddress",
@@ -555,12 +482,6 @@ func makeApexAvailableWhitelist() map[string][]string {
// 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",
@@ -631,13 +552,21 @@ func makeApexAvailableWhitelist() map[string][]string {
// Module separator
//
m["com.android.tethering"] = []string{
- "libnativehelper_compat_libc++",
- "android.hardware.tetheroffload.config@1.0",
+ "android.hardware.tetheroffload.config-V1.0-java",
+ "android.hardware.tetheroffload.control-V1.0-java",
+ "android.hidl.base-V1.0-java",
+ "ipmemorystore-aidl-interfaces-java",
"libcgrouprc",
"libcgrouprc_format",
+ "libnativehelper_compat_libc++",
"libtetherutilsjni",
"libvndksupport",
+ "net-utils-framework-common",
+ "netd_aidl_interface-V3-java",
+ "netlink-client",
+ "networkstack-aidl-interfaces-java",
"tethering-aidl-interfaces-java",
+ "TetheringApiCurrentLib",
}
//
// Module separator
@@ -661,8 +590,6 @@ func makeApexAvailableWhitelist() map[string][]string {
"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",
@@ -684,7 +611,6 @@ func makeApexAvailableWhitelist() map[string][]string {
"wifi-nano-protos",
"wifi-service-pre-jarjar",
"wifi-service-resources",
- "prebuilt_androidx.annotation_annotation-nodeps",
}
//
// Module separator
@@ -704,6 +630,15 @@ func makeApexAvailableWhitelist() map[string][]string {
// Module separator
//
m[android.AvailableToAnyApex] = []string{
+ // TODO(b/156996905) Set apex_available/min_sdk_version for androidx/extras support libraries
+ "androidx",
+ "androidx-constraintlayout_constraintlayout",
+ "androidx-constraintlayout_constraintlayout-nodeps",
+ "androidx-constraintlayout_constraintlayout-solver",
+ "androidx-constraintlayout_constraintlayout-solver-nodeps",
+ "com.google.android.material_material",
+ "com.google.android.material_material-nodeps",
+
"libatomic",
"libclang_rt",
"libgcc_stripped",
@@ -723,6 +658,7 @@ func init() {
android.RegisterModuleType("apex_defaults", defaultsFactory)
android.RegisterModuleType("prebuilt_apex", PrebuiltFactory)
android.RegisterModuleType("override_apex", overrideApexFactory)
+ android.RegisterModuleType("apex_set", apexSetFactory)
android.PreDepsMutators(RegisterPreDepsMutators)
android.PostDepsMutators(RegisterPostDepsMutators)
@@ -759,7 +695,7 @@ func apexDepsMutator(mctx android.TopDownMutatorContext) {
apexBundles = []android.ApexInfo{{
ApexName: mctx.ModuleName(),
MinSdkVersion: a.minSdkVersion(mctx),
- Updatable: proptools.Bool(a.properties.Updatable),
+ Updatable: a.Updatable(),
}}
directDep = true
} else if am, ok := mctx.Module().(android.ApexModule); ok {
@@ -1208,12 +1144,14 @@ func (class apexFileClass) NameInMake() string {
// apexFile represents a file in an APEX bundle
type apexFile struct {
builtFile android.Path
+ stem string
moduleName string
installDir string
class apexFileClass
module android.Module
// list of symlinks that will be created in installDir that point to this apexFile
symlinks []string
+ dataPaths android.Paths
transitiveDep bool
moduleDir string
@@ -1249,16 +1187,27 @@ func (af *apexFile) Ok() bool {
return af.builtFile != nil && af.builtFile.String() != ""
}
+func (af *apexFile) apexRelativePath(path string) string {
+ return filepath.Join(af.installDir, path)
+}
+
// Path() returns path of this apex file relative to the APEX root
func (af *apexFile) Path() string {
- return filepath.Join(af.installDir, af.builtFile.Base())
+ return af.apexRelativePath(af.Stem())
+}
+
+func (af *apexFile) Stem() string {
+ if af.stem != "" {
+ return af.stem
+ }
+ return af.builtFile.Base()
}
// SymlinkPaths() returns paths of the symlinks (if any) relative to the APEX root
func (af *apexFile) SymlinkPaths() []string {
var ret []string
for _, symlink := range af.symlinks {
- ret = append(ret, filepath.Join(af.installDir, symlink))
+ ret = append(ret, af.apexRelativePath(symlink))
}
return ret
}
@@ -1458,19 +1407,7 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
target,
a.getImageVariation(config))
}
-
- if strings.HasPrefix(ctx.ModuleName(), "com.android.runtime") && target.Os.Class == android.Device {
- for _, sanitizer := range ctx.Config().SanitizeDevice() {
- if sanitizer == "hwaddress" {
- addDependenciesForNativeModules(ctx,
- ApexNativeDependencies{[]string{"libclang_rt.hwasan-aarch64-android"}, nil, nil, nil},
- target, a.getImageVariation(config))
- break
- }
- }
- }
}
-
}
// For prebuilt_etc, use the first variant (64 on 64/32bit device,
@@ -1602,6 +1539,21 @@ func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizer
return android.InList(sanitizerName, globalSanitizerNames)
}
+func (a *apexBundle) AddSanitizerDependencies(ctx android.BottomUpMutatorContext, sanitizerName string) {
+ if ctx.Device() && sanitizerName == "hwaddress" && strings.HasPrefix(a.Name(), "com.android.runtime") {
+ for _, target := range ctx.MultiTargets() {
+ if target.Arch.ArchType.Multilib == "lib64" {
+ ctx.AddFarVariationDependencies(append(target.Variations(), []blueprint.Variation{
+ {Mutator: "image", Variation: a.getImageVariation(ctx.DeviceConfig())},
+ {Mutator: "link", Variation: "shared"},
+ {Mutator: "version", Variation: ""}, // "" is the non-stub variant
+ }...), sharedLibTag, "libclang_rt.hwasan-aarch64-android")
+ break
+ }
+ }
+ }
+}
+
var _ cc.Coverage = (*apexBundle)(nil)
func (a *apexBundle) IsNativeCoverageNeeded(ctx android.BaseModuleContext) bool {
@@ -1664,6 +1616,7 @@ func apexFileForExecutable(ctx android.BaseModuleContext, cc *cc.Module) apexFil
fileToCopy := cc.OutputFile().Path()
af := newApexFile(ctx, fileToCopy, cc.Name(), dirInApex, nativeExecutable, cc)
af.symlinks = cc.Symlinks()
+ af.dataPaths = cc.DataPaths()
return af
}
@@ -1694,17 +1647,17 @@ func apexFileForShBinary(ctx android.BaseModuleContext, sh *android.ShBinary) ap
return af
}
-// TODO(b/146586360): replace javaLibrary(in apex/apex.go) with java.Dependency
-type javaLibrary interface {
- android.Module
+type javaDependency interface {
java.Dependency
+ Stem() string
}
-func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaLibrary) apexFile {
+func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaDependency, module android.Module) apexFile {
dirInApex := "javalib"
fileToCopy := lib.DexJar()
- af := newApexFile(ctx, fileToCopy, lib.Name(), dirInApex, javaSharedLib, lib)
+ af := newApexFile(ctx, fileToCopy, module.Name(), dirInApex, javaSharedLib, module)
af.jacocoReportClassesFile = lib.JacocoReportClassesFile()
+ af.stem = lib.Stem() + ".jar"
return af
}
@@ -1810,6 +1763,12 @@ func (a *apexBundle) minSdkVersion(ctx android.BaseModuleContext) int {
return intVer
}
+func (a *apexBundle) Updatable() bool {
+ return proptools.Bool(a.properties.Updatable)
+}
+
+var _ android.ApexBundleDepsInfoIntf = (*apexBundle)(nil)
+
// 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
@@ -1851,7 +1810,7 @@ func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
}
func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) {
- if proptools.Bool(a.properties.Updatable) {
+ if a.Updatable() {
if String(a.properties.Min_sdk_version) == "" {
ctx.PropertyErrorf("updatable", "updatable APEXes should set min_sdk_version as well")
}
@@ -1860,6 +1819,51 @@ func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) {
}
}
+// Ensures that a lib providing stub isn't statically linked
+func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext) {
+ // Practically, we only care about regular APEXes on the device.
+ if ctx.Host() || a.testApex || a.vndkApex {
+ return
+ }
+
+ a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool {
+ if ccm, ok := to.(*cc.Module); ok {
+ apexName := ctx.ModuleName()
+ fromName := ctx.OtherModuleName(from)
+ toName := ctx.OtherModuleName(to)
+
+ // 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
+ }
+
+ // TODO(jiyong) remove this check when R is published to AOSP. Currently, libstatssocket
+ // is capable of providing a stub variant, but is being statically linked from the bluetooth
+ // APEX.
+ if toName == "libstatssocket" {
+ return false
+ }
+
+ // The dynamic linker and crash_dump tool in the runtime APEX is the only exception to this rule.
+ // It can't make the static dependencies dynamic because it can't
+ // do the dynamic linking for itself.
+ if apexName == "com.android.runtime" && (fromName == "linker" || fromName == "crash_dump") {
+ return false
+ }
+
+ isStubLibraryFromOtherApex := ccm.HasStubsVariants() && !android.DirectlyInApex(apexName, toName)
+ if isStubLibraryFromOtherApex && !externalDep {
+ ctx.ModuleErrorf("%q required by %q is a native library providing stub. "+
+ "It shouldn't be included in this APEX via static linking. Dependency path: %s", to.String(), fromName, ctx.GetPathString(false))
+ }
+
+ }
+ return true
+ })
+}
+
func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
buildFlattenedAsDefault := ctx.Config().FlattenApex() && !ctx.Config().UnbundledBuild()
switch a.properties.ApexType {
@@ -1897,6 +1901,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.checkApexAvailability(ctx)
a.checkUpdatable(ctx)
+ a.checkStaticLinkingToStubLibraries(ctx)
handleSpecialLibs := !android.Bool(a.properties.Ignore_system_library_special_case)
@@ -1941,13 +1946,13 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
case sharedLibTag, jniLibTag:
isJniLib := depTag == jniLibTag
if c, ok := child.(*cc.Module); ok {
- // bootstrap bionic libs are treated as provided by system
- if c.HasStubsVariants() && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) {
- provideNativeLibs = append(provideNativeLibs, c.OutputFile().Path().Base())
- }
fi := apexFileForNativeLibrary(ctx, c, handleSpecialLibs)
fi.isJniLib = isJniLib
filesInfo = append(filesInfo, fi)
+ // bootstrap bionic libs are treated as provided by system
+ if c.HasStubsVariants() && !cc.InstallToBootstrap(c.BaseModuleName(), ctx.Config()) {
+ provideNativeLibs = append(provideNativeLibs, fi.Stem())
+ }
return true // track transitive dependencies
} else {
propertyName := "native_shared_libs"
@@ -1971,7 +1976,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
case javaLibTag:
if javaLib, ok := child.(*java.Library); ok {
- af := apexFileForJavaLibrary(ctx, javaLib)
+ af := apexFileForJavaLibrary(ctx, javaLib, javaLib)
if !af.Ok() {
ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
} else {
@@ -1979,7 +1984,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
return true // track transitive dependencies
}
} else if sdkLib, ok := child.(*java.SdkLibrary); ok {
- af := apexFileForJavaLibrary(ctx, sdkLib)
+ af := apexFileForJavaLibrary(ctx, sdkLib, sdkLib)
if !af.Ok() {
ctx.PropertyErrorf("java_libs", "%q is not configured to be compiled into dex", depName)
return false
@@ -2067,6 +2072,8 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// don't include it in this APEX
return false
}
+ af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
+ af.transitiveDep = true
if !a.Host() && !android.DirectlyInApex(ctx.ModuleName(), ctx.OtherModuleName(cc)) && (cc.IsStubs() || cc.HasStubsVariants()) {
// If the dependency is a stubs lib, don't include it in this APEX,
// but make sure that the lib is installed on the device.
@@ -2078,12 +2085,10 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if !android.DirectlyInAnyApex(ctx, cc.Name()) && !android.InList(cc.BaseModuleName(), a.requiredDeps) {
a.requiredDeps = append(a.requiredDeps, cc.BaseModuleName())
}
- requireNativeLibs = append(requireNativeLibs, cc.OutputFile().Path().Base())
+ requireNativeLibs = append(requireNativeLibs, af.Stem())
// Don't track further
return false
}
- af := apexFileForNativeLibrary(ctx, cc, handleSpecialLibs)
- af.transitiveDep = true
filesInfo = append(filesInfo, af)
return true // track transitive dependencies
}
@@ -2191,7 +2196,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// We don't need the optimization for updatable APEXes, as it might give false signal
// to the system health when the APEXes are still bundled (b/149805758)
- if proptools.Bool(a.properties.Updatable) && a.properties.ApexType == imageApex {
+ if a.Updatable() && a.properties.ApexType == imageApex {
a.linkToSystemLib = false
}
@@ -2257,6 +2262,10 @@ func normalizeModuleName(moduleName string) string {
// We don't want to list them all
moduleName = "libclang_rt"
}
+ if strings.HasPrefix(moduleName, "androidx.") {
+ // TODO(b/156996905) Set apex_available/min_sdk_version for androidx support libraries
+ moduleName = "androidx"
+ }
return moduleName
}