You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
972 B

  1. #!/bin/bash
  2. set -e
  3. # Enable tracing if set.
  4. [ -n "$BASH_XTRACEFD" ] && set -x
  5. function _init() {
  6. ## All binaries are static make sure to disable CGO.
  7. export CGO_ENABLED=0
  8. ## List of architectures and OS to test coss compilation.
  9. SUPPORTED_OSARCH="linux/ppc64le linux/mips64 linux/amd64 linux/arm64 linux/s390x darwin/arm64 darwin/amd64 freebsd/amd64 windows/amd64 linux/arm linux/386 netbsd/amd64 linux/mips openbsd/amd64 linux/riscv64"
  10. }
  11. function _build() {
  12. local osarch=$1
  13. IFS=/ read -r -a arr <<<"$osarch"
  14. os="${arr[0]}"
  15. arch="${arr[1]}"
  16. package=$(go list -f '{{.ImportPath}}')
  17. printf -- "--> %15s:%s\n" "${osarch}" "${package}"
  18. # go build -trimpath to build the binary.
  19. export GOOS=$os
  20. export GOARCH=$arch
  21. export GO111MODULE=on
  22. go build -trimpath -tags kqueue -o /dev/null
  23. }
  24. function main() {
  25. echo "Testing builds for OS/Arch: ${SUPPORTED_OSARCH}"
  26. for each_osarch in ${SUPPORTED_OSARCH}; do
  27. _build "${each_osarch}"
  28. done
  29. }
  30. _init && main "$@"