Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 1 | // Copyright 2020 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package java |
| 16 | |
| 17 | import ( |
| 18 | "fmt" |
| 19 | "sort" |
Colin Cross | 988dfcc | 2020-07-16 17:32:17 -0700 | [diff] [blame] | 20 | "strings" |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 21 | |
Pedro Loureiro | 5d190cc | 2021-02-15 15:41:33 +0000 | [diff] [blame] | 22 | "github.com/google/blueprint/proptools" |
| 23 | |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 24 | "android/soong/android" |
Colin Cross | 31972dc | 2021-03-04 10:44:12 -0800 | [diff] [blame] | 25 | "android/soong/java/config" |
| 26 | "android/soong/remoteexec" |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 27 | ) |
| 28 | |
Jaewoong Jung | 79e6f6b | 2021-04-21 14:01:55 -0700 | [diff] [blame] | 29 | // lint checks automatically enforced for modules that have different min_sdk_version than |
| 30 | // sdk_version |
| 31 | var updatabilityChecks = []string{"NewApi"} |
| 32 | |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 33 | type LintProperties struct { |
| 34 | // Controls for running Android Lint on the module. |
| 35 | Lint struct { |
| 36 | |
| 37 | // If true, run Android Lint on the module. Defaults to true. |
| 38 | Enabled *bool |
| 39 | |
| 40 | // Flags to pass to the Android Lint tool. |
| 41 | Flags []string |
| 42 | |
| 43 | // Checks that should be treated as fatal. |
| 44 | Fatal_checks []string |
| 45 | |
| 46 | // Checks that should be treated as errors. |
| 47 | Error_checks []string |
| 48 | |
| 49 | // Checks that should be treated as warnings. |
| 50 | Warning_checks []string |
| 51 | |
| 52 | // Checks that should be skipped. |
| 53 | Disabled_checks []string |
Colin Cross | 92e4b46 | 2020-06-18 15:56:48 -0700 | [diff] [blame] | 54 | |
| 55 | // Modules that provide extra lint checks |
| 56 | Extra_check_modules []string |
Pedro Loureiro | 5d190cc | 2021-02-15 15:41:33 +0000 | [diff] [blame] | 57 | |
| 58 | // Name of the file that lint uses as the baseline. Defaults to "lint-baseline.xml". |
| 59 | Baseline_filename *string |
Jaewoong Jung | 48de883 | 2021-04-21 16:17:25 -0700 | [diff] [blame] | 60 | |
| 61 | // If true, baselining updatability lint checks (e.g. NewApi) is prohibited. Defaults to false. |
| 62 | Strict_updatability_linting *bool |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 63 | } |
| 64 | } |
| 65 | |
| 66 | type linter struct { |
Pedro Loureiro | f4a88b1 | 2021-02-25 16:23:22 +0000 | [diff] [blame] | 67 | name string |
| 68 | manifest android.Path |
| 69 | mergedManifest android.Path |
| 70 | srcs android.Paths |
| 71 | srcJars android.Paths |
| 72 | resources android.Paths |
| 73 | classpath android.Paths |
| 74 | classes android.Path |
| 75 | extraLintCheckJars android.Paths |
| 76 | test bool |
| 77 | library bool |
| 78 | minSdkVersion string |
| 79 | targetSdkVersion string |
| 80 | compileSdkVersion string |
| 81 | javaLanguageLevel string |
| 82 | kotlinLanguageLevel string |
| 83 | outputs lintOutputs |
| 84 | properties LintProperties |
| 85 | extraMainlineLintErrors []string |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 86 | |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 87 | reports android.Paths |
| 88 | |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 89 | buildModuleReportZip bool |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | type lintOutputs struct { |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 93 | html android.Path |
| 94 | text android.Path |
| 95 | xml android.Path |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 96 | |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 97 | depSets LintDepSets |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 98 | } |
| 99 | |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 100 | type lintOutputsIntf interface { |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 101 | lintOutputs() *lintOutputs |
| 102 | } |
| 103 | |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 104 | type lintDepSetsIntf interface { |
| 105 | LintDepSets() LintDepSets |
Jaewoong Jung | 476b9d6 | 2021-05-10 15:30:00 -0700 | [diff] [blame] | 106 | |
| 107 | // Methods used to propagate strict_updatability_linting values. |
| 108 | getStrictUpdatabilityLinting() bool |
| 109 | setStrictUpdatabilityLinting(bool) |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | type LintDepSets struct { |
| 113 | HTML, Text, XML *android.DepSet |
| 114 | } |
| 115 | |
| 116 | type LintDepSetsBuilder struct { |
| 117 | HTML, Text, XML *android.DepSetBuilder |
| 118 | } |
| 119 | |
| 120 | func NewLintDepSetBuilder() LintDepSetsBuilder { |
| 121 | return LintDepSetsBuilder{ |
| 122 | HTML: android.NewDepSetBuilder(android.POSTORDER), |
| 123 | Text: android.NewDepSetBuilder(android.POSTORDER), |
| 124 | XML: android.NewDepSetBuilder(android.POSTORDER), |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | func (l LintDepSetsBuilder) Direct(html, text, xml android.Path) LintDepSetsBuilder { |
| 129 | l.HTML.Direct(html) |
| 130 | l.Text.Direct(text) |
| 131 | l.XML.Direct(xml) |
| 132 | return l |
| 133 | } |
| 134 | |
| 135 | func (l LintDepSetsBuilder) Transitive(depSets LintDepSets) LintDepSetsBuilder { |
| 136 | if depSets.HTML != nil { |
| 137 | l.HTML.Transitive(depSets.HTML) |
| 138 | } |
| 139 | if depSets.Text != nil { |
| 140 | l.Text.Transitive(depSets.Text) |
| 141 | } |
| 142 | if depSets.XML != nil { |
| 143 | l.XML.Transitive(depSets.XML) |
| 144 | } |
| 145 | return l |
| 146 | } |
| 147 | |
| 148 | func (l LintDepSetsBuilder) Build() LintDepSets { |
| 149 | return LintDepSets{ |
| 150 | HTML: l.HTML.Build(), |
| 151 | Text: l.Text.Build(), |
| 152 | XML: l.XML.Build(), |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | func (l *linter) LintDepSets() LintDepSets { |
| 157 | return l.outputs.depSets |
| 158 | } |
| 159 | |
Jaewoong Jung | 476b9d6 | 2021-05-10 15:30:00 -0700 | [diff] [blame] | 160 | func (l *linter) getStrictUpdatabilityLinting() bool { |
| 161 | return BoolDefault(l.properties.Lint.Strict_updatability_linting, false) |
| 162 | } |
| 163 | |
| 164 | func (l *linter) setStrictUpdatabilityLinting(strictLinting bool) { |
| 165 | l.properties.Lint.Strict_updatability_linting = &strictLinting |
| 166 | } |
| 167 | |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 168 | var _ lintDepSetsIntf = (*linter)(nil) |
| 169 | |
| 170 | var _ lintOutputsIntf = (*linter)(nil) |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 171 | |
| 172 | func (l *linter) lintOutputs() *lintOutputs { |
| 173 | return &l.outputs |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | func (l *linter) enabled() bool { |
| 177 | return BoolDefault(l.properties.Lint.Enabled, true) |
| 178 | } |
| 179 | |
Colin Cross | 92e4b46 | 2020-06-18 15:56:48 -0700 | [diff] [blame] | 180 | func (l *linter) deps(ctx android.BottomUpMutatorContext) { |
| 181 | if !l.enabled() { |
| 182 | return |
| 183 | } |
| 184 | |
Colin Cross | 988dfcc | 2020-07-16 17:32:17 -0700 | [diff] [blame] | 185 | extraCheckModules := l.properties.Lint.Extra_check_modules |
| 186 | |
| 187 | if checkOnly := ctx.Config().Getenv("ANDROID_LINT_CHECK"); checkOnly != "" { |
| 188 | if checkOnlyModules := ctx.Config().Getenv("ANDROID_LINT_CHECK_EXTRA_MODULES"); checkOnlyModules != "" { |
| 189 | extraCheckModules = strings.Split(checkOnlyModules, ",") |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | ctx.AddFarVariationDependencies(ctx.Config().BuildOSCommonTarget.Variations(), |
| 194 | extraLintCheckTag, extraCheckModules...) |
Colin Cross | 92e4b46 | 2020-06-18 15:56:48 -0700 | [diff] [blame] | 195 | } |
| 196 | |
Colin Cross | ad22bc2 | 2021-03-10 09:45:40 -0800 | [diff] [blame] | 197 | // lintPaths contains the paths to lint's inputs and outputs to make it easier to pass them |
| 198 | // around. |
Colin Cross | 31972dc | 2021-03-04 10:44:12 -0800 | [diff] [blame] | 199 | type lintPaths struct { |
| 200 | projectXML android.WritablePath |
| 201 | configXML android.WritablePath |
| 202 | cacheDir android.WritablePath |
| 203 | homeDir android.WritablePath |
| 204 | srcjarDir android.WritablePath |
Colin Cross | 31972dc | 2021-03-04 10:44:12 -0800 | [diff] [blame] | 205 | } |
| 206 | |
Colin Cross | 9b93af4 | 2021-03-10 10:40:58 -0800 | [diff] [blame] | 207 | func lintRBEExecStrategy(ctx android.ModuleContext) string { |
| 208 | return ctx.Config().GetenvWithDefault("RBE_LINT_EXEC_STRATEGY", remoteexec.LocalExecStrategy) |
| 209 | } |
| 210 | |
Colin Cross | 31972dc | 2021-03-04 10:44:12 -0800 | [diff] [blame] | 211 | func (l *linter) writeLintProjectXML(ctx android.ModuleContext, rule *android.RuleBuilder) lintPaths { |
Colin Cross | 31972dc | 2021-03-04 10:44:12 -0800 | [diff] [blame] | 212 | projectXMLPath := android.PathForModuleOut(ctx, "lint", "project.xml") |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 213 | // Lint looks for a lint.xml file next to the project.xml file, give it one. |
Colin Cross | 31972dc | 2021-03-04 10:44:12 -0800 | [diff] [blame] | 214 | configXMLPath := android.PathForModuleOut(ctx, "lint", "lint.xml") |
| 215 | cacheDir := android.PathForModuleOut(ctx, "lint", "cache") |
| 216 | homeDir := android.PathForModuleOut(ctx, "lint", "home") |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 217 | |
Colin Cross | 1661aff | 2021-03-12 17:56:51 -0800 | [diff] [blame] | 218 | srcJarDir := android.PathForModuleOut(ctx, "lint", "srcjars") |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 219 | srcJarList := zipSyncCmd(ctx, rule, srcJarDir, l.srcJars) |
| 220 | |
| 221 | cmd := rule.Command(). |
Jaewoong Jung | 5a42025 | 2021-04-19 17:58:22 -0700 | [diff] [blame] | 222 | BuiltTool("lint_project_xml"). |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 223 | FlagWithOutput("--project_out ", projectXMLPath). |
| 224 | FlagWithOutput("--config_out ", configXMLPath). |
| 225 | FlagWithArg("--name ", ctx.ModuleName()) |
| 226 | |
| 227 | if l.library { |
| 228 | cmd.Flag("--library") |
| 229 | } |
| 230 | if l.test { |
| 231 | cmd.Flag("--test") |
| 232 | } |
| 233 | if l.manifest != nil { |
Colin Cross | 5bedfa2 | 2021-03-23 17:07:14 -0700 | [diff] [blame] | 234 | cmd.FlagWithInput("--manifest ", l.manifest) |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 235 | } |
| 236 | if l.mergedManifest != nil { |
Colin Cross | 5bedfa2 | 2021-03-23 17:07:14 -0700 | [diff] [blame] | 237 | cmd.FlagWithInput("--merged_manifest ", l.mergedManifest) |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 238 | } |
| 239 | |
Colin Cross | 5bedfa2 | 2021-03-23 17:07:14 -0700 | [diff] [blame] | 240 | // TODO(ccross): some of the files in l.srcs are generated sources and should be passed to |
| 241 | // lint separately. |
| 242 | srcsList := android.PathForModuleOut(ctx, "lint-srcs.list") |
| 243 | cmd.FlagWithRspFileInputList("--srcs ", srcsList, l.srcs) |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 244 | |
| 245 | cmd.FlagWithInput("--generated_srcs ", srcJarList) |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 246 | |
Colin Cross | 5bedfa2 | 2021-03-23 17:07:14 -0700 | [diff] [blame] | 247 | if len(l.resources) > 0 { |
| 248 | resourcesList := android.PathForModuleOut(ctx, "lint-resources.list") |
| 249 | cmd.FlagWithRspFileInputList("--resources ", resourcesList, l.resources) |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | if l.classes != nil { |
Colin Cross | 5bedfa2 | 2021-03-23 17:07:14 -0700 | [diff] [blame] | 253 | cmd.FlagWithInput("--classes ", l.classes) |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 254 | } |
| 255 | |
Colin Cross | 5bedfa2 | 2021-03-23 17:07:14 -0700 | [diff] [blame] | 256 | cmd.FlagForEachInput("--classpath ", l.classpath) |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 257 | |
Colin Cross | 5bedfa2 | 2021-03-23 17:07:14 -0700 | [diff] [blame] | 258 | cmd.FlagForEachInput("--extra_checks_jar ", l.extraLintCheckJars) |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 259 | |
Colin Cross | 1661aff | 2021-03-12 17:56:51 -0800 | [diff] [blame] | 260 | cmd.FlagWithArg("--root_dir ", "$PWD") |
Colin Cross | c31efeb | 2020-06-23 10:25:26 -0700 | [diff] [blame] | 261 | |
| 262 | // The cache tag in project.xml is relative to the root dir, or the project.xml file if |
| 263 | // the root dir is not set. |
| 264 | cmd.FlagWithArg("--cache_dir ", cacheDir.String()) |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 265 | |
| 266 | cmd.FlagWithInput("@", |
| 267 | android.PathForSource(ctx, "build/soong/java/lint_defaults.txt")) |
| 268 | |
Pedro Loureiro | f4a88b1 | 2021-02-25 16:23:22 +0000 | [diff] [blame] | 269 | cmd.FlagForEachArg("--error_check ", l.extraMainlineLintErrors) |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 270 | cmd.FlagForEachArg("--disable_check ", l.properties.Lint.Disabled_checks) |
| 271 | cmd.FlagForEachArg("--warning_check ", l.properties.Lint.Warning_checks) |
| 272 | cmd.FlagForEachArg("--error_check ", l.properties.Lint.Error_checks) |
| 273 | cmd.FlagForEachArg("--fatal_check ", l.properties.Lint.Fatal_checks) |
| 274 | |
Jaewoong Jung | 476b9d6 | 2021-05-10 15:30:00 -0700 | [diff] [blame] | 275 | if l.getStrictUpdatabilityLinting() { |
Jaewoong Jung | 3c87b1d | 2021-04-22 11:01:36 -0700 | [diff] [blame] | 276 | // Verify the module does not baseline issues that endanger safe updatability. |
Jaewoong Jung | 48de883 | 2021-04-21 16:17:25 -0700 | [diff] [blame] | 277 | if baselinePath := l.getBaselineFilepath(ctx); baselinePath.Valid() { |
| 278 | cmd.FlagWithInput("--baseline ", baselinePath.Path()) |
| 279 | cmd.FlagForEachArg("--disallowed_issues ", updatabilityChecks) |
| 280 | } |
| 281 | } |
| 282 | |
Colin Cross | 31972dc | 2021-03-04 10:44:12 -0800 | [diff] [blame] | 283 | return lintPaths{ |
| 284 | projectXML: projectXMLPath, |
| 285 | configXML: configXMLPath, |
| 286 | cacheDir: cacheDir, |
| 287 | homeDir: homeDir, |
Colin Cross | 31972dc | 2021-03-04 10:44:12 -0800 | [diff] [blame] | 288 | } |
| 289 | |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 290 | } |
| 291 | |
Liz Kammer | 20ebfb4 | 2020-07-28 11:32:07 -0700 | [diff] [blame] | 292 | // generateManifest adds a command to the rule to write a simple manifest that contains the |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 293 | // minSdkVersion and targetSdkVersion for modules (like java_library) that don't have a manifest. |
Colin Cross | 1661aff | 2021-03-12 17:56:51 -0800 | [diff] [blame] | 294 | func (l *linter) generateManifest(ctx android.ModuleContext, rule *android.RuleBuilder) android.WritablePath { |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 295 | manifestPath := android.PathForModuleOut(ctx, "lint", "AndroidManifest.xml") |
| 296 | |
| 297 | rule.Command().Text("("). |
| 298 | Text(`echo "<?xml version='1.0' encoding='utf-8'?>" &&`). |
| 299 | Text(`echo "<manifest xmlns:android='http://schemas.android.com/apk/res/android'" &&`). |
| 300 | Text(`echo " android:versionCode='1' android:versionName='1' >" &&`). |
| 301 | Textf(`echo " <uses-sdk android:minSdkVersion='%s' android:targetSdkVersion='%s'/>" &&`, |
| 302 | l.minSdkVersion, l.targetSdkVersion). |
| 303 | Text(`echo "</manifest>"`). |
| 304 | Text(") >").Output(manifestPath) |
| 305 | |
| 306 | return manifestPath |
| 307 | } |
| 308 | |
Jaewoong Jung | 302c5b8 | 2021-04-19 08:54:36 -0700 | [diff] [blame] | 309 | func (l *linter) getBaselineFilepath(ctx android.ModuleContext) android.OptionalPath { |
| 310 | var lintBaseline android.OptionalPath |
| 311 | if lintFilename := proptools.StringDefault(l.properties.Lint.Baseline_filename, "lint-baseline.xml"); lintFilename != "" { |
| 312 | if String(l.properties.Lint.Baseline_filename) != "" { |
| 313 | // if manually specified, we require the file to exist |
| 314 | lintBaseline = android.OptionalPathForPath(android.PathForModuleSrc(ctx, lintFilename)) |
| 315 | } else { |
| 316 | lintBaseline = android.ExistentPathForSource(ctx, ctx.ModuleDir(), lintFilename) |
| 317 | } |
| 318 | } |
| 319 | return lintBaseline |
| 320 | } |
| 321 | |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 322 | func (l *linter) lint(ctx android.ModuleContext) { |
| 323 | if !l.enabled() { |
| 324 | return |
| 325 | } |
| 326 | |
Pedro Loureiro | f4a88b1 | 2021-02-25 16:23:22 +0000 | [diff] [blame] | 327 | if l.minSdkVersion != l.compileSdkVersion { |
Jaewoong Jung | 79e6f6b | 2021-04-21 14:01:55 -0700 | [diff] [blame] | 328 | l.extraMainlineLintErrors = append(l.extraMainlineLintErrors, updatabilityChecks...) |
| 329 | _, filtered := android.FilterList(l.properties.Lint.Warning_checks, updatabilityChecks) |
| 330 | if len(filtered) != 0 { |
| 331 | ctx.PropertyErrorf("lint.warning_checks", |
| 332 | "Can't treat %v checks as warnings if min_sdk_version is different from sdk_version.", filtered) |
| 333 | } |
| 334 | _, filtered = android.FilterList(l.properties.Lint.Disabled_checks, updatabilityChecks) |
| 335 | if len(filtered) != 0 { |
| 336 | ctx.PropertyErrorf("lint.disabled_checks", |
| 337 | "Can't disable %v checks if min_sdk_version is different from sdk_version.", filtered) |
| 338 | } |
Pedro Loureiro | f4a88b1 | 2021-02-25 16:23:22 +0000 | [diff] [blame] | 339 | } |
| 340 | |
Colin Cross | 92e4b46 | 2020-06-18 15:56:48 -0700 | [diff] [blame] | 341 | extraLintCheckModules := ctx.GetDirectDepsWithTag(extraLintCheckTag) |
| 342 | for _, extraLintCheckModule := range extraLintCheckModules { |
Colin Cross | dcf71b2 | 2021-02-01 13:59:03 -0800 | [diff] [blame] | 343 | if ctx.OtherModuleHasProvider(extraLintCheckModule, JavaInfoProvider) { |
| 344 | dep := ctx.OtherModuleProvider(extraLintCheckModule, JavaInfoProvider).(JavaInfo) |
| 345 | l.extraLintCheckJars = append(l.extraLintCheckJars, dep.ImplementationAndResourcesJars...) |
Colin Cross | 92e4b46 | 2020-06-18 15:56:48 -0700 | [diff] [blame] | 346 | } else { |
| 347 | ctx.PropertyErrorf("lint.extra_check_modules", |
| 348 | "%s is not a java module", ctx.OtherModuleName(extraLintCheckModule)) |
| 349 | } |
| 350 | } |
| 351 | |
Colin Cross | 1661aff | 2021-03-12 17:56:51 -0800 | [diff] [blame] | 352 | rule := android.NewRuleBuilder(pctx, ctx). |
| 353 | Sbox(android.PathForModuleOut(ctx, "lint"), |
| 354 | android.PathForModuleOut(ctx, "lint.sbox.textproto")). |
| 355 | SandboxInputs() |
| 356 | |
| 357 | if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_LINT") { |
| 358 | pool := ctx.Config().GetenvWithDefault("RBE_LINT_POOL", "java16") |
| 359 | rule.Remoteable(android.RemoteRuleSupports{RBE: true}) |
| 360 | rule.Rewrapper(&remoteexec.REParams{ |
| 361 | Labels: map[string]string{"type": "tool", "name": "lint"}, |
| 362 | ExecStrategy: lintRBEExecStrategy(ctx), |
| 363 | ToolchainInputs: []string{config.JavaCmd(ctx).String()}, |
| 364 | EnvironmentVariables: []string{ |
| 365 | "LANG", |
| 366 | }, |
| 367 | Platform: map[string]string{remoteexec.PoolKey: pool}, |
| 368 | }) |
| 369 | } |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 370 | |
| 371 | if l.manifest == nil { |
| 372 | manifest := l.generateManifest(ctx, rule) |
| 373 | l.manifest = manifest |
Colin Cross | 1661aff | 2021-03-12 17:56:51 -0800 | [diff] [blame] | 374 | rule.Temporary(manifest) |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 375 | } |
| 376 | |
Colin Cross | 31972dc | 2021-03-04 10:44:12 -0800 | [diff] [blame] | 377 | lintPaths := l.writeLintProjectXML(ctx, rule) |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 378 | |
Colin Cross | 1661aff | 2021-03-12 17:56:51 -0800 | [diff] [blame] | 379 | html := android.PathForModuleOut(ctx, "lint", "lint-report.html") |
| 380 | text := android.PathForModuleOut(ctx, "lint", "lint-report.txt") |
| 381 | xml := android.PathForModuleOut(ctx, "lint", "lint-report.xml") |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 382 | |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 383 | depSetsBuilder := NewLintDepSetBuilder().Direct(html, text, xml) |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 384 | |
| 385 | ctx.VisitDirectDepsWithTag(staticLibTag, func(dep android.Module) { |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 386 | if depLint, ok := dep.(lintDepSetsIntf); ok { |
| 387 | depSetsBuilder.Transitive(depLint.LintDepSets()) |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 388 | } |
| 389 | }) |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 390 | |
Colin Cross | 31972dc | 2021-03-04 10:44:12 -0800 | [diff] [blame] | 391 | rule.Command().Text("rm -rf").Flag(lintPaths.cacheDir.String()).Flag(lintPaths.homeDir.String()) |
| 392 | rule.Command().Text("mkdir -p").Flag(lintPaths.cacheDir.String()).Flag(lintPaths.homeDir.String()) |
Colin Cross | 5c113d1 | 2021-03-04 10:01:34 -0800 | [diff] [blame] | 393 | rule.Command().Text("rm -f").Output(html).Output(text).Output(xml) |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 394 | |
Colin Cross | 8a6ed37 | 2020-07-06 11:45:51 -0700 | [diff] [blame] | 395 | var annotationsZipPath, apiVersionsXMLPath android.Path |
Jeongik Cha | 816a23a | 2020-07-08 01:09:23 +0900 | [diff] [blame] | 396 | if ctx.Config().AlwaysUsePrebuiltSdks() { |
Colin Cross | 8a6ed37 | 2020-07-06 11:45:51 -0700 | [diff] [blame] | 397 | annotationsZipPath = android.PathForSource(ctx, "prebuilts/sdk/current/public/data/annotations.zip") |
| 398 | apiVersionsXMLPath = android.PathForSource(ctx, "prebuilts/sdk/current/public/data/api-versions.xml") |
| 399 | } else { |
| 400 | annotationsZipPath = copiedAnnotationsZipPath(ctx) |
| 401 | apiVersionsXMLPath = copiedAPIVersionsXmlPath(ctx) |
| 402 | } |
| 403 | |
Colin Cross | 31972dc | 2021-03-04 10:44:12 -0800 | [diff] [blame] | 404 | cmd := rule.Command() |
| 405 | |
Pedro Loureiro | 70acc3d | 2021-04-06 17:49:19 +0000 | [diff] [blame] | 406 | cmd.Flag(`JAVA_OPTS="-Xmx3072m --add-opens java.base/java.util=ALL-UNNAMED"`). |
Colin Cross | 31972dc | 2021-03-04 10:44:12 -0800 | [diff] [blame] | 407 | FlagWithArg("ANDROID_SDK_HOME=", lintPaths.homeDir.String()). |
Colin Cross | 8a6ed37 | 2020-07-06 11:45:51 -0700 | [diff] [blame] | 408 | FlagWithInput("SDK_ANNOTATIONS=", annotationsZipPath). |
Colin Cross | 31972dc | 2021-03-04 10:44:12 -0800 | [diff] [blame] | 409 | FlagWithInput("LINT_OPTS=-DLINT_API_DATABASE=", apiVersionsXMLPath) |
| 410 | |
Colin Cross | 1661aff | 2021-03-12 17:56:51 -0800 | [diff] [blame] | 411 | cmd.BuiltTool("lint").ImplicitTool(ctx.Config().HostJavaToolPath(ctx, "lint.jar")). |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 412 | Flag("--quiet"). |
Colin Cross | 31972dc | 2021-03-04 10:44:12 -0800 | [diff] [blame] | 413 | FlagWithInput("--project ", lintPaths.projectXML). |
| 414 | FlagWithInput("--config ", lintPaths.configXML). |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 415 | FlagWithOutput("--html ", html). |
| 416 | FlagWithOutput("--text ", text). |
| 417 | FlagWithOutput("--xml ", xml). |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 418 | FlagWithArg("--compile-sdk-version ", l.compileSdkVersion). |
| 419 | FlagWithArg("--java-language-level ", l.javaLanguageLevel). |
| 420 | FlagWithArg("--kotlin-language-level ", l.kotlinLanguageLevel). |
| 421 | FlagWithArg("--url ", fmt.Sprintf(".=.,%s=out", android.PathForOutput(ctx).String())). |
| 422 | Flag("--exitcode"). |
| 423 | Flags(l.properties.Lint.Flags). |
Colin Cross | 31972dc | 2021-03-04 10:44:12 -0800 | [diff] [blame] | 424 | Implicit(annotationsZipPath). |
Colin Cross | 5bedfa2 | 2021-03-23 17:07:14 -0700 | [diff] [blame] | 425 | Implicit(apiVersionsXMLPath) |
Colin Cross | 988dfcc | 2020-07-16 17:32:17 -0700 | [diff] [blame] | 426 | |
Colin Cross | 1661aff | 2021-03-12 17:56:51 -0800 | [diff] [blame] | 427 | rule.Temporary(lintPaths.projectXML) |
| 428 | rule.Temporary(lintPaths.configXML) |
| 429 | |
Colin Cross | 988dfcc | 2020-07-16 17:32:17 -0700 | [diff] [blame] | 430 | if checkOnly := ctx.Config().Getenv("ANDROID_LINT_CHECK"); checkOnly != "" { |
| 431 | cmd.FlagWithArg("--check ", checkOnly) |
| 432 | } |
| 433 | |
Jaewoong Jung | 302c5b8 | 2021-04-19 08:54:36 -0700 | [diff] [blame] | 434 | lintBaseline := l.getBaselineFilepath(ctx) |
| 435 | if lintBaseline.Valid() { |
| 436 | cmd.FlagWithInput("--baseline ", lintBaseline.Path()) |
Pedro Loureiro | 5d190cc | 2021-02-15 15:41:33 +0000 | [diff] [blame] | 437 | } |
| 438 | |
Colin Cross | 31972dc | 2021-03-04 10:44:12 -0800 | [diff] [blame] | 439 | cmd.Text("|| (").Text("if [ -e").Input(text).Text("]; then cat").Input(text).Text("; fi; exit 7)") |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 440 | |
Colin Cross | 31972dc | 2021-03-04 10:44:12 -0800 | [diff] [blame] | 441 | rule.Command().Text("rm -rf").Flag(lintPaths.cacheDir.String()).Flag(lintPaths.homeDir.String()) |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 442 | |
Colin Cross | ee4a8b7 | 2021-04-05 18:38:05 -0700 | [diff] [blame] | 443 | // The HTML output contains a date, remove it to make the output deterministic. |
| 444 | rule.Command().Text(`sed -i.tmp -e 's|Check performed at .*\(</nav>\)|\1|'`).Output(html) |
| 445 | |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 446 | rule.Build("lint", "lint") |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 447 | |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 448 | l.outputs = lintOutputs{ |
| 449 | html: html, |
| 450 | text: text, |
| 451 | xml: xml, |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 452 | |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 453 | depSets: depSetsBuilder.Build(), |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 454 | } |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 455 | |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 456 | if l.buildModuleReportZip { |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 457 | l.reports = BuildModuleLintReportZips(ctx, l.LintDepSets()) |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 458 | } |
| 459 | } |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 460 | |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 461 | func BuildModuleLintReportZips(ctx android.ModuleContext, depSets LintDepSets) android.Paths { |
| 462 | htmlList := depSets.HTML.ToSortedList() |
| 463 | textList := depSets.Text.ToSortedList() |
| 464 | xmlList := depSets.XML.ToSortedList() |
| 465 | |
| 466 | if len(htmlList) == 0 && len(textList) == 0 && len(xmlList) == 0 { |
| 467 | return nil |
| 468 | } |
| 469 | |
| 470 | htmlZip := android.PathForModuleOut(ctx, "lint-report-html.zip") |
| 471 | lintZip(ctx, htmlList, htmlZip) |
| 472 | |
| 473 | textZip := android.PathForModuleOut(ctx, "lint-report-text.zip") |
| 474 | lintZip(ctx, textList, textZip) |
| 475 | |
| 476 | xmlZip := android.PathForModuleOut(ctx, "lint-report-xml.zip") |
| 477 | lintZip(ctx, xmlList, xmlZip) |
| 478 | |
| 479 | return android.Paths{htmlZip, textZip, xmlZip} |
| 480 | } |
| 481 | |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 482 | type lintSingleton struct { |
| 483 | htmlZip android.WritablePath |
| 484 | textZip android.WritablePath |
| 485 | xmlZip android.WritablePath |
| 486 | } |
| 487 | |
| 488 | func (l *lintSingleton) GenerateBuildActions(ctx android.SingletonContext) { |
| 489 | l.generateLintReportZips(ctx) |
| 490 | l.copyLintDependencies(ctx) |
| 491 | } |
| 492 | |
| 493 | func (l *lintSingleton) copyLintDependencies(ctx android.SingletonContext) { |
Jeongik Cha | 816a23a | 2020-07-08 01:09:23 +0900 | [diff] [blame] | 494 | if ctx.Config().AlwaysUsePrebuiltSdks() { |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 495 | return |
| 496 | } |
| 497 | |
| 498 | var frameworkDocStubs android.Module |
| 499 | ctx.VisitAllModules(func(m android.Module) { |
| 500 | if ctx.ModuleName(m) == "framework-doc-stubs" { |
| 501 | if frameworkDocStubs == nil { |
| 502 | frameworkDocStubs = m |
| 503 | } else { |
| 504 | ctx.Errorf("lint: multiple framework-doc-stubs modules found: %s and %s", |
| 505 | ctx.ModuleSubDir(m), ctx.ModuleSubDir(frameworkDocStubs)) |
| 506 | } |
| 507 | } |
| 508 | }) |
| 509 | |
| 510 | if frameworkDocStubs == nil { |
| 511 | if !ctx.Config().AllowMissingDependencies() { |
| 512 | ctx.Errorf("lint: missing framework-doc-stubs") |
| 513 | } |
| 514 | return |
| 515 | } |
| 516 | |
| 517 | ctx.Build(pctx, android.BuildParams{ |
Colin Cross | 00d93b1 | 2021-03-04 10:00:09 -0800 | [diff] [blame] | 518 | Rule: android.CpIfChanged, |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 519 | Input: android.OutputFileForModule(ctx, frameworkDocStubs, ".annotations.zip"), |
Colin Cross | 8a6ed37 | 2020-07-06 11:45:51 -0700 | [diff] [blame] | 520 | Output: copiedAnnotationsZipPath(ctx), |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 521 | }) |
| 522 | |
| 523 | ctx.Build(pctx, android.BuildParams{ |
Colin Cross | 00d93b1 | 2021-03-04 10:00:09 -0800 | [diff] [blame] | 524 | Rule: android.CpIfChanged, |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 525 | Input: android.OutputFileForModule(ctx, frameworkDocStubs, ".api_versions.xml"), |
Colin Cross | 8a6ed37 | 2020-07-06 11:45:51 -0700 | [diff] [blame] | 526 | Output: copiedAPIVersionsXmlPath(ctx), |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 527 | }) |
| 528 | } |
| 529 | |
Colin Cross | 8a6ed37 | 2020-07-06 11:45:51 -0700 | [diff] [blame] | 530 | func copiedAnnotationsZipPath(ctx android.PathContext) android.WritablePath { |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 531 | return android.PathForOutput(ctx, "lint", "annotations.zip") |
| 532 | } |
| 533 | |
Colin Cross | 8a6ed37 | 2020-07-06 11:45:51 -0700 | [diff] [blame] | 534 | func copiedAPIVersionsXmlPath(ctx android.PathContext) android.WritablePath { |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 535 | return android.PathForOutput(ctx, "lint", "api_versions.xml") |
| 536 | } |
| 537 | |
| 538 | func (l *lintSingleton) generateLintReportZips(ctx android.SingletonContext) { |
Colin Cross | 8a6ed37 | 2020-07-06 11:45:51 -0700 | [diff] [blame] | 539 | if ctx.Config().UnbundledBuild() { |
| 540 | return |
| 541 | } |
| 542 | |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 543 | var outputs []*lintOutputs |
| 544 | var dirs []string |
| 545 | ctx.VisitAllModules(func(m android.Module) { |
Jingwen Chen | cda22c9 | 2020-11-23 00:22:30 -0500 | [diff] [blame] | 546 | if ctx.Config().KatiEnabled() && !m.ExportedToMake() { |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 547 | return |
| 548 | } |
| 549 | |
Colin Cross | 56a8321 | 2020-09-15 18:30:11 -0700 | [diff] [blame] | 550 | if apex, ok := m.(android.ApexModule); ok && apex.NotAvailableForPlatform() { |
| 551 | apexInfo := ctx.ModuleProvider(m, android.ApexInfoProvider).(android.ApexInfo) |
| 552 | if apexInfo.IsForPlatform() { |
| 553 | // There are stray platform variants of modules in apexes that are not available for |
| 554 | // the platform, and they sometimes can't be built. Don't depend on them. |
| 555 | return |
| 556 | } |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 557 | } |
| 558 | |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 559 | if l, ok := m.(lintOutputsIntf); ok { |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 560 | outputs = append(outputs, l.lintOutputs()) |
| 561 | } |
| 562 | }) |
| 563 | |
| 564 | dirs = android.SortedUniqueStrings(dirs) |
| 565 | |
| 566 | zip := func(outputPath android.WritablePath, get func(*lintOutputs) android.Path) { |
| 567 | var paths android.Paths |
| 568 | |
| 569 | for _, output := range outputs { |
Colin Cross | 08dca38 | 2020-07-21 20:31:17 -0700 | [diff] [blame] | 570 | if p := get(output); p != nil { |
| 571 | paths = append(paths, p) |
| 572 | } |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 573 | } |
| 574 | |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 575 | lintZip(ctx, paths, outputPath) |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 576 | } |
| 577 | |
| 578 | l.htmlZip = android.PathForOutput(ctx, "lint-report-html.zip") |
| 579 | zip(l.htmlZip, func(l *lintOutputs) android.Path { return l.html }) |
| 580 | |
| 581 | l.textZip = android.PathForOutput(ctx, "lint-report-text.zip") |
| 582 | zip(l.textZip, func(l *lintOutputs) android.Path { return l.text }) |
| 583 | |
| 584 | l.xmlZip = android.PathForOutput(ctx, "lint-report-xml.zip") |
| 585 | zip(l.xmlZip, func(l *lintOutputs) android.Path { return l.xml }) |
| 586 | |
| 587 | ctx.Phony("lint-check", l.htmlZip, l.textZip, l.xmlZip) |
| 588 | } |
| 589 | |
| 590 | func (l *lintSingleton) MakeVars(ctx android.MakeVarsContext) { |
Colin Cross | 8a6ed37 | 2020-07-06 11:45:51 -0700 | [diff] [blame] | 591 | if !ctx.Config().UnbundledBuild() { |
| 592 | ctx.DistForGoal("lint-check", l.htmlZip, l.textZip, l.xmlZip) |
| 593 | } |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 594 | } |
| 595 | |
| 596 | var _ android.SingletonMakeVarsProvider = (*lintSingleton)(nil) |
| 597 | |
| 598 | func init() { |
| 599 | android.RegisterSingletonType("lint", |
| 600 | func() android.Singleton { return &lintSingleton{} }) |
Jaewoong Jung | 476b9d6 | 2021-05-10 15:30:00 -0700 | [diff] [blame] | 601 | |
| 602 | registerLintBuildComponents(android.InitRegistrationContext) |
| 603 | } |
| 604 | |
| 605 | func registerLintBuildComponents(ctx android.RegistrationContext) { |
| 606 | ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) { |
| 607 | ctx.TopDown("enforce_strict_updatability_linting", enforceStrictUpdatabilityLintingMutator).Parallel() |
| 608 | }) |
Colin Cross | 014489c | 2020-06-02 20:09:13 -0700 | [diff] [blame] | 609 | } |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 610 | |
| 611 | func lintZip(ctx android.BuilderContext, paths android.Paths, outputPath android.WritablePath) { |
| 612 | paths = android.SortedUniquePaths(android.CopyOfPaths(paths)) |
| 613 | |
| 614 | sort.Slice(paths, func(i, j int) bool { |
| 615 | return paths[i].String() < paths[j].String() |
| 616 | }) |
| 617 | |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 618 | rule := android.NewRuleBuilder(pctx, ctx) |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 619 | |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 620 | rule.Command().BuiltTool("soong_zip"). |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 621 | FlagWithOutput("-o ", outputPath). |
| 622 | FlagWithArg("-C ", android.PathForIntermediates(ctx).String()). |
Colin Cross | 70c4741 | 2021-03-12 17:48:14 -0800 | [diff] [blame] | 623 | FlagWithRspFileInputList("-r ", outputPath.ReplaceExtension(ctx, "rsp"), paths) |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 624 | |
Colin Cross | f1a035e | 2020-11-16 17:32:30 -0800 | [diff] [blame] | 625 | rule.Build(outputPath.Base(), outputPath.Base()) |
Colin Cross | c0efd1d | 2020-07-03 11:56:24 -0700 | [diff] [blame] | 626 | } |
Jaewoong Jung | 476b9d6 | 2021-05-10 15:30:00 -0700 | [diff] [blame] | 627 | |
| 628 | // Enforce the strict updatability linting to all applicable transitive dependencies. |
| 629 | func enforceStrictUpdatabilityLintingMutator(ctx android.TopDownMutatorContext) { |
| 630 | m := ctx.Module() |
| 631 | if d, ok := m.(lintDepSetsIntf); ok && d.getStrictUpdatabilityLinting() { |
| 632 | ctx.VisitDirectDepsWithTag(staticLibTag, func(d android.Module) { |
| 633 | if a, ok := d.(lintDepSetsIntf); ok { |
| 634 | a.setStrictUpdatabilityLinting(true) |
| 635 | } |
| 636 | }) |
| 637 | } |
| 638 | } |