improved build_win_premake.bat and package_win.bat

This commit is contained in:
Sak32009 2024-08-18 11:08:23 +02:00
parent 34f664621c
commit 26a07e06e7
6 changed files with 239 additions and 214 deletions

View File

@ -58,12 +58,12 @@ jobs:
dir /s /b /a:-d build\win dir /s /b /a:-d build\win
### remove linker files ### remove linker files
- name: Remove linker files ### - name: Remove linker files
shell: cmd ### shell: cmd
working-directory: ${{ github.workspace }} ### working-directory: ${{ github.workspace }}
run: | ### run: |
del /f /s /q build\win\*.exp,build\win\*.lib ### del /f /s /q build\win\*.exp,build\win\*.lib
exit /b 0 ### exit /b 0
### package (release mode) ### package (release mode)
- name: Package build (release) - name: Package build (release)

View File

@ -1,120 +1,117 @@
@echo off @echo off
setlocal setlocal EnableDelayedExpansion
cd /d "%~dp0"
:: use 70% set /a "MAX_THREADS=2"
set /a build_threads=2
if defined NUMBER_OF_PROCESSORS ( if defined NUMBER_OF_PROCESSORS (
set /a build_threads=NUMBER_OF_PROCESSORS*70/100 :: use 70%
) set /a "MAX_THREADS=%NUMBER_OF_PROCESSORS% * 70 / 100"
if %build_threads% lss 1 ( if %MAX_THREADS% lss 1 (
set /a build_threads=1 set /a "MAX_THREADS=1"
)
) )
set /a BUILD_DEPS=0 set /a "BUILD_DEPS=0"
:args_loop :args_loop
if "%~1"=="" ( if "%~1" equ "" (
goto :args_loop_end goto :args_loop_end
) else if "%~1"=="--deps" ( ) else if "%~1" equ "--deps" (
set /a BUILD_DEPS=1 set /a "BUILD_DEPS=1"
) else if "%~1"=="--help" ( ) else if "%~1" equ "--help" (
call :help_page goto :help_page
goto :end_script
) else ( ) else (
1>&2 echo "invalid arg %~1" 1>&2 echo: invalid arg %~1
goto :end_script_with_err goto :end_script_with_err
) )
shift /1
goto :args_loop shift /1
goto :args_loop
:args_loop_end :args_loop_end
:: check premake
set "PREMAKE_EXE=third-party\common\win\premake\premake5.exe"
if not exist "%PREMAKE_EXE%" (
1>&2 echo: premake wasn't found
goto :end_script_with_err
)
set "premake_exe=third-party\common\win\premake\premake5.exe" :: build deps
if not exist "%premake_exe%" ( if %BUILD_DEPS% equ 1 (
1>&2 echo "preamke wasn't found" set "CMAKE_GENERATOR=Visual Studio 17 2022"
goto :end_script_with_err call "%PREMAKE_EXE%" --file="premake5-deps.lua" --64-build --32-build --all-ext --all-build --j=2 --verbose --clean --os=windows vs2022
) if %errorlevel% neq 0 (
goto :end_script_with_err
)
goto :end_script
)
:: build deps :: check vswhere
if %BUILD_DEPS%==0 ( set "VSWHERE_EXE=third-party\common\win\vswhere\vswhere.exe"
goto :build_deps_end if not exist "%VSWHERE_EXE%" (
) 1>&2 echo: vswhere wasn't found
set "CMAKE_GENERATOR=Visual Studio 17 2022" goto :end_script_with_err
call "%premake_exe%" --file="premake5-deps.lua" --all-ext --all-build --64-build --32-build --verbose --clean --os=windows vs2022 )
if %errorlevel% neq 0 (
goto :end_script_with_err
)
:build_deps_end
:: VS WHERE to get MSBUILD :: check msbuild
set "vswhere_exe=third-party\common\win\vswhere\vswhere.exe" set "MSBUILD_EXE="
if not exist "%vswhere_exe%" ( for /f "tokens=* delims=" %%A in ('"%VSWHERE_EXE%" -prerelease -latest -nocolor -nologo -property installationPath 2^>nul') do (
1>&2 echo "vswhere wasn't found" set "MSBUILD_EXE=%%~A\MSBuild\Current\Bin\MSBuild.exe"
goto :end_script_with_err )
) if not exist "%MSBUILD_EXE%" (
1>&2 echo: MSBuild wasn't found
goto :end_script_with_err
)
:: .sln file :: create .sln
set "sln_file=build\project\vs2022\win\gbe.sln" call "%PREMAKE_EXE%" --file="premake5.lua" --genproto --dosstub --winrsrc --winsign --os=windows vs2022
if %errorlevel% neq 0 (
goto :end_script_with_err
)
:: get msbuild path :: check .sln
set "my_vs_path=" set "SLN_FILE=build\project\vs2022\win\gbe.sln"
for /f "tokens=* delims=" %%A in ('"%vswhere_exe%" -prerelease -latest -nocolor -nologo -property installationPath 2^>nul') do ( if not exist "%SLN_FILE%" (
set "my_vs_path=%%~A\MSBuild\Current\Bin\MSBuild.exe" 1>&2 echo: .sln file wasn't found
) goto :end_script_with_err
if not exist "%my_vs_path%" ( )
1>&2 echo "MSBuild wasn't found"
goto :end_script_with_err
)
call "%premake_exe%" --file="premake5.lua" --dosstub --winrsrc --winsign --genproto --os=windows vs2022 :: build .sln
if %errorlevel% neq 0 ( set "BUILD_TYPES=release debug"
goto :end_script_with_err set "BUILD_PLATFORMS=x64 Win32"
) set "BUILD_TARGETS=api_regular api_experimental steamclient_experimental_stub steamclient_experimental steamclient_experimental_loader steamclient_experimental_extra lib_game_overlay_renderer tool_lobby_connect tool_generate_interfaces"
if not exist "%sln_file%" (
1>&2 echo "project solution file wasn't found"
goto :end_script_with_err
)
:: -v:n make it so we can actually see what commands it runs for %%A in (%BUILD_TYPES%) do (
echo: & echo building debug x64 set "BUILD_TYPE=%%A"
call "%my_vs_path%" /nologo "%sln_file%" /p:Configuration=debug /p:Platform=x64 -v:n -m:%build_threads% for %%B in (%BUILD_PLATFORMS%) do (
if %errorlevel% neq 0 ( set "BUILD_PLATFORM=%%B"
goto :end_script_with_err for %%C in (%BUILD_TARGETS%) do (
) set "BUILD_TARGET=%%C"
echo. & echo: building !BUILD_TARGET! !BUILD_TYPE! !BUILD_PLATFORM!
call "%MSBUILD_EXE%" /nologo -m:%MAX_THREADS% -v:n /p:Configuration=!BUILD_TYPE!,Platform=!BUILD_PLATFORM! /target:!BUILD_TARGET! "%SLN_FILE%"
if %errorlevel% neq 0 (
goto :end_script_with_err
)
)
)
)
echo: & echo building debug x32 goto :end_script
call "%my_vs_path%" /nologo "%sln_file%" /p:Configuration=debug /p:Platform=Win32 -v:n -m:%build_threads%
if %errorlevel% neq 0 (
goto :end_script_with_err
)
echo: & echo building release x64 :: exit without error
call "%my_vs_path%" /nologo "%sln_file%" /p:Configuration=release /p:Platform=x64 -v:n -m:%build_threads%
if %errorlevel% neq 0 (
goto :end_script_with_err
)
echo: & echo building release x32
call "%my_vs_path%" /nologo "%sln_file%" /p:Configuration=release /p:Platform=Win32 -v:n -m:%build_threads%
if %errorlevel% neq 0 (
goto :end_script_with_err
)
:: if all ok
:end_script :end_script
endlocal endlocal
exit /b 0 exit /b 0
:: exit with error :: exit with error
:end_script_with_err :end_script_with_err
endlocal endlocal
exit /b 1 exit /b 1
:: show help page
:help_page :help_page
echo: echo: "%~nx0" [switches]
echo "%~nx0" [switches] echo: switches:
echo switches: echo: --deps: rebuild third-party dependencies
echo --deps: rebuild third-party dependencies echo: --help: show this page
echo --help: show this page goto :end_script
exit /b 0

