Merge "Build transitive lint reports for apex modules"

This commit is contained in:
Treehugger Robot
2020-07-24 11:50:39 +00:00
committed by Gerrit Code Review
8 changed files with 157 additions and 42 deletions

View File

@@ -353,6 +353,10 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData {
if apexType == imageApex {
fmt.Fprintln(w, "ALL_MODULES.$(my_register_name).BUNDLE :=", a.bundleModuleFile.String())
}
if len(a.lintReports) > 0 {
fmt.Fprintln(w, "ALL_MODULES.$(my_register_name).LINT_REPORTS :=",
strings.Join(a.lintReports.Strings(), " "))
}
if a.installedFilesFile != nil {
goal := "checkbuild"

View File

@@ -1151,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
@@ -1275,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,
@@ -1663,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()
@@ -1673,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
}
@@ -2272,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

View File

@@ -815,3 +815,12 @@ func (a *apexBundle) buildApexDependencyInfo(ctx android.ModuleContext) {
},
})
}
func (a *apexBundle) buildLintReports(ctx android.ModuleContext) {
depSetsBuilder := java.NewLintDepSetBuilder()
for _, fi := range a.filesInfo {
depSetsBuilder.Transitive(fi.lintDepSets)
}
a.lintReports = java.BuildModuleLintReportZips(ctx, depSetsBuilder.Build())
}