forked from gjbae1212/fluent-bit-pubsub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
46 lines (39 loc) · 1.48 KB
/
Makefile
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
CURRENT=$(shell pwd)
OSNAME=linux
ARCHNAME=amd64
CONTAINER_NAME=fluent-bit-pubsub-custom
GOLANG_IMAGE=golang:1.22.5
local-build:
go build -buildmode=c-shared -o pubsub.so .
local-build-fast:
go build pubsub.go
build-linux:
@if [ $$(docker images -q $(GOLANG_IMAGE) | wc -l) -eq 0 ]; then \
docker pull $(GOLANG_IMAGE); \
fi
@if [ $$(docker ps -a | grep $(CONTAINER_NAME) | wc -l) -eq 1 ]; then \
docker rm -f $(CONTAINER_NAME); \
fi
docker run -itd --platform ${OSNAME}/${ARCHNAME} -v $(CURRENT):/build --name $(CONTAINER_NAME) $(GOLANG_IMAGE) /bin/bash
docker exec $(CONTAINER_NAME) sh -c "cd /build && go build -buildmode=c-shared -o pubsub.so ."
docker kill $(CONTAINER_NAME)
build-linux-fast:
@if [ $$(docker images -q $(GOLANG_IMAGE) | wc -l) -eq 0 ]; then \
docker pull $(GOLANG_IMAGE); \
fi
@if [ $$(docker ps -a | grep $(CONTAINER_NAME) | wc -l) -eq 0 ]; then \
docker run -itd --platform $(OSNAME)/$(ARCHNAME) -v $(CURRENT):/build --name $(CONTAINER_NAME) $(GOLANG_IMAGE) /bin/bash; \
elif [ $$(docker ps | grep $(CONTAINER_NAME) | wc -l) -eq 0 ]; then \
docker start $(CONTAINER_NAME); \
fi
docker exec $(CONTAINER_NAME) sh -c "cd /build && go build -buildmode=c-shared -o pubsub.so ."
docker stop $(CONTAINER_NAME)
test:
go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
cover:
go tool cover -html=coverage.txt
clean:
@if [ $$(docker ps -a | grep $(CONTAINER_NAME) | wc -l) -eq 1 ]; then \
docker rm -f $(CONTAINER_NAME); \
fi
rm -rf *.so *.h *~