forked from sarunask/s3-copy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
58 lines (46 loc) · 917 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
SHELL := /bin/bash
ARTIFACTS_DIR := ./artifacts
OSNAME = $(shell go env GOOS)
ARCH = $(shell go env GOARCH)
ARCHS := arm64 amd64
OSES := linux darwin windows
version=$(shell cat version | tr -d '\n')
include linting.mk
define build_target
CGO_ENABLED=0 \
GOOS=$(1) \
GOARCH=$(2) \
go build \
-mod=vendor \
-ldflags="-s -w "\
-o $(ARTIFACTS_DIR)/s3-copy-$(1)-$(2) \
./cmd ;
endef
ifeq ($(OS),Windows_NT)
OSNAME = windows
else
UNAME_S := $(shell uname -s)
endif
ifdef os
OSNAME=$(os)
endif
ifndef GOOS
GOOS=$(OSNAME)
endif
ifndef GOARCH
GOARCH=amd64
endif
.PHONY: all
all: unit_test lint build
.PHONY: build
build:
$(foreach os,$(OSES),$(foreach arch,$(ARCHS),$(call build_target,$(os),$(arch))))
.PHONY: local_build
local_build:
$(call build_target,$(OSNAME),$(ARCH))
.PHONY: deps
deps:
go mod vendor
.PHONY: test
test:
go test -v -parallel=6 -mod=vendor -cover $$(go list ./...)