build.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. IFS=$'\n\t'
  4. case "${1:-default}" in
  5. default)
  6. go run build.go
  7. ;;
  8. clean)
  9. go run build.go "$1"
  10. ;;
  11. test)
  12. go run build.go "$1"
  13. ;;
  14. tar)
  15. go run build.go "$1"
  16. ;;
  17. deps)
  18. go run build.go "$1"
  19. ;;
  20. assets)
  21. go run build.go "$1"
  22. ;;
  23. xdr)
  24. go run build.go "$1"
  25. ;;
  26. translate)
  27. go run build.go "$1"
  28. ;;
  29. transifex)
  30. go run build.go "$1"
  31. ;;
  32. noupgrade)
  33. go run build.go -no-upgrade tar
  34. ;;
  35. all)
  36. go run build.go test
  37. go run build.go -goos linux -goarch amd64 tar
  38. go run build.go -goos linux -goarch 386 tar
  39. go run build.go -goos linux -goarch armv5 tar
  40. go run build.go -goos linux -goarch armv6 tar
  41. go run build.go -goos linux -goarch armv7 tar
  42. go run build.go -goos freebsd -goarch amd64 tar
  43. go run build.go -goos freebsd -goarch 386 tar
  44. go run build.go -goos darwin -goarch amd64 tar
  45. go run build.go -goos windows -goarch amd64 zip
  46. go run build.go -goos windows -goarch 386 zip
  47. ;;
  48. setup)
  49. echo "Don't worry, just build."
  50. ;;
  51. test-cov)
  52. go get github.com/axw/gocov/gocov
  53. go get github.com/AlekSi/gocov-xml
  54. echo "mode: set" > coverage.out
  55. fail=0
  56. # For every package in the repo
  57. for dir in $(go list ./...) ; do
  58. # run the tests
  59. godep go test -coverprofile=profile.out $dir
  60. if [ -f profile.out ] ; then
  61. # and if there was test output, append it to coverage.out
  62. grep -v "mode: set" profile.out >> coverage.out
  63. rm profile.out
  64. fi
  65. done
  66. gocov convert coverage.out | gocov-xml > coverage.xml
  67. # This is usually run from within Jenkins. If it is, we need to
  68. # tweak the paths in coverage.xml so cobertura finds the
  69. # source.
  70. if [[ "${WORKSPACE:-default}" != "default" ]] ; then
  71. sed "s#$WORKSPACE##g" < coverage.xml > coverage.xml.new && mv coverage.xml.new coverage.xml
  72. fi
  73. ;;
  74. *)
  75. echo "Unknown build command $1"
  76. ;;
  77. esac