Skip to content

Commit

Permalink
Move to build-tools 2.2.0 in support of getting ddev to appveyor (#1470)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay committed Mar 1, 2019
1 parent b39e6f2 commit e7c0133
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ ifeq ($(BUILD_OS),linux)
endif

ifeq ($(BUILD_OS),windows)
DDEV_BINARY_FULLPATH=$(PWD)/$(GOTMP)/bin/$(BUILD_OS)_$(BUILD_ARCH)/ddev.exe
DDEV_BINARY_FULLPATH=$(shell pwd)/$(GOTMP)/bin/$(BUILD_OS)_$(BUILD_ARCH)/ddev.exe
endif

ifeq ($(BUILD_OS),darwin)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion build-tools/build_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ tar -xf $local_file
rm -rf build-tools/*
cp -r $internal_name/ build-tools/
rm -rf $internal_name/
rm -rf build-tools/{tests,circle.yml,.circleci,.github,.appveyor.yml,.buildkite}
rm -rf build-tools/{tests,circle.yml,.circleci,.github,.appveyor.yml,.buildkite,.autotests}
touch build-tools/build-tools-VERSION-$tag.txt
git add build-tools
echo "Updated build-tools to $tag
Expand Down
53 changes: 35 additions & 18 deletions build-tools/makefile_components/base_build_go.mak
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,26 @@
##### contents into ../Makefile and commenting out the include and adding a
##### comment about what you did and why.

# The //workdir prevents docker and friends from trying to convert the thing to a non-unix path.
# The $(S) in fromt of paths is a slash used only for Docker Toolbox, for the same reason.
DOCKERBUILDCMD=docker run -t --rm -u $(shell id -u):$(shell id -g) \
-v "$(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG)" \
-v "$(S)$$PWD:/workdir$(DOCKERMOUNTFLAG)" \
-v "$(S)$(PWD):/workdir$(DOCKERMOUNTFLAG)" \
-v "$(S)$(PWD)/$(GOTMP)/bin:$(S)/go/bin" \
-e CGO_ENABLED=0 \
-e GOOS=$@ \
-w $(S)/workdir \
-e GOPATH="//workdir/$(GOTMP)" \
-e GOFLAGS="$(USEMODVENDOR)" \
-w //workdir \
$(BUILD_IMAGE)

DOCKERTESTCMD=docker run -t --rm -u $(shell id -u):$(shell id -g) \
-v "$(S)$$PWD/$(GOTMP):/go$(DOCKERMOUNTFLAG)" \
-v "$(S)$$PWD:/workdir$(DOCKERMOUNTFLAG)" \
-w $(S)/workdir \
-v "$(S)$(PWD):/workdir$(DOCKERMOUNTFLAG)" \
-e GOPATH="//workdir/$(GOTMP)" \
-e GOFLAGS="$(USEMODVENDOR)" \
-w //workdir \
$(BUILD_IMAGE)

.PHONY: all build test push clean container-clean bin-clean version static gofmt govet golint golangci-lint container
.PHONY: all build test push clean container-clean bin-clean version static gofmt govet golint golangci-lint container pull
GOTMP=.gotmp

SHELL = /bin/bash
Expand All @@ -27,9 +32,9 @@ GOFILES = $(shell find $(SRC_DIRS) -name "*.go")

BUILD_OS = $(shell go env GOHOSTOS)

BUILD_IMAGE ?= drud/golang-build-container:v1.11.4.2
BUILD_IMAGE ?= drud/golang-build-container:v1.12

BUILD_BASE_DIR ?= $$PWD
BUILD_BASE_DIR ?= $(PWD)

# Expands SRC_DIRS into the common golang ./dir/... format for "all below"
SRC_AND_UNDER = $(patsubst %,./%/...,$(SRC_DIRS))
Expand All @@ -39,7 +44,7 @@ GOMETALINTER_ARGS ?= --vendored-linters --disable-all --enable=gofmt --enable=ve
GOLANGCI_LINT_ARGS ?= --out-format=line-number --disable-all --enable=gofmt --enable=govet --enable=golint --enable=errcheck --enable=staticcheck --enable=ineffassign --enable=varcheck --enable=deadcode

COMMIT := $(shell git describe --tags --always --dirty)
BUILDINFO = $(shell echo Built $$(date) $$(whoami)@$$(hostname) $(BUILD_IMAGE) )
BUILDINFO = $(shell echo Built $$(date) $(BUILD_IMAGE) )

VERSION_VARIABLES += VERSION COMMIT BUILDINFO

Expand All @@ -52,23 +57,35 @@ DOCKERMOUNTFLAG := :delegated
# See https://github.com/golang/go/issues/27227
USEMODVENDOR := $(shell if [ -d vendor ]; then echo "-mod=vendor"; fi)


PWD=$(shell pwd)
S =
ifeq ($(BUILD_OS),windows)
# On Windows docker toolbox, volume mounts oddly need a // at the beginning for things to work out, so
# add that extra slash only on Windows.
DOCKERMOUNTFLAG=
endif

# On Docker Toolbox we can't use paths like C:\xxx\xxx, must use /C/xxx/xxx
# However, on Docker-for-Windows/Appveyor we must use C:\xxx
# On all other (macos/linux) $PWD will already be OK.
ifneq ($(shell if [ "$(BUILD_OS)" = "windows" ] && [ -z "$(DOCKER_TOOLBOX_INSTALL_PATH)" ]; then echo true; fi),)
PWD=$(shell cmd //c "echo %cd%")
endif
ifneq ($(DOCKER_TOOLBOX_INSTALL_PATH),)
PWD=$(shell pwd)
S=/
endif

build: $(BUILD_OS)

linux darwin windows: $(GOFILES)
pull:
@if [[ "$(docker images -q $(BUILD_IMAGE) 2> /dev/null)" == "" ]]; then docker pull $(BUILD_IMAGE) >/dev/null 2>&1; fi


linux darwin windows: pull $(GOFILES)
@echo "building $@ from $(SRC_AND_UNDER)"
@echo $(shell if [ "$(BUILD_OS)" = "windows" ]; then echo "windows build: BUILD_OS=$(BUILD_OS) DOCKER_TOOLBOX_INSTALL_PATH=$(DOCKER_TOOLBOX_INSTALL_PATH) PWD=$(PWD) S=$(S)"; fi )
@mkdir -p $(GOTMP)/{.cache,pkg,src,bin}
@$(DOCKERBUILDCMD) \
go install $(USEMODVENDOR) -installsuffix static -ldflags ' $(LDFLAGS) ' $(SRC_AND_UNDER)
@$(shell touch $@)
$(DOCKERBUILDCMD) \
go install -installsuffix static -ldflags ' $(LDFLAGS) ' $(SRC_AND_UNDER) && touch $@
$( shell if [ -d $(GOTMP) ]; then chmod -R u+w $(GOTMP); fi )
@echo $(VERSION) >VERSION.txt

Expand All @@ -79,7 +96,7 @@ gofmt:

govet:
@echo "Checking go vet: "
@$(DOCKERTESTCMD) \
$(DOCKERTESTCMD) \
bash -c 'go vet $(SRC_AND_UNDER)'

golint:
Expand Down
11 changes: 2 additions & 9 deletions build-tools/makefile_components/base_test_go.mak
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,9 @@ TESTOS = $(BUILD_OS)
test: build
@echo "Testing $(SRC_AND_UNDER) with TESTARGS=$(TESTARGS)"
@mkdir -p $(GOTMP)/{.cache,pkg,src,bin}
@docker run -t --rm -u $(shell id -u):$(shell id -g) \
-v $(PWD)/$(GOTMP):/go$(DOCKERMOUNTFLAG) \
-v $(PWD):/go/src/$(PKG)$(DOCKERMOUNTFLAG) \
-v $(PWD)/bin/linux:/go/bin$(DOCKERMOUNTFLAG) \
-v $(PWD)/$(GOTMP)/std/linux:/usr/local/go/pkg/linux_amd64_static$(DOCKERMOUNTFLAG) \
-e CGO_ENABLED=0 \
-w /go/src/$(PKG) \
$(BUILD_IMAGE) \
@$(DOCKERTESTCMD) \
go test $(USEMODVENDOR) -v -installsuffix static -ldflags '$(LDFLAGS)' $(SRC_AND_UNDER) $(TESTARGS)
@$(shell chmod -R u+w $(GOTMP))
$( shell if [ -d $(GOTMP) ]; then chmod -R u+w $(GOTMP); fi )

# test_precompile allows a full compilation of _test.go files, without execution of the tests.
# Setup and teardown in TestMain is still executed though, so this can cost some time.
Expand Down

0 comments on commit e7c0133

Please sign in to comment.