allow injecting id string during build via command line switch +build_str <str>

This commit is contained in:
otavepto 2024-04-10 10:59:51 +02:00
parent 9fe55f2e81
commit e62f9251df
8 changed files with 101 additions and 6 deletions

View File

@ -147,7 +147,7 @@ jobs:
- name: Build release mode - name: Build release mode
shell: bash shell: bash
working-directory: ${{ github.workspace }} working-directory: ${{ github.workspace }}
run: "sudo chmod 777 build_linux.sh && ./build_linux.sh -verbose release" run: "sudo chmod 777 build_linux.sh && ./build_linux.sh -verbose release +build_str ${{ github.sha }}"
### package (release mode) ### package (release mode)
- name: Package build (release) - name: Package build (release)
@ -169,7 +169,7 @@ jobs:
- name: Build debug mode - name: Build debug mode
shell: bash shell: bash
working-directory: ${{ github.workspace }} working-directory: ${{ github.workspace }}
run: "sudo chmod 777 build_linux.sh && ./build_linux.sh -verbose debug" run: "sudo chmod 777 build_linux.sh && ./build_linux.sh -verbose debug +build_str ${{ github.sha }}"
### package (debug mode) ### package (debug mode)
- name: Package build (debug) - name: Package build (debug)

View File

@ -148,7 +148,7 @@ jobs:
- name: Build release mode - name: Build release mode
shell: cmd shell: cmd
working-directory: ${{ github.workspace }} working-directory: ${{ github.workspace }}
run: build_win.bat -verbose +exclient-extra-32 +exclient-extra-64 +lib-gameoverlay-32 +lib-gameoverlay-64 release run: build_win.bat -verbose release +build_str ${{ github.sha }} +exclient-extra-32 +exclient-extra-64 +lib-gameoverlay-32 +lib-gameoverlay-64
### package (release mode) ### package (release mode)
- name: Package build (release) - name: Package build (release)
@ -170,7 +170,7 @@ jobs:
- name: Build debug mode - name: Build debug mode
shell: cmd shell: cmd
working-directory: ${{ github.workspace }} working-directory: ${{ github.workspace }}
run: build_win.bat -verbose +exclient-extra-32 +exclient-extra-64 +lib-gameoverlay-32 +lib-gameoverlay-64 debug run: build_win.bat -verbose debug +build_str ${{ github.sha }} +exclient-extra-32 +exclient-extra-64 +lib-gameoverlay-32 +lib-gameoverlay-64
### package (debug mode) ### package (debug mode)
- name: Package build (debug) - name: Package build (debug)

View File

@ -16,6 +16,7 @@
* output function name in debug log * output function name in debug log
* imitate Windows resources of gameoverlayrenderer + add resources to networkingsocketslib * imitate Windows resources of gameoverlayrenderer + add resources to networkingsocketslib
* force add gameserver if `always_lan_type` was specified, not necessary but just in case * force add gameserver if `always_lan_type` was specified, not necessary but just in case
* allow injecting id string during build via command line switch `+build_str <str>`
--- ---

View File

@ -130,6 +130,7 @@ Arguments you can pass to this script:
>>>>>>>>> ___ >>>>>>>>> ___
* `-j <n>`: build with `<n>` parallel jobs, by default 70% of the available threads * `-j <n>`: build with `<n>` parallel jobs, by default 70% of the available threads
* `+build_str <str>`: add an identification string to the build (default date-time)
* `-verbose`: output compiler/linker commands * `-verbose`: output compiler/linker commands
>>>>>>>>> ___ >>>>>>>>> ___
@ -194,6 +195,7 @@ Arguments you can pass to this script:
>>>>>>>>> ___ >>>>>>>>> ___
* `-j <n>`: build with `<n>` parallel jobs, by default 70% of the available threads * `-j <n>`: build with `<n>` parallel jobs, by default 70% of the available threads
* `+build_str <str>`: add an identification string to the build (default date-time)
* `-verbose`: output compiler/linker commands * `-verbose`: output compiler/linker commands
>>>>>>>>> ___ >>>>>>>>> ___

View File

