diff options
Diffstat (limited to 'apex/apex.go')
| -rw-r--r-- | apex/apex.go | 84 |
1 files changed, 59 insertions, 25 deletions
diff --git a/apex/apex.go b/apex/apex.go index fa71ffa5c..9659c3fcd 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -244,19 +244,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", @@ -723,6 +710,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) @@ -1214,6 +1202,7 @@ type apexFile struct { 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 +1238,20 @@ 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.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 } @@ -1664,6 +1657,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,16 +1688,10 @@ 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 - java.Dependency -} - -func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaLibrary) apexFile { +func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib java.Dependency, 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() return af } @@ -1860,6 +1848,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 +1930,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) @@ -1971,7 +2005,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 +2013,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 |