-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (55 loc) · 2.12 KB
/
Makefile
File metadata and controls
71 lines (55 loc) · 2.12 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
BINARY_NAME := gh-ql-mcp-client
MODULE := github.com/advanced-security/codeql-development-mcp-server/client
VERSION := $(shell grep 'Version = ' cmd/root.go | head -1 | sed 's/.*"\(.*\)"/\1/')
# Disable CGO to avoid Xcode/C compiler dependency
export CGO_ENABLED = 0
# Build flags
LDFLAGS := -s -w
.PHONY: all build test test-unit test-integration lint clean install build-all
all: lint test build
## build: Build the binary for the current platform
build:
go build -ldflags "$(LDFLAGS)" -o $(BINARY_NAME) .
## test: Run unit tests and integration tests
test: test-unit test-integration
## test-unit: Run Go unit tests only
test-unit:
go test ./...
## test-integration: Build binary and run integration tests via run-integration-tests.sh
test-integration: build
ENABLE_ANNOTATION_TOOLS=true scripts/run-integration-tests.sh --no-install-packs
## test-verbose: Run all unit tests with verbose output
test-verbose:
go test -v ./...
## test-coverage: Run tests with coverage
test-coverage:
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
## lint: Run linters
lint:
@if command -v golangci-lint > /dev/null 2>&1; then \
golangci-lint run ./...; \
else \
echo "golangci-lint not found, running go vet only"; \
go vet ./...; \
fi
## clean: Remove build artifacts
clean:
rm -f $(BINARY_NAME) $(BINARY_NAME)-* coverage.out coverage.html
## install: Install the binary to GOPATH/bin
install:
go install -ldflags "$(LDFLAGS)" .
## build-all: Cross-compile for all supported platforms
build-all:
GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BINARY_NAME)-darwin-amd64 .
GOOS=darwin GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o $(BINARY_NAME)-darwin-arm64 .
GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BINARY_NAME)-linux-amd64 .
GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o $(BINARY_NAME)-linux-arm64 .
GOOS=windows GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o $(BINARY_NAME)-windows-amd64.exe .
## tidy: Tidy go.mod
tidy:
go mod tidy
## help: Show this help
help:
@echo "Available targets:"
@grep -E '^## ' $(MAKEFILE_LIST) | sed 's/## / /'