-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (60 loc) · 2 KB
/
Copy pathMakefile
File metadata and controls
77 lines (60 loc) · 2 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
BINARY ?= phi
MAIN_SRC = ./cmd
GOBIN ?= $(shell go env GOBIN)
GOPATH ?= $(shell go env GOPATH)
ifeq ($(GOBIN),)
GOBIN = $(GOPATH)/bin
endif
GO ?= go
GOFLAGS ?= -ldflags="-s -w"
CGO ?= 0
.PHONY: all build install run clean test fmt fmt-check lint deadcode check help
all: build
build:
CGO_ENABLED=$(CGO) $(GO) build $(GOFLAGS) -o $(BINARY) $(MAIN_SRC)
install: build
@mkdir -p $(GOBIN)
mv $(BINARY) $(GOBIN)/$(BINARY)
@echo "installed $(BINARY) -> $(GOBIN)/$(BINARY)"
run: build
./$(BINARY)
clean:
rm -f $(BINARY)
$(GO) clean
test:
$(GO) test ./...
$(GO) test -C ext/go ./...
# Rust extension SDK (ext/rust): build + test.
test-rust:
cd ext/rust && cargo test --all-targets
# Apply gofumpt / goimports / golines via .golangci.yml formatters.
fmt:
golangci-lint fmt ./...
cd ext/go && golangci-lint fmt ./...
# Fail if formatting would change files (used by CI).
fmt-check:
golangci-lint fmt --diff ./...
cd ext/go && golangci-lint fmt --diff ./...
lint:
golangci-lint run ./...
cd ext/go && golangci-lint run ./...
deadcode:
./scripts/deadcode-check.sh
check: fmt-check lint deadcode
# Rust extension SDK checks: format + lint (CI mirrors this).
check-rust:
cd ext/rust && cargo fmt --check && cargo clippy --all-targets -- -D warnings
help:
@echo "Usage:"
@echo " make - build binary ($(BINARY))"
@echo " make install - build & install to \$$GOBIN ($(GOBIN))"
@echo " make run - build & run"
@echo " make clean - remove binary & cache"
@echo " make test - run all tests (root + nested ext module)"
@echo " make fmt - format Go sources (gofumpt/goimports/golines)"
@echo " make fmt-check - check formatting without writing (CI)"
@echo " make lint - run golangci-lint"
@echo " make deadcode - unreachable func check (deadcode -test vs baseline)"
@echo " make check - fmt-check + lint + deadcode (CI)"
@echo " make test-rust - test Rust extension SDK (ext/rust)"
@echo " make check-rust - format + lint Rust extension SDK (CI)"