-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
80 lines (67 loc) · 1.32 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
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
# Static variables
BIN_DIR := ./bin
APP_NAME := tforganize
# Go parameters
GOCMD = go
GOBUILD = $(GOCMD) build
GOCLEAN = $(GOCMD) clean
GOCOMPILE = $(GOTOOL) compile
GOGET = $(GOCMD) get
GOINSTALL = $(GOCMD) install
GOTEST = $(GOCMD) test
GOTOOL = $(GOCMD) tool
# Default target
default: all
#####################
# Phony targets
#####################
# Build the application
.PHONY: all
all: configure build
# Build target
.PHONY: build
build:
$(GOBUILD) -o $(BIN_DIR)/${APP_NAME}
# Clean target
.PHONY: clean
clean:
$(GOCLEAN)
rm -rf $(BIN_DIR)
# Configure the development environment
.PHONY: configure
configure:
$(GOCMD) mod tidy
$(GOCMD) mod vendor
$(GOINSTALL) github.com/githubnemo/CompileDaemon@latest
$(GOGET) github.com/dthagard/tforganize
# Cache the dependencies locally
.PHONY: dep
dep:
go mod download
# Install target
.PHONY: install
install:
$(GOINSTALL)
# Run target
.PHONY: run
run: build
$(BIN_DIR)/$(APP_NAME) $(TARGET)
# Test target
.PHONY: test
test:
$(GOTEST) -v ./...
# Generate the test coverage report
.PHONY: test_coverage
test_coverage:
$(GOTEST) ./... -coverprofile=coverage.out
# Watch the target files and rebuild on change
.PHONY: watch
watch:
CompileDaemon \
-build="make build" \
-command="make test" \
-directory=. \
-exclude-dir=.git \
-exclude-dir=vendor \
-include=Makefile \
&