Revert "Print the modules that had strict_updatability_linting set"

This reverts commit ada543ed86.

Reason for revert: b/323773738

Change-Id: Iaddd35b275392c8d0eb7ce1cc65523467462d7b3
This commit is contained in:
Cole Faust
2024-02-05 19:37:05 +00:00
committed by Android (Google) Code Review
parent ada543ed86
commit 75dd41b576
5 changed files with 21 additions and 108 deletions

View File

@@ -1104,7 +1104,6 @@ func apexStrictUpdatibilityLintMutator(mctx android.TopDownMutatorContext) {
return return
} }
if apex, ok := mctx.Module().(*apexBundle); ok && apex.checkStrictUpdatabilityLinting() { if apex, ok := mctx.Module().(*apexBundle); ok && apex.checkStrictUpdatabilityLinting() {
parents := []string{mctx.ModuleName()}
mctx.WalkDeps(func(child, parent android.Module) bool { mctx.WalkDeps(func(child, parent android.Module) bool {
// b/208656169 Do not propagate strict updatability linting to libcore/ // b/208656169 Do not propagate strict updatability linting to libcore/
// These libs are available on the classpath during compilation // These libs are available on the classpath during compilation
@@ -1118,7 +1117,7 @@ func apexStrictUpdatibilityLintMutator(mctx android.TopDownMutatorContext) {
return false return false
} }
if lintable, ok := child.(java.LintDepSetsIntf); ok { if lintable, ok := child.(java.LintDepSetsIntf); ok {
lintable.SetStrictUpdatabilityLinting(parents) lintable.SetStrictUpdatabilityLinting(true)
} }
// visit transitive deps // visit transitive deps
return true return true

View File

@@ -62,10 +62,6 @@ type LintProperties struct {
// If true, baselining updatability lint checks (e.g. NewApi) is prohibited. Defaults to false. // If true, baselining updatability lint checks (e.g. NewApi) is prohibited. Defaults to false.
Strict_updatability_linting *bool Strict_updatability_linting *bool
// The reverse dependency that had strict_updatability_linting set that caused this module to
// have it enabled, for use in error messages.
Strict_updatability_parents []string
// Treat the code in this module as test code for @VisibleForTesting enforcement. // Treat the code in this module as test code for @VisibleForTesting enforcement.
// This will be true by default for test module types, false otherwise. // This will be true by default for test module types, false otherwise.
// If soong gets support for testonly, this flag should be replaced with that. // If soong gets support for testonly, this flag should be replaced with that.
@@ -121,8 +117,8 @@ type LintDepSetsIntf interface {
LintDepSets() LintDepSets LintDepSets() LintDepSets
// Methods used to propagate strict_updatability_linting values. // Methods used to propagate strict_updatability_linting values.
GetStrictUpdatabilityLinting(ctx android.BaseModuleContext) []string GetStrictUpdatabilityLinting() bool
SetStrictUpdatabilityLinting([]string) SetStrictUpdatabilityLinting(bool)
} }
type LintDepSets struct { type LintDepSets struct {
@@ -217,22 +213,12 @@ func (l *linter) LintDepSets() LintDepSets {
return l.outputs.depSets return l.outputs.depSets
} }
// GetStrictUpdatabilityLinting returns a list of names of modules func (l *linter) GetStrictUpdatabilityLinting() bool {
// that set strict_updatability_linting: true and affect the current module. return BoolDefault(l.properties.Lint.Strict_updatability_linting, false)
// Strict updatability linting should be enabled if the result is non-empty.
func (l *linter) GetStrictUpdatabilityLinting(ctx android.BaseModuleContext) []string {
result := l.properties.Lint.Strict_updatability_parents
if proptools.Bool(l.properties.Lint.Strict_updatability_linting) {
result = append(result, ctx.ModuleName())
}
return result
} }
// SetStrictUpdatabilityLinting adds the given list of modules to this module's func (l *linter) SetStrictUpdatabilityLinting(strictLinting bool) {
// list of "strict updatable parent" modules. If then given list is non-empty, l.properties.Lint.Strict_updatability_linting = &strictLinting
// it causes strict updatability linting to be enabled on this module.
func (l *linter) SetStrictUpdatabilityLinting(parents []string) {
l.properties.Lint.Strict_updatability_parents = android.SortedUniqueStrings(append(l.properties.Lint.Strict_updatability_parents, parents...))
} }
var _ LintDepSetsIntf = (*linter)(nil) var _ LintDepSetsIntf = (*linter)(nil)
@@ -339,10 +325,9 @@ func (l *linter) writeLintProjectXML(ctx android.ModuleContext, rule *android.Ru
cmd.FlagForEachArg("--error_check ", l.properties.Lint.Error_checks) cmd.FlagForEachArg("--error_check ", l.properties.Lint.Error_checks)
cmd.FlagForEachArg("--fatal_check ", l.properties.Lint.Fatal_checks) cmd.FlagForEachArg("--fatal_check ", l.properties.Lint.Fatal_checks)
if strict_mods := l.GetStrictUpdatabilityLinting(ctx); len(strict_mods) > 0 { if l.GetStrictUpdatabilityLinting() {
// Verify the module does not baseline issues that endanger safe updatability. // Verify the module does not baseline issues that endanger safe updatability.
if l.properties.Lint.Baseline_filename != nil { if l.properties.Lint.Baseline_filename != nil {
cmd.FlagWithArg("--strict_updatability_parents ", proptools.ShellEscape(strings.Join(strict_mods, ",")))
cmd.FlagWithInput("--baseline ", android.PathForModuleSrc(ctx, *l.properties.Lint.Baseline_filename)) cmd.FlagWithInput("--baseline ", android.PathForModuleSrc(ctx, *l.properties.Lint.Baseline_filename))
cmd.FlagForEachArg("--disallowed_issues ", updatabilityChecks) cmd.FlagForEachArg("--disallowed_issues ", updatabilityChecks)
} }
@@ -748,13 +733,11 @@ func lintZip(ctx android.BuilderContext, paths android.Paths, outputPath android
// Enforce the strict updatability linting to all applicable transitive dependencies. // Enforce the strict updatability linting to all applicable transitive dependencies.
func enforceStrictUpdatabilityLintingMutator(ctx android.TopDownMutatorContext) { func enforceStrictUpdatabilityLintingMutator(ctx android.TopDownMutatorContext) {
m := ctx.Module() m := ctx.Module()
if d, ok := m.(LintDepSetsIntf); ok { if d, ok := m.(LintDepSetsIntf); ok && d.GetStrictUpdatabilityLinting() {
if strict_mods := d.GetStrictUpdatabilityLinting(ctx); len(strict_mods) > 0 {
ctx.VisitDirectDepsWithTag(staticLibTag, func(d android.Module) { ctx.VisitDirectDepsWithTag(staticLibTag, func(d android.Module) {
if a, ok := d.(LintDepSetsIntf); ok { if a, ok := d.(LintDepSetsIntf); ok {
a.SetStrictUpdatabilityLinting(strict_mods) a.SetStrictUpdatabilityLinting(true)
} }
}) })
} }
} }
}

View File

@@ -202,71 +202,6 @@ func TestJavaLintStrictUpdatabilityLinting(t *testing.T) {
} }
} }
func TestJavaLintStrictUpdatabilityLintingMultipleParents(t *testing.T) {
bp := `
java_library {
name: "a",
srcs: ["a.java"],
static_libs: ["b"],
min_sdk_version: "29",
sdk_version: "current",
lint: {
strict_updatability_linting: true,
baseline_filename: "lint-baseline.xml",
},
}
java_library {
name: "b",
srcs: ["b.java"],
static_libs: ["c"],
min_sdk_version: "29",
sdk_version: "current",
lint: {
strict_updatability_linting: true,
},
}
java_library {
name: "d",
srcs: ["d.java"],
static_libs: ["c"],
min_sdk_version: "29",
sdk_version: "current",
lint: {
strict_updatability_linting: true,
},
}
java_library {
name: "c",
srcs: ["c.java"],
min_sdk_version: "29",
sdk_version: "current",
lint: {
baseline_filename: "lint-baseline.xml",
}
}
`
fs := android.MockFS{
"lint-baseline.xml": nil,
}
result := android.GroupFixturePreparers(PrepareForTestWithJavaDefaultModules, fs.AddToFixture()).
RunTestWithBp(t, bp)
c := result.ModuleForTests("c", "android_common")
sboxProto := android.RuleBuilderSboxProtoForTests(t, result.TestContext, c.Output("lint.sbox.textproto"))
if !strings.Contains(*sboxProto.Commands[0].Command,
"--baseline lint-baseline.xml --disallowed_issues NewApi") {
t.Error("did not restrict baselining NewApi")
}
if !strings.Contains(*sboxProto.Commands[0].Command,
"--strict_updatability_parents a,b,d") {
t.Errorf("Did not find correct strict_updatability_parents in command %q", *sboxProto.Commands[0].Command)
}
}
func TestJavaLintDatabaseSelectionFull(t *testing.T) { func TestJavaLintDatabaseSelectionFull(t *testing.T) {
testCases := []struct { testCases := []struct {
sdk_version string sdk_version string

View File

@@ -2968,17 +2968,17 @@ func (module *SdkLibraryImport) LintDepSets() LintDepSets {
} }
} }
func (module *SdkLibraryImport) GetStrictUpdatabilityLinting(ctx android.BaseModuleContext) []string { func (module *SdkLibraryImport) GetStrictUpdatabilityLinting() bool {
if module.implLibraryModule == nil { if module.implLibraryModule == nil {
return nil return false
} else { } else {
return module.implLibraryModule.GetStrictUpdatabilityLinting(ctx) return module.implLibraryModule.GetStrictUpdatabilityLinting()
} }
} }
func (module *SdkLibraryImport) SetStrictUpdatabilityLinting(parents []string) { func (module *SdkLibraryImport) SetStrictUpdatabilityLinting(strictLinting bool) {
if module.implLibraryModule != nil { if module.implLibraryModule != nil {
module.implLibraryModule.SetStrictUpdatabilityLinting(parents) module.implLibraryModule.SetStrictUpdatabilityLinting(strictLinting)
} }
} }

View File

@@ -77,8 +77,6 @@ def parse_args():
help='file containing merged manifest for the module and its dependencies.') help='file containing merged manifest for the module and its dependencies.')
parser.add_argument('--baseline', dest='baseline_path', parser.add_argument('--baseline', dest='baseline_path',
help='file containing baseline lint issues.') help='file containing baseline lint issues.')
parser.add_argument('--strict_updatability_parents',
help='reverse dependencies that set strict_updatability_linting: true, for use in error messages')
parser.add_argument('--library', dest='library', action='store_true', parser.add_argument('--library', dest='library', action='store_true',
help='mark the module as a library.') help='mark the module as a library.')
parser.add_argument('--test', dest='test', action='store_true', parser.add_argument('--test', dest='test', action='store_true',
@@ -163,10 +161,8 @@ def main():
baseline = minidom.parse(args.baseline_path) baseline = minidom.parse(args.baseline_path)
disallowed_issues = check_baseline_for_disallowed_issues(baseline, args.disallowed_issues) disallowed_issues = check_baseline_for_disallowed_issues(baseline, args.disallowed_issues)
if disallowed_issues: if disallowed_issues:
error_message = f'disallowed issues {disallowed_issues} found in lint baseline file {args.baseline_path} for module {args.name}' sys.exit('disallowed issues %s found in lint baseline file %s for module %s'
if args.strict_updatability_parents: % (disallowed_issues, args.baseline_path, args.name))
error_message += f'. The parent modules that set strict_updatability_linting are {args.strict_updatability_parent}'
sys.exit(error_message)
if args.project_out: if args.project_out:
with open(args.project_out, 'w') as f: with open(args.project_out, 'w') as f: