forked from uhppoted/uhppoted
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
229 lines (186 loc) · 9.83 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
DEBUG ?= --debug
DIST ?= development
LINUX = env GOOS=linux GOARCH=amd64
ARM7 = env GOOS=linux GOARCH=arm GOARM=7
DARWIN = env GOOS=darwin GOARCH=amd64
WINDOWS = env GOOS=windows GOARCH=amd64
.PHONY: debug
.PHONY: docker
.PHONY: simulator
.PHONY: uhppoted-rest
.PHONY: uhppoted-mqtt
.PHONY: uhppoted-app-s3
.PHONY: uhppoted-app-sheets
.PHONY: uhppoted-app-wild-apricot
.PHONY: integration-tests
.PHONY: fly.io
all: test \
benchmark \
coverage
clean:
go clean
rm -rf bin
format:
cd uhppote-core && go fmt ./...
cd uhppoted-lib && go fmt ./...
cd uhppote-simulator && go fmt ./...
cd uhppote-cli && go fmt ./...
cd uhppoted-dll && go fmt ./...
cd uhppoted-rest && go fmt ./...
cd uhppoted-mqtt && go fmt ./...
cd uhppoted-app-s3 && go fmt ./...
cd uhppoted-app-sheets && go fmt ./...
cd uhppoted-app-wild-apricot && go fmt ./...
cd integration-tests && go fmt ./...
go fmt ./...
build: format
mkdir -p bin
cd uhppote-core && go build -trimpath ./...
cd uhppoted-lib && go build -trimpath ./...
cd uhppote-simulator && go build -trimpath -o ../bin/ ./...
cd uhppote-cli && go build -trimpath -o ../bin/ ./...
cd uhppoted-rest && go build -trimpath -o ../bin/ ./...
cd uhppoted-mqtt && go build -trimpath -o ../bin/ ./...
cd uhppoted-app-s3 && go build -trimpath -o ../bin/ ./...
cd uhppoted-app-sheets && go build -trimpath -o ../bin/ ./...
cd uhppoted-app-wild-apricot && go build -trimpath -o ../bin/ ./...
test: build
cd uhppote-core && go test ./...
cd uhppoted-lib && go test ./...
cd uhppote-simulator && go test ./...
cd uhppote-cli && go test ./...
cd uhppoted-rest && go test ./...
cd uhppoted-mqtt && go test ./...
cd uhppoted-app-s3 && go test ./...
cd uhppoted-app-sheets && go test ./...
cd uhppoted-app-wild-apricot && go test ./...
make -C ./uhppoted-dll -f Makefile tests
vet: build
go vet ./...
lint: build
golint ./...
benchmark: build
go test -bench ./...
coverage: build
go test -cover ./...
integration-tests:
cd integration-tests && go fmt ./...
# go test integration-tests/cli/*.go
go test -v integration-tests/mqttd/*.go
# go clean -testcache && go test -count=1 integration-tests/simulator/*.go
build-all: test vet
mkdir -p dist/linux/$(DIST)
mkdir -p dist/arm7/$(DIST)
mkdir -p dist/darwin/$(DIST)
mkdir -p dist/windows/$(DIST)
mkdir -p dist/openapi/$(DIST)
cd uhppote-cli && $(LINUX) go build -trimpath -o ../dist/linux/$(DIST) ./...
cd uhppote-cli && $(ARM7) go build -trimpath -o ../dist/arm7/$(DIST) ./...
cd uhppote-cli && $(DARWIN) go build -trimpath -o ../dist/darwin/$(DIST) ./...
cd uhppote-cli && $(WINDOWS) go build -trimpath -o ../dist/windows/$(DIST) ./...
cd uhppoted-rest && $(LINUX) go build -trimpath -o ../dist/linux/$(DIST) ./...
cd uhppoted-rest && $(ARM7) go build -trimpath -o ../dist/arm7/$(DIST) ./...
cd uhppoted-rest && $(DARWIN) go build -trimpath -o ../dist/darwin/$(DIST) ./...
cd uhppoted-rest && $(WINDOWS) go build -trimpath -o ../dist/windows/$(DIST) ./...
cd uhppoted-mqtt && $(LINUX) go build -trimpath -o ../dist/linux/$(DIST) ./...
cd uhppoted-mqtt && $(ARM7) go build -trimpath -o ../dist/arm7/$(DIST) ./...
cd uhppoted-mqtt && $(DARWIN) go build -trimpath -o ../dist/darwin/$(DIST) ./...
cd uhppoted-mqtt && $(WINDOWS) go build -trimpath -o ../dist/windows/$(DIST) ./...
cd uhppoted-app-s3 && $(LINUX) go build -trimpath -o ../dist/linux/$(DIST) ./...
cd uhppoted-app-s3 && $(ARM7) go build -trimpath -o ../dist/arm7/$(DIST) ./...
cd uhppoted-app-s3 && $(DARWIN) go build -trimpath -o ../dist/darwin/$(DIST) ./...
cd uhppoted-app-s3 && $(WINDOWS) go build -trimpath -o ../dist/windows/$(DIST) ./...
cd uhppoted-app-sheets && $(LINUX) go build -trimpath -o ../dist/linux/$(DIST) ./...
cd uhppoted-app-sheets && $(ARM7) go build -trimpath -o ../dist/arm7/$(DIST) ./...
cd uhppoted-app-sheets && $(DARWIN) go build -trimpath -o ../dist/darwin/$(DIST) ./...
cd uhppoted-app-sheets && $(WINDOWS) go build -trimpath -o ../dist/windows/$(DIST) ./...
cd uhppoted-app-wild-apricot && $(LINUX) go build -trimpath -o ../dist/linux/$(DIST) ./...
cd uhppoted-app-wild-apricot && $(ARM7) go build -trimpath -o ../dist/arm7/$(DIST) ./...
cd uhppoted-app-wild-apricot && $(DARWIN) go build -trimpath -o ../dist/darwin/$(DIST) ./...
cd uhppoted-app-wild-apricot && $(WINDOWS) go build -trimpath -o ../dist/windows/$(DIST) ./...
cd uhppote-simulator && $(LINUX) go build -trimpath -o ../dist/linux/$(DIST) ./...
cd uhppote-simulator && $(ARM7) go build -trimpath -o ../dist/arm7/$(DIST) ./...
cd uhppote-simulator && $(DARWIN) go build -trimpath -o ../dist/darwin/$(DIST) ./...
cd uhppote-simulator && $(WINDOWS) go build -trimpath -o ../dist/windows/$(DIST) ./...
cp uhppoted-rest/documentation/uhppoted-api.yaml documentation/openapi/
cp uhppote-simulator/documentation/simulator-api.yaml documentation/openapi/
cp uhppoted-rest/documentation/uhppoted-api.yaml install/openapi/
cp uhppote-simulator/documentation/simulator-api.yaml install/openapi/
cp -r install/openapi/* dist/openapi/$(DIST)/
cp uhppoted-mqtt/documentation/TLS.md cookbook/mqtt/
cp uhppoted-mqtt/documentation/signatures.md cookbook/mqtt/
cp uhppoted-app-s3/documentation/signing.md cookbook/s3/
release: build-all docker integration-tests
find . -name ".DS_Store" -delete
tar --directory=dist/linux --exclude=".DS_Store" -cvzf dist/$(DIST)-linux.tar.gz $(DIST)
tar --directory=dist/arm7 --exclude=".DS_Store" -cvzf dist/$(DIST)-arm7.tar.gz $(DIST)
tar --directory=dist/darwin --exclude=".DS_Store" -cvzf dist/$(DIST)-darwin.tar.gz $(DIST)
cd dist/windows && zip --recurse-paths ../$(DIST)-windows.zip $(DIST)
build-github:
cd uhppote-core && go build -trimpath ./...
cd uhppoted-lib && go build -trimpath ./...
cd uhppote-simulator && go build -trimpath ./...
cd uhppote-cli && go build -trimpath ./...
cd uhppoted-rest && go build -trimpath ./...
cd uhppoted-mqtt && go build -trimpath ./...
cd uhppoted-app-s3 && go build -trimpath ./...
cd uhppoted-app-sheets && go build -trimpath ./...
cd uhppoted-app-wild-apricot && go build -trimpath ./...
# make -C ./uhppoted-dll -f Makefile build-all
debug: build
echo ">>> DEBUG"
simulator:
./bin/uhppote-simulator --debug --bind 0.0.0.0:60000 --rest 0.0.0.0:8000 --devices "./runtime/simulation/devices"
uhppoted-rest:
./bin/uhppoted-rest --console
uhppoted-mqtt:
./bin/uhppoted-mqtt --console
swagger:
docker run --detach --publish 80:8080 --name swagger --rm swaggerapi/swagger-editor
sleep 1
open http://127.0.0.1:80
docker:
cd uhppote-simulator && env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -o ../docker/simulator ./...
cd uhppote-simulator && env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -o ../docker/uhppoted-rest ./...
cd uhppote-simulator && env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -o ../docker/integration-tests/simulator ./...
cd uhppoted-rest && env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -o ../docker/uhppoted-rest ./...
cd uhppoted-mqtt && env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -o ../docker/uhppoted-mqtt ./...
docker image prune -f
docker container prune -f
cd ./docker/simulator && docker build -f Dockerfile -t uhppoted/simulator .
cd ./docker/uhppoted-rest && docker build -f Dockerfile -t uhppoted/rest .
cd ./docker/uhppoted-mqtt && docker build -f Dockerfile -t uhppoted/mqtt .
cd ./docker/hivemq && docker build -f Dockerfile -t hivemq/uhppoted .
cd ./docker/integration-tests/simulator && docker build -f Dockerfile -t integration-tests/simulator .
cd ./docker/integration-tests/mqttd && docker build -f Dockerfile -t integration-tests/mqttd .
cd ./docker/integration-tests/hivemq && docker build -f Dockerfile -t integration-tests/hivemq .
docker-simulator:
docker run --detach --publish 8000:8000 --publish 60000:60000/udp --name simulator --rm uhppoted/simulator
sleep 1
./bin/uhppote-cli --debug set-listener 405419896 192.168.1.100:60001
./bin/uhppote-cli --debug set-listener 303986753 192.168.1.100:60001
./bin/uhppote-cli --debug set-listener 201020304 192.168.1.100:60001
docker-simulator-tunnel:
docker run --detach --publish 8000:8000 --publish 60005:60000/udp --name simulator --rm uhppoted/simulator
docker-hivemq:
docker run --detach --publish 8081:8080 --publish 1883:1883 --publish 8883:8883 --name hivemq --rm hivemq/uhppoted
docker-rest:
docker run --detach --publish 8080:8080 --name restd --rm uhppoted/rest
docker-mqtt:
docker run --detach --name mqttd --rm uhppoted/mqtt
docker-stop:
docker stop $$(docker container ls -q)
docker-integration-tests:
docker run --detach --publish 8000:8000 --publish 60000:60000/udp --name qwerty --rm integration-tests/simulator
hivemq-listen:
mqtt subscribe --topic 'uhppoted/reply/#' | jq '.'
# mqtt subscribe --topic 'uhppoted/#' | jq '.'
# open runtime/mqtt-spy-0.5.4-jar-with-dependencies.jar
fly.io:
cd uhppote-simulator && env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -o ../docker/fly.io ./...
cd uhppoted-httpd && env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -trimpath -o ../docker/fly.io ./...
cp -R uhppoted-httpd/html docker/fly.io/httpd
cp -R uhppoted-httpd/translations docker/fly.io/httpd
cd ./docker/fly.io && docker build -f Dockerfile -t uhppoted/fly.io .
# docker run --publish 8080:8080 --name fly.io --rm uhppoted/fly.io
docker run --detach --publish 8080:8080 --name fly.io --rm uhppoted/fly.io