From 5d9c25428282dac27e7bf6024816902cad4c1649 Mon Sep 17 00:00:00 2001 From: Sergey Krashevich Date: Wed, 1 May 2024 09:03:45 +0300 Subject: [PATCH] feat(build): add multi-platform build script for go2rtc --- scripts/build.sh | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 scripts/build.sh diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 000000000..0814ba481 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,82 @@ +#!/bin/sh + +check_command() { + if ! command -v $1 &> /dev/null + then + echo "Error: $1 could not be found. Please install it." + exit 1 + fi +} + +# Check for required commands +check_command go +check_command 7z +check_command upx + +# Windows amd64 +export GOOS=windows +export GOARCH=amd64 +FILENAME="go2rtc_win64.zip" +go build -ldflags "-s -w" -trimpath && 7z a -mx9 -bso0 -sdel $FILENAME go2rtc.exe + +# Windows 386 +export GOOS=windows +export GOARCH=386 +FILENAME="go2rtc_win32.zip" +go build -ldflags "-s -w" -trimpath && 7z a -mx9 -bso0 -sdel $FILENAME go2rtc.exe + +# Windows arm64 +export GOOS=windows +export GOARCH=arm64 +FILENAME="go2rtc_win_arm64.zip" +go build -ldflags "-s -w" -trimpath && 7z a -mx9 -bso0 -sdel $FILENAME go2rtc.exe + +# Linux amd64 +export GOOS=linux +export GOARCH=amd64 +FILENAME="go2rtc_linux_amd64" +go build -ldflags "-s -w" -trimpath -o $FILENAME && upx --lzma --force-overwrite -q --no-progress $FILENAME + +# Linux 386 +export GOOS=linux +export GOARCH=386 +FILENAME="go2rtc_linux_i386" +go build -ldflags "-s -w" -trimpath -o $FILENAME && upx --lzma --force-overwrite -q --no-progress $FILENAME + +# Linux arm64 +export GOOS=linux +export GOARCH=arm64 +FILENAME="go2rtc_linux_arm64" +go build -ldflags "-s -w" -trimpath -o $FILENAME && upx --lzma --force-overwrite -q --no-progress $FILENAME + +# Linux arm v7 +export GOOS=linux +export GOARCH=arm +export GOARM=7 +FILENAME="go2rtc_linux_arm" +go build -ldflags "-s -w" -trimpath -o $FILENAME && upx --lzma --force-overwrite -q --no-progress $FILENAME + +# Linux arm v6 +export GOOS=linux +export GOARCH=arm +export GOARM=6 +FILENAME="go2rtc_linux_armv6" +go build -ldflags "-s -w" -trimpath -o $FILENAME && upx --lzma --force-overwrite -q --no-progress $FILENAME + +# Linux mipsle +export GOOS=linux +export GOARCH=mipsle +FILENAME="go2rtc_linux_mipsel" +go build -ldflags "-s -w" -trimpath -o $FILENAME && upx --lzma --force-overwrite -q --no-progress $FILENAME + +# Darwin amd64 +export GOOS=darwin +export GOARCH=amd64 +FILENAME="go2rtc_mac_amd64.zip" +go build -ldflags "-s -w" -trimpath && 7z a -mx9 -bso0 -sdel $FILENAME go2rtc + +# Darwin arm64 +export GOOS=darwin +export GOARCH=arm64 +FILENAME="go2rtc_mac_arm64.zip" +go build -ldflags "-s -w" -trimpath && 7z a -mx9 -bso0 -sdel $FILENAME go2rtc \ No newline at end of file