diff options
Diffstat (limited to 'apex/apex.go')
-rw-r--r-- | apex/apex.go | 122 |
1 files changed, 16 insertions, 106 deletions
diff --git a/apex/apex.go b/apex/apex.go index 587f63fe1..dc24df3d1 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -63,14 +63,11 @@ func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) { func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) { ctx.TopDown("apex_info", apexInfoMutator) ctx.BottomUp("apex_unique", apexUniqueVariationsMutator) - ctx.BottomUp("apex_test_for_deps", apexTestForDepsMutator) - ctx.BottomUp("apex_test_for", apexTestForMutator) // Run mark_platform_availability before the apexMutator as the apexMutator needs to know whether // it should create a platform variant. ctx.BottomUp("mark_platform_availability", markPlatformAvailability) ctx.Transition("apex", &apexTransitionMutator{}) ctx.BottomUp("apex_directly_in_any", apexDirectlyInAnyMutator).MutatesDependencies() - ctx.BottomUp("apex_dcla_deps", apexDCLADepsMutator) } type apexBundleProperties struct { @@ -108,11 +105,10 @@ type apexBundleProperties struct { Rros []string // List of bootclasspath fragments that are embedded inside this APEX bundle. - Bootclasspath_fragments []string + Bootclasspath_fragments proptools.Configurable[[]string] // List of systemserverclasspath fragments that are embedded inside this APEX bundle. - Systemserverclasspath_fragments proptools.Configurable[[]string] - ResolvedSystemserverclasspathFragments []string `blueprint:"mutated"` + Systemserverclasspath_fragments proptools.Configurable[[]string] // List of java libraries that are embedded inside this APEX bundle. Java_libs []string @@ -515,7 +511,7 @@ type apexBundle struct { // Text file having the list of individual files that are included in this APEX. Used for // debugging purpose. - installedFilesFile android.WritablePath + installedFilesFile android.Path // List of module names that this APEX is including (to be shown via *-deps-info target). // Used for debugging purpose. @@ -734,7 +730,6 @@ var ( androidAppTag = &dependencyTag{name: "androidApp", payload: true} bpfTag = &dependencyTag{name: "bpf", payload: true} certificateTag = &dependencyTag{name: "certificate"} - dclaTag = &dependencyTag{name: "dcla"} executableTag = &dependencyTag{name: "executable", payload: true} fsTag = &dependencyTag{name: "filesystem", payload: true} bcpfTag = &dependencyTag{name: "bootclasspathFragment", payload: true, sourceOnly: true, memberType: java.BootclasspathFragmentSdkMemberType} @@ -747,7 +742,6 @@ var ( prebuiltTag = &dependencyTag{name: "prebuilt", payload: true} rroTag = &dependencyTag{name: "rro", payload: true} sharedLibTag = &dependencyTag{name: "sharedLib", payload: true} - testForTag = &dependencyTag{name: "test for"} testTag = &dependencyTag{name: "test", payload: true} shBinaryTag = &dependencyTag{name: "shBinary", payload: true} ) @@ -896,13 +890,11 @@ func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) { } } - a.properties.ResolvedSystemserverclasspathFragments = a.properties.Systemserverclasspath_fragments.GetOrDefault(ctx, nil) - // Common-arch dependencies come next commonVariation := ctx.Config().AndroidCommonTarget.Variations() ctx.AddFarVariationDependencies(commonVariation, rroTag, a.properties.Rros...) - ctx.AddFarVariationDependencies(commonVariation, bcpfTag, a.properties.Bootclasspath_fragments...) - ctx.AddFarVariationDependencies(commonVariation, sscpfTag, a.properties.ResolvedSystemserverclasspathFragments...) + ctx.AddFarVariationDependencies(commonVariation, bcpfTag, a.properties.Bootclasspath_fragments.GetOrDefault(ctx, nil)...) + ctx.AddFarVariationDependencies(commonVariation, sscpfTag, a.properties.Systemserverclasspath_fragments.GetOrDefault(ctx, nil)...) ctx.AddFarVariationDependencies(commonVariation, javaLibTag, a.properties.Java_libs...) ctx.AddFarVariationDependencies(commonVariation, fsTag, a.properties.Filesystems...) ctx.AddFarVariationDependencies(commonVariation, compatConfigTag, a.properties.Compat_configs...) @@ -952,33 +944,6 @@ func (a *apexBundle) OverridablePropertiesDepsMutator(ctx android.BottomUpMutato } } -func apexDCLADepsMutator(mctx android.BottomUpMutatorContext) { - if !mctx.Config().ApexTrimEnabled() { - return - } - if a, ok := mctx.Module().(*apexBundle); ok && a.overridableProperties.Trim_against != nil { - commonVariation := mctx.Config().AndroidCommonTarget.Variations() - mctx.AddFarVariationDependencies(commonVariation, dclaTag, String(a.overridableProperties.Trim_against)) - } else if o, ok := mctx.Module().(*OverrideApex); ok { - for _, p := range o.GetProperties() { - properties, ok := p.(*overridableProperties) - if !ok { - continue - } - if properties.Trim_against != nil { - commonVariation := mctx.Config().AndroidCommonTarget.Variations() - mctx.AddFarVariationDependencies(commonVariation, dclaTag, String(properties.Trim_against)) - } - } - } -} - -type DCLAInfo struct { - ProvidedLibs []string -} - -var DCLAInfoProvider = blueprint.NewMutatorProvider[DCLAInfo]("apex_info") - var _ ApexInfoMutator = (*apexBundle)(nil) func (a *apexBundle) ApexVariationName() string { @@ -1087,12 +1052,6 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) { child.(android.ApexModule).BuildForApex(apexInfo) // leave a mark! return true }) - - if a.dynamic_common_lib_apex() { - android.SetProvider(mctx, DCLAInfoProvider, DCLAInfo{ - ProvidedLibs: a.properties.Native_shared_libs.GetOrDefault(mctx, nil), - }) - } } type ApexInfoMutator interface { @@ -1185,40 +1144,6 @@ func apexUniqueVariationsMutator(mctx android.BottomUpMutatorContext) { } } -// apexTestForDepsMutator checks if this module is a test for an apex. If so, add a dependency on -// the apex in order to retrieve its contents later. -// TODO(jiyong): move this to android/apex.go? -func apexTestForDepsMutator(mctx android.BottomUpMutatorContext) { - if !mctx.Module().Enabled(mctx) { - return - } - if am, ok := mctx.Module().(android.ApexModule); ok { - if testFor := am.TestFor(); len(testFor) > 0 { - mctx.AddFarVariationDependencies([]blueprint.Variation{ - {Mutator: "os", Variation: am.Target().OsVariation()}, - {"arch", "common"}, - }, testForTag, testFor...) - } - } -} - -// TODO(jiyong): move this to android/apex.go? -func apexTestForMutator(mctx android.BottomUpMutatorContext) { - if !mctx.Module().Enabled(mctx) { - return - } - if _, ok := mctx.Module().(android.ApexModule); ok { - var contents []*android.ApexContents - for _, testFor := range mctx.GetDirectDepsWithTag(testForTag) { - abInfo, _ := android.OtherModuleProvider(mctx, testFor, android.ApexBundleInfoProvider) - contents = append(contents, abInfo.Contents) - } - android.SetProvider(mctx, android.ApexTestForInfoProvider, android.ApexTestForInfo{ - ApexContents: contents, - }) - } -} - // markPlatformAvailability marks whether or not a module can be available to platform. A module // cannot be available to platform if 1) it is explicitly marked as not available (i.e. // "//apex_available:platform" is absent) or 2) it depends on another module that isn't (or can't @@ -1442,19 +1367,6 @@ func (a *apexBundle) dynamic_common_lib_apex() bool { return proptools.BoolDefault(a.properties.Dynamic_common_lib_apex, false) } -// See the list of libs to trim -func (a *apexBundle) libs_to_trim(ctx android.ModuleContext) []string { - dclaModules := ctx.GetDirectDepsWithTag(dclaTag) - if len(dclaModules) > 1 { - panic(fmt.Errorf("expected exactly at most one dcla dependency, got %d", len(dclaModules))) - } - if len(dclaModules) > 0 { - DCLAInfo, _ := android.OtherModuleProvider(ctx, dclaModules[0], DCLAInfoProvider) - return DCLAInfo.ProvidedLibs - } - return []string{} -} - // These functions are interfacing with cc/sanitizer.go. The entire APEX (along with all of its // members) can be sanitized, either forcibly, or by the global configuration. For some of the // sanitizers, extra dependencies can be forcibly added as well. @@ -2159,8 +2071,7 @@ func (a *apexBundle) depVisitor(vctx *visitorContext, ctx android.ModuleContext, af := apexFileForNativeLibrary(ctx, ch, vctx.handleSpecialLibs) af.transitiveDep = true - abInfo, _ := android.ModuleProvider(ctx, android.ApexBundleInfoProvider) - if !abInfo.Contents.DirectlyInApex(depName) && (ch.IsStubs() || ch.HasStubsVariants()) { + if ch.IsStubs() || ch.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. // In case no APEX is having the lib, the lib is installed to the system @@ -2664,7 +2575,10 @@ func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext return } - abInfo, _ := android.ModuleProvider(ctx, android.ApexBundleInfoProvider) + librariesDirectlyInApex := make(map[string]bool) + ctx.VisitDirectDepsProxyWithTag(sharedLibTag, func(dep android.ModuleProxy) { + librariesDirectlyInApex[ctx.OtherModuleName(dep)] = true + }) a.WalkPayloadDeps(ctx, func(ctx android.BaseModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) bool { if ccm, ok := to.(*cc.Module); ok { @@ -2690,7 +2604,7 @@ func (a *apexBundle) checkStaticLinkingToStubLibraries(ctx android.ModuleContext return false } - isStubLibraryFromOtherApex := ccm.HasStubsVariants() && !abInfo.Contents.DirectlyInApex(toName) + isStubLibraryFromOtherApex := ccm.HasStubsVariants() && !librariesDirectlyInApex[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)) @@ -2723,7 +2637,7 @@ func (a *apexBundle) checkUpdatable(ctx android.ModuleContext) { // checkClasspathFragments enforces that all classpath fragments in deps generate classpaths.proto config. func (a *apexBundle) checkClasspathFragments(ctx android.ModuleContext) { - ctx.VisitDirectDeps(func(module android.Module) { + ctx.VisitDirectDepsProxy(func(module android.ModuleProxy) { if tag := ctx.OtherModuleDependencyTag(module); tag == bcpfTag || tag == sscpfTag { info, _ := android.OtherModuleProvider(ctx, module, java.ClasspathFragmentProtoContentInfoProvider) if !info.ClasspathFragmentProtoGenerated { @@ -2830,12 +2744,12 @@ func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) { // checkStaticExecutable ensures that executables in an APEX are not static. func (a *apexBundle) checkStaticExecutables(ctx android.ModuleContext) { - ctx.VisitDirectDeps(func(module android.Module) { + ctx.VisitDirectDepsProxy(func(module android.ModuleProxy) { if ctx.OtherModuleDependencyTag(module) != executableTag { return } - if l, ok := module.(cc.LinkableInterface); ok && l.StaticExecutable() { + if android.OtherModuleProviderOrDefault(ctx, module, cc.LinkableInfoKey).StaticExecutable { apex := a.ApexVariationName() exec := ctx.OtherModuleName(module) if isStaticExecutableAllowed(apex, exec) { @@ -2861,8 +2775,8 @@ func isStaticExecutableAllowed(apex string, exec string) bool { // Collect information for opening IDE project files in java/jdeps.go. func (a *apexBundle) IDEInfo(ctx android.BaseModuleContext, dpInfo *android.IdeInfo) { dpInfo.Deps = append(dpInfo.Deps, a.properties.Java_libs...) - dpInfo.Deps = append(dpInfo.Deps, a.properties.Bootclasspath_fragments...) - dpInfo.Deps = append(dpInfo.Deps, a.properties.ResolvedSystemserverclasspathFragments...) + dpInfo.Deps = append(dpInfo.Deps, a.properties.Bootclasspath_fragments.GetOrDefault(ctx, nil)...) + dpInfo.Deps = append(dpInfo.Deps, a.properties.Systemserverclasspath_fragments.GetOrDefault(ctx, nil)...) } func init() { @@ -2941,10 +2855,6 @@ func rBcpPackages() map[string][]string { } } -func (a *apexBundle) IsTestApex() bool { - return a.testApex -} - // verifyNativeImplementationLibs compares the list of transitive implementation libraries used to link native // libraries in the apex against the list of implementation libraries in the apex, ensuring that none of the // libraries in the apex have references to private APIs from outside the apex. |