build.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. IFS=$'\n\t'
  4. STTRACE=${STTRACE:-}
  5. case "${1:-default}" in
  6. default)
  7. go run build.go
  8. ;;
  9. clean)
  10. go run build.go "$1"
  11. ;;
  12. test)
  13. ulimit -t 60 &>/dev/null || true
  14. ulimit -d 512000 &>/dev/null || true
  15. ulimit -m 512000 &>/dev/null || true
  16. go run build.go test
  17. ;;
  18. bench)
  19. LOGGER_DISCARD=1 go run build.go bench | go run benchfilter.go
  20. ;;
  21. tar)
  22. go run build.go "$1"
  23. ;;
  24. deps)
  25. go run build.go "$1"
  26. ;;
  27. assets)
  28. go run build.go "$1"
  29. ;;
  30. xdr)
  31. go run build.go "$1"
  32. ;;
  33. translate)
  34. go run build.go "$1"
  35. ;;
  36. prerelease)
  37. go run build.go transifex
  38. git add -A gui/assets/ internal/auto/
  39. pushd man ; ./refresh.sh ; popd
  40. git add -A man
  41. echo
  42. echo Changelog:
  43. go run changelog.go
  44. ;;
  45. noupgrade)
  46. go run build.go -no-upgrade tar
  47. ;;
  48. all)
  49. go run build.go -goos darwin -goarch amd64 tar
  50. go run build.go -goos darwin -goarch 386 tar
  51. go run build.go -goos dragonfly -goarch 386 tar
  52. go run build.go -goos dragonfly -goarch amd64 tar
  53. go run build.go -goos freebsd -goarch 386 tar
  54. go run build.go -goos freebsd -goarch amd64 tar
  55. go run build.go -goos linux -goarch 386 tar
  56. go run build.go -goos linux -goarch amd64 tar
  57. go run build.go -goos linux -goarch arm tar
  58. go run build.go -goos netbsd -goarch 386 tar
  59. go run build.go -goos netbsd -goarch amd64 tar
  60. go run build.go -goos openbsd -goarch 386 tar
  61. go run build.go -goos openbsd -goarch amd64 tar
  62. go run build.go -goos solaris -goarch amd64 tar
  63. go run build.go -goos windows -goarch 386 zip
  64. go run build.go -goos windows -goarch amd64 zip
  65. ;;
  66. setup)
  67. echo "Don't worry, just build."
  68. ;;
  69. test-cov)
  70. ulimit -t 600 &>/dev/null || true
  71. ulimit -d 512000 &>/dev/null || true
  72. ulimit -m 512000 &>/dev/null || true
  73. go get github.com/axw/gocov/gocov
  74. go get github.com/AlekSi/gocov-xml
  75. echo "mode: set" > coverage.out
  76. fail=0
  77. # For every package in the repo
  78. for dir in $(go list ./...) ; do
  79. # run the tests
  80. godep go test -coverprofile=profile.out $dir
  81. if [ -f profile.out ] ; then
  82. # and if there was test output, append it to coverage.out
  83. grep -v "mode: set" profile.out >> coverage.out
  84. rm profile.out
  85. fi
  86. done
  87. gocov convert coverage.out | gocov-xml > coverage.xml
  88. # This is usually run from within Jenkins. If it is, we need to
  89. # tweak the paths in coverage.xml so cobertura finds the
  90. # source.
  91. if [[ "${WORKSPACE:-default}" != "default" ]] ; then
  92. sed "s#$WORKSPACE##g" < coverage.xml > coverage.xml.new && mv coverage.xml.new coverage.xml
  93. fi
  94. ;;
  95. docker-all)
  96. docker run --rm -h syncthing-builder -u $(id -u) -t \
  97. -v $(pwd):/go/src/github.com/syncthing/syncthing \
  98. -w /go/src/github.com/syncthing/syncthing \
  99. -e "STTRACE=$STTRACE" \
  100. syncthing/build:latest \
  101. sh -c './build.sh clean \
  102. && ./build.sh test-cov \
  103. && ./build.sh bench \
  104. && ./build.sh all'
  105. ;;
  106. docker-test)
  107. docker run --rm -h syncthing-builder -u $(id -u) -t \
  108. -v $(pwd):/go/src/github.com/syncthing/syncthing \
  109. -w /go/src/github.com/syncthing/syncthing \
  110. -e "STTRACE=$STTRACE" \
  111. syncthing/build:latest \
  112. sh -euxc './build.sh clean \
  113. && go run build.go -race \
  114. && export GOPATH=$(pwd)/Godeps/_workspace:$GOPATH \
  115. && cd test \
  116. && go test -tags integration -v -timeout 90m -short \
  117. && git clean -fxd .'
  118. ;;
  119. docker-lint)
  120. docker run --rm -h syncthing-builder -u $(id -u) -t \
  121. -v $(pwd):/go/src/github.com/syncthing/syncthing \
  122. -w /go/src/github.com/syncthing/syncthing \
  123. -e "STTRACE=$STTRACE" \
  124. syncthing/build:latest \
  125. sh -euxc 'go run build.go lint'
  126. ;;
  127. docker-vet)
  128. docker run --rm -h syncthing-builder -u $(id -u) -t \
  129. -v $(pwd):/go/src/github.com/syncthing/syncthing \
  130. -w /go/src/github.com/syncthing/syncthing \
  131. -e "STTRACE=$STTRACE" \
  132. syncthing/build:latest \
  133. sh -euxc 'go run build.go vet'
  134. ;;
  135. *)
  136. echo "Unknown build command $1"
  137. ;;
  138. esac