From 453435f916a98599a2f9e51a8289a198fb483477 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 3 May 2026 20:55:07 -0500 Subject: [PATCH] Switch to downloading prebuilt release artifacts instead of a submodule --- .github/workflows/build-win-mac.yml | 4 ++ .gitignore | 1 + .gitmodules | 4 -- README.md | 5 +- app/app.pro | 8 +++ libs | 1 - scripts/build-arch.bat | 6 ++ scripts/build-steamlink-app.sh | 3 + scripts/clean-libs.sh | 92 ----------------------------- scripts/generate-dmg.sh | 3 + setup-deps.ps1 | 31 ++++++++++ setup-deps.py | 51 ++++++++++++++++ 12 files changed, 111 insertions(+), 98 deletions(-) delete mode 160000 libs delete mode 100755 scripts/clean-libs.sh create mode 100644 setup-deps.ps1 create mode 100644 setup-deps.py diff --git a/.github/workflows/build-win-mac.yml b/.github/workflows/build-win-mac.yml index 54ecb063..17cf3f64 100644 --- a/.github/workflows/build-win-mac.yml +++ b/.github/workflows/build-win-mac.yml @@ -34,6 +34,10 @@ jobs: submodules: 'recursive' fetch-depth: 1 + - name: Download dependencies (Windows) + if: runner.os == 'Windows' + run: powershell ./setup-deps.ps1 + - name: Install create-dmg (macOS) if: runner.os == 'macOS' run: | diff --git a/.gitignore b/.gitignore index 3a5180ac..a04bcb2b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,6 @@ **/.vs/ .vscode/ build/ +libs/ config.tests/*/.qmake.stash config.tests/*/Makefile diff --git a/.gitmodules b/.gitmodules index 42c2f1a7..8c92b208 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,7 +10,3 @@ [submodule "h264bitstream/h264bitstream"] path = h264bitstream/h264bitstream url = https://github.com/aizvorski/h264bitstream.git -[submodule "libs"] - path = libs - url = https://github.com/cgutman/moonlight-qt-prebuilts.git - shallow = true diff --git a/README.md b/README.md index fc47631a..54464b17 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,10 @@ for different architectures, which handle building deps and extra linking for yo * You can install Qt via Homebrew on macOS, but you will need to use `brew install qt --with-debug` to be able to create debug builds of Moonlight. * You may also use your Linux distro's package manager for the Qt SDK as long as the packages are Qt 5.12 or later. * This step is not required for building on Steam Link, because the Steam Link SDK includes Qt 5.14. -2. Run `git submodule update --init --recursive` from within `moonlight-qt/` +2. Download submodules and dependencies + * Run `git submodule update --init --recursive` from within `moonlight-qt/`. + * On Windows and macOS, you must also run `setup-deps.ps1` (Windows) or `setup-deps.py` (macOS). + * Perform these steps each time you pull new changes from the Git repository. 3. Open the project in Qt Creator or build from qmake on the command line. * To build a binary for use on non-development machines, use the scripts in the `scripts` folder. * For Windows builds, use `scripts\build-arch.bat` and `scripts\generate-bundle.bat`. Execute these scripts from the root of the repository within a Qt command prompt. Ensure 7-Zip binary directory is on your `%PATH%`. diff --git a/app/app.pro b/app/app.pro index 9fb043dd..232f7b18 100644 --- a/app/app.pro +++ b/app/app.pro @@ -36,6 +36,10 @@ DEFINES += QT_DEPRECATED_WARNINGS DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 win32 { + !exists($$PWD/../libs/windows) { + error("Missing dependencies. Please run 'powershell .\setup-deps.ps1' to fetch prebuilt libraries.") + } + contains(QT_ARCH, x86_64) { LIBS += -L$$PWD/../libs/windows/lib/x64 INCLUDEPATH += $$PWD/../libs/windows/include/x64 $$PWD/../libs/windows/include/x64/SDL2 @@ -49,6 +53,10 @@ win32 { LIBS += ws2_32.lib winmm.lib dxva2.lib ole32.lib gdi32.lib user32.lib d3d9.lib dwmapi.lib dbghelp.lib } macx:!disable-prebuilts { + !exists($$PWD/../libs/mac) { + error("Missing dependencies. Please run 'python3 setup-deps.py' to fetch prebuilt libraries.") + } + INCLUDEPATH += $$PWD/../libs/mac/include $$PWD/../libs/mac/include/SDL2 LIBS += -L$$PWD/../libs/mac/lib } diff --git a/libs b/libs deleted file mode 160000 index 7cf4f7b9..00000000 --- a/libs +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 7cf4f7b9d23e03963228a27dd28253689be57fff diff --git a/scripts/build-arch.bat b/scripts/build-arch.bat index 2c774fde..8b487230 100644 --- a/scripts/build-arch.bat +++ b/scripts/build-arch.bat @@ -25,6 +25,12 @@ if /I "%BUILD_CONFIG%"=="debug" ( echo Signed release builds must not have unstaged changes! exit /b 1 ) + + echo Updating dependencies + powershell %cd%\setup-deps.ps1 + if !ERRORLEVEL! NEQ 0 ( + exit /b 1 + ) ) else ( echo Invalid build configuration - expected 'debug' or 'release' echo Usage: scripts\build-arch.bat ^(release^|debug^) diff --git a/scripts/build-steamlink-app.sh b/scripts/build-steamlink-app.sh index be0abe30..b4eb7f15 100755 --- a/scripts/build-steamlink-app.sh +++ b/scripts/build-steamlink-app.sh @@ -23,6 +23,9 @@ else VERSION=`cat $SOURCE_ROOT/app/version.txt` fi +echo Updating dependencies +python3 $SOURCE_ROOT/setup-deps.py + echo Cleaning output directories rm -rf $BUILD_FOLDER rm -rf $DEPLOY_FOLDER diff --git a/scripts/clean-libs.sh b/scripts/clean-libs.sh deleted file mode 100755 index b3fc0bb5..00000000 --- a/scripts/clean-libs.sh +++ /dev/null @@ -1,92 +0,0 @@ -LIB_PATH=$(pwd)/libs - -while [[ "$#" -gt 0 ]]; do - echo $1 - case "$1" in - --sdl2_win) - rm -r $LIB_PATH/windows/include/*/SDL2 - rm $LIB_PATH/windows/lib/*/SDL2.* $LIB_PATH/windows/lib/*/SDL2main.* - shift - ;; - --sdl2_mac) - rm -r $LIB_PATH/mac/include/SDL2 - rm $LIB_PATH/mac/lib/libSDL2.dylib - shift - ;; - --sdl3_win) - rm -r $LIB_PATH/windows/include/*/SDL3 - rm $LIB_PATH/windows/lib/*/SDL3.* $LIB_PATH/windows/lib/*/SDL3main.* - shift - ;; - --sdl3_mac) - rm -r $LIB_PATH/mac/include/SDL3 - rm $LIB_PATH/mac/lib/libSDL3.dylib - shift - ;; - --sdl_ttf_win) - rm $LIB_PATH/windows/include/*/SDL2/SDL_ttf.h $LIB_PATH/windows/lib/*/SDL2_ttf.* - shift - ;; - --sdl_ttf_mac) - rm $LIB_PATH/mac/include/SDL2/SDL_ttf.h $LIB_PATH/mac/lib/libSDL2_ttf.dylib - shift - ;; - --detours_win) - rm $LIB_PATH/windows/include/detver.h $LIB_PATH/windows/include/detours.h $LIB_PATH/windows/lib/*/detours.* - shift - ;; - --discord-rpc_win) - rm $LIB_PATH/windows/include/discord_*.h $LIB_PATH/windows/lib/*/discord-rpc.* - shift - ;; - --discord-rpc_mac) - rm $LIB_PATH/mac/include/discord_*.h $LIB_PATH/mac/lib/libdiscord-rpc.a - shift - ;; - --opus_win) - rm $LIB_PATH/windows/include/opus*.h $LIB_PATH/windows/lib/*/opus.* - shift - ;; - --opus_mac) - rm $LIB_PATH/mac/include/opus*.h $LIB_PATH/mac/lib/libopus.a - shift - ;; - --openssl_win) - rm -r $LIB_PATH/windows/include/*/openssl - rm $LIB_PATH/windows/lib/*/libcrypto* $LIB_PATH/windows/lib/*/libssl* - shift - ;; - --openssl_mac) - rm -r $LIB_PATH/mac/include/openssl - rm $LIB_PATH/mac/lib/libssl*.dylib $LIB_PATH/mac/lib/libcrypto*.dylib - shift - ;; - --ffmpeg_win) - rm -r $LIB_PATH/windows/include/*/libavcodec $LIB_PATH/windows/include/*/libavutil $LIB_PATH/windows/include/*/libavformat $LIB_PATH/windows/include/*/libswscale - rm $LIB_PATH/windows/lib/*/avcodec* $LIB_PATH/windows/lib/*/avutil* $LIB_PATH/windows/lib/*/avformat* $LIB_PATH/windows/lib/*/swscale* - shift - ;; - --dav1d_win) - rm $LIB_PATH/windows/lib/*/dav1d* - shift - ;; - --ffmpeg_mac) - rm -r $LIB_PATH/mac/include/libavcodec $LIB_PATH/mac/include/libavutil $LIB_PATH/mac/include/libavformat $LIB_PATH/mac/include/libswscale - rm $LIB_PATH/mac/lib/libavcodec* $LIB_PATH/mac/lib/libavutil* $LIB_PATH/mac/lib/libavformat* $LIB_PATH/mac/lib/libswscale* - shift - ;; - --libplacebo_win) - rm -r $LIB_PATH/windows/include/*/libplacebo - rm $LIB_PATH/windows/lib/*/libplacebo* - shift - ;; - --) - shift; - break - ;; - *) - echo "Unexpected option: $1" - exit - ;; - esac -done \ No newline at end of file diff --git a/scripts/generate-dmg.sh b/scripts/generate-dmg.sh index a6cde650..f19f76d4 100755 --- a/scripts/generate-dmg.sh +++ b/scripts/generate-dmg.sh @@ -31,6 +31,9 @@ fi [ "$SIGNING_IDENTITY" == "" ] || git diff-index --quiet HEAD -- || fail "Signed release builds must not have unstaged changes!" +echo Updating dependencies +python3 $SOURCE_ROOT/setup-deps.py + echo Cleaning output directories rm -rf $BUILD_FOLDER rm -rf $INSTALLER_FOLDER diff --git a/setup-deps.ps1 b/setup-deps.ps1 new file mode 100644 index 00000000..ad3e9477 --- /dev/null +++ b/setup-deps.ps1 @@ -0,0 +1,31 @@ +$ErrorActionPreference = 'Stop' + +$Organization = "moonlight-stream" +$PrebuiltRepo = "moonlight-qt-deps" +$TargetDir = Join-Path $PSScriptRoot "libs\windows" +$Assets = @("windows-x64.zip", "windows-ARM64.zip") +$Tag = "v1.0.1" + +if (Test-Path $TargetDir) { + Write-Host "Cleaning target directory..." -ForegroundColor Cyan + Remove-Item -Path "$TargetDir\*" -Recurse -Force +} else { + New-Item -ItemType Directory -Path $TargetDir | Out-Null +} + +foreach ($AssetName in $Assets) { + $Url = "https://github.com/$Organization/$PrebuiltRepo/releases/download/$Tag/$AssetName" + $ArchivePath = Join-Path $env:TEMP $AssetName + + Write-Host "Downloading $AssetName..." -ForegroundColor Cyan + curl.exe -s -L -f -o "$ArchivePath" "$Url" + if ($LASTEXITCODE -ne 0) { + exit $LASTEXITCODE + } + + Write-Host "Extracting $AssetName..." -ForegroundColor Cyan + Expand-Archive -Path $ArchivePath -DestinationPath $TargetDir -Force + Remove-Item $ArchivePath +} + +Write-Host "Dependencies successfully deployed" -ForegroundColor Green \ No newline at end of file diff --git a/setup-deps.py b/setup-deps.py new file mode 100644 index 00000000..9ef35264 --- /dev/null +++ b/setup-deps.py @@ -0,0 +1,51 @@ +import os +import sys +import platform +import urllib.request +import zipfile +import shutil + +ORGANIZATION = "moonlight-stream" +PREBUILT_REPO = "moonlight-qt-deps" +TAG = "v1.0.1" + +def get_platform_config(): + system = platform.system() + if system == "Darwin": + return "mac", "macos-universal.zip" + if system == "Linux": + return "steamlink", "steamlink.zip" + + print(f"Error: Unsupported platform ({system})") + sys.exit(1) + +def download_and_extract(): + subfolder, asset_name = get_platform_config() + + target_dir = os.path.join(os.getcwd(), "libs", subfolder) + url = f"https://github.com/{ORGANIZATION}/{PREBUILT_REPO}/releases/download/{TAG}/{asset_name}" + + if os.path.exists(target_dir): + print("Cleaning target directory...") + shutil.rmtree(target_dir) + + os.makedirs(target_dir, exist_ok=True) + + archive_path = os.path.join(target_dir, asset_name) + + print(f"Downloading {asset_name}...") + try: + urllib.request.urlretrieve(url, archive_path) + except Exception as e: + print(f"Download failed: {e}") + sys.exit(1) + + print(f"Extracting {asset_name}...") + with zipfile.ZipFile(archive_path, 'r') as zip_ref: + zip_ref.extractall(target_dir) + + os.remove(archive_path) + print(f"Dependencies successfully deployed") + +if __name__ == "__main__": + download_and_extract() \ No newline at end of file