-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (59 loc) · 1.95 KB
/
Copy pathMakefile
File metadata and controls
71 lines (59 loc) · 1.95 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
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
BINARY_NAME=elasticphp-exporter
VERSION?=1.0.0
BUILD_DIR=build
DOCKER_REPO=elasticphphq
IMAGE_NAME=php:8.4-fpm-bookworm
CONTAINER_NAME=elasticphp-dev
# Build all platforms (works on both glibc and musl systems)
build-all:
mkdir -p $(BUILD_DIR)
@echo "Building static binaries for all platforms..."
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -ldflags '-w -s' -o $(BUILD_DIR)/elasticphp-linux-amd64 -v .
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(GOBUILD) -ldflags '-w -s' -o $(BUILD_DIR)/elasticphp-linux-arm64 -v .
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GOBUILD) -ldflags '-w -s' -o $(BUILD_DIR)/elasticphp-darwin-amd64 -v .
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 $(GOBUILD) -ldflags '-w -s' -o $(BUILD_DIR)/elasticphp-darwin-arm64 -v .
# Quick local build (current platform)
build:
mkdir -p $(BUILD_DIR)
CGO_ENABLED=0 $(GOBUILD) -ldflags '-w -s' -o $(BUILD_DIR)/$(BINARY_NAME) -v .
# Legacy aliases for backwards compatibility
build-glibc: build-all
build-musl: build-all
build-musl-quick: build
test:
$(GOTEST) -v -cover ./...
test-coverage:
$(GOTEST) -v -coverprofile=coverage.out ./...
$(GOCMD) tool cover -func=coverage.out
$(GOCMD) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report saved to coverage.html"
test-coverage-clean:
rm -f coverage.out coverage.html
build-docker:
docker build -t $(IMAGE_NAME) .
build-pbf:
clang -O2 -g -target bpf -c ./bpf/monitor.c \
-D__TARGET_ARCH_arm64 \
-o ./internal/ebpf/monitor.o \
-I/usr/include -I/usr/src/linux-headers-$(uname -r)/include \
-I/usr/src/linux-headers-$(shell uname -r)/include \
-D __BPF_TRACING__
run:
docker run -it --rm \
--name $(CONTAINER_NAME) \
-v $(CURDIR):/app \
-w /app \
$(IMAGE_NAME) bash
shell:
docker exec -it $(CONTAINER_NAME) bash
stop:
docker stop $(CONTAINER_NAME) || true
clean:
docker rmi $(IMAGE_NAME) || true