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

Commit c901de3

Browse files
authored
Merge pull request #1839 from yolken-stripe/yolken-build-all-cgo
Set CGO_ENABLED=1 for OS X builds in hack/build-all script
2 parents f9cb443 + 8b166f2 commit c901de3

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ jobs:
4848
- trap EXIT
4949
- make test
5050
- go: 1.10.x
51+
# Run on OS X so that we get a CGO-enabled binary for this OS; see
52+
# https://github.com/golang/dep/issues/1838 for more details.
53+
os: osx
5154
stage: deploy
5255
go_import_path: github.com/golang/dep
5356
install: skip

Makefile

-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ GOBIN=$(GOPATH)/bin
77
default: build validate test
88

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

1612
build:

hack/build-all.bash

+12-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ DEP_ROOT=$(git rev-parse --show-toplevel)
1414
VERSION=$(git describe --tags --dirty)
1515
COMMIT_HASH=$(git rev-parse --short HEAD 2>/dev/null)
1616
DATE=$(date "+%Y-%m-%d")
17+
BUILD_PLATFORM=$(uname -a | awk '{print tolower($1);}')
1718
IMPORT_DURING_SOLVE=${IMPORT_DURING_SOLVE:-false}
1819

1920
if [[ "$(pwd)" != "${DEP_ROOT}" ]]; then
@@ -41,8 +42,17 @@ for OS in ${DEP_BUILD_PLATFORMS[@]}; do
4142
if [[ "${OS}" == "windows" ]]; then
4243
NAME="${NAME}.exe"
4344
fi
44-
echo "Building for ${OS}/${ARCH}"
45-
GOARCH=${ARCH} GOOS=${OS} CGO_ENABLED=0 ${GO_BUILD_CMD} -ldflags "${GO_BUILD_LDFLAGS}"\
45+
46+
# Enable CGO if building for OS X on OS X; see
47+
# https://github.com/golang/dep/issues/1838 for details.
48+
if [[ "${OS}" == "darwin" && "${BUILD_PLATFORM}" == "darwin" ]]; then
49+
CGO_ENABLED=1
50+
else
51+
CGO_ENABLED=0
52+
fi
53+
54+
echo "Building for ${OS}/${ARCH} with CGO_ENABLED=${CGO_ENABLED}"
55+
GOARCH=${ARCH} GOOS=${OS} CGO_ENABLED=${CGO_ENABLED} ${GO_BUILD_CMD} -ldflags "${GO_BUILD_LDFLAGS}"\
4656
-o "${DEP_ROOT}/release/${NAME}" ./cmd/dep/
4757
shasum -a 256 "${DEP_ROOT}/release/${NAME}" > "${DEP_ROOT}/release/${NAME}".sha256
4858
done

0 commit comments

Comments
 (0)