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