diff --git a/.travis.yml b/.travis.yml index 87a186f1c0..017f65f63a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Makefile b/Makefile index cfed53530b..a37104937d 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/hack/build-all.bash b/hack/build-all.bash index 01dacd21fb..83cb08f9fc 100755 --- a/hack/build-all.bash +++ b/hack/build-all.bash @@ -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 @@ -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