-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathMakefile
More file actions
238 lines (200 loc) · 8.89 KB
/
Copy pathMakefile
File metadata and controls
238 lines (200 loc) · 8.89 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# Makefile for pyscn
# Variables
BINARY_NAME := pyscn
MCP_BINARY_NAME := pyscn-mcp
GO_MODULE := github.com/ludo-technologies/pyscn
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE := $(shell date +%Y-%m-%d)
LDFLAGS := -ldflags "-s -w \
-X '$(GO_MODULE)/internal/version.Version=$(VERSION)' \
-X '$(GO_MODULE)/internal/version.Commit=$(COMMIT)' \
-X '$(GO_MODULE)/internal/version.Date=$(DATE)' \
-X '$(GO_MODULE)/internal/version.BuiltBy=make'"
# Colors for output
GREEN := \033[0;32m
YELLOW := \033[1;33m
NC := \033[0m # No Color
.PHONY: all build test clean install run version help build-python python-wheel python-test python-clean build-mcp install-mcp clean-mcp docs-serve docs-build bench-communities
## help: Show this help message
help:
@echo 'Usage:'
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
## all: Build and test
all: test build
## build: Build the binary
build:
@printf "$(GREEN)Building $(BINARY_NAME) $(VERSION)...$(NC)\n"
go build $(LDFLAGS) -o $(BINARY_NAME) ./cmd/pyscn
## build-mcp: Build the MCP server binary
build-mcp:
@printf "$(GREEN)Building $(MCP_BINARY_NAME) $(VERSION)...$(NC)\n"
go build $(LDFLAGS) -o $(MCP_BINARY_NAME) ./cmd/pyscn-mcp
## test: Run tests
test:
@printf "$(GREEN)Running tests...$(NC)\n"
go test -v ./...
## bench: Run benchmarks
bench:
@printf "$(GREEN)Running benchmarks...$(NC)\n"
go test -bench=. -benchmem ./...
## bench-communities: Run community detection graduation benchmarks
bench-communities:
@printf "$(GREEN)Running community detection benchmarks...$(NC)\n"
go test -run '^$$' -bench 'BenchmarkDetectCommunitiesLeiden_MediumGraph' -benchmem -count=10 ./internal/analyzer
## coverage: Generate coverage report
coverage:
@printf "$(GREEN)Generating coverage report...$(NC)\n"
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@printf "$(GREEN)Coverage report generated: coverage.html$(NC)\n"
## clean: Clean build artifacts
clean:
@printf "$(YELLOW)Cleaning...$(NC)\n"
rm -f $(BINARY_NAME)
rm -f $(MCP_BINARY_NAME)
rm -f coverage.out coverage.html
rm -rf dist/
go clean
## clean-mcp: Clean MCP build artifacts
clean-mcp:
@printf "$(YELLOW)Cleaning MCP artifacts...$(NC)\n"
rm -f $(MCP_BINARY_NAME)
## install: Install the binary
install: build
@printf "$(GREEN)Installing $(BINARY_NAME)...$(NC)\n"
go install $(LDFLAGS) ./cmd/pyscn
## install-mcp: Install the MCP server binary
install-mcp: build-mcp
@printf "$(GREEN)Installing $(MCP_BINARY_NAME)...$(NC)\n"
go install $(LDFLAGS) ./cmd/pyscn-mcp
## run: Run the application
run:
go run $(LDFLAGS) ./cmd/pyscn
## version: Show version information
version:
@echo "Version: $(VERSION)"
@echo "Commit: $(COMMIT)"
@echo "Date: $(DATE)"
## fmt: Format code
fmt:
@printf "$(GREEN)Formatting code...$(NC)\n"
go fmt ./...
gofmt -s -w .
## lint: Run linters
lint:
@printf "$(GREEN)Running linters...$(NC)\n"
go vet ./...
golangci-lint run
## release: Create a new release (use: make release VERSION=v0.1.0)
release:
@if [ -z "$(VERSION)" ]; then \
printf "$(YELLOW)Please specify VERSION. Usage: make release VERSION=v0.1.0$(NC)\n"; \
exit 1; \
fi
@printf "$(GREEN)Creating release $(VERSION)...$(NC)\n"
git tag -a $(VERSION) -m "Release $(VERSION)"
git push origin $(VERSION)
@printf "$(GREEN)Release $(VERSION) created and pushed!$(NC)\n"
## docs-serve: Serve the documentation site locally with live reload (requires uv)
docs-serve:
@which uvx > /dev/null || (printf "$(YELLOW)uv is required: https://docs.astral.sh/uv/getting-started/installation/$(NC)\n" && exit 1)
cd website && uvx --with-requirements requirements.txt --from mkdocs mkdocs serve
## docs-build: Build the documentation site in strict mode (requires uv)
docs-build:
@which uvx > /dev/null || (printf "$(YELLOW)uv is required: https://docs.astral.sh/uv/getting-started/installation/$(NC)\n" && exit 1)
cd website && uvx --with-requirements requirements.txt --from mkdocs mkdocs build --strict
## dev: Development build with hot reload (requires air)
dev:
@which air > /dev/null || (echo "Installing air..." && go install github.com/cosmtrek/air@latest)
air
# Platform-specific builds
## build-all: Build for all platforms (CLI + MCP)
build-all: build-linux build-darwin build-windows build-mcp-all
build-linux:
@printf "$(GREEN)Building for Linux...$(NC)\n"
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-amd64 ./cmd/pyscn
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-linux-arm64 ./cmd/pyscn
build-darwin:
@printf "$(GREEN)Building for macOS...$(NC)\n"
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-amd64 ./cmd/pyscn
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-darwin-arm64 ./cmd/pyscn
build-windows:
@printf "$(GREEN)Building for Windows...$(NC)\n"
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-windows-amd64.exe ./cmd/pyscn
GOOS=windows GOARCH=arm64 go build $(LDFLAGS) -o dist/$(BINARY_NAME)-windows-arm64.exe ./cmd/pyscn
# MCP Server Platform-specific builds
## build-mcp-all: Build MCP server for all platforms
build-mcp-all: build-mcp-linux build-mcp-darwin build-mcp-windows
build-mcp-linux:
@printf "$(GREEN)Building MCP server for Linux...$(NC)\n"
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o dist/$(MCP_BINARY_NAME)-linux-amd64 ./cmd/pyscn-mcp
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o dist/$(MCP_BINARY_NAME)-linux-arm64 ./cmd/pyscn-mcp
build-mcp-darwin:
@printf "$(GREEN)Building MCP server for macOS...$(NC)\n"
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o dist/$(MCP_BINARY_NAME)-darwin-amd64 ./cmd/pyscn-mcp
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o dist/$(MCP_BINARY_NAME)-darwin-arm64 ./cmd/pyscn-mcp
build-mcp-windows:
@printf "$(GREEN)Building MCP server for Windows...$(NC)\n"
GOOS=windows GOARCH=amd64 go build $(LDFLAGS) -o dist/$(MCP_BINARY_NAME)-windows-amd64.exe ./cmd/pyscn-mcp
GOOS=windows GOARCH=arm64 go build $(LDFLAGS) -o dist/$(MCP_BINARY_NAME)-windows-arm64.exe ./cmd/pyscn-mcp
# Python packaging
## build-python: Build Python wheels with embedded binaries (all platforms)
build-python: build-mcp-all
@printf "$(GREEN)Building Python wheels with all platform binaries...$(NC)\n"
@mkdir -p python/src/pyscn/bin
@cp dist/$(MCP_BINARY_NAME)-* python/src/pyscn/bin/ 2>/dev/null || true
@printf "$(GREEN)Binaries copied to python/src/pyscn/bin/$(NC)\n"
@ls -lh python/src/pyscn/bin/
uv build
@printf "$(GREEN)Python wheel built: $(NC)\n"
@ls -lh dist/*.whl
## python-wheel: Build Python wheel with current platform binary only
python-wheel:
@printf "$(GREEN)Building Python wheel for current platform...$(NC)\n"
@mkdir -p python/src/pyscn/bin dist
go build $(LDFLAGS) -o python/src/pyscn/bin/pyscn-$$(go env GOOS)-$$(go env GOARCH)$$(if [ "$$(go env GOOS)" = "windows" ]; then echo ".exe"; fi) ./cmd/pyscn
go build $(LDFLAGS) -o python/src/pyscn/bin/$(MCP_BINARY_NAME)-$$(go env GOOS)-$$(go env GOARCH)$$(if [ "$$(go env GOOS)" = "windows" ]; then echo ".exe"; fi) ./cmd/pyscn-mcp
uv build
## python-dev-install: Install development version with uv
python-dev-install: python-wheel
@printf "$(GREEN)Uninstalling old version...$(NC)\n"
-uv tool uninstall pyscn 2>/dev/null || pip uninstall -y pyscn 2>/dev/null || true
@printf "$(GREEN)Installing development version with uv...$(NC)\n"
uv tool install --force --editable .
@printf "$(GREEN)Testing installation...$(NC)\n"
pyscn --version
@printf "$(GREEN)Testing uvx pyscn-mcp...$(NC)\n"
@printf "Run: uvx pyscn-mcp --help\n"
## python-install: Install from built wheel with uv
python-install: python-wheel
@printf "$(GREEN)Uninstalling old version...$(NC)\n"
-uv tool uninstall pyscn 2>/dev/null || pip uninstall -y pyscn 2>/dev/null || true
@printf "$(GREEN)Installing from wheel...$(NC)\n"
uv tool install $$(ls -t dist/*.whl | head -1)
@printf "$(GREEN)Installation complete!$(NC)\n"
@printf "$(GREEN)Testing commands:$(NC)\n"
pyscn --version
uvx pyscn-mcp --help
## python-test: Test Python package installation
python-test: python-wheel
@printf "$(GREEN)Testing Python package...$(NC)\n"
pip install --force-reinstall $$(ls -t dist/*.whl | head -1)
@printf "$(GREEN)Testing pyscn command...$(NC)\n"
pyscn --version
@printf "$(GREEN)Testing pyscn-mcp command...$(NC)\n"
pyscn-mcp --help || python -m pyscn.mcp_main --help
## python-uninstall: Uninstall pyscn from uv and pip
python-uninstall:
@printf "$(YELLOW)Uninstalling pyscn...$(NC)\n"
-uv tool uninstall pyscn 2>/dev/null || true
-pip uninstall -y pyscn 2>/dev/null || true
@printf "$(GREEN)Uninstall complete$(NC)\n"
## python-clean: Clean Python build artifacts
python-clean:
@printf "$(YELLOW)Cleaning Python build artifacts...$(NC)\n"
rm -rf python/src/pyscn/bin
rm -rf dist/*.whl
rm -rf build
rm -rf *.egg-info
rm -rf .eggs