clippy.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. package rust
  15. import (
  16. "android/soong/rust/config"
  17. )
  18. type ClippyProperties struct {
  19. // name of the lint set that should be used to validate this module.
  20. //
  21. // Possible values are "default" (for using a sensible set of lints
  22. // depending on the module's location), "android" (for the strictest
  23. // lint set that applies to all Android platform code), "vendor" (for a
  24. // relaxed set) and "none" (to disable the execution of clippy). The
  25. // default value is "default". See also the `lints` property.
  26. Clippy_lints *string
  27. }
  28. type clippy struct {
  29. Properties ClippyProperties
  30. }
  31. func (c *clippy) props() []interface{} {
  32. return []interface{}{&c.Properties}
  33. }
  34. func (c *clippy) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags, PathDeps) {
  35. enabled, lints, err := config.ClippyLintsForDir(ctx.ModuleDir(), c.Properties.Clippy_lints)
  36. if err != nil {
  37. ctx.PropertyErrorf("clippy_lints", err.Error())
  38. }
  39. flags.Clippy = enabled
  40. flags.ClippyFlags = append(flags.ClippyFlags, lints)
  41. return flags, deps
  42. }