-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
105 lines (88 loc) · 4.06 KB
/
Makefile
File metadata and controls
105 lines (88 loc) · 4.06 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
.PHONY: all build test clean vet ci release coverage coverage-html
BINDIR := bin
COVERDIR := coverage
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS := -s -w -X main.version=$(VERSION)
PLATFORMS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64
# Core binaries that agents need
CORE_BINS := daemon pilotctl gateway
all: build
build:
@mkdir -p $(BINDIR)
go build -o $(BINDIR)/registry ./cmd/registry
go build -o $(BINDIR)/beacon ./cmd/beacon
go build -o $(BINDIR)/daemon ./cmd/daemon
go build -o $(BINDIR)/rendezvous ./cmd/rendezvous
go build -o $(BINDIR)/pilotctl ./cmd/pilotctl
go build -o $(BINDIR)/nameserver ./cmd/nameserver
go build -o $(BINDIR)/gateway ./cmd/gateway
go build -o $(BINDIR)/webserver ./examples/go/webserver
go build -o $(BINDIR)/client ./examples/go/client
go build -o $(BINDIR)/echo ./examples/go/echo
go build -o $(BINDIR)/dataexchange ./examples/go/dataexchange
go build -o $(BINDIR)/eventstream ./examples/go/eventstream
go build -o $(BINDIR)/secure ./examples/go/secure
test:
go test -parallel 4 -count=1 ./tests/ ./pkg/beacon/
coverage:
@mkdir -p $(COVERDIR)
@cd tests && go test -parallel 4 -count=1 -coverprofile=../$(COVERDIR)/coverage.out -covermode=atomic -timeout 30s
@go tool cover -func=$(COVERDIR)/coverage.out | tail -1 | awk '{print "Total coverage: " $$3}'
@go tool cover -func=$(COVERDIR)/coverage.out -o=$(COVERDIR)/coverage.txt
@./scripts/generate-coverage-badge.sh
coverage-html: coverage
@go tool cover -html=$(COVERDIR)/coverage.out -o=$(COVERDIR)/coverage.html
@echo "Coverage report generated: $(COVERDIR)/coverage.html"
clean:
rm -rf $(BINDIR) $(COVERDIR)
# Build the C-shared library for the Python SDK (ctypes)
LIBNAME_DARWIN := libpilot.dylib
LIBNAME_LINUX := libpilot.so
LIBNAME_WIN := libpilot.dll
sdk-lib:
@mkdir -p $(BINDIR)
CGO_ENABLED=1 go build -buildmode=c-shared -o $(BINDIR)/$(LIBNAME_$(shell uname -s | sed 's/Darwin/DARWIN/;s/Linux/LINUX/')) ./sdk/cgo/
@echo "Built shared library in $(BINDIR)/"
sdk-lib-linux:
@mkdir -p $(BINDIR)
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -buildmode=c-shared -o $(BINDIR)/$(LIBNAME_LINUX) ./sdk/cgo/
sdk-lib-darwin:
@mkdir -p $(BINDIR)
CGO_ENABLED=1 GOOS=darwin GOARCH=arm64 go build -buildmode=c-shared -o $(BINDIR)/$(LIBNAME_DARWIN) ./sdk/cgo/
# Build for Linux (GCP deployment)
build-linux:
@mkdir -p $(BINDIR)
GOOS=linux GOARCH=amd64 go build -o $(BINDIR)/rendezvous-linux ./cmd/rendezvous
GOOS=linux GOARCH=amd64 go build -o $(BINDIR)/daemon-linux ./cmd/daemon
GOOS=linux GOARCH=amd64 go build -o $(BINDIR)/pilotctl-linux ./cmd/pilotctl
GOOS=linux GOARCH=amd64 go build -o $(BINDIR)/nameserver-linux ./cmd/nameserver
GOOS=linux GOARCH=amd64 go build -o $(BINDIR)/gateway-linux ./cmd/gateway
GOOS=linux GOARCH=amd64 go build -o $(BINDIR)/echo-linux ./examples/go/echo
GOOS=linux GOARCH=amd64 go build -o $(BINDIR)/client-linux ./examples/go/client
GOOS=linux GOARCH=amd64 go build -o $(BINDIR)/webserver-linux ./examples/go/webserver
GOOS=linux GOARCH=amd64 go build -o $(BINDIR)/dataexchange-linux ./examples/go/dataexchange
GOOS=linux GOARCH=amd64 go build -o $(BINDIR)/eventstream-linux ./examples/go/eventstream
GOOS=linux GOARCH=amd64 go build -o $(BINDIR)/secure-linux ./examples/go/secure
vet:
go vet ./...
ci: vet test build build-linux
@echo "CI: all checks passed"
# All binaries included in release archives
RELEASE_BINS := daemon pilotctl gateway registry beacon rendezvous nameserver
# Cross-platform release builds
release:
@mkdir -p $(BINDIR)/release
@for platform in $(PLATFORMS); do \
os=$$(echo $$platform | cut -d/ -f1); \
arch=$$(echo $$platform | cut -d/ -f2); \
echo "Building $$os/$$arch..."; \
mkdir -p $(BINDIR)/release/$$os-$$arch; \
for bin in $(RELEASE_BINS); do \
CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build -ldflags "$(LDFLAGS)" \
-o $(BINDIR)/release/$$os-$$arch/$$bin ./cmd/$$bin; \
done; \
tar -czf $(BINDIR)/release/pilot-$$os-$$arch.tar.gz \
-C $(BINDIR)/release/$$os-$$arch .; \
rm -rf $(BINDIR)/release/$$os-$$arch; \
done
@echo "Release archives in $(BINDIR)/release/"