@ -37,6 +37,8 @@ BUILD_LIB_NET_SOCKETS_64=0
# < 0: deduce, > 1: force # < 0: deduce, > 1: force
PARALLEL_THREADS_OVERRIDE=-1 PARALLEL_THREADS_OVERRIDE=-1
CMD_BUILD_STR=''
# 0 = release, 1 = debug, otherwise error # 0 = release, 1 = debug, otherwise error
BUILD_TYPE=-1 BUILD_TYPE=-1
@ -54,6 +56,13 @@ for (( i=1; i<=$#; i++ )); do
exit 1; exit 1;
} }
#echo "[?] Overriding parralel build jobs count with $PARALLEL_THREADS_OVERRIDE" #echo "[?] Overriding parralel build jobs count with $PARALLEL_THREADS_OVERRIDE"
elif [[ "$var" = "+build_str" ]]; then
i=$((i+1))
CMD_BUILD_STR="${!i}"
[[ -z "$CMD_BUILD_STR" ]] && {
echo "[X] Expected a build string" >&2;
exit 1;
}
elif [[ "$var" = "-lib-32" ]]; then elif [[ "$var" = "-lib-32" ]]; then
BUILD_LIB32=0 BUILD_LIB32=0
elif [[ "$var" = "-lib-64" ]]; then elif [[ "$var" = "-lib-64" ]]; then
@ -257,8 +266,14 @@ release_src=(
"helpers/common_helpers.cpp" "helpers/common_helpers.cpp"
) )
emu_build_string="$CMD_BUILD_STR"
[[ -z "$emu_build_string" ]] && {
emu_build_string="$(date +'%m%d%Y-%H%M')"
}
# https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html
# additional #defines # additional #defines
common_defs="-DGNUC -DUTF_CPP_CPLUSPLUS=201703L -DCURL_STATICLIB" common_defs="-DGNUC -DUTF_CPP_CPLUSPLUS=201703L -DCURL_STATICLIB -D'EMU_BUILD_STRING=$emu_build_string'"
release_defs="$dbg_defs $common_defs" release_defs="$dbg_defs $common_defs"
# errors to ignore during build # errors to ignore during build

View File

