You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.4 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #!/bin/bash
  2. # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
  3. #
  4. # Use of this source code is governed by a BSD-style license
  5. # that can be found in the LICENSE file in the root of the source
  6. # tree. An additional intellectual property rights grant can be found
  7. # in the file PATENTS. All contributing project authors may
  8. # be found in the AUTHORS file in the root of the source tree.
  9. # This script is run in a git repository. It lists all header files,
  10. # sorted by the number of other files where the file name of the file
  11. # occurs. It is intentionally not limited to only source files, and
  12. # there may be some false hits because we search only for the file
  13. # part (sans directory). It is quite slow.
  14. #
  15. # Headers close to the top of the list are candidates for removal.
  16. # If the name includes at most one directory, keep name unchanged,
  17. # otherwise strip directories. Needed to work with relative #includes
  18. # which are used in some parts of the tree, while still avoiding,
  19. # e.g., api/foo.h to match includes of pc/foo.h.
  20. simplify_name () {
  21. if expr "$1" : '.*/.*/' > /dev/null ; then
  22. basename "$1"
  23. else
  24. echo "$1"
  25. fi
  26. }
  27. git ls-files '*.h' '*.hpp' | while read header ; do
  28. name="$(simplify_name "${header}")"
  29. count="$(git grep -l -F "${name}" \
  30. | grep -v -e '\.gn' -e '\.gyp' \
  31. | wc -l)"
  32. echo "${count}" "${header}"
  33. done | sort -n