coverity.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/sh
  2. #
  3. # This scripts attempts to build the project via cov-build utility, and prepare
  4. # a package for uploading to the coverity scan service.
  5. #
  6. # (See http://scan.coverity.com for more info.)
  7. set -e
  8. # Check presence of coverity static analyzer.
  9. if ! which cov-build; then
  10. echo "Utility cov-build not found in PATH."
  11. exit 1
  12. fi
  13. # Choose a build system (ninja or GNU make).
  14. if which ninja; then
  15. BUILD_TOOL=ninja
  16. GENERATOR=Ninja
  17. elif which make; then
  18. BUILD_TOOL=make
  19. GENERATOR="MSYS Makefiles"
  20. else
  21. echo "No suitable build system found."
  22. exit 1
  23. fi
  24. # Choose a zip tool.
  25. if which 7za; then
  26. MKZIP="7za a -r -mx9"
  27. elif which 7z; then
  28. MKZIP="7z a -r -mx9"
  29. elif which zip; then
  30. MKZIP="zip -r"
  31. else
  32. echo "No suitable zip utility found"
  33. exit 1
  34. fi
  35. # Change dir to project root.
  36. cd `dirname "$0"`/..
  37. CWD=`pwd`
  38. ROOT_DIR="$CWD"
  39. BUILD_DIR="$CWD/coverity"
  40. OUTPUT="$CWD/cov-int.zip"
  41. # Sanity checks.
  42. if [ ! -x "$ROOT_DIR/scripts/coverity.sh" ]; then
  43. echo "There is some path mismatch."
  44. exit 1
  45. fi
  46. if [ -e "$BUILD_DIR" ]; then
  47. echo "Path $BUILD_DIR already exists. Delete it and retry."
  48. exit 1
  49. fi
  50. if [ -e "$OUTPUT" ]; then
  51. echo "Path $OUTPUT already exists. Delete it and retry."
  52. exit 1
  53. fi
  54. # Build the project with the Coverity analyzes enabled.
  55. mkdir -p "$BUILD_DIR"
  56. cd "$BUILD_DIR"
  57. cmake -G "$GENERATOR" "$ROOT_DIR"
  58. cov-build --dir cov-int "$BUILD_TOOL"
  59. $MKZIP "$OUTPUT" "cov-int"
  60. cd "$ROOT_DIR"
  61. rm -rf "$BUILD_DIR"