build.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 -goos linux -goarch amd64 tar
  37. go run build.go -goos linux -goarch 386 tar
  38. go run build.go -goos linux -goarch armv5 tar
  39. go run build.go -goos linux -goarch armv6 tar
  40. go run build.go -goos linux -goarch armv7 tar
  41. go run build.go -goos freebsd -goarch amd64 tar
  42. go run build.go -goos freebsd -goarch 386 tar
  43. go run build.go -goos darwin -goarch amd64 tar
  44. go run build.go -goos windows -goarch amd64 zip
  45. go run build.go -goos windows -goarch 386 zip
  46. ;;
  47. setup)
  48. echo "Don't worry, just build."
  49. ;;
  50. test-cov)
  51. go get github.com/axw/gocov/gocov
  52. go get github.com/AlekSi/gocov-xml
  53. echo "mode: set" > coverage.out
  54. fail=0
  55. # For every package in the repo
  56. for dir in $(go list ./...) ; do
  57. # run the tests
  58. godep go test -coverprofile=profile.out $dir
  59. if [ -f profile.out ] ; then
  60. # and if there was test output, append it to coverage.out
  61. grep -v "mode: set" profile.out >> coverage.out
  62. rm profile.out
  63. fi
  64. done
  65. gocov convert coverage.out | gocov-xml > coverage.xml
  66. # This is usually run from within Jenkins. If it is, we need to
  67. # tweak the paths in coverage.xml so cobertura finds the
  68. # source.
  69. if [[ "${WORKSPACE:-default}" != "default" ]] ; then
  70. sed "s#$WORKSPACE##g" < coverage.xml > coverage.xml.new && mv coverage.xml.new coverage.xml
  71. fi
  72. ;;
  73. *)
  74. echo "Unknown build command $1"
  75. ;;
  76. esac