From f302ce578b49a00de31aacc0c5e845274de3deac Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 19 Jan 2021 10:27:01 +0100 Subject: make bindings generation more robuts The Go gods did not shine upon us trying to understand what's going on in #9000. The symptom is that `go generate` did not add required imports to a generated file, ultimately breaking subsequent compilation. While it still remains unclear *why* Go is behaving like that, the symptom disappears when `go generate` runs in module mode; that is without `-mod=vendor` and without `GO111MODULE=off`. This was reproducible on two separate machines (Ubuntu and Fedora). Also, when facing an unset GOPATH, set it to Go's default (i.e., $HOME/go) and make sure that GOBIN is in PATH since `goimports` is required by `go generate`. Fixes: #9000 Signed-off-by: Valentin Rothberg --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index bdedd046f..e3cdb8a19 100644 --- a/Makefile +++ b/Makefile @@ -86,7 +86,7 @@ PODMAN_SERVER_LOG ?= # If GOPATH not specified, use one in the local directory ifeq ($(GOPATH),) -export GOPATH := $(CURDIR)/_output +export GOPATH := $(HOME)/go unexport GOBIN endif FIRST_GOPATH := $(firstword $(subst :, ,$(GOPATH))) @@ -98,6 +98,8 @@ ifeq ($(GOBIN),) GOBIN := $(FIRST_GOPATH)/bin endif +export PATH := $(PATH):$(GOBIN) + GOMD2MAN ?= $(shell command -v go-md2man || echo '$(GOBIN)/go-md2man') CROSS_BUILD_TARGETS := \ @@ -466,7 +468,7 @@ podman-remote-%-release: BINDINGS_SOURCE = $(wildcard pkg/bindings/**/types.go) .generate-bindings: $(BINDINGS_SOURCE) ifneq ($(shell uname -s), Darwin) - $(GO) generate -mod=vendor ./pkg/bindings/... ; + GO111MODULE=off $(GO) generate ./pkg/bindings/... ; endif touch .generate-bindings -- cgit v1.2.3-54-g00ecf