@ -45,6 +45,8 @@ set /a BUILD_LIB_GAMEOVERLAY_64=0
:: < 0: deduce, > 1: force :: < 0: deduce, > 1: force
set /a PARALLEL_THREADS_OVERRIDE=-1 set /a PARALLEL_THREADS_OVERRIDE=-1
set "CMD_BUILD_STR="
:: 0 = release, 1 = debug, otherwise error :: 0 = release, 1 = debug, otherwise error
set /a BUILD_TYPE=-1 set /a BUILD_TYPE=-1
@ -99,6 +101,14 @@ set /a VERBOSE=0
goto :end_script goto :end_script
) )
shift /1 shift /1
) else if "%~1"=="+build_str" (
if "%~2"=="" (
call :err_msg "Expected a build string"
set /a last_code=1
goto :end_script
)
set "CMD_BUILD_STR=%~2"
shift /1
) else if "%~1"=="-verbose" ( ) else if "%~1"=="-verbose" (
set /a VERBOSE=1 set /a VERBOSE=1
) else if "%~1"=="clean" ( ) else if "%~1"=="clean" (
@ -239,9 +249,14 @@ set release_libs64=%release_libs_both% %ssq_lib64% %curl_lib64% %protob_lib64% %
:: common source files used everywhere, just for convinience, you still have to provide a complete list later :: common source files used everywhere, just for convinience, you still have to provide a complete list later
set release_src="dll/*.cpp" "%protoc_out_dir%/*.cc" "crash_printer/win.cpp" "helpers/common_helpers.cpp" set release_src="dll/*.cpp" "%protoc_out_dir%/*.cc" "crash_printer/win.cpp" "helpers/common_helpers.cpp"
set "emu_build_string=%CMD_BUILD_STR%"
if not defined emu_build_string (
call :get_date_time_str emu_build_string
)
:: additional #defines :: additional #defines
set "common_defs=/DUTF_CPP_CPLUSPLUS=201703L /DCURL_STATICLIB /DUNICODE /D_UNICODE" set "common_defs=/DUTF_CPP_CPLUSPLUS=201703L /DCURL_STATICLIB /DUNICODE /D_UNICODE"
set "release_defs=%dbg_defs% %common_defs%" set release_defs=%dbg_defs% %common_defs% /D"EMU_BUILD_STRING=%emu_build_string%"
if not exist "%deps_dir%\" ( if not exist "%deps_dir%\" (
@ -1008,6 +1023,58 @@ endlocal & exit /b %_exit%
endlocal & exit /b %errorlevel% endlocal & exit /b %errorlevel%
:: 1: (ref) out string
:get_date_time_str
setlocal
set "_date_v1="
set "_date_v2="
set "_date_v3="
set "_date_v4="
for /f "tokens=1-4 delims=/:-., " %%A in (' date /t') do (
set "_date_v1=%%~A"
set "_date_v2=%%~B"
set "_date_v3=%%~C"
set "_date_v4=%%~D"
)
if defined _date_v1 if "%_date_v1:~0,1%" lss "0" set "_date_v1="
if defined _date_v1 if "%_date_v1:~0,1%" gtr "9" set "_date_v1="
if defined _date_v2 if "%_date_v2:~0,1%" lss "0" set "_date_v2="
if defined _date_v2 if "%_date_v2:~0,1%" gtr "9" set "_date_v2="
if defined _date_v3 if "%_date_v3:~0,1%" lss "0" set "_date_v3="
if defined _date_v3 if "%_date_v3:~0,1%" gtr "9" set "_date_v3="
if defined _date_v4 if "%_date_v4:~0,1%" lss "0" set "_date_v4="
if defined _date_v4 if "%_date_v4:~0,1%" gtr "9" set "_date_v4="
set "_time_v1="
set "_time_v2="
set "_time_v3="
set "_time_v4="
for /f "tokens=1-4 delims=/:-., " %%A in (' time /t') do (
set "_time_v1=%%~A"
set "_time_v2=%%~B"
set "_time_v3=%%~C"
set "_time_v4=%%~D"
)
if defined _time_v1 if "%_time_v1:~0,1%" lss "0" set "_time_v1="
if defined _time_v1 if "%_time_v1:~0,1%" gtr "9" set "_time_v1="
if defined _time_v2 if "%_time_v2:~0,1%" lss "0" set "_time_v2="
if defined _time_v2 if "%_time_v2:~0,1%" gtr "9" set "_time_v2="
if defined _time_v3 if "%_time_v3:~0,1%" lss "0" set "_time_v3="
if defined _time_v3 if "%_time_v3:~0,1%" gtr "9" set "_time_v3="
if defined _time_v4 if "%_time_v4:~0,1%" lss "0" set "_time_v4="
if defined _time_v4 if "%_time_v4:~0,1%" gtr "9" set "_time_v4="
endlocal & (
set "%~1=%_date_v1%%_date_v2%%_date_v3%%_date_v4%-%_time_v1%%_time_v2%%_time_v3%%_time_v4%"
exit /b
)
:cleanup :cleanup
del /f /q *.exp >nul 2>&1 del /f /q *.exp >nul 2>&1
del /f /q *.lib >nul 2>&1 del /f /q *.lib >nul 2>&1

View File

@ -175,6 +175,9 @@ static inline void reset_LastError()
#include "steam/steam_gameserver.h" #include "steam/steam_gameserver.h"
#include "steam/steamdatagram_tickets.h" #include "steam/steamdatagram_tickets.h"
#define AS_STR(x) #x
#define EXPAND_AS_STR(x) AS_STR(x)
// PRINT_DEBUG definition // PRINT_DEBUG definition
// notice the extra call to WSASetLastError(0) in Windows def // notice the extra call to WSASetLastError(0) in Windows def
#ifndef EMU_RELEASE_BUILD #ifndef EMU_RELEASE_BUILD

View File

@ -1295,6 +1295,13 @@ static void parse_simple_features(class Settings *settings_client, class Setting
uint32 create_localstorage_settings(Settings **settings_client_out, Settings **settings_server_out, Local_Storage **local_storage_out) uint32 create_localstorage_settings(Settings **settings_client_out, Settings **settings_server_out, Local_Storage **local_storage_out)
{ {
PRINT_DEBUG_ENTRY(); PRINT_DEBUG_ENTRY();
#if defined(EMU_BUILD_STRING)
PRINT_DEBUG("emu build '%s'", EXPAND_AS_STR(EMU_BUILD_STRING));
#else
PRINT_DEBUG("<unspecified emu build>");
#endif
parse_crash_printer_location(); parse_crash_printer_location();
std::string program_path(Local_Storage::get_program_path()); std::string program_path(Local_Storage::get_program_path());