ituoke/scripts/sync-macos-runtime.sh

26 lines
1.7 KiB
Bash

#!/usr/bin/env bash
# Build machine only. Bundle ffmpeg and its full non-system dylib closure.
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
DEST="$ROOT/third_party"
CACHE="$ROOT/.task/runtime-downloads"
mkdir -p "$DEST/scrcpy" "$DEST/ffmpeg/lib" "$CACHE"
[[ "$(uname -s)" == Darwin ]] || { echo 'Run macOS dependency preparation on a Mac.' >&2; exit 1; }
npm --prefix "$ROOT/runtime/filesystem" run stage
npm --prefix "$ROOT/runtime/mobile" run stage
curl -fL --retry 3 https://github.com/Genymobile/scrcpy/releases/download/v5.0.1/scrcpy-server-v5.0.1 -o "$DEST/scrcpy/scrcpy-server-v5.0.1"
echo '764eb6f79811d5211fe9df341120882ba9994c7a61b897d7bf3fb662e53bc536 '"$DEST/scrcpy/scrcpy-server-v5.0.1" | shasum -a 256 -c -
curl -fL --retry 3 https://raw.githubusercontent.com/Genymobile/scrcpy/v5.0.1/LICENSE -o "$DEST/scrcpy/LICENSE.txt"
# Always use the macOS platform-tools archive, never a stale Windows SDK.
curl -fL --retry 3 https://dl.google.com/android/repository/platform-tools-latest-darwin.zip -o "$CACHE/platform-tools-darwin.zip"
unzip -oq "$CACHE/platform-tools-darwin.zip" -d "$CACHE/darwin"
mkdir -p "$DEST/platform-tools"
rsync -a --delete "$CACHE/darwin/platform-tools/" "$DEST/platform-tools/"
FFMPEG="${ITUOKE_FFMPEG_SOURCE:-$(command -v ffmpeg || true)}"
[[ -f "$FFMPEG" ]] || { echo 'Build machine needs ffmpeg (or ITUOKE_FFMPEG_SOURCE). Customers do not need it.' >&2; exit 1; }
# Python is a build tool only; no Python interpreter is shipped or needed by the current stub.
python3 "$ROOT/scripts/bundle-macos-libs.py" "$FFMPEG" "$DEST/ffmpeg"
echo '{"platform":"darwin","scrcpy":"5.0.1"}' > "$DEST/runtime-manifest.json"
echo 'macOS dependencies prepared. Validate the target architecture when packaging.'