forked from lf-edge/ekuiper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
206 lines (173 loc) · 7.73 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
BUILD_PATH ?= _build
PACKAGES_PATH ?= _packages
VERSION := $(shell git describe --tags --always)
PACKAGE_NAME := kuiper-$(VERSION)-$(shell go env GOOS)-$(shell go env GOARCH)
TARGET ?= lfedge/ekuiper
export KUIPER_SOURCE := $(shell pwd)
.PHONY: build
build: build_without_edgex
.PHONY:pkg
pkg: pkg_without_edgex
@if [ "$$(uname -s)" = "Linux" ]; then make -C deploy/packages; fi
.PHONY: build_prepare
build_prepare:
@mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/bin
@mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/etc
@mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/etc/sources
@mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/etc/sinks
@mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/etc/services
@mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/etc/services/schemas
@mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/data
@mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/plugins
@mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/plugins/sources
@mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/plugins/sinks
@mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/plugins/functions
@mkdir -p $(BUILD_PATH)/$(PACKAGE_NAME)/log
@cp -r etc/* $(BUILD_PATH)/$(PACKAGE_NAME)/etc
.PHONY: build_without_edgex
build_without_edgex: build_prepare
GO111MODULE=on CGO_ENABLED=1 go build -ldflags="-s -w -X main.Version=$(VERSION) -X main.LoadFileType=relative" -o kuiper cmd/kuiper/main.go
GO111MODULE=on CGO_ENABLED=1 go build -trimpath -ldflags="-s -w -X main.Version=$(VERSION) -X main.LoadFileType=relative" -o kuiperd cmd/kuiperd/main.go
@if [ ! -z $$(which upx) ]; then upx ./kuiper; upx ./kuiperd; fi
@mv ./kuiper ./kuiperd $(BUILD_PATH)/$(PACKAGE_NAME)/bin
@echo "Build successfully"
.PHONY: pkg_without_edgex
pkg_without_edgex: build_without_edgex
@make real_pkg
.PHONY: build_with_edgex
build_with_edgex: build_prepare
GO111MODULE=on CGO_ENABLED=1 go build -ldflags="-s -w -X main.Version=$(VERSION) -X main.LoadFileType=relative" -tags edgex -o kuiper cmd/kuiper/main.go
GO111MODULE=on CGO_ENABLED=1 go build -trimpath -ldflags="-s -w -X main.Version=$(VERSION) -X main.LoadFileType=relative" -tags edgex -o kuiperd cmd/kuiperd/main.go
@if [ ! -z $$(which upx) ]; then upx ./kuiper; upx ./kuiperd; fi
@mv ./kuiper ./kuiperd $(BUILD_PATH)/$(PACKAGE_NAME)/bin
@echo "Build successfully"
.PHONY: pkg_with_edgex
pkg_with_edgex: build_with_edgex
@make real_pkg
.PHONY: real_pkg
real_pkg:
@mkdir -p $(PACKAGES_PATH)
@cd $(BUILD_PATH) && zip -rq $(PACKAGE_NAME).zip $(PACKAGE_NAME)
@cd $(BUILD_PATH) && tar -czf $(PACKAGE_NAME).tar.gz $(PACKAGE_NAME)
@mv $(BUILD_PATH)/$(PACKAGE_NAME).zip $(BUILD_PATH)/$(PACKAGE_NAME).tar.gz $(PACKAGES_PATH)
@echo "Package build success"
.PHONY:cross_prepare
cross_prepare:
@docker run --rm --privileged tonistiigi/binfmt --install all
.PHONY: cross_build
cross_build: cross_prepare
@docker buildx build --no-cache \
--platform=linux/amd64,linux/arm64,linux/arm/v7 \
-t cross_build \
--output type=tar,dest=cross_build.tar \
-f .ci/Dockerfile .
@mkdir -p $(PACKAGES_PATH)
@tar -xvf cross_build.tar --wildcards linux_amd64/go/kuiper/_packages/ \
&& mv linux_amd64/go/kuiper/_packages/* $(PACKAGES_PATH)
@tar -xvf cross_build.tar --wildcards linux_arm64/go/kuiper/_packages/ \
&& mv linux_arm64/go/kuiper/_packages/* $(PACKAGES_PATH)
@tar -xvf cross_build.tar --wildcards linux_arm_v7/go/kuiper/_packages/ \
&& mv linux_arm_v7/go/kuiper/_packages/* $(PACKAGES_PATH)
@rm -f cross_build.tar
@echo "Cross build success"
.PHONY: cross_build_for_rpm
cross_build_for_rpm: cross_prepare
@docker buildx build --no-cache \
--platform=linux/amd64,linux/arm64 \
-t cross_build \
--output type=tar,dest=cross_build_for_rpm.tar \
-f .ci/Dockerfile-centos .
@mkdir -p $(PACKAGES_PATH)
@tar -xvf cross_build_for_rpm.tar --wildcards linux_amd64/go/kuiper/_packages/ \
&& mv linux_amd64/go/kuiper/_packages/*.rpm $(PACKAGES_PATH)
@tar -xvf cross_build_for_rpm.tar --wildcards linux_arm64/go/kuiper/_packages/ \
&& mv linux_arm64/go/kuiper/_packages/*.rpm $(PACKAGES_PATH)
@rm -f cross_build_for_rpm.tar
@echo "Cross build rpm packages success"
.PHONE: all_pkgs
all_pkgs: cross_build cross_build_for_rpm
.PHONY: docker
docker:
docker buildx build --no-cache --platform=linux/amd64 -t $(TARGET):$(VERSION) -f deploy/docker/Dockerfile . --load
docker buildx build --no-cache --platform=linux/amd64 -t $(TARGET):$(VERSION)-slim -f deploy/docker/Dockerfile-slim . --load
docker buildx build --no-cache --platform=linux/amd64 -t $(TARGET):$(VERSION)-alpine -f deploy/docker/Dockerfile-alpine . --load
.PHONY:cross_docker
cross_docker: cross_prepare
docker buildx build --no-cache \
--platform=linux/amd64,linux/arm64,linux/arm/v7,linux/386 \
-t $(TARGET):$(VERSION) \
-f deploy/docker/Dockerfile . \
--push
docker buildx build --no-cache \
--platform=linux/amd64,linux/arm64,linux/arm/v7,linux/386 \
-t $(TARGET):$(VERSION)-slim \
-f deploy/docker/Dockerfile-slim . \
--push
docker buildx build --no-cache \
--platform=linux/amd64,linux/arm64,linux/arm/v7,linux/386 \
-t $(TARGET):$(VERSION)-alpine \
-f deploy/docker/Dockerfile-alpine . \
--push
PLUGINS := sinks/file \
sinks/influx \
sinks/zmq \
sinks/image \
sinks/redis \
sources/random \
sources/zmq \
functions/accumulateWordCount \
functions/countPlusOne \
functions/image \
functions/geohash \
functions/echo
.PHONY: plugins sinks/tdengine $(PLUGINS)
plugins: cross_prepare sinks/tdengine functions/labelImage $(PLUGINS)
sinks/tdengine:
@docker buildx build --no-cache \
--platform=linux/amd64,linux/arm64 \
-t cross_build \
--build-arg VERSION=$(VERSION) \
--build-arg PLUGIN_TYPE=sinks \
--build-arg PLUGIN_NAME=tdengine \
--output type=tar,dest=/tmp/cross_build_plugins_sinks_tdengine.tar \
-f .ci/Dockerfile-plugins .
@mkdir -p _plugins/debian/sinks
@for arch in amd64 arm64; do \
tar -xvf /tmp/cross_build_plugins_sinks_tdengine.tar --wildcards "linux_$${arch}/go/kuiper/plugins/sinks/tdengine/tdengine_$$(echo $${arch%%_*}).zip" \
&& mv $$(ls linux_$${arch}/go/kuiper/plugins/sinks/tdengine/tdengine_$$(echo $${arch%%_*}).zip) _plugins/debian/sinks; \
done
@rm -f /tmp/cross_build_plugins_sinks_tdengine.tar
functions/labelImage:
@docker buildx build --no-cache \
--platform=linux/amd64 \
-t cross_build \
--build-arg VERSION=$(VERSION) \
--build-arg PLUGIN_TYPE=functions \
--build-arg PLUGIN_NAME=labelImage \
--output type=tar,dest=/tmp/cross_build_plugins_functions_labelImage.tar \
-f .ci/Dockerfile-plugins .
@mkdir -p _plugins/debian/functions
@tar -xvf /tmp/cross_build_plugins_functions_labelImage.tar --wildcards "go/kuiper/plugins/functions/labelImage/labelImage_amd64.zip"
@mv $$(ls go/kuiper/plugins/functions/labelImage/labelImage_amd64.zip) _plugins/debian/functions
@rm -f /tmp/cross_build_plugins_functions_labelImage.tar
$(PLUGINS): PLUGIN_TYPE = $(word 1, $(subst /, , $@))
$(PLUGINS): PLUGIN_NAME = $(word 2, $(subst /, , $@))
$(PLUGINS):
@docker buildx build --no-cache \
--platform=linux/amd64,linux/arm64,linux/arm/v7,linux/386 \
-t cross_build \
--build-arg VERSION=$(VERSION) \
--build-arg PLUGIN_TYPE=$(PLUGIN_TYPE)\
--build-arg PLUGIN_NAME=$(PLUGIN_NAME)\
--output type=tar,dest=/tmp/cross_build_plugins_$(PLUGIN_TYPE)_$(PLUGIN_NAME).tar \
-f .ci/Dockerfile-plugins .
@mkdir -p _plugins/debian/$(PLUGIN_TYPE)
@for arch in amd64 arm64 arm_v7 386; do \
tar -xvf /tmp/cross_build_plugins_$(PLUGIN_TYPE)_$(PLUGIN_NAME).tar --wildcards "linux_$${arch}/go/kuiper/plugins/$(PLUGIN_TYPE)/$(PLUGIN_NAME)/$(PLUGIN_NAME)_$$(echo $${arch%%_*}).zip" \
&& mv $$(ls linux_$${arch}/go/kuiper/plugins/$(PLUGIN_TYPE)/$(PLUGIN_NAME)/$(PLUGIN_NAME)_$$(echo $${arch%%_*}).zip) _plugins/debian/$(PLUGIN_TYPE); \
done
@rm -f /tmp/cross_build_plugins_$(PLUGIN_TYPE)_$(PLUGIN_NAME).tar
.PHONY: clean
clean:
@rm -rf cross_build.tar linux_amd64 linux_arm64 linux_arm_v7 linux_386
@rm -rf _build _packages _plugins