-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (62 loc) · 1.75 KB
/
Makefile
File metadata and controls
84 lines (62 loc) · 1.75 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
GOFMT=gofmt
# Binary info
BINARY_NAME=tukey
BINARY_UNIX=$(BINARY_NAME)_unix
BINARY_WINDOWS=$(BINARY_NAME).exe
BINARY_MAC=$(BINARY_NAME)_darwin
# Build info
VERSION := $(shell git describe --tags --always --dirty)
COMMIT := $(shell git rev-parse --short HEAD)
DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
# Linker flags
LDFLAGS=-ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)"
.PHONY: all build clean test deps fmt vet install
all: test build
build:
$(GOBUILD) $(LDFLAGS) -o $(BINARY_NAME) -v ./cmd/tukey
build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(BINARY_UNIX) -v ./cmd/tukey
build-windows:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(BINARY_WINDOWS) -v ./cmd/tukey
build-mac:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(BINARY_MAC) -v ./cmd/tukey
build-all: build-linux build-windows build-mac
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
rm -f $(BINARY_UNIX)
rm -f $(BINARY_WINDOWS)
rm -f $(BINARY_MAC)
test:
$(GOTEST) -v ./...
test-coverage:
$(GOTEST) -coverprofile=coverage.out ./...
$(GOCMD) tool cover -html=coverage.out
deps:
$(GOMOD) download
$(GOMOD) verify
fmt:
$(GOFMT) -s -w .
vet:
$(GOCMD) vet ./...
lint:
golangci-lint run
install: build
cp $(BINARY_NAME) /usr/local/bin/
dev:
$(GOCMD) run ./cmd/tukey $(ARGS)
# Example usage: make dev ARGS="-v ./testdata/sample_project"
example:
./$(BINARY_NAME) -v ./testdata/sample_project
# Release targets
release: clean deps test build-all
@echo "Built binaries:"
@ls -la $(BINARY_NAME) $(BINARY_UNIX) $(BINARY_WINDOWS) $(BINARY_MAC)
.DEFAULT_GOAL := build