Skip to content

Commit

Permalink
Add script to release a macOS static binary
Browse files Browse the repository at this point in the history
Provide a prebuilt binary for macOS.

Co-authored-by: Muvaffak Onus <[email protected]>
  • Loading branch information
rom1v and muvaf committed Nov 23, 2024
1 parent c0a49e2 commit bf3f1d5
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,34 @@ jobs:
name: build-win64-intermediate
path: release/work/build-win64/dist-tar/

build-macos:
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install dependencies
run: |
brew install meson ninja nasm libiconv zlib automake autoconf \
libtool
- name: Build macOS
run: release/build_macos.sh

# upload-artifact does not preserve permissions
- name: Tar
run: |
cd release/work/build-macos
mkdir dist-tar
cd dist-tar
tar -C .. -cvf dist.tar.gz dist/
- name: Upload build-macos artifact
uses: actions/upload-artifact@v4
with:
name: build-macos-intermediate
path: release/work/build-macos/dist-tar/

package-linux:
needs:
- build-scrcpy-server
Expand Down Expand Up @@ -271,6 +299,42 @@ jobs:
name: release-win64
path: release/output

package-macos:
needs:
- build-scrcpy-server
- build-macos
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Download scrcpy-server
uses: actions/download-artifact@v4
with:
name: scrcpy-server
path: release/work/build-server/server/

- name: Download build-macos
uses: actions/download-artifact@v4
with:
name: build-macos-intermediate
path: release/work/build-macos/dist-tar/

# upload-artifact does not preserve permissions
- name: Detar
run: |
cd release/work/build-macos
tar xf dist-tar/dist.tar.gz
- name: Package macos
run: release/package_client.sh macos tar.gz

- name: Upload macos release
uses: actions/upload-artifact@v4
with:
name: release-macos
path: release/output/

release:
needs:
- build-scrcpy-server
Expand Down
29 changes: 29 additions & 0 deletions app/deps/adb_macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash
set -ex
DEPS_DIR=$(dirname ${BASH_SOURCE[0]})
cd "$DEPS_DIR"
. common

VERSION=35.0.2
FILENAME=platform-tools_r$VERSION-darwin.zip
PROJECT_DIR=platform-tools-$VERSION-darwin
SHA256SUM=1820078db90bf21628d257ff052528af1c61bb48f754b3555648f5652fa35d78

cd "$SOURCES_DIR"

if [[ -d "$PROJECT_DIR" ]]
then
echo "$PWD/$PROJECT_DIR" found
else
get_file "https://dl.google.com/android/repository/$FILENAME" "$FILENAME" "$SHA256SUM"
mkdir -p "$PROJECT_DIR"
cd "$PROJECT_DIR"
ZIP_PREFIX=platform-tools
unzip "../$FILENAME" "$ZIP_PREFIX"/adb
mv "$ZIP_PREFIX"/* .
rmdir "$ZIP_PREFIX"
fi

mkdir -p "$INSTALL_DIR/adb-macos"
cd "$INSTALL_DIR/adb-macos"
cp -r "$SOURCES_DIR/$PROJECT_DIR"/. "$INSTALL_DIR/adb-macos/"
35 changes: 35 additions & 0 deletions release/build_macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
set -ex
cd "$(dirname ${BASH_SOURCE[0]})"
. build_common
cd .. # root project dir

MACOS_BUILD_DIR="$WORK_DIR/build-macos"

app/deps/adb_macos.sh
app/deps/sdl.sh macos native static
app/deps/ffmpeg.sh macos native static
app/deps/libusb.sh macos native static

DEPS_INSTALL_DIR="$PWD/app/deps/work/install/macos-native-static"
ADB_INSTALL_DIR="$PWD/app/deps/work/install/adb-macos"

rm -rf "$MACOS_BUILD_DIR"
meson setup "$MACOS_BUILD_DIR" \
--pkg-config-path="$DEPS_INSTALL_DIR/lib/pkgconfig" \
-Dc_args="-I$DEPS_INSTALL_DIR/include" \
-Dc_link_args="-L$DEPS_INSTALL_DIR/lib" \
--buildtype=release \
--strip \
-Db_lto=true \
-Dcompile_server=false \
-Dportable=true \
-Dstatic=true
ninja -C "$MACOS_BUILD_DIR"

# Group intermediate outputs into a 'dist' directory
mkdir -p "$MACOS_BUILD_DIR/dist"
cp "$MACOS_BUILD_DIR"/app/scrcpy "$MACOS_BUILD_DIR/dist/scrcpy_bin"
cp app/data/icon.png "$MACOS_BUILD_DIR/dist/"
cp app/data/scrcpy_static_wrapper.sh "$MACOS_BUILD_DIR/dist/scrcpy"
cp -r "$ADB_INSTALL_DIR"/. "$MACOS_BUILD_DIR/dist/"
1 change: 1 addition & 0 deletions release/generate_checksums.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ sha256sum "scrcpy-server-$VERSION" \
"scrcpy-linux-$VERSION.zip" \
"scrcpy-win32-$VERSION.zip" \
"scrcpy-win64-$VERSION.zip" \
"scrcpy-macos-$VERSION.zip" \
| tee SHA256SUMS.txt
echo "Release checksums generated in $PWD/SHA256SUMS.txt"

0 comments on commit bf3f1d5

Please sign in to comment.