From 7989c939a3ba444059d9e244e3e598f4694e7076 Mon Sep 17 00:00:00 2001 From: Saisree Valluri Date: Thu, 19 Jan 2023 19:33:23 +0000 Subject: [PATCH] Add -buildvcs=false to Makefile --- Makefile | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a0db556..1f3ffb7 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ LOCAL_IPAM_PLUGIN_BINARY=bin/plugins/ecs-ipam LOCAL_BRIDGE_PLUGIN_BINARY=bin/plugins/ecs-bridge VERSION=$(shell cat $(ROOT)/VERSION) GO_EXECUTABLE=$(shell command -v go 2> /dev/null) +GO_VERSION=`go version | cut -d' ' -f3 | cut -c 3-` # We want to embed some git details in the build. We support pulling # these details from the environment in order support builds outside @@ -25,6 +26,15 @@ ifeq ($(strip $(GIT_PORCELAIN)),) GIT_PORCELAIN=1 endif +# buildvcs=false excludes version control information in golang >= 1.18. +# This is required for compiling agent with included repositories +ifeq ($(shell expr $(GO_VERSION) \>= 1.18), 1) + BUILD_VCS := -buildvcs=false +else + # leaving BUILD_VCS empty as it is not required for golang < 1.18. + BUILD_VCS := +endif + .PHONY: get-deps get-deps: @@ -37,7 +47,7 @@ get-deps: plugins: $(LOCAL_ENI_PLUGIN_BINARY) $(LOCAL_IPAM_PLUGIN_BINARY) $(LOCAL_BRIDGE_PLUGIN_BINARY) $(LOCAL_ENI_PLUGIN_BINARY): $(SOURCES) - GOOS=linux CGO_ENABLED=0 go build -installsuffix cgo -a -ldflags "\ + GOOS=linux CGO_ENABLED=0 go build $(BUILD_VCS) -installsuffix cgo -a -ldflags "\ -X github.com/aws/amazon-ecs-cni-plugins/pkg/version.GitShortHash=$(GIT_SHORT_HASH) \ -X github.com/aws/amazon-ecs-cni-plugins/pkg/version.GitPorcelain=$(GIT_PORCELAIN) \ -X github.com/aws/amazon-ecs-cni-plugins/pkg/version.Version=$(VERSION) -s" \ @@ -45,7 +55,7 @@ $(LOCAL_ENI_PLUGIN_BINARY): $(SOURCES) @echo "Built eni plugin" $(LOCAL_IPAM_PLUGIN_BINARY): $(SOURCES) - GOOS=linux CGO_ENABLED=0 go build -installsuffix cgo -a -ldflags "\ + GOOS=linux CGO_ENABLED=0 go build $(BUILD_VCS) -installsuffix cgo -a -ldflags "\ -X github.com/aws/amazon-ecs-cni-plugins/pkg/version.GitShortHash=$(GIT_SHORT_HASH) \ -X github.com/aws/amazon-ecs-cni-plugins/pkg/version.GitPorcelain=$(GIT_PORCELAIN) \ -X github.com/aws/amazon-ecs-cni-plugins/pkg/version.Version=$(VERSION) -s" \ @@ -53,7 +63,7 @@ $(LOCAL_IPAM_PLUGIN_BINARY): $(SOURCES) @echo "Built ipam plugin" $(LOCAL_BRIDGE_PLUGIN_BINARY): $(SOURCES) - GOOS=linux CGO_ENABLED=0 go build -installsuffix cgo -a -ldflags "\ + GOOS=linux CGO_ENABLED=0 go build $(BUILD_VCS) -installsuffix cgo -a -ldflags "\ -X github.com/aws/amazon-ecs-cni-plugins/pkg/version.GitShortHash=$(GIT_SHORT_HASH) \ -X github.com/aws/amazon-ecs-cni-plugins/pkg/version.GitPorcelain=$(GIT_PORCELAIN) \ -X github.com/aws/amazon-ecs-cni-plugins/pkg/version.Version=$(VERSION) -s" \