Add clippy-driver build rule

Depending on the location of the repository (e.g. external/, vendor/), a
different set of lints will be enabled. Add the clippy property to the
rust_* modules. This property can be used to overwrite the default
behaviour.

Test: m checkbuild
Bug: 157238651
Change-Id: Ife0f723ef4a74abb102597f8486a7b9f30e7d351
This commit is contained in:
Thiébaud Weksteen
2020-06-22 13:28:02 +02:00
parent a5d1fab176
commit 92f703b084
7 changed files with 225 additions and 8 deletions

View File

@@ -49,8 +49,10 @@ type Flags struct {
GlobalLinkFlags []string // Flags that apply globally to linker
RustFlags []string // Flags that apply to rust
LinkFlags []string // Flags that apply to linker
ClippyFlags []string // Flags that apply to clippy-driver, during the linting
Toolchain config.Toolchain
Coverage bool
Clippy bool
}
type BaseProperties struct {
@@ -75,6 +77,7 @@ type Module struct {
compiler compiler
coverage *coverage
clippy *clippy
cachedToolchain config.Toolchain
subAndroidMkOnce map[subAndroidMkProvider]bool
outputFile android.OptionalPath
@@ -306,6 +309,7 @@ func DefaultsFactory(props ...interface{}) android.Module {
&PrebuiltProperties{},
&TestProperties{},
&cc.CoverageProperties{},
&ClippyProperties{},
)
android.InitDefaultsModule(module)
@@ -456,6 +460,9 @@ func (mod *Module) Init() android.Module {
if mod.coverage != nil {
mod.AddProperties(mod.coverage.props()...)
}
if mod.clippy != nil {
mod.AddProperties(mod.clippy.props()...)
}
android.InitAndroidArchModule(mod, mod.hod, mod.multilib)
@@ -487,6 +494,7 @@ func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib)
func newModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
module := newBaseModule(hod, multilib)
module.coverage = &coverage{}
module.clippy = &clippy{}
return module
}
@@ -576,6 +584,9 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
if mod.coverage != nil {
flags, deps = mod.coverage.flags(ctx, flags, deps)
}
if mod.clippy != nil {
flags, deps = mod.clippy.flags(ctx, flags, deps)
}
if mod.compiler != nil {
outputFile := mod.compiler.compile(ctx, flags, deps)