diff options
-rw-r--r-- | apex/apex.go | 12 | ||||
-rw-r--r-- | apex/builder.go | 4 | ||||
-rw-r--r-- | java/app_import.go | 4 | ||||
-rw-r--r-- | java/base.go | 3 | ||||
-rw-r--r-- | java/java.go | 8 | ||||
-rw-r--r-- | java/lint.go | 90 | ||||
-rw-r--r-- | java/sdk_library.go | 13 |
7 files changed, 56 insertions, 78 deletions
diff --git a/apex/apex.go b/apex/apex.go index 9e3f288ce..df80b3a80 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -588,7 +588,7 @@ type apexFile struct { dataPaths []android.DataPath // becomes LOCAL_TEST_DATA jacocoReportClassesFile android.Path // only for javalibs and apps - lintDepSets java.LintDepSets // only for javalibs and apps + lintInfo *java.LintInfo // only for javalibs and apps certificate java.Certificate // only for apps overriddenPackageName string // only for apps @@ -1667,7 +1667,6 @@ type javaModule interface { BaseModuleName() string DexJarBuildPath(ctx android.ModuleErrorfContext) java.OptionalDexJarPath JacocoReportClassesFile() android.Path - LintDepSets() java.LintDepSets Stem() string } @@ -1687,7 +1686,9 @@ func apexFileForJavaModuleWithFile(ctx android.ModuleContext, module javaModule, dirInApex := "javalib" af := newApexFile(ctx, dexImplementationJar, module.BaseModuleName(), dirInApex, javaSharedLib, module) af.jacocoReportClassesFile = module.JacocoReportClassesFile() - af.lintDepSets = module.LintDepSets() + if lintInfo, ok := android.OtherModuleProvider(ctx, module, java.LintProvider); ok { + af.lintInfo = lintInfo + } af.customStem = module.Stem() + ".jar" // TODO: b/338641779 - Remove special casing of sdkLibrary once bcpf and sscpf depends // on the implementation library @@ -1725,7 +1726,6 @@ type androidApp interface { JacocoReportClassesFile() android.Path Certificate() java.Certificate BaseModuleName() string - LintDepSets() java.LintDepSets PrivAppAllowlist() android.OptionalPath } @@ -1761,7 +1761,9 @@ func apexFilesForAndroidApp(ctx android.BaseModuleContext, aapp androidApp) []ap af := newApexFile(ctx, fileToCopy, aapp.BaseModuleName(), dirInApex, app, aapp) af.jacocoReportClassesFile = aapp.JacocoReportClassesFile() - af.lintDepSets = aapp.LintDepSets() + if lintInfo, ok := android.OtherModuleProvider(ctx, aapp, java.LintProvider); ok { + af.lintInfo = lintInfo + } af.certificate = aapp.Certificate() if app, ok := aapp.(interface { diff --git a/apex/builder.go b/apex/builder.go index 437189fdb..5ddbc1861 100644 --- a/apex/builder.go +++ b/apex/builder.go @@ -1158,7 +1158,9 @@ 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) + if fi.lintInfo != nil { + depSetsBuilder.Transitive(fi.lintInfo) + } } a.lintReports = java.BuildModuleLintReportZips(ctx, depSetsBuilder.Build()) diff --git a/java/app_import.go b/java/app_import.go index 045a89a34..a54cf2fc3 100644 --- a/java/app_import.go +++ b/java/app_import.go @@ -533,10 +533,6 @@ func (a *AndroidAppImport) MinSdkVersion(ctx android.EarlyModuleContext) android return android.SdkSpecPrivate.ApiLevel } -func (a *AndroidAppImport) LintDepSets() LintDepSets { - return LintDepSets{} -} - var _ android.ApexModule = (*AndroidAppImport)(nil) // Implements android.ApexModule diff --git a/java/base.go b/java/base.go index 3d42f4609..fc8cf95ba 100644 --- a/java/base.go +++ b/java/base.go @@ -707,9 +707,6 @@ func setOutputFiles(ctx android.ModuleContext, m Module) { ctx.SetOutputFiles(android.Paths{m.dexer.proguardDictionary.Path()}, ".proguard_map") } ctx.SetOutputFiles(m.properties.Generated_srcjars, ".generated_srcjars") - if m.linter.outputs.xml != nil { - ctx.SetOutputFiles(android.Paths{m.linter.outputs.xml}, ".lint") - } } func InitJavaModule(module android.DefaultableModule, hod android.HostOrDeviceSupported) { diff --git a/java/java.go b/java/java.go index 95f4fd892..1fa083058 100644 --- a/java/java.go +++ b/java/java.go @@ -2607,10 +2607,6 @@ func (a *Import) JacocoReportClassesFile() android.Path { return nil } -func (j *Import) LintDepSets() LintDepSets { - return LintDepSets{} -} - func (j *Import) getStrictUpdatabilityLinting() bool { return false } @@ -3120,10 +3116,6 @@ func (a *DexImport) JacocoReportClassesFile() android.Path { return nil } -func (a *DexImport) LintDepSets() LintDepSets { - return LintDepSets{} -} - func (j *DexImport) IsInstallable() bool { return true } diff --git a/java/lint.go b/java/lint.go index 6782adc5f..5cd49a8b7 100644 --- a/java/lint.go +++ b/java/lint.go @@ -19,6 +19,7 @@ import ( "sort" "strings" + "github.com/google/blueprint" "github.com/google/blueprint/proptools" "android/soong/android" @@ -90,7 +91,6 @@ type linter struct { compileSdkKind android.SdkKind javaLanguageLevel string kotlinLanguageLevel string - outputs lintOutputs properties LintProperties extraMainlineLintErrors []string compile_data android.Paths @@ -100,22 +100,7 @@ type linter struct { buildModuleReportZip bool } -type lintOutputs struct { - html android.Path - text android.Path - xml android.Path - referenceBaseline android.Path - - depSets LintDepSets -} - -type lintOutputsIntf interface { - lintOutputs() *lintOutputs -} - type LintDepSetsIntf interface { - LintDepSets() LintDepSets - // Methods used to propagate strict_updatability_linting values. GetStrictUpdatabilityLinting() bool SetStrictUpdatabilityLinting(bool) @@ -144,15 +129,15 @@ func (l LintDepSetsBuilder) Direct(html, text, xml android.Path) LintDepSetsBuil return l } -func (l LintDepSetsBuilder) Transitive(depSets LintDepSets) LintDepSetsBuilder { - if depSets.HTML != nil { - l.HTML.Transitive(depSets.HTML) +func (l LintDepSetsBuilder) Transitive(info *LintInfo) LintDepSetsBuilder { + if info.TransitiveHTML != nil { + l.HTML.Transitive(info.TransitiveHTML) } - if depSets.Text != nil { - l.Text.Transitive(depSets.Text) + if info.TransitiveText != nil { + l.Text.Transitive(info.TransitiveText) } - if depSets.XML != nil { - l.XML.Transitive(depSets.XML) + if info.TransitiveXML != nil { + l.XML.Transitive(info.TransitiveXML) } return l } @@ -209,10 +194,6 @@ var allLintDatabasefiles = map[android.SdkKind]lintDatabaseFiles{ }, } -func (l *linter) LintDepSets() LintDepSets { - return l.outputs.depSets -} - func (l *linter) GetStrictUpdatabilityLinting() bool { return BoolDefault(l.properties.Lint.Strict_updatability_linting, false) } @@ -223,10 +204,17 @@ func (l *linter) SetStrictUpdatabilityLinting(strictLinting bool) { var _ LintDepSetsIntf = (*linter)(nil) -var _ lintOutputsIntf = (*linter)(nil) +var LintProvider = blueprint.NewProvider[*LintInfo]() + +type LintInfo struct { + HTML android.Path + Text android.Path + XML android.Path + ReferenceBaseline android.Path -func (l *linter) lintOutputs() *lintOutputs { - return &l.outputs + TransitiveHTML *android.DepSet[android.Path] + TransitiveText *android.DepSet[android.Path] + TransitiveXML *android.DepSet[android.Path] } func (l *linter) enabled() bool { @@ -447,11 +435,13 @@ func (l *linter) lint(ctx android.ModuleContext) { depSetsBuilder := NewLintDepSetBuilder().Direct(html, text, xml) ctx.VisitDirectDepsWithTag(staticLibTag, func(dep android.Module) { - if depLint, ok := dep.(LintDepSetsIntf); ok { - depSetsBuilder.Transitive(depLint.LintDepSets()) + if info, ok := android.OtherModuleProvider(ctx, dep, LintProvider); ok { + depSetsBuilder.Transitive(info) } }) + depSets := depSetsBuilder.Build() + rule.Command().Text("rm -rf").Flag(lintPaths.cacheDir.String()).Flag(lintPaths.homeDir.String()) rule.Command().Text("mkdir -p").Flag(lintPaths.cacheDir.String()).Flag(lintPaths.homeDir.String()) rule.Command().Text("rm -f").Output(html).Output(text).Output(xml) @@ -530,22 +520,26 @@ func (l *linter) lint(ctx android.ModuleContext) { rule.Build("lint", "lint") - l.outputs = lintOutputs{ - html: html, - text: text, - xml: xml, - referenceBaseline: referenceBaseline, + android.SetProvider(ctx, LintProvider, &LintInfo{ + HTML: html, + Text: text, + XML: xml, + ReferenceBaseline: referenceBaseline, - depSets: depSetsBuilder.Build(), - } + TransitiveHTML: depSets.HTML, + TransitiveText: depSets.Text, + TransitiveXML: depSets.XML, + }) if l.buildModuleReportZip { - l.reports = BuildModuleLintReportZips(ctx, l.LintDepSets()) + l.reports = BuildModuleLintReportZips(ctx, depSets) } // Create a per-module phony target to run the lint check. phonyName := ctx.ModuleName() + "-lint" ctx.Phony(phonyName, xml) + + ctx.SetOutputFiles(android.Paths{xml}, ".lint") } func BuildModuleLintReportZips(ctx android.ModuleContext, depSets LintDepSets) android.Paths { @@ -642,7 +636,7 @@ func (l *lintSingleton) generateLintReportZips(ctx android.SingletonContext) { return } - var outputs []*lintOutputs + var outputs []*LintInfo var dirs []string ctx.VisitAllModules(func(m android.Module) { if ctx.Config().KatiEnabled() && !m.ExportedToMake() { @@ -658,14 +652,14 @@ func (l *lintSingleton) generateLintReportZips(ctx android.SingletonContext) { } } - if l, ok := m.(lintOutputsIntf); ok { - outputs = append(outputs, l.lintOutputs()) + if lintInfo, ok := android.OtherModuleProvider(ctx, m, LintProvider); ok { + outputs = append(outputs, lintInfo) } }) dirs = android.SortedUniqueStrings(dirs) - zip := func(outputPath android.WritablePath, get func(*lintOutputs) android.Path) { + zip := func(outputPath android.WritablePath, get func(*LintInfo) android.Path) { var paths android.Paths for _, output := range outputs { @@ -678,16 +672,16 @@ func (l *lintSingleton) generateLintReportZips(ctx android.SingletonContext) { } l.htmlZip = android.PathForOutput(ctx, "lint-report-html.zip") - zip(l.htmlZip, func(l *lintOutputs) android.Path { return l.html }) + zip(l.htmlZip, func(l *LintInfo) android.Path { return l.HTML }) l.textZip = android.PathForOutput(ctx, "lint-report-text.zip") - zip(l.textZip, func(l *lintOutputs) android.Path { return l.text }) + zip(l.textZip, func(l *LintInfo) android.Path { return l.Text }) l.xmlZip = android.PathForOutput(ctx, "lint-report-xml.zip") - zip(l.xmlZip, func(l *lintOutputs) android.Path { return l.xml }) + zip(l.xmlZip, func(l *LintInfo) android.Path { return l.XML }) l.referenceBaselineZip = android.PathForOutput(ctx, "lint-report-reference-baselines.zip") - zip(l.referenceBaselineZip, func(l *lintOutputs) android.Path { return l.referenceBaseline }) + zip(l.referenceBaselineZip, func(l *LintInfo) android.Path { return l.ReferenceBaseline }) ctx.Phony("lint-check", l.htmlZip, l.textZip, l.xmlZip, l.referenceBaselineZip) } diff --git a/java/sdk_library.go b/java/sdk_library.go index 725aaed9b..5deb49fe7 100644 --- a/java/sdk_library.go +++ b/java/sdk_library.go @@ -1568,7 +1568,10 @@ func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) module.dexer.proguardDictionary = module.implLibraryModule.dexer.proguardDictionary module.dexer.proguardUsageZip = module.implLibraryModule.dexer.proguardUsageZip module.linter.reports = module.implLibraryModule.linter.reports - module.linter.outputs.depSets = module.implLibraryModule.LintDepSets() + + if lintInfo, ok := android.OtherModuleProvider(ctx, module.implLibraryModule, LintProvider); ok { + android.SetProvider(ctx, LintProvider, lintInfo) + } if !module.Host() { module.hostdexInstallFile = module.implLibraryModule.hostdexInstallFile @@ -2919,14 +2922,6 @@ func (module *SdkLibraryImport) JacocoReportClassesFile() android.Path { } // to satisfy apex.javaDependency interface -func (module *SdkLibraryImport) LintDepSets() LintDepSets { - if module.implLibraryModule == nil { - return LintDepSets{} - } else { - return module.implLibraryModule.LintDepSets() - } -} - func (module *SdkLibraryImport) GetStrictUpdatabilityLinting() bool { if module.implLibraryModule == nil { return false |