2018-07-25 09:53:51 +00:00
|
|
|
@echo off
|
2019-08-14 01:07:42 +00:00
|
|
|
setlocal enableDelayedExpansion
|
|
|
|
|
|
|
|
rem Run from Qt command prompt with working directory set to root of repo
|
2018-07-25 09:53:51 +00:00
|
|
|
|
|
|
|
set BUILD_CONFIG=%1
|
|
|
|
set ARCH=%2
|
|
|
|
|
2018-07-29 02:56:08 +00:00
|
|
|
rem Convert to lower case for windeployqt
|
|
|
|
if /I "%BUILD_CONFIG%"=="debug" (
|
|
|
|
set BUILD_CONFIG=debug
|
2020-05-05 01:32:38 +00:00
|
|
|
set WIX_MUMS=10
|
2018-07-29 02:56:08 +00:00
|
|
|
) else (
|
|
|
|
if /I "%BUILD_CONFIG%"=="release" (
|
|
|
|
set BUILD_CONFIG=release
|
2020-05-05 01:32:38 +00:00
|
|
|
set WIX_MUMS=10
|
2018-07-29 02:56:08 +00:00
|
|
|
) else (
|
2018-08-01 01:14:04 +00:00
|
|
|
if /I "%BUILD_CONFIG%"=="signed-release" (
|
|
|
|
set BUILD_CONFIG=release
|
|
|
|
set SIGN=1
|
2018-09-04 08:03:01 +00:00
|
|
|
set MUST_DEPLOY_SYMBOLS=1
|
2019-01-06 01:25:40 +00:00
|
|
|
|
|
|
|
rem Fail if there are unstaged changes
|
|
|
|
git diff-index --quiet HEAD --
|
|
|
|
if !ERRORLEVEL! NEQ 0 (
|
|
|
|
echo Signed release builds must not have unstaged changes!
|
|
|
|
exit /b 1
|
|
|
|
)
|
2018-08-01 01:14:04 +00:00
|
|
|
) else (
|
2019-08-14 01:07:42 +00:00
|
|
|
echo Invalid build configuration - expected 'debug' or 'release'
|
2020-12-12 19:08:45 +00:00
|
|
|
echo Usage: scripts\build-arch.bat ^(release^|debug^) ^(x86^|x64^|ARM64^)
|
2018-08-01 01:14:04 +00:00
|
|
|
exit /b 1
|
|
|
|
)
|
2018-07-25 09:53:51 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2018-07-29 02:43:40 +00:00
|
|
|
if /I "%ARCH%" NEQ "x86" (
|
|
|
|
if /I "%ARCH%" NEQ "x64" (
|
2020-12-12 19:08:45 +00:00
|
|
|
if /I "%ARCH%" NEQ "ARM64" (
|
|
|
|
echo Invalid build architecture - expected 'x86', 'x64', or 'ARM64'
|
|
|
|
echo Usage: scripts\build-arch.bat ^(release^|debug^) ^(x86^|x64^|ARM64^)
|
|
|
|
exit /b 1
|
|
|
|
)
|
2018-07-25 09:53:51 +00:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2018-08-01 01:14:04 +00:00
|
|
|
set SIGNTOOL_PARAMS=sign /tr http://timestamp.digicert.com /td sha256 /fd sha256 /sha1 1B3C676E831A94EC0327C3347EB32C68C26B3A67 /v
|
2018-07-26 02:52:58 +00:00
|
|
|
|
2018-07-25 09:53:51 +00:00
|
|
|
set BUILD_ROOT=%cd%\build
|
|
|
|
set SOURCE_ROOT=%cd%
|
|
|
|
set BUILD_FOLDER=%BUILD_ROOT%\build-%ARCH%-%BUILD_CONFIG%
|
|
|
|
set DEPLOY_FOLDER=%BUILD_ROOT%\deploy-%ARCH%-%BUILD_CONFIG%
|
|
|
|
set INSTALLER_FOLDER=%BUILD_ROOT%\installer-%ARCH%-%BUILD_CONFIG%
|
2018-09-04 08:03:01 +00:00
|
|
|
set SYMBOLS_FOLDER=%BUILD_ROOT%\symbols-%ARCH%-%BUILD_CONFIG%
|
2019-01-06 02:09:52 +00:00
|
|
|
set /p VERSION=<%SOURCE_ROOT%\app\version.txt
|
2018-07-25 09:53:51 +00:00
|
|
|
|
2020-12-12 19:08:45 +00:00
|
|
|
rem Use the correct VC tools for the specified architecture
|
|
|
|
if /I "%ARCH%" EQU "x64" (
|
|
|
|
rem x64 is a special case that doesn't match %PROCESSOR_ARCHITECTURE%
|
|
|
|
set VC_ARCH=AMD64
|
|
|
|
) else (
|
|
|
|
set VC_ARCH=%ARCH%
|
|
|
|
)
|
|
|
|
|
|
|
|
rem If we're not building for the current platform, use the cross compiling toolchain
|
|
|
|
if /I "%VC_ARCH%" NEQ "%PROCESSOR_ARCHITECTURE%" (
|
|
|
|
set VC_ARCH=%PROCESSOR_ARCHITECTURE%_%VC_ARCH%
|
|
|
|
)
|
|
|
|
|
2019-09-29 21:52:06 +00:00
|
|
|
rem Find Visual Studio and run vcvarsall.bat
|
|
|
|
set VSWHERE="%SOURCE_ROOT%\scripts\vswhere.exe"
|
|
|
|
for /f "usebackq delims=" %%i in (`%VSWHERE% -latest -property installationPath`) do (
|
2020-12-12 19:08:45 +00:00
|
|
|
call "%%i\VC\Auxiliary\Build\vcvarsall.bat" %VC_ARCH%
|
2019-09-29 21:52:06 +00:00
|
|
|
)
|
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
|
|
|
|
|
|
|
rem Find VC redistributable DLLs
|
|
|
|
for /f "usebackq delims=" %%i in (`%VSWHERE% -latest -find VC\Redist\MSVC\*\%ARCH%\Microsoft.VC*.CRT`) do set VC_REDIST_DLL_PATH=%%i
|
|
|
|
|
2018-07-25 09:53:51 +00:00
|
|
|
echo Cleaning output directories
|
|
|
|
rmdir /s /q %DEPLOY_FOLDER%
|
|
|
|
rmdir /s /q %BUILD_FOLDER%
|
|
|
|
rmdir /s /q %INSTALLER_FOLDER%
|
2018-09-04 08:03:01 +00:00
|
|
|
rmdir /s /q %SYMBOLS_FOLDER%
|
2018-07-25 09:53:51 +00:00
|
|
|
mkdir %BUILD_ROOT%
|
|
|
|
mkdir %DEPLOY_FOLDER%
|
|
|
|
mkdir %BUILD_FOLDER%
|
|
|
|
mkdir %INSTALLER_FOLDER%
|
2018-09-04 08:03:01 +00:00
|
|
|
mkdir %SYMBOLS_FOLDER%
|
2018-07-25 09:53:51 +00:00
|
|
|
|
|
|
|
echo Configuring the project
|
|
|
|
pushd %BUILD_FOLDER%
|
|
|
|
qmake %SOURCE_ROOT%\moonlight-qt.pro
|
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
|
|
|
popd
|
|
|
|
|
|
|
|
echo Compiling Moonlight in %BUILD_CONFIG% configuration
|
|
|
|
pushd %BUILD_FOLDER%
|
2020-05-05 01:06:32 +00:00
|
|
|
%SOURCE_ROOT%\scripts\jom.exe %BUILD_CONFIG%
|
2018-07-25 09:53:51 +00:00
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
|
|
|
popd
|
|
|
|
|
2018-09-04 08:03:01 +00:00
|
|
|
echo Saving PDBs
|
|
|
|
for /r "%BUILD_FOLDER%" %%f in (*.pdb) do (
|
2018-09-15 02:32:23 +00:00
|
|
|
copy "%%f" %SYMBOLS_FOLDER%
|
2018-09-04 08:03:01 +00:00
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
|
|
|
)
|
2018-09-15 02:32:23 +00:00
|
|
|
copy %SOURCE_ROOT%\libs\windows\lib\%ARCH%\*.pdb %SYMBOLS_FOLDER%
|
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
2019-01-06 02:09:52 +00:00
|
|
|
7z a %SYMBOLS_FOLDER%\MoonlightDebuggingSymbols-%ARCH%-%VERSION%.zip %SYMBOLS_FOLDER%\*.pdb
|
2018-09-04 08:03:01 +00:00
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
|
|
|
|
|
|
|
if "%ML_SYMBOL_STORE%" NEQ "" (
|
|
|
|
echo Publishing PDBs to symbol store: %ML_SYMBOL_STORE%
|
|
|
|
symstore add /f %SYMBOLS_FOLDER%\*.pdb /s %ML_SYMBOL_STORE% /t Moonlight
|
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
|
|
|
) else (
|
|
|
|
if "%MUST_DEPLOY_SYMBOLS%"=="1" (
|
|
|
|
echo "A symbol server must be specified in ML_SYMBOL_STORE for signed release builds"
|
|
|
|
exit /b 1
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2019-01-06 02:20:53 +00:00
|
|
|
if "%ML_SYMBOL_ARCHIVE%" NEQ "" (
|
|
|
|
echo Copying PDB ZIP to symbol archive: %ML_SYMBOL_ARCHIVE%
|
|
|
|
copy %SYMBOLS_FOLDER%\MoonlightDebuggingSymbols-%ARCH%-%VERSION%.zip %ML_SYMBOL_ARCHIVE%
|
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
|
|
|
) else (
|
|
|
|
if "%MUST_DEPLOY_SYMBOLS%"=="1" (
|
|
|
|
echo "A symbol archive directory must be specified in ML_SYMBOL_ARCHIVE for signed release builds"
|
|
|
|
exit /b 1
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2018-07-25 09:53:51 +00:00
|
|
|
echo Copying DLL dependencies
|
|
|
|
copy %SOURCE_ROOT%\libs\windows\lib\%ARCH%\*.dll %DEPLOY_FOLDER%
|
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
|
|
|
|
2020-12-12 19:59:47 +00:00
|
|
|
if /I "%ARCH%" NEQ "ARM64" (
|
|
|
|
echo Copying AntiHooking.dll
|
|
|
|
copy %BUILD_FOLDER%\AntiHooking\%BUILD_CONFIG%\AntiHooking.dll %DEPLOY_FOLDER%
|
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
|
|
|
)
|
2019-01-20 07:05:56 +00:00
|
|
|
|
2018-09-13 18:17:51 +00:00
|
|
|
echo Copying GC mapping list
|
2018-09-29 23:43:14 +00:00
|
|
|
copy %SOURCE_ROOT%\app\SDL_GameControllerDB\gamecontrollerdb.txt %DEPLOY_FOLDER%
|
2018-09-13 18:17:51 +00:00
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
|
|
|
|
2018-08-02 03:40:05 +00:00
|
|
|
echo Deploying Qt dependencies
|
2020-12-31 17:44:59 +00:00
|
|
|
windeployqt.exe --dir %DEPLOY_FOLDER% --%BUILD_CONFIG% --qmldir %SOURCE_ROOT%\app\gui --no-opengl-sw --no-compiler-runtime --no-qmltooling --no-virtualkeyboard --no-sql %BUILD_FOLDER%\app\%BUILD_CONFIG%\Moonlight.exe
|
2018-07-25 09:53:51 +00:00
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
|
|
|
|
2020-12-31 17:44:59 +00:00
|
|
|
echo Deleting unused styles
|
|
|
|
rem Qt 5.x directories
|
|
|
|
rmdir /s /q %DEPLOY_FOLDER%\QtQuick\Controls.2\Fusion
|
|
|
|
rmdir /s /q %DEPLOY_FOLDER%\QtQuick\Controls.2\Imagine
|
|
|
|
rmdir /s /q %DEPLOY_FOLDER%\QtQuick\Controls.2\Universal
|
|
|
|
rem Qt 6.x directories
|
|
|
|
rmdir /s /q %DEPLOY_FOLDER%\QtQuick\Controls\Fusion
|
|
|
|
rmdir /s /q %DEPLOY_FOLDER%\QtQuick\Controls\Imagine
|
|
|
|
rmdir /s /q %DEPLOY_FOLDER%\QtQuick\Controls\Universal
|
|
|
|
|
2019-04-23 04:04:21 +00:00
|
|
|
echo Generating QML cache
|
2019-04-24 06:25:10 +00:00
|
|
|
forfiles /p %DEPLOY_FOLDER% /m *.qml /s /c "cmd /c qmlcachegen.exe @path"
|
2019-04-24 05:28:28 +00:00
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
|
|
|
|
|
|
|
echo Deleting original QML files
|
2019-04-24 06:25:10 +00:00
|
|
|
forfiles /p %DEPLOY_FOLDER% /m *.qml /s /c "cmd /c del @path"
|
2019-04-24 05:28:28 +00:00
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
2019-04-23 04:04:21 +00:00
|
|
|
|
2018-07-25 09:53:51 +00:00
|
|
|
echo Harvesting files for WiX
|
2018-08-01 01:14:04 +00:00
|
|
|
"%WIX%\bin\heat" dir %DEPLOY_FOLDER% -srd -sfrag -ag -sw5150 -cg MoonlightDependencies -var var.SourceDir -dr INSTALLFOLDER -out %BUILD_FOLDER%\Dependencies.wxs
|
2018-07-25 09:53:51 +00:00
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
|
|
|
|
|
|
|
echo Copying application binary to deployment directory
|
|
|
|
copy %BUILD_FOLDER%\app\%BUILD_CONFIG%\Moonlight.exe %DEPLOY_FOLDER%
|
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
|
|
|
|
2018-08-01 01:14:04 +00:00
|
|
|
if "%SIGN%"=="1" (
|
|
|
|
echo Signing deployed binaries
|
2018-10-12 01:45:29 +00:00
|
|
|
set FILES_TO_SIGN=
|
2018-08-01 01:14:04 +00:00
|
|
|
for /r "%DEPLOY_FOLDER%" %%f in (*.dll *.exe) do (
|
2018-10-12 01:45:29 +00:00
|
|
|
set FILES_TO_SIGN=!FILES_TO_SIGN! %%f
|
2018-08-01 01:14:04 +00:00
|
|
|
)
|
2018-10-12 01:45:29 +00:00
|
|
|
signtool %SIGNTOOL_PARAMS% !FILES_TO_SIGN!
|
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
2018-08-01 01:14:04 +00:00
|
|
|
)
|
|
|
|
|
2019-12-04 03:14:19 +00:00
|
|
|
if "%ML_SYMBOL_STORE%" NEQ "" (
|
|
|
|
echo Publishing binaries to symbol store: %ML_SYMBOL_STORE%
|
|
|
|
symstore add /r /f %DEPLOY_FOLDER%\*.* /s %ML_SYMBOL_STORE% /t Moonlight
|
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
|
|
|
)
|
|
|
|
|
2018-08-16 03:29:59 +00:00
|
|
|
echo Building MSI
|
|
|
|
msbuild %SOURCE_ROOT%\wix\Moonlight\Moonlight.wixproj /p:Configuration=%BUILD_CONFIG% /p:Platform=%ARCH%
|
2018-07-25 09:53:51 +00:00
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
|
|
|
|
2018-08-16 03:29:59 +00:00
|
|
|
if "%SIGN%"=="1" (
|
|
|
|
echo Signing MSI
|
|
|
|
signtool %SIGNTOOL_PARAMS% %BUILD_FOLDER%\Moonlight.msi
|
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
|
|
|
)
|
|
|
|
|
|
|
|
echo Building portable package
|
|
|
|
rem This must be done after WiX harvesting and signing, since the VCRT dlls are MS signed
|
|
|
|
rem and should not be harvested for inclusion in the full installer
|
2019-09-29 21:52:06 +00:00
|
|
|
copy "%VC_REDIST_DLL_PATH%\*.dll" %DEPLOY_FOLDER%
|
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
2018-08-17 04:04:47 +00:00
|
|
|
rem This file tells Moonlight that it's a portable installation
|
|
|
|
echo. > %DEPLOY_FOLDER%\portable.dat
|
2018-08-16 03:29:59 +00:00
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
2019-01-06 02:09:52 +00:00
|
|
|
7z a %INSTALLER_FOLDER%\MoonlightPortable-%ARCH%-%VERSION%.zip %DEPLOY_FOLDER%\*
|
2018-08-16 03:29:59 +00:00
|
|
|
if !ERRORLEVEL! NEQ 0 goto Error
|
|
|
|
|
2020-11-30 03:13:27 +00:00
|
|
|
echo Build successful for Moonlight v%VERSION% %ARCH% binaries!
|
2018-07-25 09:53:51 +00:00
|
|
|
exit /b 0
|
|
|
|
|
|
|
|
:Error
|
|
|
|
echo Build failed!
|
2018-09-13 18:17:51 +00:00
|
|
|
exit /b !ERRORLEVEL!
|