build.sh 2.0 KB

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