From c902134c5515520caf1deb2bc916d73dd9ce59b7 Mon Sep 17 00:00:00 2001 From: Live session user Date: Fri, 17 Oct 2025 06:14:03 -0700 Subject: [PATCH] Windows build shell script --- .ci/build-windows-clang-cl.ps1 | 141 --------------------------------- .ci/build-windows-clang-cl.sh | 99 +++++++++++++++++++++++ .github/workflows/rpcs3.yml | 7 +- 3rdparty/zstd/CMakeLists.txt | 15 ++-- 4 files changed, 108 insertions(+), 154 deletions(-) delete mode 100644 .ci/build-windows-clang-cl.ps1 create mode 100755 .ci/build-windows-clang-cl.sh diff --git a/.ci/build-windows-clang-cl.ps1 b/.ci/build-windows-clang-cl.ps1 deleted file mode 100644 index 19200974e5..0000000000 --- a/.ci/build-windows-clang-cl.ps1 +++ /dev/null @@ -1,141 +0,0 @@ -# .ci/build-windows-clang-cl.ps1 -# Enable strict error handling -$ErrorActionPreference = "Stop" - -trap { - Write-Host "ERROR: $($_.Exception.Message)" - exit 1 -} - -Write-Host "Starting RPCS3 build (PowerShell script)" - -# Automatically find clang_rt.builtins-x86_64.lib -Write-Host "Searching for clang_rt.builtins-x86_64.lib ..." -$clangBuiltinsLibPath = Get-ChildItem -Path "C:/Program Files/LLVM/lib/clang" -Recurse -Filter "clang_rt.builtins-x86_64.lib" -ErrorAction SilentlyContinue | - Where-Object { $_.FullName -match "windows\\clang_rt\.builtins-x86_64\.lib$" } | - Select-Object -First 1 - -if (-not $clangBuiltinsLibPath) { - Write-Error "Could not find clang_rt.builtins-x86_64.lib in LLVM installation." - exit 1 -} - -function Get-ShortPath([string]$path) { - $fso = New-Object -ComObject Scripting.FileSystemObject - return $fso.GetFolder($path).ShortPath -} - -$clangBuiltinsDir = Split-Path -Parent $clangBuiltinsLibPath.FullName -$clangBuiltinsDirShort = Get-ShortPath $clangBuiltinsDir -$clangBuiltinsLib = Split-Path -Leaf $clangBuiltinsLibPath.FullName -$clangPath = "C:\Program Files\LLVM\bin" -#$clangPath = Get-ChildItem -Path "D:\a\rpcs3\rpcs3\llvm-*\bin" - -Write-Host "Found Clang builtins library: $clangBuiltinsLib in $clangBuiltinsDir or short $clangBuiltinsDirShort" -Write-Host "Found Clang Path: $clangPath" - -# Get Windows Kits root from registry -$kitsRoot = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Kits\Installed Roots" -Name "KitsRoot10" -$kitsRootPath = $kitsRoot.KitsRoot10 - -# Search for mt.exe in x64 SDK bin directories -Write-Host "Searching for mt.exe ..." -$mtPath = Get-ChildItem -Path "$clangPath" -Recurse -Filter "llvm-mt.exe" -ErrorAction SilentlyContinue | - Where-Object { $_.FullName -match "\\llvm-mt\.exe$" } | - Sort-Object FullName -Descending | - Select-Object -First 1 - -if (-not $mtPath) { - Write-Error "Could not find mt.exe in Windows Kits directories." - exit 1 -} - -$mtExePath = "$mtPath" - -Write-Host "Found mt.exe at: $mtExePath" - -$VcpkgRoot="$(Get-Location)/vcpkg" -$VcpkgTriplet=$env:VCPKG_TRIPLET -$VcpkgInstall="$VcpkgRoot/installed/$VcpkgTriplet" -$VcpkgInclude="$VcpkgInstall/include" -$VcpkgLib="$VcpkgInstall/lib" -$VcpkgBin="$VcpkgInstall/bin" - -# Configure git safe directory -Write-Host "Configuring git safe directory" -& git config --global --add safe.directory '*' - -# Initialize submodules except certain ones -Write-Host "Initializing submodules" -$excludedSubs = @('llvm','opencv','ffmpeg','FAudio','zlib','libpng','feralinteractive') - -# Get submodule paths excluding those in $excludedSubs -$submodules = Select-String -Path .gitmodules -Pattern 'path = (.+)' | ForEach-Object { - $_.Matches[0].Groups[1].Value -} | Where-Object { - $path = $_ - -not ($excludedSubs | Where-Object { $path -like "*$_*" }) -} - -Write-Host "Updating submodules: $($submodules -join ', ')" -& git submodule update --init --quiet $submodules - -# Create and enter build directory -Write-Host "Creating build directory" -if (!(Test-Path build)) { - New-Item -ItemType Directory -Path build | Out-Null -} -Set-Location build -Write-Host "Changed directory to: $(Get-Location)" - -# Run CMake with Ninja generator and required flags -Write-Host "Running CMake configuration" -& cmake .. ` - -G Ninja ` - -DCMAKE_BUILD_TYPE=Release ` - -DCMAKE_C_COMPILER="$clangPath/clang-cl.exe" ` - -DCMAKE_CXX_COMPILER="$clangPath/clang-cl.exe" ` - -DCMAKE_LINKER="$clangPath/lld-link.exe" ` - -DCMAKE_INSTALL_PREFIX=/usr ` - -DCMAKE_TOOLCHAIN_FILE="$VcpkgRoot/scripts/buildsystems/vcpkg.cmake" ` - -DCMAKE_EXE_LINKER_FLAGS="/LIBPATH:$clangBuiltinsDirShort /defaultlib:$clangBuiltinsLib" ` - -DCMAKE_MT="$clangPath/llvm-mt.exe" ` - -DUSE_NATIVE_INSTRUCTIONS=OFF ` - -DUSE_PRECOMPILED_HEADERS=OFF ` - -DVCPKG_TARGET_TRIPLET="$VcpkgTriplet" ` - -DFFMPEG_INCLUDE_DIR="$VcpkgInclude" ` - -DFFMPEG_LIBAVCODEC="$VcpkgLib/avcodec.lib" ` - -DFFMPEG_LIBAVFORMAT="$VcpkgLib/avformat.lib" ` - -DFFMPEG_LIBAVUTIL="$VcpkgLib/avutil.lib" ` - -DFFMPEG_LIBSWSCALE="$VcpkgLib/swscale.lib" ` - -DFFMPEG_LIBSWRESAMPLE="$VcpkgLib/swresample.lib" ` - -DUSE_SYSTEM_CURL=OFF ` - -DUSE_FAUDIO=OFF ` - -DUSE_SDL=ON ` - -DUSE_SYSTEM_SDL=OFF ` - -DUSE_SYSTEM_FFMPEG=ON ` - -DUSE_SYSTEM_OPENCV=ON ` - -DUSE_SYSTEM_OPENAL=OFF ` - -DUSE_SYSTEM_LIBPNG=ON ` - -DUSE_DISCORD_RPC=ON ` - -DUSE_SYSTEM_ZSTD=ON ` - -DWITH_LLVM=ON ` - -DSTATIC_LINK_LLVM=ON ` - -DBUILD_RPCS3_TESTS=OFF - -Write-Host "CMake configuration complete" - -# Build with ninja -Write-Host "Starting build with Ninja..." -& ninja -if ($LASTEXITCODE -ne 0) { - Write-Host "Build failed with exit code $LASTEXITCODE" - exit 1 -} - -Write-Host "Build succeeded" - -# Go back to root directory -Set-Location .. -Write-Host "Returned to root directory: $(Get-Location)" - diff --git a/.ci/build-windows-clang-cl.sh b/.ci/build-windows-clang-cl.sh new file mode 100755 index 0000000000..a24d8f8361 --- /dev/null +++ b/.ci/build-windows-clang-cl.sh @@ -0,0 +1,99 @@ +#!/bin/sh -e + +echo "Starting RPCS3 build (Bash script)" + +# Automatically find clang_rt.builtins-x86_64.lib +echo "Searching for clang_rt.builtins-x86_64.lib ..." +clangBuiltinsLibPath=$(find "C:\Program Files\LLVM\lib\clang" -name "clang_rt.builtins-x86_64.lib" | sed 's|Program Files|PROGRA~1|g') + +if [ -z "$clangBuiltinsLibPath" ]; then + echo "ERROR: Could not find clang_rt.builtins-x86_64.lib in LLVM installation." + exit 1 +fi + +clangBuiltinsDir=$(dirname "$clangBuiltinsLibPath") +clangBuiltinsLib=$(basename "$clangBuiltinsLibPath") +# shellcheck disable=SC2028 +clangPath=$(echo "C:\Program Files\LLVM\bin" | sed 's|Program Files|PROGRA~1|g') + +echo "Found Clang builtins library: $clangBuiltinsLib in $clangBuiltinsDir" +echo "Found Clang Path: $clangPath" + +# Search for mt.exe in SDK bin directories +echo "Searching for llvm-mt.exe ..." +mtPath=$(find "$clangPath" -name "llvm-mt.exe") + +if [ -z "$mtPath" ]; then + echo "ERROR: Could not find llvm-mt.exe in SDK directories." + exit 1 +fi + +echo "Found llvm-mt.exe at: $mtPath" + +VcpkgRoot="$(pwd)/vcpkg" +VcpkgTriplet="$VCPKG_TRIPLET" +VcpkgInstall="$VcpkgRoot/installed/$VcpkgTriplet" +VcpkgInclude="$VcpkgInstall/include" +VcpkgLib="$VcpkgInstall/lib" + +# Configure git safe directory +echo "Configuring git safe directory" +git config --global --add safe.directory '*' + +# Initialize submodules except certain ones +echo "Initializing submodules" +# shellcheck disable=SC2046 +git submodule -q update --init $(awk '/path/ && !/llvm/ && !/opencv/ && !/FAudio/ && !/libpng/ && !/zlib/ && !/feralinteractive/ { print $3 }' .gitmodules) + +# Create and enter build directory +echo "Creating build directory" +mkdir -p build +cd build || exit +echo "Changed directory to: $(pwd)" + +# Run CMake with Ninja generator and required flags +echo "Running CMake configuration" +cmake .. \ + -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_C_COMPILER="${clangPath}/clang-cl.exe" \ + -DCMAKE_CXX_COMPILER="${clangPath}/clang-cl.exe" \ + -DCMAKE_LINKER="${clangPath}/lld-link.exe" \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_TOOLCHAIN_FILE="$VcpkgRoot/scripts/buildsystems/vcpkg.cmake" \ + -DCMAKE_EXE_LINKER_FLAGS="/LIBPATH:${clangBuiltinsDir} /defaultlib:${clangBuiltinsLib}" \ + -DCMAKE_MT="${mtPath}" \ + -DUSE_NATIVE_INSTRUCTIONS=OFF \ + -DUSE_PRECOMPILED_HEADERS=OFF \ + -DVCPKG_TARGET_TRIPLET="$VcpkgTriplet" \ + -DFFMPEG_INCLUDE_DIR="$VcpkgInclude" \ + -DFFMPEG_LIBAVCODEC="$VcpkgLib/avcodec.lib" \ + -DFFMPEG_LIBAVFORMAT="$VcpkgLib/avformat.lib" \ + -DFFMPEG_LIBAVUTIL="$VcpkgLib/avutil.lib" \ + -DFFMPEG_LIBSWSCALE="$VcpkgLib/swscale.lib" \ + -DFFMPEG_LIBSWRESAMPLE="$VcpkgLib/swresample.lib" \ + -DUSE_SYSTEM_CURL=OFF \ + -DUSE_FAUDIO=OFF \ + -DUSE_SDL=ON \ + -DUSE_SYSTEM_SDL=OFF \ + -DUSE_SYSTEM_FFMPEG=ON \ + -DUSE_SYSTEM_OPENCV=ON \ + -DUSE_SYSTEM_OPENAL=OFF \ + -DUSE_SYSTEM_LIBPNG=ON \ + -DUSE_DISCORD_RPC=ON \ + -DUSE_SYSTEM_ZSTD=ON \ + -DWITH_LLVM=ON \ + -DSTATIC_LINK_LLVM=ON \ + -DBUILD_RPCS3_TESTS=OFF + +echo "CMake configuration complete" + +# Build with ninja +echo "Starting build with Ninja..." +ninja + +echo "Build succeeded" + +# Go back to root directory +cd .. +echo "Returned to root directory: $(pwd)" diff --git a/.github/workflows/rpcs3.yml b/.github/workflows/rpcs3.yml index 7630729902..16ad0c5ffb 100644 --- a/.github/workflows/rpcs3.yml +++ b/.github/workflows/rpcs3.yml @@ -392,7 +392,6 @@ jobs: id: restore-vcpkg-cache with: path: | - vcpkg/vcpkg.exe vcpkg/installed vcpkg/buildtrees key: vcpkg-${{ runner.os }}-${{ matrix.compiler }}-${{ runner.arch }}-${{ hashFiles('**/vcpkg') }} @@ -422,7 +421,6 @@ jobs: uses: actions/cache/save@main with: path: | - vcpkg/vcpkg.exe vcpkg/installed vcpkg/buildtrees key: ${{ steps.restore-vcpkg-cache.outputs.cache-primary-key }} @@ -481,13 +479,12 @@ jobs: run: | mkdir -p "C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional" || true cp -r "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/DIA SDK" "C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/DIA SDK" + "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 - name: Build RPCS3 if: ${{ matrix.compiler == 'clang-cl' }} shell: cmd - run: | - call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 - powershell -ExecutionPolicy Bypass -File .ci/build-windows-clang-cl.ps1 + run: .ci/build-windows-clang-cl.sh - name: Save build Ccache #if: github.ref == 'refs/heads/master' diff --git a/3rdparty/zstd/CMakeLists.txt b/3rdparty/zstd/CMakeLists.txt index e0454c9ea9..c5c8dd66ff 100644 --- a/3rdparty/zstd/CMakeLists.txt +++ b/3rdparty/zstd/CMakeLists.txt @@ -1,6 +1,10 @@ -# zstd -# Select the version of zstd to use, default is builtin -if(NOT USE_SYSTEM_ZSTD) +if(USE_SYSTEM_ZSTD) + message(STATUS "RPCS3: using shared zstd") + pkg_check_modules(zstd REQUIRED IMPORTED_TARGET libzstd) + add_library(3rdparty_zstd INTERFACE) + target_link_libraries(3rdparty_zstd INTERFACE PkgConfig::zstd) + target_include_directories(3rdparty_zstd INTERFACE PkgConfig::RtMidi) +else() option(ZSTD_BUILD_PROGRAMS "BUILD PROGRAMS" OFF) option(ZSTD_BUILD_SHARED "BUILD SHARED LIBRARIES" OFF) option(ZSTD_BUILD_STATIC "BUILD STATIC LIBRARIES" ON) @@ -8,9 +12,4 @@ if(NOT USE_SYSTEM_ZSTD) add_subdirectory(zstd/build/cmake EXLUDE_FROM_ALL) add_library(3rdparty_zstd INTERFACE) target_link_libraries(3rdparty_zstd INTERFACE libzstd_static) -else() - message(STATUS "RPCS3: using VCPKG zstd") - find_package(zstd CONFIG REQUIRED) - add_library(3rdparty_zstd INTERFACE) - target_link_libraries(3rdparty_zstd INTERFACE zstd::libzstd) endif()