-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
82 lines (65 loc) · 2.41 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
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
SHELL = /bin/bash
CRYSTAL ?= crystal
RELEASE=
STATIC ?= ""
LINK_FLAGS = --link-flags ${STATIC}
SRCDIR = ./src/bin
BINDIR = ./bin
SRCS = ${wildcard src/bin/*.cr}
BINS = $(addprefix $(BINDIR)/, $(SRCS:src/bin/%.cr=%))
DATA_GEN = ./bin/kafka-packet -v -X --api-ver
VERSION=
CURRENT_VERSION=$(shell git tag -l | sort -V | tail -1)
GUESSED_VERSION=$(shell git tag -l | sort -V | tail -1 | awk 'BEGIN { FS="." } { $$3++; } { printf "%d.%d.%d", $$1, $$2, $$3 }')
GIT_REV_ID=`(git describe --tags 2>|/dev/null) || (LC_ALL=C date +"%F-%X")`
.PHONY : all build clean test spec ci bin
all: compile
deps:
@if [ ! -d lib ]; then \
docker-compose run crystal shards update; \
fi
compile: deps
docker-compose run crystal make build
release: deps
docker-compose run crystal make build RELEASE=--release STATIC=-static
clean:
rm -rf bin tmp
build: clean $(BINS)
$(BINDIR)/%: $(SRCDIR)/%.cr
@mkdir -p bin
${CRYSTAL} build ${RELEASE} $^ -o $@ ${LINK_FLAGS}
umount:
docker run --rm -t -v $$(pwd)/bin:/mnt alpine chown -R $$(id -u):$$(id -g) /mnt
test: check_version_mismatch compile spec
spec:
docker-compose run spec
spec-clean:
docker-compose stop
docker-compose rm -f
.PHONY : check_version_mismatch
check_version_mismatch: shard.yml README.md
diff -w -c <(grep version: README.md) <(grep ^version: shard.yml)
.PHONY : version
version:
@if [ "$(VERSION)" = "" ]; then \
echo "ERROR: specify VERSION as bellow. (current: $(CURRENT_VERSION))";\
echo " make version VERSION=$(GUESSED_VERSION)";\
else \
sed -i -e 's/^version: .*/version: $(VERSION)/' shard.yml ;\
sed -i -e 's/^ version: [0-9]\+\.[0-9]\+\.[0-9]\+/ version: $(VERSION)/' README.md ;\
echo git commit -a -m "'$(COMMIT_MESSAGE)'" ;\
git commit -a -m 'version: $(VERSION)' ;\
git tag "v$(VERSION)" ;\
fi
.PHONY : bump
bump:
make version VERSION=$(GUESSED_VERSION) -s
data-gen: bin/kafka-packet
$(DATA_GEN) 5 data/Produce/5/req.pcap > data/Produce/5/req.text
$(DATA_GEN) 5 data/Produce/5/res.pcap > data/Produce/5/res.text
$(DATA_GEN) 5 data/Metadata/5/req.pcap > data/Metadata/5/req.text
$(DATA_GEN) 5 data/Metadata/5/res.pcap > data/Metadata/5/res.text
$(DATA_GEN) 1 data/ApiVersions/1/req.pcap > data/ApiVersions/1/req.text
$(DATA_GEN) 1 data/ApiVersions/1/res.pcap > data/ApiVersions/1/res.text
$(DATA_GEN) 0 data/InitProducerId/0/req.pcap > data/InitProducerId/0/req.text
$(DATA_GEN) 0 data/InitProducerId/0/res.pcap > data/InitProducerId/0/res.text