-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
107 lines (94 loc) · 2.59 KB
/
Copy pathMakefile
File metadata and controls
107 lines (94 loc) · 2.59 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Go parameters
GOCMD=go
GOTEST=$(GOCMD) test
GOBUILD=$(GOCMD) build
GOMOD=$(GOCMD) mod
GOTIDY=$(GOMOD) tidy
GOVET=$(GOCMD) vet
GOFMT=gofmt
GOINSTALL=$(GOCMD) install
# Binary name
BINARY_NAME=gomemo-example
BINARY_OUTPUT=dist
# Build the main example
BUILD_INPUT ?= cmd/examples/*.go
BUILD_OUTPUT ?= $(BINARY_OUTPUT)/$(BINARY_NAME)
.PHONY: build
build:
mkdir -p $(BINARY_OUTPUT)
@$(GOBUILD) -ldflags="-s -w" -o $(BUILD_OUTPUT) $(BUILD_INPUT)
# Run the example
RUN_INPUT ?= cmd/examples/*.go
.PHONY: run
run:
$(GOCMD) run $(RUN_INPUT)
# Install the example
INSTALL_INPUT ?= cmd/examples/main.go
.PHONY: install
install:
$(GOINSTALL) $(INSTALL_INPUT)
# Run tests
.PHONY: test
test:
$(GOTEST) -v ./...
# Run tests with coverage
.PHONY: test-coverage
test-coverage:
$(GOTEST) -v -cover -coverpkg=./... -coverprofile=coverage.out ./...
$(GOCMD) tool cover -html=coverage.out -o coverage.html
# Run go vet
.PHONY: vet
vet:
$(GOVET) ./...
# Run go fmt
.PHONY: fmt
fmt:
$(GOFMT) -w .
# Tidy go modules
.PHONY: tidy
tidy:
$(GOTIDY)
# Clean build artifacts
.PHONY: clean
clean:
rm -rf $(BINARY_OUTPUT)
rm -f coverage.out
rm -f coverage.html
# Run all checks
.PHONY: check
check: vet fmt test
# Build example and run it
.PHONY: demo
NAME ?= ""
demo:
$(GOCMD) run $(RUN_INPUT) -name $(NAME)
# Show project information
.PHONY: info
info:
@echo "Project: gomemo"
@echo "Description: Generic memoization library for Go with pluggable backends"
@echo "Author: Leo Daidone <leo.daidone@gmail.com>"
@echo "Main package: memo"
@echo "Available commands:"
@echo " make build <BUILD_INPUT> <BUILD_OUTPUT> - Build the example binary"
@echo " make run <RUN_INPUT> - Run the example directly"
@echo " make test - Run all tests"
@echo " make test-coverage - Run tests with coverage"
@echo " make vet - Run go vet"
@echo " make fmt - Run go fmt"
@echo " make tidy - Tidy go modules"
@echo " make check - Run all checks (vet, fmt, test)"
@echo " make demo - Build and run the demo"
@echo " make clean - Clean build artifacts"
@echo " make info - Show this information"
# Show available demos
.PHONY: demo-help
demo-help:
@echo "Available demos:"
@echo " metrics - Performance metrics demonstration"
@echo " fibonacci - Fibonacci sequence calculation with memoization"
@echo " db_query - Database query optimization example"
@echo " api - API response caching example"
@echo ""
@echo "Usage: make demo NAME=<demo>"
@echo "Example: make demo NAME=metrics"