-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
95 lines (73 loc) · 2.19 KB
/
Makefile
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
BINARY_COMPILE=braces-compile
BINARY_VM=braces-vm
BINARY_INTROSPECT=braces-introspect
TEST?='./...'
GOFMT_FILES?=$$(find . -name '*.go')
GOLANGCI_LINT_VERSION?='v1.52.2'
IN_CI ?= false
.PHONY: build build-compile build-vm test lint format check-format vet clean tidy install-tools repl build-introspect
build: tidy build-compile build-vm build-introspect
build-compile:
@echo "Building $(BINARY_COMPILE)..."
@go build -o target/$(BINARY_COMPILE) ./cmd/$(BINARY_COMPILE)
build-vm:
@echo "Building $(BINARY_VM)..."
@go build -o target/$(BINARY_VM) ./cmd/$(BINARY_VM)
build-introspect:
@echo "Building $(BINARY_INTROSPECT)..."
@go build -o target/$(BINARY_INTROSPECT) ./cmd/$(BINARY_INTROSPECT)
test:
@echo "Running tests..."
@if [ $(IN_CI) = false ]; then \
gotestsum $(TEST); \
else \
go test $(TEST); \
fi
lint:
@echo "Running linters..."
@golangci-lint run --tests=false --timeout=5m
staticcheck:
@echo "Running staticcheck..."
@staticcheck ./...
format:
@echo "Formatting code..."
@gofmt -w $(GOFMT_FILES)
check-format:
@echo "Checking code format..."
@gofmt -d . |grep -q '^' && (echo "Not formatted correctly"; exit 1) || exit 0
vet:
@echo "Vetting code..."
@go vet ./...
clean:
@echo "Cleaning up..."
@rm -rf target/*
tidy:
@echo "Tidying up..."
@go mod tidy
doc:
@echo "Starting godoc server at localhost:6060"
@godoc -http=:6060
install-tools: install-linter install-gotestsum install-staticcheck
install-linter:
@if ! command -v golangci-lint &> /dev/null; then \
echo "Installing linter..."; \
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION); \
fi
install-gotestsum:
@if [ $(IN_CI) = false ]; then \
if ! command -v gotestsum &> /dev/null; then \
echo "Installing gotestsum..."; \
go install gotest.tools/gotestsum; \
fi \
fi
install-staticcheck:
@if ! command -v staticcheck &> /dev/null; then \
echo "Installing staticcheck..."; \
go install honnef.co/go/tools/cmd/staticcheck@latest; \
fi
run_simple: build
./target/braces-vm run examples/simple.braces
introspect_simple: build
./target/braces-vm run --introspect-compiler examples/simple.braces
introspect: build
./target/braces-introspect compiler