-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
87 lines (77 loc) · 2.44 KB
/
Makefile
File metadata and controls
87 lines (77 loc) · 2.44 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
.PHONY: build clean test lint
# Build all cc-tools binaries
build:
@echo "Building cc-tools binaries..."
@mkdir -p build
go build -o build/cc-tools-statusline ./cmd/cc-tools-statusline/
go build -o build/cc-tools ./cmd/cc-tools/
@echo "Binaries built in build/"
@ls -la build/
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
@rm -rf build/ coverage.out coverage.html
# Test with coverage
test:
@echo "Running tests..."
go test -race -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated in coverage.html"
# Lint check
lint:
@echo "Running linters..."
gofmt -w .
golangci-lint run
deadcode -test ./...
# Install all cc-tools binaries
install: build
@echo "Installing cc-tools binaries..."
@mkdir -p ~/bin
cp build/cc-tools ~/bin/
cp build/cc-tools-statusline ~/bin/
@echo "cc-tools binaries installed to ~/bin/"
@echo "Make sure ~/bin is in your PATH"
# Run statusline subcommand
run-statusline: build
./build/cc-tools statusline
# Nix build
nix-build:
@echo "Building with Nix..."
@if command -v nix >/dev/null 2>&1; then \
nix build .#default -L; \
echo "Nix build completed. Binaries in ./result/bin/"; \
else \
echo "Nix not installed, skipping nix build"; \
fi
# Test nix build
test-nix:
@echo "Testing nix build..."
@if command -v nix >/dev/null 2>&1; then \
CURRENT_SYSTEM=$$(nix eval --raw --impure --expr builtins.currentSystem); \
echo "Building for current system ($$CURRENT_SYSTEM)..."; \
nix build .#packages.$$CURRENT_SYSTEM.default -L --no-link || exit 1; \
echo "Testing cc-tools binary..."; \
nix build .#packages.$$CURRENT_SYSTEM.cc-tools -L --no-link || exit 1; \
echo "Nix build succeeded for $$CURRENT_SYSTEM!"; \
else \
echo "Nix not installed, skipping nix build test"; \
fi
# Enter nix development shell
nix-shell:
@if command -v nix >/dev/null 2>&1; then \
nix develop; \
else \
echo "Nix not installed"; \
fi
.PHONY: help nix-build test-nix nix-shell
help:
@echo "Available targets:"
@echo " build - Build cc-tools binaries"
@echo " clean - Remove build artifacts"
@echo " test - Run tests with coverage"
@echo " lint - Run linters"
@echo " install - Install commands to ~/bin"
@echo " run-statusline - Run the statusline subcommand"
@echo " nix-build - Build with Nix"
@echo " test-nix - Test Nix builds"
@echo " nix-shell - Enter Nix development shell"