github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/hack/make/.binary (about)

     1  #!/usr/bin/env bash
     2  set -e
     3  
     4  # a helper to provide ".exe" when it's appropriate
     5  binary_extension() {
     6  	if [ "$(go env GOOS)" = 'windows' ]; then
     7  		echo -n '.exe'
     8  	fi
     9  }
    10  
    11  GO_PACKAGE='github.com/docker/docker/cmd/dockerd'
    12  BINARY_SHORT_NAME='dockerd'
    13  BINARY_NAME="$BINARY_SHORT_NAME-$VERSION"
    14  BINARY_EXTENSION="$(binary_extension)"
    15  BINARY_FULLNAME="$BINARY_NAME$BINARY_EXTENSION"
    16  
    17  source "${MAKEDIR}/.go-autogen"
    18  
    19  hash_files() {
    20  	while [ $# -gt 0 ]; do
    21  		f="$1"
    22  		shift
    23  		dir="$(dirname "$f")"
    24  		base="$(basename "$f")"
    25  		for hashAlgo in md5 sha256; do
    26  			if command -v "${hashAlgo}sum" &> /dev/null; then
    27  				(
    28  					# subshell and cd so that we get output files like:
    29  					#   $HASH docker-$VERSION
    30  					# instead of:
    31  					#   $HASH /go/src/github.com/.../$VERSION/binary/docker-$VERSION
    32  					cd "$dir"
    33  					"${hashAlgo}sum" "$base" > "$base.$hashAlgo"
    34  				)
    35  			fi
    36  		done
    37  	done
    38  }
    39  
    40  (
    41  export GOGC=${DOCKER_BUILD_GOGC:-1000}
    42  
    43  if [ "$(go env GOOS)/$(go env GOARCH)" != "$(go env GOHOSTOS)/$(go env GOHOSTARCH)" ]; then
    44  	# must be cross-compiling!
    45  	case "$(go env GOOS)/$(go env GOARCH)" in
    46  		windows/amd64)
    47  			export CC=x86_64-w64-mingw32-gcc
    48  			export CGO_ENABLED=1
    49  			;;
    50  	esac
    51  fi
    52  
    53  echo "Building: $DEST/$BINARY_FULLNAME"
    54  go build \
    55  	-o "$DEST/$BINARY_FULLNAME" \
    56  	"${BUILDFLAGS[@]}" \
    57  	-ldflags "
    58  		$LDFLAGS
    59  		$LDFLAGS_STATIC_DOCKER
    60  		$DOCKER_LDFLAGS
    61  	" \
    62  	$GO_PACKAGE
    63  )
    64  
    65  echo "Created binary: $DEST/$BINARY_FULLNAME"
    66  ln -sf "$BINARY_FULLNAME" "$DEST/$BINARY_SHORT_NAME$BINARY_EXTENSION"
    67  
    68  hash_files "$DEST/$BINARY_FULLNAME"