mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-22 22:05:38 +00:00
b1c00cfd95
Nobody's actually running debug DS builds except me...
220 lines
9.5 KiB
Batchfile
220 lines
9.5 KiB
Batchfile
@echo off
|
|
setlocal enabledelayedexpansion
|
|
|
|
echo Setting environment...
|
|
if exist "%ProgramFiles%\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" (
|
|
call "%ProgramFiles%\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
|
|
) else if exist "%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" (
|
|
call "%ProgramFiles%\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
|
|
) else (
|
|
echo Visual Studio 2022 not found.
|
|
goto error
|
|
)
|
|
|
|
set SEVENZIP="C:\Program Files\7-Zip\7z.exe"
|
|
set PATCH="C:\Program Files\Git\usr\bin\patch.exe"
|
|
|
|
if defined DEBUG (
|
|
echo DEBUG=%DEBUG%
|
|
) else (
|
|
set DEBUG=1
|
|
)
|
|
|
|
pushd %~dp0
|
|
set "SCRIPTDIR=%CD%"
|
|
cd ..\dep\msvc
|
|
mkdir deps-build
|
|
cd deps-build || goto error
|
|
set "BUILDDIR=%CD%"
|
|
cd ..
|
|
mkdir deps-x64
|
|
cd deps-x64 || goto error
|
|
set "INSTALLDIR=%CD%"
|
|
popd
|
|
|
|
echo SCRIPTDIR=%SCRIPTDIR%
|
|
echo BUILDDIR=%BUILDDIR%
|
|
echo INSTALLDIR=%INSTALLDIR%
|
|
|
|
set "PATH=%PATH%;%INSTALLDIR%\bin"
|
|
|
|
cd "%BUILDDIR%"
|
|
|
|
set LIBJPEG=9f
|
|
set LIBPNG=1643
|
|
set QT=6.6.2
|
|
set QTMINOR=6.6
|
|
set SDL=SDL2-2.30.1
|
|
set WEBP=1.3.2
|
|
set ZLIB=1.3.1
|
|
set ZLIBSHORT=131
|
|
set ZSTD=1.5.5
|
|
|
|
call :downloadfile "lpng%LIBPNG%.zip" https://download.sourceforge.net/libpng/lpng1643.zip fc466a1e638e635d6c66363bdf3f38555b81b0141d0b06ba45b49ccca327436d || goto error
|
|
call :downloadfile "jpegsr%LIBJPEG%.zip" https://ijg.org/files/jpegsr%LIBJPEG%.zip 6255da8c89e09d694e6800688c76145eb6870a76ac0d36c74fccd61b3940aafa || goto error
|
|
call :downloadfile "%SDL%.zip" "https://libsdl.org/release/%SDL%.zip" c15ded54e9f32f8a1f9ed3e3dc072837a320ed23c5d0e95b7c18ecbe05c1187b || goto error
|
|
call :downloadfile "qtbase-everywhere-src-%QT%.zip" "https://download.qt.io/official_releases/qt/%QTMINOR%/%QT%/submodules/qtbase-everywhere-src-%QT%.zip" 3582dbc46df280365fc5d5e6cc8fcfc72ddbddbd330a03a98eec24b8b44fa4d0 || goto error
|
|
call :downloadfile "qtimageformats-everywhere-src-%QT%.zip" "https://download.qt.io/official_releases/qt/%QTMINOR%/%QT%/submodules/qtimageformats-everywhere-src-%QT%.zip" 2176b623c9141b1136d57ff9ca1ed12e3636146b53c6feed2083e1cbecff6454 || goto error
|
|
call :downloadfile "qtsvg-everywhere-src-%QT%.zip" "https://download.qt.io/official_releases/qt/%QTMINOR%/%QT%/submodules/qtsvg-everywhere-src-%QT%.zip" 84ba758ef06b93532f2d098f0d08d7bbddf6f3e6273c9e0d3a58498338f85b18 || goto error
|
|
call :downloadfile "qttools-everywhere-src-%QT%.zip" "https://download.qt.io/official_releases/qt/%QTMINOR%/%QT%/submodules/qttools-everywhere-src-%QT%.zip" c760fbd229de8a02e793fa41ddd6843cd2cb9c93a4e99bc5384c646599aee996 || goto error
|
|
call :downloadfile "qttranslations-everywhere-src-%QT%.zip" "https://download.qt.io/official_releases/qt/%QTMINOR%/%QT%/submodules/qttranslations-everywhere-src-%QT%.zip" a061e8d61eb7c03823ead92fe46b5722ed7b8119aeb84157d80f10a53c77d262 || goto error
|
|
call :downloadfile "libwebp-%WEBP%.tar.gz" "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-%WEBP%.tar.gz" 2a499607df669e40258e53d0ade8035ba4ec0175244869d1025d460562aa09b4 || goto error
|
|
call :downloadfile "zlib%ZLIBSHORT%.zip" "https://zlib.net/zlib%ZLIBSHORT%.zip" 72af66d44fcc14c22013b46b814d5d2514673dda3d115e64b690c1ad636e7b17 || goto error
|
|
call :downloadfile "zstd-%ZSTD%.zip" "https://github.com/facebook/zstd/archive/refs/tags/v%ZSTD%.zip" c5c8daa1d40dabc51790c62a5b86af2b36dfc4e1a738ff10dc4a46ea4e68ee51 || goto error
|
|
|
|
if %DEBUG%==1 (
|
|
echo Building debug and release libraries...
|
|
) else (
|
|
echo Building release libraries...
|
|
)
|
|
|
|
set FORCEPDB=-DCMAKE_SHARED_LINKER_FLAGS_RELEASE="/DEBUG"
|
|
|
|
echo Building Zlib...
|
|
rmdir /S /Q "zlib-%ZLIB%"
|
|
%SEVENZIP% x "zlib%ZLIBSHORT%.zip" || goto error
|
|
cd "zlib-%ZLIB%" || goto error
|
|
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="%INSTALLDIR%" -DCMAKE_INSTALL_PREFIX="%INSTALLDIR%" -DBUILD_SHARED_LIBS=ON -DZLIB_BUILD_EXAMPLES=OFF -B build -G Ninja || goto error
|
|
cmake --build build --parallel || goto error
|
|
ninja -C build install || goto error
|
|
cd .. || goto error
|
|
|
|
echo Building libpng...
|
|
rmdir /S /Q "lpng%LIBPNG%"
|
|
%SEVENZIP% x "lpng%LIBPNG%.zip" || goto error
|
|
cd "lpng%LIBPNG%" || goto error
|
|
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="%INSTALLDIR%" -DCMAKE_INSTALL_PREFIX="%INSTALLDIR%" -DBUILD_SHARED_LIBS=ON -DBUILD_SHARED_LIBS=ON -DPNG_TESTS=OFF -DPNG_STATIC=OFF -DPNG_SHARED=ON -DPNG_TOOLS=OFF -B build -G Ninja || goto error
|
|
cmake --build build --parallel || goto error
|
|
ninja -C build install || goto error
|
|
cd .. || goto error
|
|
|
|
echo Building libjpeg...
|
|
%SEVENZIP% x "jpegsr%LIBJPEG%.zip" || goto error
|
|
cd "jpeg-%LIBJPEG%" || goto error
|
|
%PATCH% -p1 < "%SCRIPTDIR%\libjpeg-cmake.patch" || goto error
|
|
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="%INSTALLDIR%" -DCMAKE_INSTALL_PREFIX="%INSTALLDIR%" -DBUILD_SHARED_LIBS=ON -DBUILD_STATIC_LIBS=OFF -B build -G Ninja || goto error
|
|
cmake --build build --parallel || goto error
|
|
ninja -C build install || goto error
|
|
cd .. || goto error
|
|
|
|
echo Building Zstandard...
|
|
rmdir /S /Q "zstd-%ZSTD%"
|
|
%SEVENZIP% x "-x^!zstd-1.5.5\tests\cli-tests\bin" "zstd-%ZSTD%.zip" || goto error
|
|
cd "zstd-%ZSTD%"
|
|
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="%INSTALLDIR%" -DCMAKE_INSTALL_PREFIX="%INSTALLDIR%" -DBUILD_SHARED_LIBS=ON -DZSTD_BUILD_SHARED=ON -DZSTD_BUILD_STATIC=OFF -DZSTD_BUILD_PROGRAMS=OFF -B build -G Ninja build/cmake
|
|
cmake --build build --parallel || goto error
|
|
ninja -C build install || goto error
|
|
cd .. || goto error
|
|
|
|
echo Building WebP...
|
|
rmdir /S /Q "libwebp-%WEBP%"
|
|
tar -xf "libwebp-%WEBP%.tar.gz" || goto error
|
|
cd "libwebp-%WEBP%" || goto error
|
|
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="%INSTALLDIR%" -DCMAKE_INSTALL_PREFIX="%INSTALLDIR%" -DWEBP_BUILD_ANIM_UTILS=OFF -DWEBP_BUILD_CWEBP=OFF -DWEBP_BUILD_DWEBP=OFF -DWEBP_BUILD_GIF2WEBP=OFF -DWEBP_BUILD_IMG2WEBP=OFF -DWEBP_BUILD_VWEBP=OFF -DWEBP_BUILD_WEBPINFO=OFF -DWEBP_BUILD_WEBPMUX=OFF -DWEBP_BUILD_EXTRAS=OFF -DBUILD_SHARED_LIBS=ON -G Ninja || goto error
|
|
cmake --build build --parallel || goto error
|
|
ninja -C build install || goto error
|
|
cd .. || goto error
|
|
|
|
echo Building SDL...
|
|
rmdir /S /Q "%SDL%"
|
|
%SEVENZIP% x "%SDL%.zip" || goto error
|
|
cd "%SDL%" || goto error
|
|
cmake -B build -DCMAKE_BUILD_TYPE=Release %FORCEPDB% -DCMAKE_INSTALL_PREFIX="%INSTALLDIR%" -DBUILD_SHARED_LIBS=ON -DSDL_SHARED=ON -DSDL_STATIC=OFF -G Ninja || goto error
|
|
cmake --build build --parallel || goto error
|
|
ninja -C build install || goto error
|
|
copy build\SDL2.pdb "%INSTALLDIR%\bin" || goto error
|
|
cd .. || goto error
|
|
|
|
if %DEBUG%==1 (
|
|
set QTBUILDSPEC=-DCMAKE_CONFIGURATION_TYPES="Release;Debug" -G "Ninja Multi-Config"
|
|
) else (
|
|
set QTBUILDSPEC=-DCMAKE_BUILD_TYPE=Release -G Ninja
|
|
)
|
|
|
|
echo Building Qt base...
|
|
rmdir /S /Q "qtbase-everywhere-src-%QT%"
|
|
%SEVENZIP% x "qtbase-everywhere-src-%QT%.zip" || goto error
|
|
cd "qtbase-everywhere-src-%QT%" || goto error
|
|
cmake -B build -DFEATURE_sql=OFF -DCMAKE_INSTALL_PREFIX="%INSTALLDIR%" %FORCEPDB% -DINPUT_gui=yes -DINPUT_widgets=yes -DINPUT_ssl=yes -DINPUT_openssl=no -DINPUT_schannel=yes -DFEATURE_system_png=ON -DFEATURE_system_jpeg=ON -DFEATURE_system_zlib=ON %QTBUILDSPEC% || goto error
|
|
cmake --build build --parallel || goto error
|
|
ninja -C build install || goto error
|
|
cd .. || goto error
|
|
|
|
echo Building Qt SVG...
|
|
rmdir /S /Q "qtsvg-everywhere-src-%QT%"
|
|
%SEVENZIP% x "qtsvg-everywhere-src-%QT%.zip" || goto error
|
|
cd "qtsvg-everywhere-src-%QT%" || goto error
|
|
mkdir build || goto error
|
|
cd build || goto error
|
|
call "%INSTALLDIR%\bin\qt-configure-module.bat" .. -- %FORCEPDB% -DCMAKE_PREFIX_PATH="%INSTALLDIR%" || goto error
|
|
cmake --build . --parallel || goto error
|
|
ninja install || goto error
|
|
cd ..\.. || goto error
|
|
|
|
echo Building Qt Image Formats...
|
|
rmdir /S /Q "qtimageformats-everywhere-src-%QT%"
|
|
%SEVENZIP% x "qtimageformats-everywhere-src-%QT%.zip" || goto error
|
|
cd "qtimageformats-everywhere-src-%QT%" || goto error
|
|
mkdir build || goto error
|
|
cd build || goto error
|
|
call "%INSTALLDIR%\bin\qt-configure-module.bat" .. -- %FORCEPDB% -DCMAKE_PREFIX_PATH="%INSTALLDIR%" -DFEATURE_system_webp=ON || goto error
|
|
cmake --build . --parallel || goto error
|
|
ninja install || goto error
|
|
cd ..\.. || goto error
|
|
|
|
echo Building Qt Tools...
|
|
rmdir /S /Q "qtimageformats-everywhere-src-%QT%"
|
|
%SEVENZIP% x "qttools-everywhere-src-%QT%.zip" || goto error
|
|
cd "qttools-everywhere-src-%QT%" || goto error
|
|
mkdir build || goto error
|
|
cd build || goto error
|
|
call "%INSTALLDIR%\bin\qt-configure-module.bat" .. -- %FORCEPDB% -DFEATURE_assistant=OFF -DFEATURE_clang=OFF -DFEATURE_designer=OFF -DFEATURE_kmap2qmap=OFF -DFEATURE_pixeltool=OFF -DFEATURE_pkg_config=OFF -DFEATURE_qev=OFF -DFEATURE_qtattributionsscanner=OFF -DFEATURE_qtdiag=OFF -DFEATURE_qtplugininfo=OFF || goto error
|
|
cmake --build . --parallel || goto error
|
|
ninja install || goto error
|
|
cd ..\.. || goto error
|
|
|
|
echo Building Qt Translations...
|
|
rmdir /S /Q "qttranslations-everywhere-src-%QT%"
|
|
%SEVENZIP% x "qttranslations-everywhere-src-%QT%.zip" || goto error
|
|
cd "qttranslations-everywhere-src-%QT%" || goto error
|
|
mkdir build || goto error
|
|
cd build || goto error
|
|
call "%INSTALLDIR%\bin\qt-configure-module.bat" .. -- %FORCEPDB% || goto error
|
|
cmake --build . --parallel || goto error
|
|
ninja install || goto error
|
|
cd ..\.. || goto error
|
|
|
|
echo Cleaning up...
|
|
cd ..
|
|
rd /S /Q deps-build
|
|
|
|
echo Exiting with success.
|
|
exit 0
|
|
|
|
:error
|
|
echo Failed with error #%errorlevel%.
|
|
pause
|
|
exit %errorlevel%
|
|
|
|
:downloadfile
|
|
if not exist "%~1" (
|
|
echo Downloading %~1 from %~2...
|
|
curl -L -o "%~1" "%~2" || goto error
|
|
)
|
|
|
|
rem based on https://gist.github.com/gsscoder/e22daefaff9b5d8ac16afb070f1a7971
|
|
set idx=0
|
|
for /f %%F in ('certutil -hashfile "%~1" SHA256') do (
|
|
set "out!idx!=%%F"
|
|
set /a idx += 1
|
|
)
|
|
set filechecksum=%out1%
|
|
|
|
if /i %~3==%filechecksum% (
|
|
echo Validated %~1.
|
|
exit /B 0
|
|
) else (
|
|
echo Expected %~3 got %filechecksum%.
|
|
exit /B 1
|
|
)
|