build 778 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. set -e
  3. CDIR=$(cd `dirname "$0"`/.. && pwd)
  4. cd "$CDIR"
  5. ORG_PATH="github.com/cloudflare"
  6. REPO_PATH="${ORG_PATH}/cfssl"
  7. export GOPATH="${CDIR}/gopath"
  8. export PATH="${PATH}:${GOPATH}/bin"
  9. eval $(go env)
  10. if [ ! -h gopath/src/${REPO_PATH} ]; then
  11. mkdir -p gopath/src/${ORG_PATH}
  12. ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255
  13. fi
  14. if [ -z "$1" ]; then
  15. OS_PLATFORM_ARG=(-os="darwin linux windows")
  16. else
  17. OS_PLATFORM_ARG=($1)
  18. fi
  19. if [ -z "$2" ]; then
  20. OS_ARCH_ARG=(-arch="386 amd64 arm ppc64le")
  21. else
  22. OS_ARCH_ARG=($2)
  23. fi
  24. if ! which gox > /dev/null ; then
  25. go get github.com/mitchellh/gox
  26. fi
  27. cd "$GOPATH/src/${REPO_PATH}"
  28. gox "${OS_PLATFORM_ARG[@]}" "${OS_ARCH_ARG[@]}" -output="dist/{{.Dir}}_{{.OS}}-{{.Arch}}" -ldflags="-w" ./cmd/...