-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
124 lines (105 loc) · 2.83 KB
/
Copy pathMakefile
File metadata and controls
124 lines (105 loc) · 2.83 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# goCBC Makefile
# Variables
BINARY_NAME=goCBC
MAIN_PATH=./cmd/goCBC
BUILD_DIR=./build
PKG_PATH=github.com/sethll/goCBC/pkg/progmeta
GIT_COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
LDFLAGS=-ldflags "-X $(PKG_PATH).build=$(GIT_COMMIT)"
EXAMPLE_ARGS=75 '1030:150' '1230:200' '3215:100' '1788:100'
VERSION?=$(shell go run -C . ./cmd/version-tag)
# Default target
.PHONY: all
all: build
# Build the binary with git commit hash
.PHONY: build
build:
@echo "Building $(BINARY_NAME) with git commit: $(GIT_COMMIT)"
test -d $(BUILD_DIR) || mkdir -p $(BUILD_DIR)
go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) $(MAIN_PATH)
# Run built binary
.PHONY: exec-example
exec-example:
$(BUILD_DIR)/$(BINARY_NAME) -vvv $(EXAMPLE_ARGS)
# Run the application
.PHONY: run
run:
go run $(LDFLAGS) $(MAIN_PATH)
# Run with example arguments
.PHONY: run-example
run-example:
go run $(LDFLAGS) $(MAIN_PATH) $(EXAMPLE_ARGS)
# Test all packages
.PHONY: test
test:
@echo "Tests not implemented :("
go test ./...
# Test with coverage
.PHONY: test-coverage
test-coverage:
@echo "Tests not implemented :("
go test -cover ./...
# Test specific package (hlcalc)
.PHONY: test-hlcalc
test-hlcalc:
@echo "Tests not implemented :("
go test ./pkg/hlcalc
# Format code
.PHONY: fmt
fmt:
go fmt ./...
# Vet code
.PHONY: vet
vet:
go vet ./...
# Tidy dependencies
.PHONY: tidy
tidy:
go mod tidy
# Clean build artifacts
.PHONY: clean
clean:
rm -rf $(BUILD_DIR)
# Lint and check (runs fmt, vet, test)
.PHONY: check
check: fmt vet test
# Install the binary to GOPATH/bin
.PHONY: install
install:
go install $(LDFLAGS) $(MAIN_PATH)
# Test version collection
.PHONY: test-version
test-version:
@echo $(VERSION)
# Create a git tag for release
.PHONY: tag
tag:
@echo "Creating git tag $(VERSION)"
@if git tag -l | grep -q "^$(VERSION)$$"; then \
echo "Tag $(VERSION) already exists"; \
exit 1; \
fi
git tag -a $(VERSION) -m "Release $(VERSION)"
@echo "Tag $(VERSION) created. Push with: git push origin $(VERSION)"
.PHONY: update-deps
update-deps:
@echo "Updating dependencies..."
go get -u ./...
# Show help
.PHONY: help
help:
@echo "Available targets:"
@echo " build - Build binary with git commit hash"
@echo " run - Run the application"
@echo " run-example - Run with example arguments"
@echo " test - Run all tests (not implemented)"
@echo " test-coverage- Run tests with coverage (not implemented)"
@echo " test-hlcalc - Test hlcalc package (not implemented)"
@echo " fmt - Format code"
@echo " vet - Vet code"
@echo " tidy - Tidy dependencies"
@echo " clean - Clean build artifacts"
@echo " check - Run fmt, vet, test"
@echo " install - Install binary to GOPATH/bin"
@echo " tag - Create git tag (use VERSION=v1.0.0)"
@echo " help - Show this help"