-
Notifications
You must be signed in to change notification settings - Fork 32
/
Makefile
53 lines (43 loc) · 1.34 KB
/
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
PROJECT := wasm-to-oci
ORG := engineerd
BINDIR := $(CURDIR)/bin
GOFLAGS :=
LDFLAGS := -w -s
TARGETS := darwin/amd64 linux/amd64 windows/amd64
TAGS :=
GOX = $(GOPATH)/bin/gox
ifeq ($(OS),Windows_NT)
TARGET = $(PROJECT).exe
SHELL = cmd.exe
CHECK = where.exe
else
TARGET = $(PROJECT)
SHELL ?= bash
CHECK ?= which
endif
.PHONY: build
build:
go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o $(BINDIR)/$(TARGET) github.com/$(ORG)/$(PROJECT)/cmd/...
.PHONY: test
test:
go test $(TESTFLAGS) ./...
$(GOX):
(cd /; GO111MODULE=on go get -u github.com/mitchellh/gox)
.PHONY: build-cross
build-cross: LDFLAGS += -extldflags "-static"
build-cross: $(GOX)
GO111MODULE=on CGO_ENABLED=0 $(GOX) -parallel=3 -output="bin/{{.OS}}-{{.Arch}}/$(PROJECT)" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/$(ORG)/$(PROJECT)/cmd/...
.PHONY: lint
lint:
golangci-lint run --config ./golangci.yml
HAS_GOLANGCI := $(shell $(CHECK) golangci-lint)
HAS_GOIMPORTS := $(shell $(CHECK) goimports)
GOLANGCI_VERSION := v1.16.0
.PHONY: bootstrap
bootstrap:
ifndef HAS_GOLANGCI
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin $(GOLANGCI_VERSION)
endif
ifndef HAS_GOIMPORTS
go get -u golang.org/x/tools/cmd/goimports
endif