-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (61 loc) · 2.45 KB
/
Makefile
File metadata and controls
78 lines (61 loc) · 2.45 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
.PHONY: build test install clean fmt lint lint-fix run help check
BINARY_NAME=carv
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILD_DIR=build
INSTALL_DIR=/usr/local/bin
GO=go
GOFLAGS=-ldflags "-X main.version=$(VERSION)"
build:
@mkdir -p $(BUILD_DIR)
$(GO) build $(GOFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/carv/
build-release:
@mkdir -p $(BUILD_DIR)
$(GO) build $(GOFLAGS) -ldflags "-s -w -X main.version=$(VERSION)" -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/carv/
test:
$(GO) test -v ./...
test-cover:
@mkdir -p $(BUILD_DIR)
$(GO) test -coverprofile=$(BUILD_DIR)/coverage.out ./...
$(GO) tool cover -html=$(BUILD_DIR)/coverage.out -o $(BUILD_DIR)/coverage.html
install: build
install -m 755 $(BUILD_DIR)/$(BINARY_NAME) $(INSTALL_DIR)/$(BINARY_NAME)
uninstall:
rm -f $(INSTALL_DIR)/$(BINARY_NAME)
clean:
rm -rf $(BUILD_DIR)
$(GO) clean
fmt:
$(GO) fmt ./...
lint:
@which golangci-lint > /dev/null 2>&1 || (echo "golangci-lint not installed. Run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest" && exit 1)
golangci-lint run ./...
lint-fix:
@which golangci-lint > /dev/null 2>&1 || (echo "golangci-lint not installed. Run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest" && exit 1)
golangci-lint run --fix ./...
check: fmt lint test
run: build
./$(BUILD_DIR)/$(BINARY_NAME) run docs/samples/hello.carv
repl: build
./$(BUILD_DIR)/$(BINARY_NAME) repl
examples: build
./$(BUILD_DIR)/$(BINARY_NAME) run docs/samples/hello.carv
./$(BUILD_DIR)/$(BINARY_NAME) run docs/samples/showcase.carv
help:
@echo "Carv Programming Language"
@echo ""
@echo "Usage:"
@echo " make build Build the carv compiler"
@echo " make build-release Build optimized release binary"
@echo " make test Run all tests"
@echo " make test-cover Run tests with coverage report"
@echo " make install Install carv to /usr/local/bin"
@echo " make uninstall Remove carv from /usr/local/bin"
@echo " make clean Remove build artifacts"
@echo " make fmt Format source code"
@echo " make lint Run golangci-lint"
@echo " make lint-fix Run golangci-lint with auto-fix"
@echo " make check Run fmt, lint, and test"
@echo " make run Build and run docs/samples/hello.carv"
@echo " make repl Start interactive REPL"
@echo " make examples Run maintained docs sample programs"
@echo " make help Show this help"