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