View File

@ -0,0 +1,3 @@
@echo off
call "build_win_premake.bat" --deps

View File

@ -1,87 +1,106 @@
@echo off @echo off
setlocal EnableDelayedExpansion
cd /d "%~dp0"
setlocal set /a "MAX_THREADS=2"
pushd "%~dp0"
set /a last_code=0
set "build_base_dir=build\win"
set "out_dir=build\package\win"
set /a MEM_PERCENT=90
set /a DICT_SIZE_MB=384
set "packager=third-party\deps\win\7za\7za.exe"
:: use 70%
set /a THREAD_COUNT=2
if defined NUMBER_OF_PROCESSORS ( if defined NUMBER_OF_PROCESSORS (
set /a THREAD_COUNT=NUMBER_OF_PROCESSORS*70/100 :: use 70%
) set /a "MAX_THREADS=%NUMBER_OF_PROCESSORS% * 70 / 100"
if %THREAD_COUNT% lss 2 ( if %MAX_THREADS% lss 1 (
set /a THREAD_COUNT=2 set /a "MAX_THREADS=1"
)
) )
if not exist "%packager%" ( set "BUILD_DIR=build\win"
1>&2 echo [X] packager app wasn't found set "OUT_DIR=build\package\win"
set /a last_code=1
goto :script_end if "%~1" equ "" (
1>&2 echo: missing build target folder arg
goto :end_script_with_err
) )
if "%~1"=="" ( set "TARGET_DIR=%BUILD_DIR%\%~1"
1>&2 echo [X] missing build folder if not exist "%TARGET_DIR%\" (
set /a last_code=1 1>&2 echo: build target folder wasn't found
goto :script_end goto :end_script_with_err
) )
set "target_src_dir=%build_base_dir%\%~1" set /a "BUILD_DEBUG=0"
if not exist "%target_src_dir%" ( if "%~2" equ "1" (
1>&2 echo [X] build folder wasn't found set /a "BUILD_DEBUG=1"
set /a last_code=1 )
goto :script_end
set /a "PKG_EXE_MEM_PERCENT=90"
set /a "PKG_EXE_DICT_SIZE_MB=384"
set "PKG_EXE=third-party\deps\win\7za\7za.exe"
if not exist "%PKG_EXE%" (
1>&2 echo: packager wasn't found
goto :end_script_with_err
) )
:::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::
echo // copying readmes + example files echo: // copying readmes + example files
xcopy /y /s /e /r "post_build\steam_settings.EXAMPLE\" "%target_src_dir%\steam_settings.EXAMPLE\"
copy /y "post_build\README.release.md" "%target_src_dir%\" xcopy /y /s /e /r "post_build\steam_settings.EXAMPLE\" "%TARGET_DIR%\steam_settings.EXAMPLE\"
copy /y "CHANGELOG.md" "%target_src_dir%\"
copy /y "CREDITS.md" "%target_src_dir%\" copy /y "post_build\README.release.md" "%TARGET_DIR%\"
if "%~2"=="1" ( copy /y "CHANGELOG.md" "%TARGET_DIR%\"
copy /y "post_build\README.debug.md" "%target_src_dir%\" copy /y "CREDITS.md" "%TARGET_DIR%\"
if %BUILD_DEBUG% equ 1 (
copy /y "post_build\README.debug.md" "%TARGET_DIR%\"
) )
if exist "%target_src_dir%\experimental\" (
copy /y "post_build\README.experimental.md" "%target_src_dir%\experimental\" if exist "%TARGET_DIR%\experimental\" (
copy /y "post_build\README.experimental.md" "%TARGET_DIR%\experimental\"
) )
if exist "%target_src_dir%\steamclient_experimental\" (
xcopy /y /s /e /r "post_build\win\ColdClientLoader.EXAMPLE\" "%target_src_dir%\steamclient_experimental\dll_injection.EXAMPLE\" if exist "%TARGET_DIR%\steamclient_experimental\" (
copy /y "post_build\README.experimental_steamclient.md" "%target_src_dir%\steamclient_experimental\" xcopy /y /s /e /r "post_build\win\ColdClientLoader.EXAMPLE\" "%TARGET_DIR%\steamclient_experimental\dll_injection.EXAMPLE\"
copy /y "tools\steamclient_loader\win\ColdClientLoader.ini" "%target_src_dir%\steamclient_experimental\" copy /y "post_build\README.experimental_steamclient.md" "%TARGET_DIR%\steamclient_experimental\"
copy /y "tools\steamclient_loader\win\ColdClientLoader.ini" "%TARGET_DIR%\steamclient_experimental\"
) )
if exist "%target_src_dir%\tools\generate_interfaces\" (
copy /y "post_build\README.generate_interfaces.md" "%target_src_dir%\tools\generate_interfaces\" if exist "%TARGET_DIR%\tools\generate_interfaces\" (
copy /y "post_build\README.generate_interfaces.md" "%TARGET_DIR%\tools\generate_interfaces\"
) )
if exist "%target_src_dir%\tools\lobby_connect\" (
copy /y "post_build\README.lobby_connect.md" "%target_src_dir%\tools\lobby_connect\" if exist "%TARGET_DIR%\tools\lobby_connect\" (
copy /y "post_build\README.lobby_connect.md" "%TARGET_DIR%\tools\lobby_connect\"
) )
:::::::::::::::::::::::::::::::::::::::::: ::::::::::::::::::::::::::::::::::::::::::
set "archive_dir=%out_dir%\%~1" set "ACHIVE_DIR=%OUT_DIR%\%~1"
if exist "%archive_dir%\" ( if exist "%ACHIVE_DIR%\" (
rmdir /s /q "%archive_dir%" rmdir /s /q "%ACHIVE_DIR%"
)
set "archive_file="
for %%A in ("%archive_dir%") do (
set "archive_file=%%~dpAemu-win-%%~nxA.7z"
) )
for %%A in ("%archive_dir%") do ( for %%A in ("%ACHIVE_DIR%") do (
mkdir "%%~dpA" md "%%~dpA"
) )
"%packager%" a "%archive_file%" ".\%target_src_dir%" -t7z -slp -ssw -mx -myx -mmemuse=p%MEM_PERCENT% -ms=on -mqs=off -mf=on -mhc+ -mhe- -m0=LZMA2:d=%DICT_SIZE_MB%m -mmt=%THREAD_COUNT% -mmtf+ -mtm- -mtc- -mta- -mtr+
set "ACHIVE_FILE="
:script_end for %%A in ("%ACHIVE_DIR%") do (
popd set "ACHIVE_FILE=%%~dpAemu-win-%%~nxA.7z"
endlocal & (
exit /b %last_code%
) )
if exist "%ACHIVE_FILE%" (
del /f /s /q "%ACHIVE_FILE%"
)
call "%PKG_EXE%" a "%ACHIVE_FILE%" ".\%TARGET_DIR%" -t7z -xr^^!*.lib -xr^^!*.exp -slp -ssw -mx -myx -mmemuse=p%PKG_EXE_MEM_PERCENT% -ms=on -mqs=off -mf=on -mhc+ -mhe- -m0=LZMA2:d=%PKG_EXE_DICT_SIZE_MB%m -mmt=%MAX_THREADS% -mmtf+ -mtm- -mtc- -mta- -mtr+
if %errorlevel% neq 0 (
goto :end_script_with_err
)
goto :end_script
:: exit without error
:end_script
endlocal
exit /b 0
:: exit with error
:end_script_with_err
endlocal
exit /b 1

3
package_win_debug.bat Normal file
View File

@ -0,0 +1,3 @@
@echo off
call "package_win.bat" vs2022/debug 1

3
package_win_release.bat Normal file
View File

@ -0,0 +1,3 @@
@echo off
call "package_win.bat" vs2022/release