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