deptag.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. package android
  15. import "github.com/google/blueprint"
  16. // Dependency tags can implement this interface and return true from InstallDepNeeded to annotate
  17. // that the installed files of the parent should depend on the installed files of the child.
  18. type InstallNeededDependencyTag interface {
  19. // If InstallDepNeeded returns true then the installed files of the parent will depend on the
  20. // installed files of the child.
  21. InstallDepNeeded() bool
  22. }
  23. // Dependency tags can embed this struct to annotate that the installed files of the parent should
  24. // depend on the installed files of the child.
  25. type InstallAlwaysNeededDependencyTag struct{}
  26. func (i InstallAlwaysNeededDependencyTag) InstallDepNeeded() bool {
  27. return true
  28. }
  29. var _ InstallNeededDependencyTag = InstallAlwaysNeededDependencyTag{}
  30. // IsInstallDepNeededTag returns true if the dependency tag implements the InstallNeededDependencyTag
  31. // interface and the InstallDepNeeded returns true, meaning that the installed files of the parent
  32. // should depend on the installed files of the child.
  33. func IsInstallDepNeededTag(tag blueprint.DependencyTag) bool {
  34. if i, ok := tag.(InstallNeededDependencyTag); ok {
  35. return i.InstallDepNeeded()
  36. }
  37. return false
  38. }