-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
83 lines (64 loc) · 2.99 KB
/
Copy pathMakefile
File metadata and controls
83 lines (64 loc) · 2.99 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
.PHONY: help build build-xref install test test-xref lint fmt clean run
# Variables
BINARY_NAME=xref
VERSION=$(shell git describe --tags --abbrev=0 2>/dev/null || echo "dev")
LDFLAGS=-ldflags "-s -w -X main.version=$(VERSION)"
GOBUILD_FLAGS=-trimpath
BIN_DIR=bin
# Default target
help:
@echo "xref — AST cross-reference search engine"
@echo ""
@echo "Build targets:"
@echo " build Build all binaries"
@echo " build-xref Build xref CLI"
@echo " install Install xref to GOPATH/bin"
@echo ""
@echo "Test targets:"
@echo " test Run all tests"
@echo " test-xref Run xref search tests only"
@echo " test-bench Run benchmarks"
@echo ""
@echo "Code quality:"
@echo " lint Run golangci-lint"
@echo " fmt Format code"
@echo " vet Run go vet"
@echo ""
@echo "Other:"
@echo " clean Remove build artifacts and cache"
@echo " run Build and run xref (pass ARGS=...)"
# ── Build ─────────────────────────────────────────────────────────────────────
build: build-xref
build-xref:
@mkdir -p $(BIN_DIR)
go build $(GOBUILD_FLAGS) $(LDFLAGS) -o $(BIN_DIR)/$(BINARY_NAME) ./cmd/xref/
@echo "Built $(BIN_DIR)/$(BINARY_NAME)"
install:
go install $(GOBUILD_FLAGS) $(LDFLAGS) ./cmd/xref/
@echo "Installed $(BINARY_NAME) to $(shell go env GOPATH)/bin"
# ── Test ──────────────────────────────────────────────────────────────────────
test:
go test ./... -count=1 -timeout=300s
test-xref:
go test . -run 'TestMatchSym|TestSymbolKind|TestRefKind|TestLangPattern|TestFormatCallTree|TestIndexer' -v -count=1 -timeout=120s
test-bench:
go test . -run '^$$' -bench 'BenchmarkGoParseFullDFA|BenchmarkGoParseIncrementalSingleByteEditDFA|BenchmarkGoParseIncrementalNoEditDFA' -benchmem -count=10 -benchtime=750ms
test-race:
go test ./cmd/xref/ -race -count=1 -timeout=120s
# ── Code quality ──────────────────────────────────────────────────────────────
lint:
golangci-lint run ./...
fmt:
gofmt -w .
goimports -w .
vet:
go vet ./...
# ── Run ───────────────────────────────────────────────────────────────────────
run: build-xref
$(BIN_DIR)/$(BINARY_NAME) $(ARGS)
# ── Clean ─────────────────────────────────────────────────────────────────────
clean:
rm -rf $(BIN_DIR)
rm -rf .xref-cache
rm -f *.prof *.out
@echo "Cleaned build artifacts"