-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
45 lines (36 loc) · 1.57 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
# ==============================================================================
# define global Makefile variables for later reference
COMMON_SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
# project root directory
ROOT_DIR := $(abspath $(shell cd $(COMMON_SELF_DIR)/ && pwd -P))
# directory for storing build output and temporary files
OUTPUT_DIR := $(ROOT_DIR)/_output
# ==============================================================================
# define the Makefile "all" phony target, which is executed by default when running 'make'
.PHONY: all
all: format build
# ==============================================================================
# define other phony targets
.PHONY: build
build: tidy # compile source code, auto adding/removing dependency packages depending on "tidy" target
go build -gcflags "all=-N -l" -v -ldflags "$(GO_LDFLAGS)" -o $(OUTPUT_DIR)/Cache $(ROOT_DIR)/example/main.go
.PHONY: format
format: # format source code
gofmt -s -w ./
.PHONY: test
test: # run unit tests
go run example/main.go
.PHONY: perf
perf: # run performance tests
go build -o $(ROOT_DIR)/example/perf/perfTest $(ROOT_DIR)/example/perf/perf.go
perf stat record -d -o $(ROOT_DIR)/example/perf/perf.data $(ROOT_DIR)/example/perf/perfTest
.PHONY: tidy
tidy: # auto add/remove dependency packages
go mod tidy
.PHONY: clean
clean: # clean build output and temporary files
-rm -vrf $(OUTPUT_DIR)
-rm -rf $(ROOT_DIR)/example/perf/perfTest
-rm -rf $(ROOT_DIR)/example/perf/perf.data*
-rm -rf $(ROOT_DIR)/example/benchMark/benchMark.test
-rm -rf $(ROOT_DIR)/example/benchMark/cpu.profile