-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
83 lines (69 loc) · 2.8 KB
/
Makefile
File metadata and controls
83 lines (69 loc) · 2.8 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
.PHONY: build build-dockerized build-ebpf test demo clean docker docker-postgres release
CLANG ?= clang
EBPF_OBJ ?= ebpf/diffkeeper.bpf.o
EBPF_SRC ?= ebpf/diffkeeper.bpf.c
EBPF_HDR := $(wildcard ebpf/*.h ebpf/include/bpf/*.h)
# Build locally (requires Go, clang, and bpftool)
build: build-ebpf
@echo "[build] Building DiffKeeper agent..."
go build -ldflags="-w -s" -o bin/diffkeeper .
@echo "[build] Done: bin/diffkeeper"
# Build via Docker (no local dependencies required)
build-dockerized:
@echo "[build] Building dev container..."
@docker build -f Dockerfile.dev -t diffkeeper-dev .
@echo "[build] Running build inside container..."
@docker run --rm \
-v .:/app \
-w /app \
diffkeeper-dev \
sh -c "make build"
@echo "[build] Dockerized build complete. Binary is in ./bin"
build-ebpf: $(EBPF_OBJ)
$(EBPF_OBJ): $(EBPF_SRC) $(EBPF_HDR)
@if [ ! -f ebpf/vmlinux.h ]; then \
echo "[ebpf] Missing ebpf/vmlinux.h (generate via: bpftool btf dump file /sys/kernel/btf/vmlinux > ebpf/vmlinux.h)"; \
exit 1; \
fi
@echo "[ebpf] Compiling kernel probes..."
$(CLANG) -O2 -g -target bpf -D__TARGET_ARCH_x86 -Iebpf -Iebpf/include -c $(EBPF_SRC) -o $(EBPF_OBJ)
cp $(EBPF_OBJ) pkg/ebpf/diffkeeper.bpf.o
@echo "[ebpf] Built: $(EBPF_OBJ) (embedded copy refreshed)"
# Run tests
test:
@echo "[test] Running tests..."
go test -v -race -coverprofile=coverage.out ./...
@echo "[test] Tests complete"
# Build Postgres demo image
docker-postgres:
@echo "[docker] Building DiffKeeper + Postgres demo..."
docker build -t diffkeeper-postgres:latest -f Dockerfile.postgres .
@echo "[docker] Built: diffkeeper-postgres:latest"
docker:
@echo "[docker] Building multi-arch image..."
docker buildx build --platform linux/amd64,linux/arm64 -t ghcr.io/saworbit/diffkeeper:latest .
@echo "[docker] Multi-arch image ready (not pushed)"
# Run end-to-end demo
demo: docker-postgres
@echo "[demo] Running demo..."
bash demo.sh
# Clean build artifacts
clean:
@echo "[clean] Removing artifacts..."
rm -rf bin/ coverage.out
docker rm -f diffkeeper-postgres-demo 2>/dev/null || true
docker volume rm diffkeeper-deltas 2>/dev/null || true
@echo "[clean] Done"
release: build
@echo "[release] Generating snapshot artifacts..."
goreleaser release --snapshot --clean
# Windows targets
build-windows-amd64:
@echo "Building Windows AMD64..."
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -trimpath -ldflags="-s -w" -o bin/diffkeeper-windows-amd64.exe .
build-windows-arm64:
@echo "Building Windows ARM64..."
CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -trimpath -ldflags="-s -w" -o bin/diffkeeper-windows-arm64.exe .
release-windows: build-windows-amd64 build-windows-arm64
upx --best --lzma bin/diffkeeper-windows-*.exe || echo "upx not installed - skipping compression"
sha256sum bin/diffkeeper-windows-*.exe > bin/diffkeeper-windows-sha256.txt