-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (82 loc) · 3.24 KB
/
Makefile
File metadata and controls
101 lines (82 loc) · 3.24 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
.PHONY: build build-cgo test test-coverage lint lint-fix fmt fmt-check vet vuln ci clean docs-validate graph-html graph-screenshot graph-preview graph-serve graph-test
VERSION ?= dev
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS := -s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)
build:
go build -ldflags="$(LDFLAGS)" -o ./floop ./cmd/floop
# Build with CGO + LanceDB static linking.
# Linux (default): make build-cgo
# macOS: CGO_LDFLAGS="-L$(pwd)/lib/darwin_arm64 -llancedb_go -framework Security -framework CoreFoundation -lc++" make build-cgo
# Prerequisites: C/C++ compiler, LanceDB native libs (run download-artifacts.sh first)
CGO_CFLAGS ?= -I$(CURDIR)/include
CGO_LDFLAGS ?= -L$(CURDIR)/lib/$$(go env GOOS)_$$(go env GOARCH) -Wl,-Bstatic -llancedb_go -Wl,-Bdynamic -lm -ldl -lstdc++ -lpthread
build-cgo:
CGO_ENABLED=1 \
CGO_CFLAGS="$(CGO_CFLAGS)" \
CGO_LDFLAGS="$(CGO_LDFLAGS)" \
go build -ldflags="$(LDFLAGS)" -o ./floop ./cmd/floop
test:
ifeq ($(CGO_ENABLED),0)
go test ./...
else
go test -race ./...
endif
test-coverage:
ifeq ($(CGO_ENABLED),0)
go test -coverprofile=coverage.out ./...
else
go test -race -coverprofile=coverage.out ./...
endif
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
lint:
golangci-lint run --timeout=5m
lint-fix:
golangci-lint run --fix --timeout=5m
fmt:
go fmt ./...
fmt-check:
@test -z "$$(gofmt -l .)" || (echo "Files need formatting:" && gofmt -l . && exit 1)
vet:
go vet ./...
vuln:
@which govulncheck > /dev/null 2>&1 || go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
ci: fmt-check lint vet test build
clean:
rm -f ./floop coverage.out coverage.html
rm -rf build/
docs-validate: build
@echo "Validating CLI reference documentation..."
@missing=""; \
for cmd in $$(./floop --help 2>&1 | awk '/Available Commands:/{found=1; next} found && /^ [a-z]/{print $$1} found && /^$$/{exit}'); do \
if ! grep -q "## $$cmd" docs/CLI_REFERENCE.md 2>/dev/null; then \
missing="$$missing $$cmd"; \
fi; \
done; \
if [ -n "$$missing" ]; then \
echo "ERROR: Commands missing from docs/CLI_REFERENCE.md:$$missing"; \
exit 1; \
fi; \
echo "All commands documented."
# Graph visualization dev targets
graph-html:
@mkdir -p build/graph
GOWORK=off go build -o ./floop ./cmd/floop
./floop graph --format html -o build/graph/graph.html --no-open
@echo "HTML written to build/graph/graph.html"
graph-screenshot: graph-html
@command -v node >/dev/null 2>&1 || (echo "node required (install Node.js)" && exit 1)
@test -d build/node_modules/playwright || (npm install --prefix build playwright && npx --prefix build playwright install chromium)
NODE_PATH=build/node_modules node scripts/screenshot.js build/graph/graph.html build/graph/graph.png
@echo "Screenshot: build/graph/graph.png"
graph-preview: graph-screenshot
@echo "Preview: build/graph/graph.html (open in browser)"
@echo "Screenshot: build/graph/graph.png"
graph-test:
@command -v node >/dev/null 2>&1 || (echo "node required (install Node.js)" && exit 1)
bash scripts/tests/run-all.sh
graph-serve:
GOWORK=off go build -o ./floop ./cmd/floop
./floop graph --format html --serve