diff options
Diffstat (limited to 'apex/apex.go')
| -rw-r--r-- | apex/apex.go | 61 |
1 files changed, 36 insertions, 25 deletions
diff --git a/apex/apex.go b/apex/apex.go index 045ae828f..fa986cd65 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -669,7 +669,7 @@ func RegisterPreDepsMutators(ctx android.RegisterMutatorsContext) { } func RegisterPostDepsMutators(ctx android.RegisterMutatorsContext) { - ctx.TopDown("apex_deps", apexDepsMutator) + ctx.TopDown("apex_deps", apexDepsMutator).Parallel() ctx.BottomUp("apex", apexMutator).Parallel() ctx.BottomUp("apex_flattened", apexFlattenedMutator).Parallel() ctx.BottomUp("apex_uses", apexUsesMutator).Parallel() @@ -682,33 +682,30 @@ func apexDepsMutator(mctx android.TopDownMutatorContext) { if !mctx.Module().Enabled() { return } - var apexBundles []android.ApexInfo - var directDep bool - if a, ok := mctx.Module().(*apexBundle); ok && !a.vndkApex { - apexBundles = []android.ApexInfo{{ - ApexName: mctx.ModuleName(), - MinSdkVersion: a.minSdkVersion(mctx), - Updatable: a.Updatable(), - }} - directDep = true - } else if am, ok := mctx.Module().(android.ApexModule); ok { - apexBundles = am.ApexVariations() - directDep = false - } - - if len(apexBundles) == 0 { + a, ok := mctx.Module().(*apexBundle) + if !ok || a.vndkApex { return } + apexInfo := android.ApexInfo{ + ApexName: mctx.ModuleName(), + MinSdkVersion: a.minSdkVersion(mctx), + Updatable: a.Updatable(), + } + mctx.WalkDeps(func(child, parent android.Module) bool { + am, ok := child.(android.ApexModule) + if !ok || !am.CanHaveApexVariants() { + return false + } + if !parent.(android.DepIsInSameApex).DepIsInSameApex(mctx, child) && !inAnySdk(child) { + return false + } - 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) || inAnySdk(child)) { - android.UpdateApexDependency(apexBundles, depName, directDep) - am.BuildForApexes(apexBundles) - } + // If the parent is apexBundle, this child is directly depended. + _, directDep := parent.(*apexBundle) + android.UpdateApexDependency(apexInfo, depName, directDep) + am.BuildForApex(apexInfo) + return true }) } @@ -1145,7 +1142,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 + dataPaths []android.DataPath transitiveDep bool moduleDir string @@ -1154,6 +1151,7 @@ type apexFile struct { hostRequiredModuleNames []string jacocoReportClassesFile android.Path // only for javalibs and apps + lintDepSets java.LintDepSets // only for javalibs and apps certificate java.Certificate // only for apps overriddenPackageName string // only for apps @@ -1278,6 +1276,9 @@ type apexBundle struct { // Struct holding the merged notice file paths in different formats mergedNotices android.NoticeOutputs + + // Optional list of lint report zip files for apexes that contain java or app modules + lintReports android.Paths } func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, @@ -1666,9 +1667,16 @@ func apexFileForShBinary(ctx android.BaseModuleContext, sh *sh.ShBinary) apexFil type javaDependency interface { DexJarBuildPath() android.Path JacocoReportClassesFile() android.Path + LintDepSets() java.LintDepSets + Stem() string } +var _ javaDependency = (*java.Library)(nil) +var _ javaDependency = (*java.SdkLibrary)(nil) +var _ javaDependency = (*java.DexImport)(nil) +var _ javaDependency = (*java.SdkLibraryImport)(nil) + func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaDependency, module android.Module) apexFile { dirInApex := "javalib" fileToCopy := lib.DexJarBuildPath() @@ -1676,6 +1684,7 @@ func apexFileForJavaLibrary(ctx android.BaseModuleContext, lib javaDependency, m name := strings.TrimPrefix(module.Name(), "prebuilt_") af := newApexFile(ctx, fileToCopy, name, dirInApex, javaSharedLib, module) af.jacocoReportClassesFile = lib.JacocoReportClassesFile() + af.lintDepSets = lib.LintDepSets() af.stem = lib.Stem() + ".jar" return af } @@ -2275,6 +2284,8 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { a.compatSymlinks = makeCompatSymlinks(a.BaseModuleName(), ctx) a.buildApexDependencyInfo(ctx) + + a.buildLintReports(ctx) } // Enforce that Java deps of the apex are using stable SDKs to compile |