1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-04 10:03:36 +00:00

Build script: Refactorization

This commit is contained in:
Jj0YzL5nvJ 2021-09-03 02:20:21 -06:00 committed by Sergey Lipskiy
parent e29adbdbcd
commit 5aa389a86b

View File

@ -7,45 +7,42 @@ set ERR=if errorlevel 1 goto err
set MSG=%DPROJ% does not exist in the same directory set MSG=%DPROJ% does not exist in the same directory
if not exist "%~dp0%DPROJ%" goto err if not exist "%~dp0%DPROJ%" goto err
set ARCH=
set BOTH=0
set CONF=Release
set KAP=7z
set NO7=0
set DQTD=1
set REB= set REB=
set NOQT=0 set CONF=Release
set NOWTL=0 set EXT=7z
set NOM64=0 set DMQT=1
set ESIM=0 set DQTD=1
set EBQ=start "" explorer . set EBQ=start "" explorer .
taskkill /im msbuild.exe /f 2>nul for %%B in (EX86 EX64 D7Z DPJQT DPJWTL DMCL ESIM) do set "%%B=0"
taskkill /im vctip.exe /f 2>nul for %%K in (msbuild vctip mspdbsrv) do taskkill /im %%K.exe /f 2>nul
taskkill /im mspdbsrv.exe /f 2>nul
if "%*"=="" goto help if "%*"=="" goto help
for %%P in (%*) do ( for %%P in (%*) do (
if /i "%%P"=="--clean" goto clean if /i "%%P"=="--clean" goto clean
if /i "%%P"=="--x86" set ARCH=x86 if /i "%%P"=="--x86" set EX86=1
if /i "%%P"=="--x64" set ARCH=x64& set BOTH=0 if /i "%%P"=="--x64" set EX64=1
if /i "%%P"=="--all" set ARCH=x64& set BOTH=1 if /i "%%P"=="--all" set EX86=1& set EX64=1
if /i "%%P"=="--debug" set CONF=Debug if /i "%%P"=="--debug" set CONF=Debug
if /i "%%P"=="--zip" set KAP=zip if /i "%%P"=="--zip" set EXT=zip
if /i "%%P"=="--nopak" set NO7=1 if /i "%%P"=="--nopak" set D7Z=1
if /i "%%P"=="--rebuild" set REB=/t:Rebuild if /i "%%P"=="--rebuild" set REB=/t:Rebuild
if /i "%%P"=="--noqt" set NOQT=1 if /i "%%P"=="--nopjqt" set DPJQT=1
if /i "%%P"=="--nowtl" set NOWTL=1 REM if /i "%%P"=="--nomqt" set DMQT=1
if /i "%%P"=="--nom64" set NOM64=1 REM if /i "%%P"=="--noqt" set DPJQT=1& set DMQT=1
if /i "%%P"=="--nopjwtl" set DPJWTL=1
if /i "%%P"=="--nomcl" set DMCL=1
if /i "%%P"=="--dlqt" set DQTD=0 if /i "%%P"=="--dlqt" set DQTD=0
if /i "%%P"=="--sim" set ESIM=1 if /i "%%P"=="--sim" set ESIM=1
if /i "%%P"=="--q" set EBQ=REM if /i "%%P"=="--q" set EBQ=REM
) )
if not defined ARCH goto help set /a TSK=%EX86%+%EX64%
set /a MOD=%NOQT%+%NOWTL%+%NOM64% if %TSK%==0 goto help
set /a DQT=%DPJQT%+%DMQT%
set /a MOD=%DQT%+%DPJWTL%+%DMCL%
set MSG=All compilation tasks were disabled on request set MSG=All compilation tasks were disabled on request
if %MOD%==3 goto err if %MOD%==4 goto err
set MSG=7z was not found in the environment set MSG=7z was not found in the environment
set /a MOD=%NO7%+%DQTD% set /a MOD=%D7Z%+%DQTD%
if %MOD% NEQ 2 7z >nul 2>&1 if %MOD% NEQ 2 7z >nul 2>&1
%ERR% %ERR%
@ -76,12 +73,14 @@ set MSG=Git was not found in the environment
git --version >nul 2>&1 git --version >nul 2>&1
%ERR% %ERR%
set ARCH=x86
if %EX64%==1 set ARCH=x64
set "TARCH=%ARCH%" set "TARCH=%ARCH%"
:X86 :X86
pushd "%~dp0..\..\" pushd "%~dp0..\..\"
if "%ARCH%"=="x86" set TARCH=Win32 if "%ARCH%"=="x86" set TARCH=Win32
if %NOQT%==1 goto noqt if %DQT%==2 goto noqt
if defined QTDIR_%ARCH% goto nodl if defined QTDIR_%ARCH% goto nodl
set "QTVER=qt-5_15-%ARCH%-msvc2017-static" set "QTVER=qt-5_15-%ARCH%-msvc2017-static"
if exist "..\Qt\%QTVER%\include\QtCore" goto nodl if exist "..\Qt\%QTVER%\include\QtCore" goto nodl
@ -92,7 +91,7 @@ set MSG=cURL was not found in the environment
curl --version >nul 2>&1 curl --version >nul 2>&1
%ERR% %ERR%
del /f /q "..\%QTVER%.7z" 2>nul del /f /q "..\%QTVER%.7z" 2>nul
set errorlevel=0 type nul
set QTURL=https://github.com/gonetz/GLideN64/releases/download/qt_build set QTURL=https://github.com/gonetz/GLideN64/releases/download/qt_build
set MSG=cURL failed to download:^& echo %QTURL%/%QTVER%.7z set MSG=cURL failed to download:^& echo %QTURL%/%QTVER%.7z
curl -L -o "..\%QTVER%.7z" "%QTURL%/%QTVER%.7z" curl -L -o "..\%QTVER%.7z" "%QTURL%/%QTVER%.7z"
@ -109,38 +108,44 @@ if "%ARCH%"=="x64" (
if defined QTDIR_x86 set "QTDIR="%QTDIR_x86%"" if defined QTDIR_x86 set "QTDIR="%QTDIR_x86%""
) )
set QTDIR=%QTDIR:"=% set QTDIR=%QTDIR:"=%
set MSG=Something went wrong when detecting Qt:^& echo %QTDIR% set MSG=Something went wrong when detecting Qt %ARCH%:^& echo %QTDIR%
if not exist "%QTDIR%\include\QtCore" goto err if not exist "%QTDIR%\include\QtCore" goto err
:noqt :noqt
if not defined BUILDROUTE set "BUILDROUTE="%~dp0..\..\build"" if not defined BUILDROUTE set "BUILDROUTE="%~dp0..\..\build""
set BUILDROUTE=%BUILDROUTE:"=% set BUILDROUTE=%BUILDROUTE:"=%
set "PJ64QT=%BUILDROUTE%\QT_for_Project64_%ARCH%" set "IDTS=%ARCH%"
set "PJ64WTL=%BUILDROUTE%\WTL_for_Project64_%ARCH%" if defined TOOLSET set "IDTS="%TOOLSET%-%ARCH%""
set "M64CL=%BUILDROUTE%\for_Mupen64Plus_%ARCH%" set IDTS=%IDTS:"=%
set JACK= set "PJ64QT=%BUILDROUTE%\Project64-Qt-%IDTS%"
if "%ARCH%"=="x64" set JACK=_x64 ::set "M64QT=%BUILDROUTE%\Mupen64Plus-Qt-%IDTS%"
set "PJ64PluginsDirQT%JACK%=%PJ64QT%" set "PJ64WTL=%BUILDROUTE%\Project64-WTL-%IDTS%"
set "PJ64PluginsDirWTL%JACK%=%PJ64WTL%" set "M64CL=%BUILDROUTE%\Mupen64Plus-CLI-%IDTS%"
set "Mupen64PluginsDir%JACK%=%M64CL%"
set MOD=%random:~0,1% set MOD=
if %MOD% LEQ 4 (set MOD=Lylat) else ( if "%ARCH%"=="x64" set MOD=_x64
if %MOD% GEQ 8 (set MOD=Kildean) else set MOD=Caryll) set "PJ64PluginsDirQT%MOD%=%PJ64QT%"
::set "Mupen64PluginsDirQT%MOD%=%M64QT%"
set "PJ64PluginsDirWTL%MOD%=%PJ64WTL%"
set "Mupen64PluginsDir%MOD%=%M64CL%"
set MBQT=msbuild set MOD=%random:~-1%
if %MOD% LEQ 4 (set MOD=Lylat
) else if %MOD% GEQ 8 (set MOD=Kildean) else set MOD=Caryll
set BPJQT=msbuild
if %ESIM%==1 ( if %ESIM%==1 (
set "MBQT=echo %MBQT%" set "BPJQT=echo %BPJQT%"
md "translations\wtl" 2>nul md "translations\wtl" 2>nul
cd.>"translations\wtl\%MOD%.Lang" cd.>"translations\wtl\%MOD%.Lang"
del /f /q "%BUILDROUTE%\*_%ARCH%.%KAP%" 2>nul del /f /q "%BUILDROUTE%\*-%IDTS%.%EXT%" 2>nul
set errorlevel=0 type nul
) )
set "MBWTL=%MBQT%" for %%C in (MQT PJWTL MCL) do set "B%%C=%BPJQT%"
set "MBM64=%MBQT%" if %DPJQT%==1 set BPJQT=REM
if %NOQT%==1 set MBQT=REM if %DMQT%==1 set BMQT=REM
if %NOWTL%==1 set MBWTL=REM if %DPJWTL%==1 set BPJWTL=REM
if %NOM64%==1 set MBM64=REM if %DMCL%==1 set BMCL=REM
set "PTS=Platform=%TARCH%" set "PTS=Platform=%TARCH%"
if defined TOOLSET set "PTS="%PTS%;PlatformToolset=%TOOLSET%"" if defined TOOLSET set "PTS="%PTS%;PlatformToolset=%TOOLSET%""
@ -150,54 +155,66 @@ goto mbbeg
:mbcl :mbcl
%~1 "%~dp0%~2" /m /p:Configuration=%CONF%%~3;%PTS% %REB% %~1 "%~dp0%~2" /m /p:Configuration=%CONF%%~3;%PTS% %REB%
%ERR% %ERR%
echo. if "%~1" NEQ "REM" echo.
goto:eof goto:eof
:mbbeg :mbbeg
set MSG=Qt version, architecture and path are really correct?^& echo %QTDIR% set MSG=Qt version, architecture and path are really correct?^& echo %QTDIR%
call :mbcl "%MBQT%" "GLideNUI.vcxproj" "" call :mbcl "%BPJQT%" "GLideNUI.vcxproj"
%DMN% %DMN%
call :mbcl "%MBQT%" "%DPROJ%" "_qt" call :mbcl "%BPJQT%" "%DPROJ%" "_qt"
%DMN%
::if %DPJQT%==1 call :mbcl "%BMQT%" "GLideNUI.vcxproj"
%DMN%
::call :mbcl "%BMQT%" "%DPROJ%" "_mupenplus_qt"
%DMN% %DMN%
set MSG=ERROR! set MSG=ERROR!
call :mbcl "%MBWTL%" "GLideNUI-wtl.vcxproj" "" call :mbcl "%BPJWTL%" "GLideNUI-wtl.vcxproj"
%DMN% %DMN%
call :mbcl "%MBWTL%" "%DPROJ%" "_wtl" call :mbcl "%BPJWTL%" "%DPROJ%" "_wtl"
%DMN% %DMN%
call :mbcl "%MBM64%" "%DPROJ%" "_mupenplus" call :mbcl "%BMCL%" "%DPROJ%" "_mupenplus"
%DMN% %DMN%
goto pjqt goto pjqt
:cini :cini
set MSG=Failed to copy some project files to:^& echo %~1 set MSG=Failed to copy some project files to:^& echo %~1
if %ESIM%==1 md "%~1" 2>nul if %ESIM%==1 md "%~1" 2>nul
set errorlevel=0 type nul
copy /y ini\GLideN64.custom.ini "%~1\" copy /y ini\GLideN64.custom.ini "%~1\"
%ERR% %ERR%
del /f /q "%~1\*.lib" "%~1\*.exp" 2>nul del /f /q "%~1\*.lib" "%~1\*.exp" 2>nul
set errorlevel=0 type nul
goto:eof goto:eof
:pjqt :pjqt
if %NOQT%==1 goto pjwtl if %DPJQT%==1 goto mqt
call :cini "%PJ64QT%" call :cini "%PJ64QT%"
%DMN% %DMN%
copy /y translations\release\*.qm "%PJ64QT%\" copy /y translations\release\*.qm "%PJ64QT%\"
%ERR% %ERR%
:mqt
if %DMQT%==1 goto pjwtl
::call :cini "%M64QT%"
%DMN%
::copy /y translations\release\*.qm "%M64QT%\"
%ERR%
:pjwtl :pjwtl
if %NOWTL%==1 goto mpcl if %DPJWTL%==1 goto mcl
call :cini "%PJ64WTL%" call :cini "%PJ64WTL%"
%DMN% %DMN%
md "%PJ64WTL%\translations" 2>nul md "%PJ64WTL%\translations" 2>nul
set errorlevel=0 type nul
copy /y translations\wtl\*.Lang "%PJ64WTL%\translations\" copy /y translations\wtl\*.Lang "%PJ64WTL%\translations\"
%ERR% %ERR%
:mpcl :mcl
if %NOM64%==1 goto pkg if %DMCL%==1 goto pkg
call :cini "%M64CL%" call :cini "%M64CL%"
%DMN% %DMN%
@ -206,17 +223,17 @@ for /f "tokens=1" %%R in ('git rev-parse --short HEAD') do set "REV=%%R"
set MSG=The route could not be accessed:^& echo %BUILDROUTE% set MSG=The route could not be accessed:^& echo %BUILDROUTE%
pushd "%BUILDROUTE%" pushd "%BUILDROUTE%"
%ERR% %ERR%
set MOD=the plugins set MOD=plugins
if %NO7%==0 ( if %D7Z%==0 (
set MOD=the compressed files set MOD=compressed files
for /f "tokens=*" %%Z in ('dir /ad /b *_%ARCH%') do 7z a -t%KAP% "GLideN64-%REV%-%%Z.%KAP%" ".\%%Z\*" for /f "tokens=*" %%Z in ('dir /ad /b *-%IDTS%') do 7z a -t%EXT% "GLideN64-%REV%-%%Z.%EXT%" ".\%%Z\*"
) )
if "%ARCH%"=="x64" ( if "%ARCH%"=="x64" (
if %BOTH%==1 set ARCH=x86& goto X86 if %TSK%==2 set ARCH=x86& goto X86
) )
set MSG=DONE!^& echo Path to %MOD%:^& echo %CD% set MSG=DONE!^& echo Path to the %MOD%:^& echo %CD%
%EBQ% %EBQ%
:err :err
set WTF=%errorlevel% set WTF=%errorlevel%
@ -257,20 +274,22 @@ echo.
echo ^<Architectures^> echo ^<Architectures^>
echo --x86 To compile x86 echo --x86 To compile x86
echo --x64 To compile x64 echo --x64 To compile x64
echo --all To compile x86 and x64 echo --all To compile x86 and x64, equivalent to using '--x86'
echo n.b. If more than one of these is used, only the last one will echo and '--x64' simultaneously
echo take effect
echo. echo.
echo ^<Others^> echo ^<Others^>
echo --clean Clean ALL auto-generated build files within the project echo --clean Clean ALL auto-generated build files within the project
echo --debug For debug builds echo --debug For debug builds
echo --dlqt Auto download and configure Qt for VS2017-2019, it echo --dlqt Auto download and configure Qt for VS2017-2019, it would
echo would have no effect if QTDIR_x* is used or if the echo have no effect if Qt variables are used or if the same
echo same version has already been extracted echo version has already been extracted
echo --noqt To build without Qt support, it will ignore the ::echo --noqt To build without Qt support, equivalent to using '--nopjqt'
echo effects of QTDIR_x* and "--dlqt" ::echo and '--nomqt' simultaneously, it will ignore the effects of
echo --nowtl To skip WTL builds ::echo Qt variables and "--dlqt"
echo --nom64 To skip mupen64plus builds echo --nopjqt To skip Project64 Qt builds
::echo --nomqt To skip Mupen64Plus Qt builds
echo --nopjwtl To skip Project64 WTL builds
echo --nomcl To skip Mupen64Plus CLI builds
echo --nopak To skip packing the plugins, "--zip" will be ineffective echo --nopak To skip packing the plugins, "--zip" will be ineffective
echo It will disable 7-Zip completely if "--dlqt" isn't used echo It will disable 7-Zip completely if "--dlqt" isn't used
echo --rebuild To rebuild without cleaning echo --rebuild To rebuild without cleaning
@ -288,9 +307,9 @@ echo %~nx0 --x86 --debug --rebuild
echo. echo.
echo set BUILDROUTE=H:\%USERNAME%\experiment echo set BUILDROUTE=H:\%USERNAME%\experiment
echo set TOOLSET=ClangCL echo set TOOLSET=ClangCL
echo %~nx0 --noqt --x64 echo %~nx0 --nopjqt --x64
echo. echo.
echo set QTDIR_x86="G:\Static Qt\qt-5.7.1-x86-msvc2015" echo set QTDIR_x86="G:\Static Qt\qt-5.7.1-x86-msvc2015"
echo set QTDIR_x64=G:\Static Qt\qt-5.7.1-x64-msvc2015 echo set QTDIR_x64=G:\Static Qt\qt-5.7.1-x64-msvc2015
echo %~nx0 --nowtl --nom64 --all echo %~nx0 --nopjwtl --nomcl --all
exit /b 0 exit /b 0