Simplify for Go modules

This commit is contained in:
Tim Hockin 2019-03-22 10:44:28 -07:00
parent 4493070350
commit 15d53f3b99
2 changed files with 7 additions and 22 deletions

View File

@ -15,9 +15,6 @@
# The binary to build (just the basename). # The binary to build (just the basename).
BIN := git-sync BIN := git-sync
# This repo's root import path (under GOPATH).
PKG := k8s.io/git-sync
# Where to push the docker image. # Where to push the docker image.
REGISTRY ?= staging-k8s.gcr.io REGISTRY ?= staging-k8s.gcr.io
@ -82,10 +79,7 @@ build: bin/$(OS)_$(ARCH)/$(BIN)
BUILD_DIRS := \ BUILD_DIRS := \
bin/$(OS)_$(ARCH) \ bin/$(OS)_$(ARCH) \
.go/src/$(PKG) \
.go/pkg \
.go/bin/$(OS)_$(ARCH) \ .go/bin/$(OS)_$(ARCH) \
.go/std/$(OS)_$(ARCH) \
.go/cache .go/cache
# The following structure defeats Go's (intentional) behavior to always touch # The following structure defeats Go's (intentional) behavior to always touch
@ -103,13 +97,11 @@ $(OUTBIN): .go/$(OUTBIN).stamp
-ti \ -ti \
--rm \ --rm \
-u $$(id -u):$$(id -g) \ -u $$(id -u):$$(id -g) \
-v $$(pwd):/go/src/$(PKG) \ -v $$(pwd):/src \
-v $$(pwd)/.go:/go \ -w /src \
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin \ -v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin \
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin/$(OS)_$(ARCH) \ -v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin/$(OS)_$(ARCH) \
-v $$(pwd)/.go/std/$(OS)_$(ARCH):/usr/local/go/pkg/$(OS)_$(ARCH)_static \
-v $$(pwd)/.go/cache:/.cache \ -v $$(pwd)/.go/cache:/.cache \
-w /go/src/$(PKG) \
--env HTTP_PROXY=$(HTTP_PROXY) \ --env HTTP_PROXY=$(HTTP_PROXY) \
--env HTTPS_PROXY=$(HTTPS_PROXY) \ --env HTTPS_PROXY=$(HTTPS_PROXY) \
$(BUILD_IMAGE) \ $(BUILD_IMAGE) \
@ -117,7 +109,6 @@ $(OUTBIN): .go/$(OUTBIN).stamp
ARCH=$(ARCH) \ ARCH=$(ARCH) \
OS=$(OS) \ OS=$(OS) \
VERSION=$(VERSION) \ VERSION=$(VERSION) \
PKG=$(PKG) \
./build/build.sh \ ./build/build.sh \
" "
@if ! cmp -s .go/$(OUTBIN) $(OUTBIN); then \ @if ! cmp -s .go/$(OUTBIN) $(OUTBIN); then \
@ -172,15 +163,13 @@ test: $(BUILD_DIRS)
@docker run \ @docker run \
-ti \ -ti \
-u $$(id -u):$$(id -g) \ -u $$(id -u):$$(id -g) \
-v $$(pwd):/go/src/$(PKG) \ -v $$(pwd):/src \
-v $$(pwd)/.go:/go \ -w /src \
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin \ -v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin \
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin/$(OS)_$(ARCH) \ -v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin/$(OS)_$(ARCH) \
-v $$(pwd)/.go/std/$(OS)_$(ARCH):/usr/local/go/pkg/$(OS)_$(ARCH)_static \
-v $$(pwd)/.go/cache:/.cache \ -v $$(pwd)/.go/cache:/.cache \
--env HTTP_PROXY=$(HTTP_PROXY) \ --env HTTP_PROXY=$(HTTP_PROXY) \
--env HTTPS_PROXY=$(HTTPS_PROXY) \ --env HTTPS_PROXY=$(HTTPS_PROXY) \
-w /go/src/$(PKG) \
$(BUILD_IMAGE) \ $(BUILD_IMAGE) \
/bin/sh -c " \ /bin/sh -c " \
./build/test.sh $(SRC_DIRS) \ ./build/test.sh $(SRC_DIRS) \

View File

@ -18,10 +18,6 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
if [ -z "${PKG:-}" ]; then
echo "PKG must be set"
exit 1
fi
if [ -z "${ARCH:-}" ]; then if [ -z "${ARCH:-}" ]; then
echo "ARCH must be set" echo "ARCH must be set"
exit 1 exit 1
@ -40,7 +36,7 @@ export GOARCH="${ARCH}"
export GOOS="${OS}" export GOOS="${OS}"
export GOFLAGS="-mod=vendor" export GOFLAGS="-mod=vendor"
go install \ go install \
-installsuffix "static" \ -installsuffix "static" \
-ldflags "-X ${PKG}/pkg/version.VERSION=${VERSION}" \ -ldflags "-X $(go list -m)/pkg/version.VERSION=${VERSION}" \
./... ./...