llvm-cov-wrapper 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/sh
  2. # This file is part of CMake-codecov.
  3. #
  4. # Copyright (c)
  5. # 2015-2017 RWTH Aachen University, Federal Republic of Germany
  6. #
  7. # See the LICENSE file in the package base directory for details
  8. #
  9. # Written by Alexander Haase, alexander.haase@rwth-aachen.de
  10. #
  11. if [ -z "$LLVM_COV_BIN" ]
  12. then
  13. echo "LLVM_COV_BIN not set!" >& 2
  14. exit 1
  15. fi
  16. # Get LLVM version to find out.
  17. LLVM_VERSION=$($LLVM_COV_BIN -version | grep -i "LLVM version" \
  18. | sed "s/^\([A-Za-z ]*\)\([0-9]\).\([0-9]\).*$/\2.\3/g")
  19. if [ "$1" = "-v" ]
  20. then
  21. echo "llvm-cov-wrapper $LLVM_VERSION"
  22. exit 0
  23. fi
  24. if [ -n "$LLVM_VERSION" ]
  25. then
  26. MAJOR=$(echo $LLVM_VERSION | cut -d'.' -f1)
  27. MINOR=$(echo $LLVM_VERSION | cut -d'.' -f2)
  28. if [ $MAJOR -eq 3 ] && [ $MINOR -le 4 ]
  29. then
  30. if [ -f "$1" ]
  31. then
  32. filename=$(basename "$1")
  33. extension="${filename##*.}"
  34. case "$extension" in
  35. "gcno") exec $LLVM_COV_BIN --gcno="$1" ;;
  36. "gcda") exec $LLVM_COV_BIN --gcda="$1" ;;
  37. esac
  38. fi
  39. fi
  40. if [ $MAJOR -eq 3 ] && [ $MINOR -le 5 ]
  41. then
  42. exec $LLVM_COV_BIN $@
  43. fi
  44. fi
  45. exec $LLVM_COV_BIN gcov $@