Skip to content

Commit

Permalink
Support building with alternate GOARCH by naming the output bundle (#75)
Browse files Browse the repository at this point in the history
Name the tar file with the GOARCH variable to ease releasing aarch64 builds.
  • Loading branch information
theatrus authored Dec 16, 2019
1 parent 782697c commit cfc3841
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
GOARCH?=amd64
export GOARCH
CGO_ENABLED=1
export CGO_ENABLED
ifeq ($(GOARCH), arm64)
export CC=aarch64-linux-gnu-gcc
endif
NAME=cni-ipvlan-vpc-k8s
VERSION:=$(shell git describe --tags)
DOCKER_IMAGE=lyft/cni-ipvlan-vpc-k8s:$(VERSION)
Expand All @@ -10,30 +17,26 @@ all: build test
clean:
rm -f *.tar.gz $(NAME)-*

.PHONY: cache
cache:
go install ./

.PHONY: lint
lint:
golangci-lint run -D errcheck -D govet

.PHONY: test
test: cache
test:
ifndef GOOS
go test -v ./aws/... ./nl ./cmd/cni-ipvlan-vpc-k8s-tool ./lib/...
else
@echo Tests not available when cross-compiling
endif

.PHONY: build
build: cache
build:
go build -i -o $(NAME)-ipam ./plugin/ipam/main.go
go build -i -o $(NAME)-ipvlan ./plugin/ipvlan/ipvlan.go
go build -i -o $(NAME)-unnumbered-ptp ./plugin/unnumbered-ptp/unnumbered-ptp.go
go build -i -ldflags "-X main.version=$(VERSION)" -o $(NAME)-tool ./cmd/cni-ipvlan-vpc-k8s-tool/cni-ipvlan-vpc-k8s-tool.go

tar cvzf cni-ipvlan-vpc-k8s-$(VERSION).tar.gz $(NAME)-ipam $(NAME)-ipvlan $(NAME)-unnumbered-ptp $(NAME)-tool
tar cvzf cni-ipvlan-vpc-k8s-${GOARCH}-$(VERSION).tar.gz $(NAME)-ipam $(NAME)-ipvlan $(NAME)-unnumbered-ptp $(NAME)-tool

.PHONY: test-docker
test-docker:
Expand Down

0 comments on commit cfc3841

Please sign in to comment.