-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
94 lines (76 loc) · 3.04 KB
/
Makefile
File metadata and controls
94 lines (76 loc) · 3.04 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
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/')
# Use bash as the Make recipe shell (required on Windows where the default
# shell cannot execute .sh scripts).
# On Windows, "bash" can resolve to C:\Windows\System32\bash.exe (WSL launcher)
# instead of Git Bash. Prefer Git Bash when available.
ifeq ($(OS),Windows_NT)
GIT_BASH := $(firstword $(wildcard $(ProgramW6432)/Git/bin/bash.exe) \
$(wildcard $(ProgramFiles)/Git/bin/bash.exe) \
$(wildcard $(PROGRAMFILES)/Git/bin/bash.exe))
ifdef GIT_BASH
SHELL := $(GIT_BASH)
else
SHELL := bash
endif
else
SHELL := bash
endif
# 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 test-integration-with-packs 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, skipping pack installation
## Pack installation is skipped by default. Use test-integration-with-packs to include it.
test-integration: build
scripts/run-integration-tests.sh --no-install-packs
## test-integration-with-packs: Build binary and run integration tests including codeql_pack_install
## Use this when CodeQL pack dependencies have not been installed in your dev environment.
test-integration-with-packs: build
scripts/run-integration-tests.sh
## 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/## / /'