Live video on the AT Protocol
1OUT_DIR?="bin"
2$(shell mkdir -p $(OUT_DIR))
3
4.PHONY: default
5default: app node
6
7VERSION?=$(shell go run ./pkg/config/git/git.go -v)
8VERSION_NO_V=$(subst v,,$(VERSION))
9VERSION_ELECTRON=$(subst -,-z,$(subst v,,$(VERSION)))
10UUID?=$(shell go run ./pkg/config/uuid/uuid.go)
11BRANCH?=$(shell go run ./pkg/config/git/git.go --branch)
12
13BUILDOS ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
14BUILDARCH ?= $(shell uname -m | tr '[:upper:]' '[:lower:]')
15ifeq ($(BUILDARCH),aarch64)
16 BUILDARCH=arm64
17endif
18ifeq ($(BUILDARCH),x86_64)
19 BUILDARCH=amd64
20endif
21BUILDDIR?=build-$(BUILDOS)-$(BUILDARCH)
22SHARED_LD_LIBRARY_PATH=$(shell pwd)/$(BUILDDIR)/lib/usr/local/lib/x86_64-linux-gnu
23SHARED_DYLD_LIBRARY_PATH=$(shell pwd)/$(BUILDDIR)/lib/usr/local/lib
24SHARED_PKG_CONFIG_PATH=$(shell pwd)/$(BUILDDIR)/meson-uninstalled
25
26.PHONY: version
27version:
28 @go run ./pkg/config/git/git.go -v \
29 && go run ./pkg/config/git/git.go --env -o .ci/build.env
30
31.PHONY: install
32install:
33 pnpm install
34
35.PHONY: app-and-node
36app-and-node:
37 $(MAKE) app
38 $(MAKE) node
39
40.PHONY: app-and-node-and-test
41app-and-node-and-test:
42 $(MAKE) app
43 $(MAKE) node
44 $(MAKE) test
45.PHONY: app
46app: schema install
47 pnpm run build
48
49.PHONY: node
50node: schema
51 $(MAKE) meson-setup
52 meson compile -C $(BUILDDIR) streamplace
53
54js/app/dist/index.html: install
55 pnpm run build
56
57.PHONY: dev-setup
58dev-setup: schema install js/app/dist/index.html
59 $(MAKE) dev-setup-meson
60 $(MAKE) dev
61
62.PHONY: dev-setup-meson
63dev-setup-meson:
64 $(MAKE) dev-setup-meson-configure
65 $(MAKE) dev-setup-meson-compile
66
67.PHONY: dev-setup-meson-configure
68dev-setup-meson-configure:
69 meson setup --default-library=shared $(BUILDDIR) $(SHARED_OPTS)
70 meson configure --default-library=shared $(BUILDDIR) $(SHARED_OPTS)
71
72.PHONY: dev-setup-meson-compile
73dev-setup-meson-compile:
74 meson compile -C $(BUILDDIR) streamplace
75 meson install --destdir lib -C $(BUILDDIR)
76
77.PHONY: dev
78dev:
79 cp ./util/streamplace-dev.sh $(BUILDDIR)/streamplace
80 PKG_CONFIG_PATH=$(SHARED_PKG_CONFIG_PATH) \
81 LD_LIBRARY_PATH=$(SHARED_LD_LIBRARY_PATH) \
82 DYLD_LIBRARY_PATH=$(SHARED_DYLD_LIBRARY_PATH) \
83 go build -o $(BUILDDIR)/libstreamplace ./cmd/libstreamplace/...
84
85.PHONY: golangci-lint
86golangci-lint:
87 @PKG_CONFIG_PATH=$(SHARED_PKG_CONFIG_PATH) \
88 go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint run -c ./.golangci.yaml
89
90.PHONY: dev-test
91dev-test:
92 PKG_CONFIG_PATH=$(SHARED_PKG_CONFIG_PATH) \
93 LD_LIBRARY_PATH=$(SHARED_LD_LIBRARY_PATH) \
94 DYLD_LIBRARY_PATH=$(SHARED_DYLD_LIBRARY_PATH) \
95 go test -p 1 -timeout 300s ./...
96
97.PHONY: schema
98schema:
99 mkdir -p js/app/generated \
100 && go run pkg/crypto/signers/eip712/export-schema/export-schema.go > js/app/generated/eip712-schema.json
101
102.PHONY: lexicons
103lexicons:
104 $(MAKE) go-lexicons \
105 && $(MAKE) js-lexicons \
106 && $(MAKE) md-lexicons \
107 && make fix
108
109.PHONY: go-lexicons
110go-lexicons:
111 rm -rf ./pkg/streamplace \
112 && mkdir -p ./pkg/streamplace \
113 && rm -rf ./pkg/streamplace/cbor_gen.go \
114 && $(MAKE) lexgen \
115 && sed -i.bak 's/\tutil/\/\/\tutil/' $$(find ./pkg/streamplace -type f) \
116 && go run golang.org/x/tools/cmd/goimports@latest -w $$(find ./pkg/streamplace -type f) \
117 && go run ./pkg/gen/gen.go \
118 && $(MAKE) lexgen \
119 && find . | grep bak$$ | xargs rm \
120 && rm -rf api
121
122.PHONY: js-lexicons
123js-lexicons:
124 node_modules/.bin/lex gen-api ./js/streamplace/src/lexicons $$(find ./lexicons -type f -name '*.json') --yes \
125 && echo 'import { ComAtprotoRepoCreateRecord, ComAtprotoRepoDeleteRecord, ComAtprotoRepoGetRecord, ComAtprotoRepoListRecords } from "@atproto/api"' >> ./js/streamplace/src/lexicons/index.ts \
126 && sed -i.bak "s/'\.\.\/\.\.\/app/'@atproto\/api\/src\/client\/types\/app/" $$(find ./js/streamplace/src/lexicons/types/place/stream -type f) \
127 && sed -i.bak "s/'\.\.\/\.\.\/\.\.\/app/'@atproto\/api\/src\/client\/types\/app/" $$(find ./js/streamplace/src/lexicons/types/place/stream -type f) \
128 && sed -i.bak "s/'\.\.\/\.\.\/com/'@atproto\/api\/src\/client\/types\/com/" $$(find ./js/streamplace/src/lexicons/types/place/stream -type f) \
129 && sed -i.bak "s/'\.\.\/\.\.\/\.\.\/com/'@atproto\/api\/src\/client\/types\/com/" $$(find ./js/streamplace/src/lexicons/types/place/stream -type f) \
130 && sed -i.bak 's/AppBskyGraphBlock\.Main/AppBskyGraphBlock\.Record/' $$(find ./js/streamplace/src/lexicons/types/place/stream -type f) \
131 && sed -i.bak 's/PlaceStreamChatProfile\.Main/PlaceStreamChatProfile\.Record/' $$(find ./js/streamplace/src/lexicons/types/place/stream -type f) \
132 && sed -i.bak "s/import\ \*\ as\ AppBskyFeedDefs\ from\ '.\/defs'/import \{ AppBskyFeedDefs } from '@atproto\/api'/" $$(find ./js/streamplace/src/lexicons/types -type f) \
133 && sed -i.bak "s/import\ \*\ as\ AppBskyActorDefs\ from\ '.\/defs'/import \{ AppBskyActorDefs } from '@atproto\/api'/" $$(find ./js/streamplace/src/lexicons -type f) \
134 && sed -i.bak "s/import\ \*\ as\ ComAtprotoAdminDefs\ from\ .*$$/import \{ ComAtprotoAdminDefs } from '@atproto\/api'/" $$(find ./js/streamplace/src/lexicons -type f) \
135 && sed -i.bak "s/import\ \*\ as\ ComAtprotoRepoStrongRef\ from\ .*$$/import \{ ComAtprotoRepoStrongRef } from '@atproto\/api'/" $$(find ./js/streamplace/src/lexicons -type f) \
136 && sed -i.bak "s/import\ \*\ as\ ComAtprotoModerationDefs\ from\ .*$$/import \{ ComAtprotoModerationDefs } from '@atproto\/api'/" $$(find ./js/streamplace/src/lexicons -type f) \
137 && npx prettier --write $$(find ./js/streamplace/src/lexicons -type f -name '*.ts') \
138 && find . | grep bak$$ | xargs rm
139
140.PHONY: md-lexicons
141md-lexicons:
142 pnpm exec lexmd \
143 ./lexicons \
144 .build/temp \
145 subprojects/atproto/lexicons \
146 js/docs/src/content/docs/lex-reference/openapi.json \
147 && ls -R .build/temp \
148 && cp -rf .build/temp/place/stream/* js/docs/src/content/docs/lex-reference/ \
149 && rm -rf .build/temp \
150 && $(MAKE) fix
151
152.PHONY: lexgen
153lexgen:
154 $(MAKE) lexgen-types
155 $(MAKE) lexgen-server
156
157.PHONY: lexgen-types
158lexgen-types:
159 go run github.com/bluesky-social/indigo/cmd/lexgen \
160 -outdir ./pkg/spxrpc \
161 --build-file util/lexgen-types.json \
162 --external-lexicons subprojects/atproto/lexicons \
163 lexicons/place/stream \
164 ./subprojects/atproto/lexicons
165
166.PHONY: lexgen-server
167lexgen-server:
168 mkdir -p ./pkg/spxrpc \
169 && go run github.com/bluesky-social/indigo/cmd/lexgen \
170 --gen-server \
171 --types-import place.stream:stream.place/streamplace/pkg/streamplace \
172 --types-import app.bsky:github.com/bluesky-social/indigo/api/bsky \
173 --types-import com.atproto:github.com/bluesky-social/indigo/api/atproto \
174 --types-import chat.bsky:github.com/bluesky-social/indigo/api/chat \
175 --types-import tools.ozone:github.com/bluesky-social/indigo/api/ozone \
176 -outdir ./pkg/spxrpc \
177 --build-file util/lexgen-types.json \
178 --external-lexicons subprojects/atproto/lexicons \
179 --package spxrpc \
180 lexicons/place/stream \
181 lexicons/app/bsky \
182 lexicons/com/atproto
183
184.PHONY: ci-lexicons
185ci-lexicons:
186 $(MAKE) lexicons \
187 && if ! git diff --exit-code >/dev/null; then echo "lexicons are out of date, run 'make lexicons' to fix"; exit 1; fi
188
189.PHONY: test
190test:
191 meson test -C $(BUILDDIR) go-tests
192
193# test to make sure we haven't added any more dynamic dependencies
194LINUX_LINK_COUNT=5
195.PHONY: link-test-linux
196link-test-linux:
197 count=$(shell ldd ./build-linux-amd64/streamplace | wc -l) \
198 && echo $$count \
199 && if [ "$$count" != "$(LINUX_LINK_COUNT)" ]; then echo "ldd reports new libaries linked! want $(LINUX_LINK_COUNT) got $$count" \
200 && ldd ./build-linux-amd64/streamplace \
201 && exit 1; \
202 fi
203
204MACOS_LINK_COUNT=10
205.PHONY: link-test-macos
206link-test-macos:
207 count=$(shell otool -L ./build-darwin-arm64/streamplace | wc -l | xargs) \
208 && echo $$count \
209 && if [ "$$count" != "$(MACOS_LINK_COUNT)" ]; then echo "otool -L reports new libaries linked! want $(MACOS_LINK_COUNT) got $$count" \
210 && otool -L ./build-darwin-arm64/streamplace \
211 && exit 1; \
212 fi
213
214WINDOWS_LINK_COUNT=16
215.PHONY: link-test-windows
216link-test-windows:
217 count=$(shell x86_64-w64-mingw32-objdump -p ./build-windows-amd64/streamplace.exe | grep "DLL Name" | tr '[:upper:]' '[:lower:]' | sort | uniq | wc -l | xargs) \
218 && echo $$count \
219 && if [ "$$count" != "$(WINDOWS_LINK_COUNT)" ]; then echo "x86_64-w64-mingw32-objdump -p reports new libaries linked! want $(WINDOWS_LINK_COUNT) got $$count" \
220 && x86_64-w64-mingw32-objdump -p ./build-windows-amd64/streamplace.exe | grep "DLL Name" \
221 && exit 1; \
222 fi
223
224.PHONY: all
225all: version install app test node-all-platforms android
226
227.PHONY: ci
228ci: version install app node-all-platforms ci-upload-node
229
230.PHONY: ci-ios
231ci-ios: version install app
232 $(MAKE) ios
233 $(MAKE) ci-upload-ios
234
235.PHONY: ci-desktop-darwin
236ci-desktop-darwin: version install
237 ./util/mac-codesign.sh \
238 && for arch in amd64 arm64; do \
239 curl -v --fail-with-body -O "$$CI_API_V4_URL/projects/$$CI_PROJECT_ID/packages/generic/$(BRANCH)/$(VERSION)/streamplace-$(VERSION)-darwin-$$arch.tar.gz" || exit 1 \
240 && tar -xzvf streamplace-$(VERSION)-darwin-$$arch.tar.gz \
241 && ./streamplace --version \
242 && ./streamplace self-test \
243 && mkdir -p build-darwin-$$arch \
244 && mv ./streamplace ./build-darwin-$$arch/streamplace; \
245 done \
246 && $(MAKE) desktop-darwin \
247 && for arch in amd64 arm64; do \
248 export file=streamplace-desktop-$(VERSION)-darwin-$$arch.zip \
249 && $(MAKE) ci-upload-file upload_file=$$file \
250 && export file=streamplace-desktop-$(VERSION)-darwin-$$arch.dmg \
251 && $(MAKE) ci-upload-file upload_file=$$file; \
252 done
253
254.PHONY: ci-android
255ci-android: version install android ci-upload-android
256
257.PHONY: ci-android-debug
258ci-android-debug: version install
259 pnpm run app prebuild
260 $(MAKE) android-debug
261 $(MAKE) ci-upload-android-debug
262
263.PHONY: ci-android-release
264ci-android-release: version install
265 pnpm run app prebuild
266 $(MAKE) android-release
267 $(MAKE) ci-upload-android-release
268
269.PHONY: ci-test
270ci-test: app
271 meson setup $(BUILDDIR) $(OPTS)
272 meson test -C $(BUILDDIR) go-tests
273
274.PHONY: ci-npm-release
275ci-npm-release: install
276 echo //registry.npmjs.org/:_authToken=$$NPM_TOKEN > ~/.npmrc \
277 && npx lerna publish from-package --yes
278
279.PHONY: android
280android: app .build/bundletool.jar
281 $(MAKE) android-release
282 $(MAKE) android-debug
283
284.PHONY: android-release
285android-release: .build/bundletool.jar
286 export NODE_ENV=production \
287 && cd ./js/app/android \
288 && ./gradlew :app:bundleRelease \
289 && cd - \
290 && mv ./js/app/android/app/build/outputs/bundle/release/app-release.aab ./bin/streamplace-$(VERSION)-android-release.aab \
291 && cd bin \
292 && java -jar ../.build/bundletool.jar build-apks --ks ../my-release-key.keystore --ks-key-alias alias_name --ks-pass pass:aquareum --bundle=streamplace-$(VERSION)-android-release.aab --output=streamplace-$(VERSION)-android-release.apks --mode=universal \
293 && unzip streamplace-$(VERSION)-android-release.apks && mv universal.apk streamplace-$(VERSION)-android-release.apk && rm toc.pb
294
295.PHONY: android-debug
296android-debug: .build/bundletool.jar
297 export NODE_ENV=production \
298 && cd ./js/app/android \
299 && ./gradlew :app:bundleDebug \
300 && cd - \
301 && mv ./js/app/android/app/build/outputs/bundle/debug/app-debug.aab ./bin/streamplace-$(VERSION)-android-debug.aab \
302 && cd bin \
303 && java -jar ../.build/bundletool.jar build-apks --ks ../my-release-key.keystore --ks-key-alias alias_name --ks-pass pass:aquareum --bundle=streamplace-$(VERSION)-android-debug.aab --output=streamplace-$(VERSION)-android-debug.apks --mode=universal \
304 && unzip streamplace-$(VERSION)-android-debug.apks && mv universal.apk streamplace-$(VERSION)-android-debug.apk && rm toc.pb
305
306.PHONY: ios
307ios: app
308 xcodebuild \
309 -workspace ./js/app/ios/Streamplace.xcworkspace \
310 -sdk iphoneos \
311 -configuration Release \
312 -scheme Streamplace \
313 -archivePath ./bin/streamplace-$(VERSION)-ios-release.xcarchive \
314 CODE_SIGN_IDENTITY=- \
315 AD_HOC_CODE_SIGNING_ALLOWED=YES \
316 CODE_SIGN_STYLE=Automatic \
317 DEVELOPMENT_TEAM=ZZZZZZZZZZ \
318 clean archive | xcpretty \
319 && cd bin \
320 && tar -czvf streamplace-$(VERSION)-ios-release.xcarchive.tar.gz streamplace-$(VERSION)-ios-release.xcarchive
321
322# xcodebuild -exportArchive -archivePath ./bin/streamplace-$(VERSION)-ios-release.xcarchive -exportOptionsPlist ./js/app/exportOptions.plist -exportPath ./bin/streamplace-$(VERSION)-ios-release.ipa
323
324.build/bundletool.jar:
325 mkdir -p .build \
326 && curl -L -o ./.build/bundletool.jar https://github.com/google/bundletool/releases/download/1.17.0/bundletool-all-1.17.0.jar
327
328BASE_OPTS = \
329 --buildtype=debugoptimized \
330 -D "gst-plugins-base:audioresample=enabled" \
331 -D "gst-plugins-base:playback=enabled" \
332 -D "gst-plugins-base:opus=enabled" \
333 -D "gst-plugins-base:gio-typefinder=enabled" \
334 -D "gst-plugins-base:videotestsrc=enabled" \
335 -D "gst-plugins-base:videoconvertscale=enabled" \
336 -D "gst-plugins-base:typefind=enabled" \
337 -D "gst-plugins-base:compositor=enabled" \
338 -D "gst-plugins-base:videorate=enabled" \
339 -D "gst-plugins-base:app=enabled" \
340 -D "gst-plugins-base:audiorate=enabled" \
341 -D "gst-plugins-base:audiotestsrc=enabled" \
342 -D "gst-plugins-base:audioconvert=enabled" \
343 -D "gst-plugins-good:matroska=enabled" \
344 -D "gst-plugins-good:multifile=enabled" \
345 -D "gst-plugins-good:rtp=enabled" \
346 -D "gst-plugins-bad:fdkaac=enabled" \
347 -D "gst-plugins-good:audioparsers=enabled" \
348 -D "gst-plugins-good:isomp4=enabled" \
349 -D "gst-plugins-good:png=enabled" \
350 -D "gst-plugins-good:videobox=enabled" \
351 -D "gst-plugins-good:jpeg=enabled" \
352 -D "gst-plugins-good:audioparsers=enabled" \
353 -D "gst-plugins-bad:videoparsers=enabled" \
354 -D "gst-plugins-bad:mpegtsmux=enabled" \
355 -D "gst-plugins-bad:mpegtsdemux=enabled" \
356 -D "gst-plugins-bad:codectimestamper=enabled" \
357 -D "gst-plugins-bad:opus=enabled" \
358 -D "gst-plugins-ugly:x264=enabled" \
359 -D "gst-plugins-ugly:gpl=enabled" \
360 -D "x264:asm=enabled" \
361 -D "gstreamer-full:gst-full=enabled" \
362 -D "gstreamer-full:gst-full-plugins=libgstopusparse.a;libgstcodectimestamper.a;libgstrtp.a;libgstaudioresample.a;libgstlibav.a;libgstmatroska.a;libgstmultifile.a;libgstjpeg.a;libgstaudiotestsrc.a;libgstaudioconvert.a;libgstaudioparsers.a;libgstfdkaac.a;libgstisomp4.a;libgstapp.a;libgstvideoconvertscale.a;libgstvideobox.a;libgstvideorate.a;libgstpng.a;libgstcompositor.a;libgstaudiorate.a;libgstx264.a;libgstopus.a;libgstvideotestsrc.a;libgstvideoparsersbad.a;libgstaudioparsers.a;libgstmpegtsmux.a;libgstmpegtsdemux.a;libgstplayback.a;libgsttypefindfunctions.a;libgstcoretracers.a" \
363 -D "gstreamer-full:gst-full-libraries=gstreamer-controller-1.0,gstreamer-plugins-base-1.0,gstreamer-pbutils-1.0" \
364 -D "gstreamer-full:gst-full-elements=coreelements:concat,filesrc,filesink,queue,queue2,multiqueue,typefind,tee,capsfilter,fakesink,identity" \
365 -D "gstreamer-full:bad=enabled" \
366 -D "gstreamer-full:tls=disabled" \
367 -D "gstreamer-full:libav=enabled" \
368 -D "gstreamer-full:ugly=enabled" \
369 -D "gstreamer-full:gpl=enabled" \
370 -D "gstreamer-full:gst-full-typefind-functions=" \
371 -D "gstreamer:coretracers=enabled" \
372 -D "gstreamer-full:glib_assert=false" \
373 -D "gstreamer:glib_assert=false" \
374 -D "gst-plugins-good:glib_assert=false" \
375 -D "gst-plugins-bad:glib_assert=false" \
376 -D "gst-plugins-base:glib_assert=false" \
377 -D "gst-plugins-ugly:glib_assert=false" \
378 -D "glib:glib_assert=false" \
379 -D "glib:glib_assert=false" \
380 -D "gst-libav:glib_assert=false" \
381 -D "gst-plugins-good:adaptivedemux2=disabled"
382
383OPTS = \
384 $(BASE_OPTS) \
385 -D "gstreamer-full:gst-full-target-type=static_library" \
386 -D "gstreamer:registry=false"
387
388SHARED_OPTS = \
389 $(BASE_OPTS) \
390 -D "FFmpeg:default_library=shared" \
391 -D "gstreamer:registry=true"
392
393.PHONY: meson-setup
394meson-setup:
395 @meson setup $(BUILDDIR) $(OPTS)
396 @meson configure $(BUILDDIR) $(OPTS)
397
398.PHONY: node-all-platforms
399node-all-platforms: app
400 meson setup build-linux-amd64 $(OPTS) --buildtype debugoptimized
401 meson compile -C build-linux-amd64 archive
402 $(MAKE) link-test-linux
403 $(MAKE) linux-arm64
404 $(MAKE) windows-amd64
405 $(MAKE) windows-amd64-startup-test
406 $(MAKE) desktop-linux
407 $(MAKE) desktop-windows-amd64
408
409.PHONY: desktop-linux
410desktop-linux:
411 $(MAKE) desktop-linux-amd64
412 $(MAKE) desktop-linux-arm64
413
414.PHONY: desktop-linux-amd64
415desktop-linux-amd64:
416 cd js/desktop \
417 && pnpm run make --platform linux --arch x64 \
418 && cd - \
419 && mv "js/desktop/out/make/AppImage/x64/Streamplace-$(VERSION_ELECTRON)-x64.AppImage" ./bin/streamplace-desktop-$(VERSION)-linux-amd64.AppImage
420
421.PHONY: desktop-linux-arm64
422desktop-linux-arm64:
423 cd js/desktop \
424 && pnpm run make --platform linux --arch arm64 \
425 && cd - \
426 && mv "js/desktop/out/make/AppImage/arm64/Streamplace-$(VERSION_ELECTRON)-arm64.AppImage" ./bin/streamplace-desktop-$(VERSION)-linux-arm64.AppImage
427
428.PHONY: desktop-windows-amd64
429desktop-windows-amd64:
430 cd js/desktop \
431 && pnpm run make --platform win32 --arch x64 \
432 && cd - \
433 && export SUM=$$(cat ./js/desktop/out/make/squirrel.windows/x64/streamplace_desktop-$(VERSION_ELECTRON)-full.nupkg | openssl sha1 | awk '{ print $$2 }') \
434 && echo $$SUM > ./bin/streamplace-desktop-$(VERSION)-windows-amd64.nupkg.sha1 \
435 && mv "js/desktop/out/make/squirrel.windows/x64/streamplace_desktop-$(VERSION_ELECTRON)-full.nupkg" ./bin/streamplace-desktop-$(VERSION)-windows-amd64.$$SUM.nupkg \
436 && mv "js/desktop/out/make/squirrel.windows/x64/Streamplace-$(VERSION_ELECTRON) Setup.exe" ./bin/streamplace-desktop-$(VERSION)-windows-amd64.exe
437
438.PHONY: linux-amd64
439linux-amd64:
440 meson setup --buildtype debugoptimized build-linux-amd64 $(OPTS)
441 meson compile -C build-linux-amd64 archive
442
443.PHONY: linux-arm64
444linux-arm64:
445 rustup target add aarch64-unknown-linux-gnu
446 meson setup --cross-file util/linux-arm64-gnu.ini --buildtype debugoptimized build-linux-arm64 $(OPTS)
447 meson compile -C build-linux-arm64 archive
448
449.PHONY: windows-amd64
450windows-amd64:
451 rustup target add x86_64-pc-windows-gnu
452 $(MAKE) windows-amd64-meson-setup
453 meson compile -C build-windows-amd64 archive 2>&1 | grep -v drectve
454 $(MAKE) link-test-windows
455
456.PHONY: windows-amd64-meson-setup
457windows-amd64-meson-setup:
458 meson setup --cross-file util/windows-amd64-gnu.ini --buildtype debugoptimized build-windows-amd64 $(OPTS)
459
460# unbuffer here is a workaround for wine trying to pop up a terminal window and failing
461.PHONY: windows-amd64-startup-test
462windows-amd64-startup-test:
463 bash -c 'set -euo pipefail && unbuffer wine64 ./build-windows-amd64/streamplace.exe self-test | cat'
464
465.PHONY: darwin-amd64
466darwin-amd64:
467 export CC=x86_64-apple-darwin24.4-clang \
468 && export CC_X86_64_APPLE_DARWIN=x86_64-apple-darwin24.4-clang \
469 && export CXX_X86_64_APPLE_DARWIN=x86_64-apple-darwin24.4-clang++ \
470 && export AR_X86_64_APPLE_DARWIN=x86_64-apple-darwin24.4-ar \
471 && export CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER=x86_64-apple-darwin24.4-clang \
472 && export LD=x86_64-apple-darwin24.4-ld \
473 && export CROSS_COMPILE=1 \
474 && meson setup --buildtype debugoptimized --cross-file util/osxcross-darwin-amd64.ini build-darwin-amd64 $(OPTS) \
475 && meson compile -C build-darwin-amd64 subprojects/glib-2.82.4/gio/gioenumtypes_h \
476 && meson compile -C build-darwin-amd64 streamplace \
477 && ./util/osxcross-codesign.sh ./build-darwin-amd64/streamplace \
478 && mkdir -p bin \
479 && cd build-darwin-amd64 \
480 && tar -czvf ../bin/streamplace-$(VERSION)-darwin-amd64.tar.gz ./streamplace \
481 && cd -
482
483.PHONY: desktop-darwin-amd64
484desktop-darwin-amd64:
485 echo "TODO"
486
487.PHONY: darwin-amd64
488darwin-arm64:
489 export CC=aarch64-apple-darwin24.4-clang \
490 && export CC_AARCH64_APPLE_DARWIN=aarch64-apple-darwin24.4-clang \
491 && export CXX_AARCH64_APPLE_DARWIN=aarch64-apple-darwin24.4-clang++ \
492 && export AR_AARCH64_APPLE_DARWIN=aarch64-apple-darwin24.4-ar \
493 && export CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER=aarch64-apple-darwin24.4-clang \
494 && export LD=aarch64-apple-darwin24.4-ld \
495 && export CROSS_COMPILE=1 \
496 && meson setup --buildtype debugoptimized --cross-file util/osxcross-darwin-arm64.ini build-darwin-arm64 $(OPTS) \
497 && meson compile -C build-darwin-arm64 streamplace \
498 && ./util/osxcross-codesign.sh ./build-darwin-arm64/streamplace \
499 && mkdir -p bin \
500 && cd build-darwin-arm64 \
501 && tar -czvf ../bin/streamplace-$(VERSION)-darwin-arm64.tar.gz ./streamplace \
502 && cd -
503
504.PHONY: desktop-darwin-arm64
505desktop-darwin-arm64:
506 echo "TODO"
507
508.PHONY: desktop-darwin
509desktop-darwin:
510 export DEBUG="electron-osx-sign*" \
511 && cd js/desktop \
512 && pnpm run make --platform darwin --arch arm64 \
513 && pnpm run make --platform darwin --arch x64 \
514 && cd - \
515 && mv js/desktop/out/make/Streamplace-$(VERSION_ELECTRON)-x64.dmg ./bin/streamplace-desktop-$(VERSION)-darwin-amd64.dmg \
516 && mv js/desktop/out/make/Streamplace-$(VERSION_ELECTRON)-arm64.dmg ./bin/streamplace-desktop-$(VERSION)-darwin-arm64.dmg \
517 && mv js/desktop/out/make/zip/darwin/x64/Streamplace-darwin-x64-$(VERSION_ELECTRON).zip ./bin/streamplace-desktop-$(VERSION)-darwin-amd64.zip \
518 && mv js/desktop/out/make/zip/darwin/arm64/Streamplace-darwin-arm64-$(VERSION_ELECTRON).zip ./bin/streamplace-desktop-$(VERSION)-darwin-arm64.zip
519
520.PHONY: selftest-macos
521selftest-macos:
522 js/desktop/out/Streamplace-darwin-arm64/Streamplace.app/Contents/MacOS/Streamplace -- --self-test
523
524# link your local version of mist for dev
525.PHONY: link-mist
526link-mist:
527 rm -rf subprojects/mistserver
528 ln -s $$(realpath ../mistserver) ./subprojects/mistserver
529
530# link your local version of c2pa-go for dev
531.PHONY: link-c2pa-go
532link-c2pa-go:
533 rm -rf subprojects/c2pa_go
534 ln -s $$(realpath ../c2pa-go) ./subprojects/c2pa_go
535
536# link your local version of gstreamer
537.PHONY: link-gstreamer
538link-gstreamer:
539 rm -rf subprojects/gstreamer-full
540 ln -s $$(realpath ../gstreamer) ./subprojects/gstreamer-full
541
542# link your local version of ffmpeg for dev
543.PHONY: link-ffmpeg
544link-ffmpeg:
545 rm -rf subprojects/FFmpeg
546 ln -s $$(realpath ../ffmpeg) ./subprojects/FFmpeg
547
548.PHONY: docker
549docker:
550 docker build -f docker/local.Dockerfile -t dist.stream.place/streamplace/streamplace:local .
551
552.PHONY: docker-build
553docker-build: docker-build-builder docker-build-in-container
554
555.PHONY: docker-test
556docker-test: docker-build-builder docker-test-in-container
557
558DOCKER_BUILD_OPTS?=
559BUILDER_TARGET?=builder
560.PHONY: docker-build-builder
561docker-build-builder:
562 podman build --target=$(BUILDER_TARGET) --os=linux --arch=amd64 -f docker/build.Dockerfile -t dist.stream.place/streamplace/streamplace:$(BUILDER_TARGET) $(DOCKER_BUILD_OPTS) .
563
564.PHONY: golangci-lint-container
565golangci-lint-container: docker-build-builder
566 podman run \
567 -v $$(pwd):$$(pwd) \
568 -w $$(pwd) \
569 -e PKG_CONFIG_PATH=$$(pwd)/build-linux-amd64/meson-uninstalled \
570 -d \
571 --name golangci-lint \
572 dist.stream.place/streamplace/streamplace:$(BUILDER_TARGET) \
573 tail -f /dev/null
574 podman exec golangci-lint mkdir -p js/app/dist
575 podman exec golangci-lint touch js/app/dist/skip-build.txt
576 podman exec golangci-lint make node
577
578.PHONY: docker-build-in-container
579docker-build-in-container:
580 podman run -v $$(pwd):$$(pwd) -w $$(pwd) --rm -it dist.stream.place/streamplace/streamplace:$(BUILDER_TARGET) make app-and-node
581
582.PHONY: docker-test-in-container
583docker-test-in-container:
584 podman run -v $$(pwd):$$(pwd) -w $$(pwd) --rm -it dist.stream.place/streamplace/streamplace:$(BUILDER_TARGET) make app-and-node-and-test
585
586IN_CONTAINER_CMD?=echo 'usage: make in-container IN_CONTAINER_CMD=\"<command>\"'
587DOCKER_BIN?=podman
588DOCKER_REF?=dist.stream.place/streamplace/streamplace:$(BUILDER_TARGET)
589DOCKER_OPTS?=
590.PHONY: in-container
591in-container: docker-build-builder
592 $(DOCKER_BIN) run $(DOCKER_OPTS) -v $$(pwd):$$(pwd) -w $$(pwd) --rm $(DOCKER_REF) bash -c "$(IN_CONTAINER_CMD)"
593
594STREAMPLACE_URL?=https://git.stream.place/streamplace/streamplace/-/package_files/10122/download
595.PHONY: docker-release
596docker-release:
597 cd docker \
598 && docker build -f release.Dockerfile \
599 --build-arg TARGETARCH=$(BUILDARCH) \
600 --build-arg STREAMPLACE_URL=$(STREAMPLACE_URL) \
601 -t dist.stream.place/streamplace/streamplace \
602 .
603
604.PHONY: docker-mistserver
605docker-mistserver:
606 cd docker \
607 && docker build -f mistserver.Dockerfile \
608 --build-arg TARGETARCH=$(BUILDARCH) \
609 --build-arg STREAMPLACE_URL=$(STREAMPLACE_URL) \
610 -t dist.stream.place/streamplace/streamplace:mistserver \
611 .
612
613FPM_BASE_OPTS= \
614 -s dir \
615 -t deb \
616 -v $(VERSION_NO_V) \
617 --force \
618 --license=GPL-3.0-or-later \
619 --maintainer="Streamplace <support@stream.place>" \
620 --vendor="Streamplace" \
621 --url="https://stream.place"
622SP_ARCH_NAME?=amd64
623.PHONY: deb-pkg
624deb-pkg:
625 fpm $(FPM_BASE_OPTS) \
626 -n streamplace \
627 -a $(SP_ARCH_NAME) \
628 -p bin/streamplace-$(VERSION)-linux-$(SP_ARCH_NAME).deb \
629 --deb-systemd=util/systemd/streamplace.service \
630 --deb-systemd-auto-start \
631 --deb-systemd-enable \
632 --deb-systemd-restart-after-upgrade \
633 --after-install=util/systemd/after-install.sh \
634 --description="Live video for the AT Protocol. Solving video for everybody forever." \
635 build-linux-$(SP_ARCH_NAME)/streamplace=/usr/bin/streamplace \
636 && fpm $(FPM_BASE_OPTS) \
637 -n streamplace-default-http \
638 -a $(SP_ARCH_NAME) \
639 -d streamplace \
640 --deb-systemd-auto-start \
641 --deb-systemd-enable \
642 --deb-systemd-restart-after-upgrade \
643 -p bin/streamplace-default-http-$(VERSION)-linux-$(SP_ARCH_NAME).deb \
644 --description="Installing this package will install Streamplace as the default HTTP server on ports 80 and 443." \
645 util/systemd/streamplace-http.socket=/lib/systemd/system/streamplace-http.socket \
646 util/systemd/streamplace-https.socket=/lib/systemd/system/streamplace-https.socket
647
648.PHONY: pkg-linux-amd64
649pkg-linux-amd64:
650 $(MAKE) deb-pkg SP_ARCH_NAME=amd64
651
652.PHONY: pkg-linux-arm64
653pkg-linux-arm64:
654 $(MAKE) deb-pkg SP_ARCH_NAME=arm64
655
656.PHONY: pkg-darwin-amd64
657pkg-darwin-amd64:
658 echo todo
659
660.PHONY: pkg-darwin-arm64
661pkg-darwin-arm64:
662 echo todo
663
664.PHONY: pkg-windows-amd64
665pkg-windows-amd64:
666 echo todo
667
668.PHONY: ci-upload
669ci-upload: ci-upload-node ci-upload-android
670
671.PHONY: ci-upload-node-linux-amd64
672ci-upload-node-linux-amd64:
673 $(MAKE) ci-upload-file upload_file=streamplace-$(VERSION)-linux-amd64.tar.gz \
674 && $(MAKE) ci-upload-file upload_file=streamplace-desktop-$(VERSION)-linux-amd64.AppImage \
675 && $(MAKE) ci-upload-file upload_file=streamplace-default-http-$(VERSION)-linux-amd64.deb \
676 && $(MAKE) ci-upload-file upload_file=streamplace-$(VERSION)-linux-amd64.deb
677
678.PHONY: ci-upload-node-linux-arm64
679ci-upload-node-linux-arm64:
680 $(MAKE) ci-upload-file upload_file=streamplace-$(VERSION)-linux-arm64.tar.gz \
681 && $(MAKE) ci-upload-file upload_file=streamplace-desktop-$(VERSION)-linux-arm64.AppImage \
682 && $(MAKE) ci-upload-file upload_file=streamplace-default-http-$(VERSION)-linux-arm64.deb \
683 && $(MAKE) ci-upload-file upload_file=streamplace-$(VERSION)-linux-arm64.deb
684
685.PHONY: ci-upload-node-darwin-arm64
686ci-upload-node-darwin-arm64:
687 export file=streamplace-$(VERSION)-darwin-arm64.tar.gz \
688 && $(MAKE) ci-upload-file upload_file=$$file;
689
690.PHONY: ci-upload-node-darwin-amd64
691ci-upload-node-darwin-amd64:
692 export file=streamplace-$(VERSION)-darwin-amd64.tar.gz \
693 && $(MAKE) ci-upload-file upload_file=$$file;
694
695.PHONY: ci-upload-node-windows-amd64
696ci-upload-node-windows-amd64:
697 export file=streamplace-$(VERSION)-windows-amd64.zip \
698 && $(MAKE) ci-upload-file upload_file=$$file; \
699 export file=streamplace-desktop-$(VERSION)-windows-amd64.exe \
700 && $(MAKE) ci-upload-file upload_file=$$file; \
701 export SUM=$$(cat bin/streamplace-desktop-$(VERSION)-windows-amd64.nupkg.sha1) \
702 && export file=streamplace-desktop-$(VERSION)-windows-amd64.$$SUM.nupkg \
703 && $(MAKE) ci-upload-file upload_file=$$file;
704
705.PHONY: ci-upload-node-macos
706ci-upload-node-macos: node-all-platforms-macos
707 for GOOS in darwin; do \
708 for GOARCH in amd64 arm64; do \
709 export file=streamplace-$(VERSION)-$$GOOS-$$GOARCH.tar.gz \
710 && $(MAKE) ci-upload-file upload_file=$$file; \
711 export file=streamplace-desktop-$(VERSION)-$$GOOS-$$GOARCH.dmg \
712 && $(MAKE) ci-upload-file upload_file=$$file; \
713 export file=streamplace-desktop-$(VERSION)-$$GOOS-$$GOARCH.zip \
714 && $(MAKE) ci-upload-file upload_file=$$file; \
715 done \
716 done;
717
718.PHONY: ci-upload-android
719ci-upload-android: android
720 $(MAKE) ci-upload-android-debug \
721 && $(MAKE) ci-upload-android-release
722
723.PHONY: ci-upload-android-debug
724ci-upload-android-debug:
725 $(MAKE) ci-upload-file upload_file=streamplace-$(VERSION)-android-debug.apk \
726 && $(MAKE) ci-upload-file upload_file=streamplace-$(VERSION)-android-debug.aab
727
728.PHONY: ci-upload-android-release
729ci-upload-android-release:
730 $(MAKE) ci-upload-file upload_file=streamplace-$(VERSION)-android-release.apk \
731 && $(MAKE) ci-upload-file upload_file=streamplace-$(VERSION)-android-release.aab
732
733.PHONY: ci-upload-ios
734ci-upload-ios: ios
735 $(MAKE) ci-upload-file upload_file=streamplace-$(VERSION)-ios-release.xcarchive.tar.gz
736
737upload_file?=""
738.PHONY: ci-upload-file
739ci-upload-file:
740 curl \
741 --fail-with-body \
742 --header "JOB-TOKEN: $$CI_JOB_TOKEN" \
743 --upload-file bin/$(upload_file) \
744 "$$CI_API_V4_URL/projects/$$CI_PROJECT_ID/packages/generic/$(BRANCH)/$(VERSION)/$(upload_file)";
745
746download_file?=""
747.PHONY: ci-download-file
748ci-download-file:
749 curl \
750 --fail-with-body \
751 --header "JOB-TOKEN: $$CI_JOB_TOKEN" \
752 -o bin/$(download_file) \
753 "$$CI_API_V4_URL/projects/$$CI_PROJECT_ID/packages/generic/$(BRANCH)/$(VERSION)/$(download_file)";
754
755.PHONY: release
756release: install
757 $(MAKE) lexicons
758 pnpm run release
759
760.PHONY: ci-release
761ci-release:
762 go install gitlab.com/gitlab-org/release-cli/cmd/release-cli
763 go run ./pkg/config/git/git.go -release -o release.yml
764 release-cli create-from-file --file release.yml
765
766.PHONY: deb-release
767deb-release:
768 aptly repo create -distribution=all -component=main streamplace-releases
769 aptly mirror create old-version $$S3_PUBLIC_URL/debian all
770 aptly mirror update old-version
771 aptly repo import old-version streamplace-releases streamplace streamplace-default-http
772 aptly repo add streamplace-releases \
773 bin/streamplace-default-http-$(VERSION)-linux-arm64.deb \
774 bin/streamplace-$(VERSION)-linux-arm64.deb \
775 bin/streamplace-default-http-$(VERSION)-linux-amd64.deb \
776 bin/streamplace-$(VERSION)-linux-amd64.deb
777 aptly snapshot create streamplace-$(VERSION) from repo streamplace-releases
778 aptly publish snapshot -distribution=all streamplace-$(VERSION) s3:streamplace-releases:
779
780.PHONY: ci-deb-release
781ci-deb-release:
782 $(MAKE) ci-download-file download_file=streamplace-default-http-$(VERSION)-linux-amd64.deb
783 $(MAKE) ci-download-file download_file=streamplace-$(VERSION)-linux-amd64.deb
784 $(MAKE) ci-download-file download_file=streamplace-default-http-$(VERSION)-linux-arm64.deb
785 $(MAKE) ci-download-file download_file=streamplace-$(VERSION)-linux-arm64.deb
786 echo $$CI_SIGNING_KEY_BASE64 | base64 -d | gpg --import
787 gpg --armor --export | gpg --no-default-keyring --keyring trustedkeys.gpg --import
788 echo '{"S3PublishEndpoints":{"streamplace-releases":{"region":"'$$S3_REGION'","bucket":"'$$S3_BUCKET_NAME'","endpoint":"'$$S3_ENDPOINT'","acl":"public-read","prefix":"debian"}}}' > ~/.aptly.conf
789 $(MAKE) deb-release
790
791.PHONY: check
792check: install
793 $(MAKE) golangci-lint
794 pnpm run check
795 if [ "`gofmt -l . | wc -l`" -gt 0 ]; then echo 'gofmt failed, run make fix'; exit 1; fi
796
797.PHONY: fix
798fix:
799 pnpm run fix
800 gofmt -w .
801
802.PHONY: precommit
803precommit: dockerfile-hash-precommit
804
805.PHONY: dockefile-hash-precommit
806dockerfile-hash-precommit:
807 @bash -c 'printf "variables:\n DOCKERFILE_HASH: `git hash-object docker/build.Dockerfile`" > .ci/dockerfile-hash.yaml' \
808 && git add .ci/dockerfile-hash.yaml
809
810.PHONY: rtcrec
811rtcrec:
812 go build -o $(BUILDDIR)/rtcrec ./pkg/rtcrec/cmd/...
813
814.PHONY: homebrew
815homebrew:
816 $(MAKE) ci-download-file download_file=streamplace-$(VERSION)-linux-amd64.tar.gz
817 $(MAKE) ci-download-file download_file=streamplace-$(VERSION)-linux-arm64.tar.gz
818 $(MAKE) ci-download-file download_file=streamplace-$(VERSION)-darwin-amd64.tar.gz
819 $(MAKE) ci-download-file download_file=streamplace-$(VERSION)-darwin-arm64.tar.gz
820 git clone git@github.com:streamplace/homebrew-streamplace.git /tmp/homebrew-streamplace
821 go run ./pkg/config/git/git.go -homebrew -o /tmp/homebrew-streamplace/Formula/streamplace.rb
822
823.PHONY: ci-homebrew
824ci-homebrew:
825 git config --global user.name "Streamplace Homebrew Robot"
826 git config --global user.email support@stream.place
827 mkdir -p ~/.ssh
828 echo "Host * \n\
829 StrictHostKeyChecking no \n\
830 UserKnownHostsFile=/dev/null" > ~/.ssh/config
831 echo "$$CI_HOMEBREW_KEY_BASE64" | base64 -d > ~/.ssh/id_ed25519
832 chmod 600 ~/.ssh/id_ed25519
833
834 chmod 600 ~/.ssh/config
835 $(MAKE) homebrew
836 cd /tmp/homebrew-streamplace \
837 && git add . \
838 && git commit -m "Update streamplace $(VERSION)" \
839 && git push