Thiébaud Weksteen | 92f703b | 2020-06-22 13:28:02 +0200 | [diff] [blame] | 1 | // Copyright 2020 The Android Open Source Project |
| 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 rust |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/rust/config" |
| 19 | ) |
| 20 | |
| 21 | type ClippyProperties struct { |
Thiébaud Weksteen | 9e8451e | 2020-08-13 12:55:59 +0200 | [diff] [blame] | 22 | // name of the lint set that should be used to validate this module. |
| 23 | // |
| 24 | // Possible values are "default" (for using a sensible set of lints |
| 25 | // depending on the module's location), "android" (for the strictest |
| 26 | // lint set that applies to all Android platform code), "vendor" (for a |
| 27 | // relaxed set) and "none" (to disable the execution of clippy). The |
| 28 | // default value is "default". See also the `lints` property. |
| 29 | Clippy_lints *string |
Thiébaud Weksteen | 92f703b | 2020-06-22 13:28:02 +0200 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | type clippy struct { |
| 33 | Properties ClippyProperties |
| 34 | } |
| 35 | |
| 36 | func (c *clippy) props() []interface{} { |
| 37 | return []interface{}{&c.Properties} |
| 38 | } |
| 39 | |
| 40 | func (c *clippy) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags, PathDeps) { |
Thiébaud Weksteen | 9e8451e | 2020-08-13 12:55:59 +0200 | [diff] [blame] | 41 | enabled, lints, err := config.ClippyLintsForDir(ctx.ModuleDir(), c.Properties.Clippy_lints) |
| 42 | if err != nil { |
| 43 | ctx.PropertyErrorf("clippy_lints", err.Error()) |
Thiébaud Weksteen | 92f703b | 2020-06-22 13:28:02 +0200 | [diff] [blame] | 44 | } |
Thiébaud Weksteen | 92f703b | 2020-06-22 13:28:02 +0200 | [diff] [blame] | 45 | flags.Clippy = enabled |
| 46 | flags.ClippyFlags = append(flags.ClippyFlags, lints) |
| 47 | return flags, deps |
| 48 | } |