Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Set CGO_ENABLED=1 for OS X builds in hack/build-all script #1839

Merged
merged 4 commits into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ jobs:
- trap EXIT
- make test
- go: 1.10.x
# Run on OS X so that we get a CGO-enabled binary for this OS; see
# https://github.com/golang/dep/issues/1838 for more details.
os: osx
stage: deploy
go_import_path: github.com/golang/dep
install: skip
Expand Down
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ GOBIN=$(GOPATH)/bin
default: build validate test

get-deps:
# Workaround https://github.com/golang/lint/issues/397
[ -d $(GOPATH)/src/golang.org/x ] || mkdir -p $(GOPATH)/src/golang.org/x
git clone --depth=1 https://github.com/golang/lint.git $(GOPATH)/src/golang.org/x/lint
# End workaround
go get -u golang.org/x/lint/golint honnef.co/go/tools/cmd/megacheck

build:
Expand Down
14 changes: 12 additions & 2 deletions hack/build-all.bash
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ DEP_ROOT=$(git rev-parse --show-toplevel)
VERSION=$(git describe --tags --dirty)
COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null)
DATE=$(date "+%Y-%m-%d")
BUILD_PLATFORM=$(uname -a | awk '{print tolower($1);}')
IMPORT_DURING_SOLVE=${IMPORT_DURING_SOLVE:-false}

if [[ "$(pwd)" != "${DEP_ROOT}" ]]; then
Expand Down Expand Up @@ -41,8 +42,17 @@ for OS in ${DEP_BUILD_PLATFORMS[@]}; do
if [[ "${OS}" == "windows" ]]; then
NAME="${NAME}.exe"
fi
echo "Building for ${OS}/${ARCH}"
GOARCH=${ARCH} GOOS=${OS} CGO_ENABLED=0 ${GO_BUILD_CMD} -ldflags "${GO_BUILD_LDFLAGS}"\

# Enable CGO if building for OS X on OS X; see
# https://github.com/golang/dep/issues/1838 for details.
if [[ "${OS}" == "darwin" && "${BUILD_PLATFORM}" == "darwin" ]]; then
CGO_ENABLED=1
else
CGO_ENABLED=0
fi

echo "Building for ${OS}/${ARCH} with CGO_ENABLED=${CGO_ENABLED}"
GOARCH=${ARCH} GOOS=${OS} CGO_ENABLED=${CGO_ENABLED} ${GO_BUILD_CMD} -ldflags "${GO_BUILD_LDFLAGS}"\
-o "${DEP_ROOT}/release/${NAME}" ./cmd/dep/
shasum -a 256 "${DEP_ROOT}/release/${NAME}" > "${DEP_ROOT}/release/${NAME}".sha256
done
Expand Down