Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -buildvcs=false to Makefile #104

Merged
merged 1 commit into from Jan 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions Makefile
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -37,23 +47,23 @@ 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" \
-o ${ROOT}/${LOCAL_ENI_PLUGIN_BINARY} github.com/aws/amazon-ecs-cni-plugins/plugins/eni
@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" \
-o ${ROOT}/${LOCAL_IPAM_PLUGIN_BINARY} github.com/aws/amazon-ecs-cni-plugins/plugins/ipam
@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" \
Expand Down