mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-11-23 19:25:35 +08:00
+ check for vswhere before attempting any detection
+ niceness for terminal output + update Windows + Linux scripts to use the new directories of third party + propagate exit error code + fix line ending + update Windows deps build script to clean generated build files by cmake after install + propagate exit code of all builds + update Linux deps build script to clean generated build files by cmake after install + propagate exit code of all builds + fix line ending!
This commit is contained in:
parent
6fa1ba1bec
commit
2e69c038cc
@ -156,6 +156,7 @@ deps_dir="build-linux-deps"
|
||||
build_root_dir="build-linux/$build_folder"
|
||||
build_temp_dir="build-linux-temp"
|
||||
third_party_dir="third-party"
|
||||
third_party_build_dir="$third_party_dir/build/linux"
|
||||
build_root_32="$build_root_dir/x32"
|
||||
build_root_64="$build_root_dir/x64"
|
||||
build_root_tools="$build_root_dir/tools"
|
||||
@ -234,7 +235,7 @@ release_libs=(
|
||||
protoc_exe_32="$deps_dir/protobuf/install32/bin/protoc"
|
||||
protoc_exe_64="$deps_dir/protobuf/install64/bin/protoc"
|
||||
|
||||
parallel_exe="$third_party_dir/rush-v0.5.4-linux/rush"
|
||||
parallel_exe="$third_party_build_dir/rush-v0.5.4-linux/rush"
|
||||
|
||||
[ ! -d "$deps_dir" ] && {
|
||||
echo "[X] Dependencies dir \"$deps_dir\" was not found" >&2;
|
||||
@ -260,6 +261,8 @@ chmod 777 "$parallel_exe"
|
||||
|
||||
echo "[?] All build operations will use $build_threads parallel jobs"
|
||||
|
||||
last_code=0
|
||||
|
||||
### create folders + copy common scripts
|
||||
echo // creating dirs + copying tools
|
||||
rm -f -r "$build_root_dir"
|
||||
@ -301,7 +304,7 @@ function build_for () {
|
||||
rm -f -r -d "$tmp_work_dir"
|
||||
mkdir -p "$tmp_work_dir" || {
|
||||
echo [X] "Failed to create compilation directory" >&2;
|
||||
exit 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
local build_cmds=()
|
||||
@ -377,6 +380,7 @@ if [[ "$BUILD_LIB32" = "1" ]]; then
|
||||
|
||||
extra_src_files=("controller/*.c")
|
||||
build_for 1 0 "$build_root_32/libsteam_api.so" '-DCONTROLLER_SUPPORT' extra_src_files
|
||||
last_code=$((last_code + $?))
|
||||
fi
|
||||
|
||||
if [[ "$BUILD_CLIENT32" = "1" ]]; then
|
||||
@ -384,6 +388,7 @@ if [[ "$BUILD_CLIENT32" = "1" ]]; then
|
||||
|
||||
extra_src_files=("controller/*.c")
|
||||
build_for 1 0 "$build_root_32/steamclient.so" '-DCONTROLLER_SUPPORT -DSTEAMCLIENT_DLL' extra_src_files
|
||||
last_code=$((last_code + $?))
|
||||
fi
|
||||
|
||||
if [[ "$BUILD_TOOL_LOBBY32" = "1" ]]; then
|
||||
@ -391,6 +396,7 @@ if [[ "$BUILD_TOOL_LOBBY32" = "1" ]]; then
|
||||
|
||||
extra_src_files=("lobby_connect.cpp")
|
||||
build_for 1 1 "$build_root_tools/lobby_connect_x32" '-DNO_DISK_WRITES -DLOBBY_CONNECT' extra_src_files
|
||||
last_code=$((last_code + $?))
|
||||
fi
|
||||
|
||||
echo; echo
|
||||
@ -409,6 +415,7 @@ if [[ "$BUILD_LIB64" = "1" ]]; then
|
||||
|
||||
extra_src_files=("controller/*.c")
|
||||
build_for 0 0 "$build_root_64/libsteam_api.so" '-DCONTROLLER_SUPPORT' extra_src_files
|
||||
last_code=$((last_code + $?))
|
||||
fi
|
||||
|
||||
if [[ "$BUILD_CLIENT64" = "1" ]]; then
|
||||
@ -416,6 +423,7 @@ if [[ "$BUILD_CLIENT64" = "1" ]]; then
|
||||
|
||||
extra_src_files=("controller/*.c")
|
||||
build_for 0 0 "$build_root_64/steamclient.so" '-DCONTROLLER_SUPPORT -DSTEAMCLIENT_DLL' extra_src_files
|
||||
last_code=$((last_code + $?))
|
||||
fi
|
||||
|
||||
if [[ "$BUILD_TOOL_LOBBY64" = "1" ]]; then
|
||||
@ -423,6 +431,7 @@ if [[ "$BUILD_TOOL_LOBBY64" = "1" ]]; then
|
||||
|
||||
extra_src_files=("lobby_connect.cpp")
|
||||
build_for 0 1 "$build_root_tools/lobby_connect_x64" '-DNO_DISK_WRITES -DLOBBY_CONNECT' extra_src_files
|
||||
last_code=$((last_code + $?))
|
||||
fi
|
||||
|
||||
echo; echo
|
||||
@ -433,3 +442,4 @@ rm -f dll/net.pb.cc
|
||||
rm -f dll/net.pb.h
|
||||
rm -f -r -d "$build_temp_dir"
|
||||
|
||||
exit $last_code
|
||||
|
@ -22,7 +22,9 @@ fi
|
||||
script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
deps_dir="$script_dir/build-linux-deps"
|
||||
third_party_dir="$script_dir/third-party"
|
||||
mycmake="$third_party_dir/cmake-3.27.7-linux-x86_64/bin/cmake"
|
||||
third_party_deps_dir="$third_party_dir/deps/linux"
|
||||
third_party_common_dir="$third_party_dir/deps/common/src"
|
||||
mycmake="$third_party_deps_dir/cmake-3.27.7-linux-x86_64/bin/cmake"
|
||||
|
||||
[[ -f "$mycmake" ]] || {
|
||||
echo "[X] Couldn't find cmake" >&2
|
||||
@ -71,6 +73,8 @@ mkdir -p "$deps_dir" || {
|
||||
|
||||
echo; echo
|
||||
|
||||
last_code=0
|
||||
|
||||
|
||||
############## required packages ##############
|
||||
echo // installing required packages
|
||||
@ -121,23 +125,25 @@ EOL
|
||||
|
||||
echo ; echo
|
||||
|
||||
|
||||
############## common CMAKE args ##############
|
||||
# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS_CONFIG.html#variable:CMAKE_%3CLANG%3E_FLAGS_%3CCONFIG%3E
|
||||
cmake_common_args='-G "Unix Makefiles" -S .'
|
||||
cmake_common_defs="-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_STANDARD_REQUIRED=ON -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_C_STANDARD=17 -DCMAKE_CXX_STANDARD=17 -DCMAKE_POSITION_INDEPENDENT_CODE=True -DBUILD_SHARED_LIBS=OFF"
|
||||
cmake_gen32="rm -f -r build32/ && rm -f -r install32/ && mkdir build32/ && mkdir install32/ && '$mycmake' $cmake_common_args -B build32 -DCMAKE_TOOLCHAIN_FILE=$deps_dir/32-bit-toolchain.cmake -DCMAKE_INSTALL_PREFIX=install32 $cmake_common_defs"
|
||||
cmake_gen64="rm -f -r build64/ && rm -f -r install64/ && mkdir build64/ && mkdir install64/ && '$mycmake' $cmake_common_args -B build64 -DCMAKE_TOOLCHAIN_FILE=$deps_dir/64-bit-toolchain.cmake -DCMAKE_INSTALL_PREFIX=install64 $cmake_common_defs"
|
||||
recreate_32="rm -f -r build32/ && rm -f -r install32/ && mkdir build32/ && mkdir install32/"
|
||||
recreate_64="rm -f -r build64/ && rm -f -r install64/ && mkdir build64/ && mkdir install64/"
|
||||
cmake_gen32="'$mycmake' $cmake_common_args -B build32 -DCMAKE_TOOLCHAIN_FILE=$deps_dir/32-bit-toolchain.cmake -DCMAKE_INSTALL_PREFIX=install32 $cmake_common_defs"
|
||||
cmake_gen64="'$mycmake' $cmake_common_args -B build64 -DCMAKE_TOOLCHAIN_FILE=$deps_dir/64-bit-toolchain.cmake -DCMAKE_INSTALL_PREFIX=install64 $cmake_common_defs"
|
||||
cmake_build32="'$mycmake' --build build32 --config Release --parallel $build_threads $VERBOSITY"
|
||||
cmake_build64="'$mycmake' --build build64 --config Release --parallel $build_threads $VERBOSITY"
|
||||
|
||||
clean_gen32="[[ -d build32 ]] && rm -f -r build32/"
|
||||
clean_gen64="[[ -d build64 ]] && rm -f -r build64/"
|
||||
|
||||
chmod 777 "$mycmake"
|
||||
|
||||
|
||||
############## build ssq ##############
|
||||
echo // building ssq lib
|
||||
tar -zxf "$third_party_dir/v3.0.0.tar.gz" -C "$deps_dir"
|
||||
tar -zxf "$third_party_common_dir/v3.0.0.tar.gz" -C "$deps_dir"
|
||||
|
||||
for i in {1..10}; do
|
||||
mv "$deps_dir/libssq-3.0.0" "$deps_dir/ssq" && { break; } || { sleep 1; }
|
||||
@ -146,11 +152,17 @@ done
|
||||
chmod -R 777 "$deps_dir/ssq"
|
||||
pushd "$deps_dir/ssq"
|
||||
|
||||
eval $recreate_32
|
||||
eval $cmake_gen32
|
||||
last_code=$((last_code + $?))
|
||||
eval $cmake_build32
|
||||
last_code=$((last_code + $?))
|
||||
|
||||
eval $recreate_64
|
||||
eval $cmake_gen64
|
||||
last_code=$((last_code + $?))
|
||||
eval $cmake_build64
|
||||
last_code=$((last_code + $?))
|
||||
|
||||
popd
|
||||
echo ; echo
|
||||
@ -158,7 +170,7 @@ echo ; echo
|
||||
|
||||
############## build zlib ##############
|
||||
echo // building zlib lib
|
||||
tar -zxf "$third_party_dir/zlib-1.3.tar.gz" -C "$deps_dir"
|
||||
tar -zxf "$third_party_common_dir/zlib-1.3.tar.gz" -C "$deps_dir"
|
||||
|
||||
for i in {1..10}; do
|
||||
mv "$deps_dir/zlib-1.3" "$deps_dir/zlib" && { break; } || { sleep 1; }
|
||||
@ -167,11 +179,19 @@ done
|
||||
chmod -R 777 "$deps_dir/zlib"
|
||||
pushd "$deps_dir/zlib"
|
||||
|
||||
eval $recreate_32
|
||||
eval $cmake_gen32
|
||||
last_code=$((last_code + $?))
|
||||
eval $cmake_build32 --target install
|
||||
last_code=$((last_code + $?))
|
||||
eval $clean_gen32
|
||||
|
||||
eval $recreate_64
|
||||
eval $cmake_gen64
|
||||
last_code=$((last_code + $?))
|
||||
eval $cmake_build64 --target install
|
||||
last_code=$((last_code + $?))
|
||||
eval $clean_gen64
|
||||
|
||||
popd
|
||||
echo ; echo
|
||||
@ -216,7 +236,7 @@ wild_zlib_64=(
|
||||
|
||||
############## build curl ##############
|
||||
echo // building curl lib
|
||||
tar -zxf "$third_party_dir/curl-8.4.0.tar.gz" -C "$deps_dir"
|
||||
tar -zxf "$third_party_common_dir/curl-8.4.0.tar.gz" -C "$deps_dir"
|
||||
|
||||
for i in {1..10}; do
|
||||
mv "$deps_dir/curl-8.4.0" "$deps_dir/curl" && { break; } || { sleep 1; }
|
||||
@ -227,11 +247,19 @@ pushd "$deps_dir/curl"
|
||||
|
||||
curl_common_defs="-DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_CURL=OFF -DBUILD_STATIC_LIBS=ON -DCURL_USE_OPENSSL=OFF -DCURL_ZLIB=ON"
|
||||
|
||||
eval $recreate_32
|
||||
eval $cmake_gen32 $curl_common_defs "${wild_zlib_32[@]}" -DCMAKE_SHARED_LINKER_FLAGS_INIT="'$deps_dir/zlib/install32/lib/libz.a'" -DCMAKE_MODULE_LINKER_FLAGS_INIT="'$deps_dir/zlib/install32/lib/libz.a'" -DCMAKE_EXE_LINKER_FLAGS_INIT="'$deps_dir/zlib/install32/lib/libz.a'"
|
||||
last_code=$((last_code + $?))
|
||||
eval $cmake_build32 --target install
|
||||
last_code=$((last_code + $?))
|
||||
eval $clean_gen32
|
||||
|
||||
eval $recreate_64
|
||||
eval $cmake_gen64 $curl_common_defs "${wild_zlib_64[@]}" -DCMAKE_SHARED_LINKER_FLAGS_INIT="'$deps_dir/zlib/install64/lib/libz.a'" -DCMAKE_MODULE_LINKER_FLAGS_INIT="'$deps_dir/zlib/install64/lib/libz.a'" -DCMAKE_EXE_LINKER_FLAGS_INIT="'$deps_dir/zlib/install64/lib/libz.a'"
|
||||
last_code=$((last_code + $?))
|
||||
eval $cmake_build64 --target install
|
||||
last_code=$((last_code + $?))
|
||||
eval $clean_gen64
|
||||
|
||||
popd
|
||||
echo ; echo
|
||||
@ -239,7 +267,7 @@ echo ; echo
|
||||
|
||||
############## build protobuf ##############
|
||||
echo // building protobuf lib
|
||||
tar -zxf "$third_party_dir/v21.12.tar.gz" -C "$deps_dir"
|
||||
tar -zxf "$third_party_common_dir/v21.12.tar.gz" -C "$deps_dir"
|
||||
|
||||
for i in {1..10}; do
|
||||
mv "$deps_dir/protobuf-21.12" "$deps_dir/protobuf" && { break; } || { sleep 1; }
|
||||
@ -250,11 +278,21 @@ pushd "$deps_dir/protobuf"
|
||||
|
||||
proto_common_defs="-Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_WITH_ZLIB=ON"
|
||||
|
||||
eval $recreate_32
|
||||
eval $cmake_gen32 $proto_common_defs "${wild_zlib_32[@]}" -DCMAKE_SHARED_LINKER_FLAGS_INIT="'$deps_dir/zlib/install32/lib/libz.a'" -DCMAKE_MODULE_LINKER_FLAGS_INIT="'$deps_dir/zlib/install32/lib/libz.a'" -DCMAKE_EXE_LINKER_FLAGS_INIT="'$deps_dir/zlib/install32/lib/libz.a'"
|
||||
last_code=$((last_code + $?))
|
||||
eval $cmake_build32 --target install
|
||||
last_code=$((last_code + $?))
|
||||
eval $clean_gen32
|
||||
|
||||
eval $recreate_64
|
||||
eval $cmake_gen64 $proto_common_defs "${wild_zlib_64[@]}" -DCMAKE_SHARED_LINKER_FLAGS_INIT="'$deps_dir/zlib/install64/lib/libz.a'" -DCMAKE_MODULE_LINKER_FLAGS_INIT="'$deps_dir/zlib/install64/lib/libz.a'" -DCMAKE_EXE_LINKER_FLAGS_INIT="'$deps_dir/zlib/install64/lib/libz.a'"
|
||||
last_code=$((last_code + $?))
|
||||
eval $cmake_build64 --target install
|
||||
last_code=$((last_code + $?))
|
||||
eval $clean_gen64
|
||||
|
||||
popd
|
||||
echo ; echo
|
||||
|
||||
exit $last_code
|
||||
|
913
build_win.bat
913
build_win.bat
@ -1,449 +1,464 @@
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
pushd "%~dp0"
|
||||
|
||||
set /a last_code=0
|
||||
|
||||
set /a BUILD_LIB32=1
|
||||
set /a BUILD_LIB64=1
|
||||
|
||||
set /a BUILD_EXP_LIB32=1
|
||||
set /a BUILD_EXP_LIB64=1
|
||||
set /a BUILD_EXP_CLIENT32=1
|
||||
set /a BUILD_EXP_CLIENT64=1
|
||||
|
||||
set /a BUILD_EXPCLIENT32=1
|
||||
set /a BUILD_EXPCLIENT64=1
|
||||
set /a BUILD_EXPCLIENT_LDR=1
|
||||
|
||||
set /a BUILD_TOOL_FIND_ITFS=1
|
||||
set /a BUILD_TOOL_LOBBY=1
|
||||
|
||||
set /a BUILD_WINXP=0
|
||||
set /a BUILD_LOW_PERF=0
|
||||
|
||||
:: < 0: deduce, > 1: force
|
||||
set /a PARALLEL_THREADS_OVERRIDE=-1
|
||||
|
||||
:: 0 = release, 1 = debug, otherwise error
|
||||
set /a BUILD_TYPE=-1
|
||||
|
||||
:: get args
|
||||
:args_loop
|
||||
if "%~1"=="" (
|
||||
goto :args_loop_end
|
||||
) else if "%~1"=="-lib-32" (
|
||||
set /a BUILD_LIB32=0
|
||||
) else if "%~1"=="-lib-64" (
|
||||
set /a BUILD_LIB64=0
|
||||
) else if "%~1"=="-ex-lib-32" (
|
||||
set /a BUILD_EXP_LIB32=0
|
||||
) else if "%~1"=="-ex-lib-64" (
|
||||
set /a BUILD_EXP_LIB64=0
|
||||
) else if "%~1"=="-ex-client-32" (
|
||||
set /a BUILD_EXP_CLIENT32=0
|
||||
) else if "%~1"=="-ex-client-64" (
|
||||
set /a BUILD_EXP_CLIENT64=0
|
||||
) else if "%~1"=="-exclient-32" (
|
||||
set /a BUILD_EXPCLIENT32=0
|
||||
) else if "%~1"=="-exclient-64" (
|
||||
set /a BUILD_EXPCLIENT64=0
|
||||
) else if "%~1"=="-exclient-ldr" (
|
||||
set /a BUILD_EXPCLIENT_LDR=0
|
||||
) else if "%~1"=="-tool-itf" (
|
||||
set /a BUILD_TOOL_FIND_ITFS=0
|
||||
) else if "%~1"=="-tool-lobby" (
|
||||
set /a BUILD_TOOL_LOBBY=0
|
||||
) else if "%~1"=="+lowperf" (
|
||||
set /a BUILD_LOW_PERF=1
|
||||
) else if "%~1"=="-j" (
|
||||
call :get_parallel_threads_count %~2 || (
|
||||
call :err_msg "Invalid arg after -j, expected a number"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
shift /1
|
||||
) else if "%~1"=="release" (
|
||||
set /a BUILD_TYPE=0
|
||||
) else if "%~1"=="debug" (
|
||||
set /a BUILD_TYPE=1
|
||||
) else (
|
||||
call :err_msg "Invalid arg: %~1"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
shift /1
|
||||
goto :args_loop
|
||||
:args_loop_end
|
||||
|
||||
:: use 70%
|
||||
if defined NUMBER_OF_PROCESSORS (
|
||||
set /a build_threads=NUMBER_OF_PROCESSORS*70/100
|
||||
) else (
|
||||
set /a build_threads=2
|
||||
)
|
||||
|
||||
if %PARALLEL_THREADS_OVERRIDE% gtr 0 (
|
||||
set /a build_threads=PARALLEL_THREADS_OVERRIDE
|
||||
)
|
||||
|
||||
if %build_threads% lss 2 (
|
||||
set /a build_threads=2
|
||||
)
|
||||
|
||||
:: build type
|
||||
set "debug_info="
|
||||
set "debug_info_format="
|
||||
set "optimization_level="
|
||||
set "dbg_defs="
|
||||
set "build_folder="
|
||||
if %BUILD_TYPE% equ 0 (
|
||||
set "debug_info=/DEBUG:NONE"
|
||||
set "debug_info_format="
|
||||
set "optimization_level=/Ox /Oi /Ob2 /Ot /O2 /Oy-"
|
||||
set "dbg_defs=/DEMU_RELEASE_BUILD /DNDEBUG"
|
||||
set "build_folder=release"
|
||||
) else if %BUILD_TYPE% equ 1 (
|
||||
set "debug_info=/DEBUG:FULL"
|
||||
set "debug_info_format=/Z7"
|
||||
set "optimization_level=/Od"
|
||||
set "dbg_defs="
|
||||
set "build_folder=debug"
|
||||
) else (
|
||||
call :err_msg "You must specify any of: [release debug]"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
set "additional_compiler_args_32="
|
||||
set "additional_compiler_args_64="
|
||||
|
||||
set "additional_win_linker_args_32="
|
||||
set "additional_win_linker_args_64="
|
||||
|
||||
set "additional_exe_linker_args_32="
|
||||
set "additional_exe_linker_args_64="
|
||||
:: win xp stuff
|
||||
:: https://stackoverflow.com/a/29804473
|
||||
:: https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt
|
||||
:: XXXX THIS DOESN"T WORK XXXX
|
||||
:: XXXX emu code (networking) uses some win APIs available only starting from win Vista XXXX
|
||||
if %BUILD_WINXP% equ 1 (
|
||||
set "additional_compiler_args_32=%additional_compiler_args_32% /D_USING_V110_SDK71_ /DNTDDI_VERSION=0x05010000 /D_WIN32_WINNT=0x0501 /DWINVER=0x0501"
|
||||
set "additional_compiler_args_64=%additional_compiler_args_64% /D_USING_V110_SDK71_ /DNTDDI_VERSION=0x05010000 /D_WIN32_WINNT=0x0501 /DWINVER=0x0501"
|
||||
|
||||
set "additional_win_linker_args_32=%additional_win_linker_args_32% /SUBSYSTEM:WINDOWS,5.01"
|
||||
set "additional_win_linker_args_64=%additional_win_linker_args_64% /SUBSYSTEM:WINDOWS,5.02"
|
||||
|
||||
set "additional_exe_linker_args_32=%additional_exe_linker_args_32% /SUBSYSTEM:CONSOLE,5.01"
|
||||
set "additional_exe_linker_args_64=%additional_exe_linker_args_64% /SUBSYSTEM:CONSOLE,5.02"
|
||||
|
||||
set "build_folder=%build_folder%-win_xp"
|
||||
)
|
||||
|
||||
if %BUILD_LOW_PERF% equ 1 (
|
||||
echo [?] Adding low perf flags
|
||||
set "additional_compiler_args_32=%additional_compiler_args_32% /arch:IA32"
|
||||
|
||||
set "build_folder=%build_folder%-low_perf"
|
||||
)
|
||||
|
||||
|
||||
:: common stuff
|
||||
set "deps_dir=build-win-deps"
|
||||
set "build_root_dir=build-win\%build_folder%"
|
||||
set "build_temp_dir=build-win-temp"
|
||||
set "tools_dir=%build_root_dir%\tools"
|
||||
set "steamclient_dir=%build_root_dir%\experimental_steamclient"
|
||||
set "experimental_dir=%build_root_dir%\experimental"
|
||||
set "find_interfaces_dir=%tools_dir%\find_interfaces"
|
||||
set "lobby_connect_dir=%tools_dir%\lobby_connect"
|
||||
|
||||
set "common_compiler_args=/std:c++17 /MP%build_threads% /DYNAMICBASE /errorReport:none /nologo /utf-8 /EHsc /GF /GL- /GS /Fo%build_temp_dir%\ /Fe%build_temp_dir%\"
|
||||
set "common_compiler_args_32=%common_compiler_args% %additional_compiler_args_32%"
|
||||
set "common_compiler_args_64=%common_compiler_args% %additional_compiler_args_64%"
|
||||
|
||||
set "common_linker_args=/DYNAMICBASE /ERRORREPORT:NONE /NOLOGO"
|
||||
set "common_win_linker_args_32=%common_linker_args% %additional_win_linker_args_32%"
|
||||
set "common_win_linker_args_64=%common_linker_args% %additional_win_linker_args_64%"
|
||||
set "common_exe_linker_args_32=%common_linker_args% %additional_exe_linker_args_32%"
|
||||
set "common_exe_linker_args_64=%common_linker_args% %additional_exe_linker_args_64%"
|
||||
|
||||
set ssq_inc=/I"%deps_dir%\ssq\include"
|
||||
set ssq_lib32="%deps_dir%\ssq\build32\Release\ssq.lib"
|
||||
set ssq_lib64="%deps_dir%\ssq\build64\Release\ssq.lib"
|
||||
|
||||
set curl_inc32=/I"%deps_dir%\curl\install32\include"
|
||||
set curl_inc64=/I"%deps_dir%\curl\install64\include"
|
||||
set curl_lib32="%deps_dir%\curl\install32\lib\libcurl.lib"
|
||||
set curl_lib64="%deps_dir%\curl\install64\lib\libcurl.lib"
|
||||
|
||||
set protob_inc32=/I"%deps_dir%\protobuf\install32\include"
|
||||
set protob_inc64=/I"%deps_dir%\protobuf\install64\include"
|
||||
set protob_lib32="%deps_dir%\protobuf\install32\lib\libprotobuf-lite.lib"
|
||||
set protob_lib64="%deps_dir%\protobuf\install64\lib\libprotobuf-lite.lib"
|
||||
|
||||
set zlib_inc32=/I"%deps_dir%\zlib\install32\include"
|
||||
set zlib_inc64=/I"%deps_dir%\zlib\install64\include"
|
||||
set zlib_lib32="%deps_dir%\zlib\install32\lib\zlibstatic.lib"
|
||||
set zlib_lib64="%deps_dir%\zlib\install64\lib\zlibstatic.lib"
|
||||
|
||||
set release_incs_both=%ssq_inc% /Iutfcpp
|
||||
set release_incs32=%release_incs_both% %curl_inc32% %protob_inc32% %zlib_inc32%
|
||||
set release_incs64=%release_incs_both% %curl_inc64% %protob_inc64% %zlib_inc64%
|
||||
|
||||
set "common_defs=/DUTF_CPP_CPLUSPLUS=201703L /DCURL_STATICLIB /D_MT /DUNICODE /D_UNICODE"
|
||||
set "release_defs=%dbg_defs% %common_defs%"
|
||||
|
||||
:: copied from Visual Studio 2022
|
||||
set "CoreLibraryDependencies=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"
|
||||
set "release_libs_both=%CoreLibraryDependencies% Ws2_32.lib Iphlpapi.lib Wldap32.lib Winmm.lib Bcrypt.lib"
|
||||
|
||||
set release_libs32=%release_libs_both% %ssq_lib32% %curl_lib32% %protob_lib32% %zlib_lib32%
|
||||
set release_libs64=%release_libs_both% %ssq_lib64% %curl_lib64% %protob_lib64% %zlib_lib64%
|
||||
|
||||
set "protoc_exe_32=%deps_dir%\protobuf\install32\bin\protoc.exe"
|
||||
set "protoc_exe_64=%deps_dir%\protobuf\install64\bin\protoc.exe"
|
||||
|
||||
if not exist "%deps_dir%\" (
|
||||
call :err_msg "Dependencies dir was not found"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
if not exist "%protoc_exe_32%" (
|
||||
call :err_msg "protobuff compiler wasn't found - 32"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
if not exist "%protoc_exe_64%" (
|
||||
call :err_msg "protobuff compiler wasn't found - 64"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
echo [?] All build operations will use %build_threads% parallel jobs
|
||||
|
||||
:: prepare folders
|
||||
echo // preparing build folders
|
||||
rmdir /s /q "%build_root_dir%\" >nul 2>&1
|
||||
mkdir "%build_root_dir%\x32"
|
||||
mkdir "%build_root_dir%\x64"
|
||||
|
||||
mkdir "%experimental_dir%\x32"
|
||||
mkdir "%experimental_dir%\x64"
|
||||
|
||||
mkdir "%steamclient_dir%"
|
||||
|
||||
mkdir "%find_interfaces_dir%"
|
||||
mkdir "%lobby_connect_dir%"
|
||||
|
||||
|
||||
:: x32 build
|
||||
setlocal
|
||||
|
||||
echo // cleaning up to build 32
|
||||
call build_win_clean.bat
|
||||
mkdir "%build_temp_dir%"
|
||||
|
||||
echo // invoking protobuf compiler - 32
|
||||
"%protoc_exe_32%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
|
||||
call build_win_set_env.bat 32 || (
|
||||
endlocal
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 32"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
echo: & echo:
|
||||
|
||||
if %BUILD_LIB32% equ 1 (
|
||||
call :compile_lib32
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
if %BUILD_EXP_LIB32% equ 1 (
|
||||
call :compile_experimental_lib32
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
if %BUILD_EXP_CLIENT32% equ 1 (
|
||||
call :compile_experimental_client32
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
if %BUILD_EXPCLIENT32% equ 1 (
|
||||
call :compile_experimentalclient_32
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
:: steamclient_loader
|
||||
if %BUILD_EXPCLIENT_LDR% equ 1 (
|
||||
call :compile_experimentalclient_ldr
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
:: tools (x32)
|
||||
if %BUILD_TOOL_FIND_ITFS% equ 1 (
|
||||
call :compile_tool_itf
|
||||
echo: & echo:
|
||||
)
|
||||
if %BUILD_TOOL_LOBBY% equ 1 (
|
||||
call :compile_tool_lobby
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
endlocal
|
||||
|
||||
|
||||
:: some times the next build will fail, a timeout solved it
|
||||
timeout /nobreak /t 5
|
||||
|
||||
|
||||
:: x64 build
|
||||
setlocal
|
||||
|
||||
echo // cleaning up to build 64
|
||||
call build_win_clean.bat
|
||||
mkdir "%build_temp_dir%"
|
||||
|
||||
echo // invoking protobuf compiler - 64
|
||||
"%protoc_exe_64%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
|
||||
call build_win_set_env.bat 64 || (
|
||||
endlocal
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 64"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
echo: & echo:
|
||||
|
||||
if %BUILD_LIB64% equ 1 (
|
||||
call :compile_lib64
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
if %BUILD_EXP_LIB64% equ 1 (
|
||||
call :compile_experimental_lib64
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
if %BUILD_EXP_CLIENT64% equ 1 (
|
||||
call :compile_experimental_client64
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
if %BUILD_EXPCLIENT64% equ 1 (
|
||||
call :compile_experimentalclient_64
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
endlocal
|
||||
|
||||
|
||||
:: copy configs + examples
|
||||
echo // copying readmes + files examples
|
||||
xcopy /y /s "files_example\*" "%build_root_dir%\"
|
||||
copy /y steamclient_loader\ColdClientLoader.ini "%steamclient_dir%\"
|
||||
copy /y Readme_release.txt "%build_root_dir%\Readme.txt"
|
||||
copy /y Readme_experimental.txt "%experimental_dir%\Readme.txt"
|
||||
copy /y Readme_experimental_steamclient.txt "%steamclient_dir%\Readme.txt"
|
||||
copy /y Readme_generate_interfaces.txt "%find_interfaces_dir%\Readme.txt"
|
||||
copy /y Readme_lobby_connect.txt "%lobby_connect_dir%\Readme.txt"
|
||||
|
||||
|
||||
:: cleanup
|
||||
echo // cleaning up
|
||||
call build_win_clean.bat
|
||||
for %%A in ("ilk" "lib" "exp") do (
|
||||
del /f /s /q "%build_root_dir%\*.%%~A" >nul 2>&1
|
||||
)
|
||||
|
||||
|
||||
goto :end_script
|
||||
|
||||
|
||||
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: x32 + tools
|
||||
:compile_lib32
|
||||
echo // building lib steam_api.dll - 32
|
||||
cl %common_compiler_args_32% %debug_info% %debug_info_format% %optimization_level% %release_defs% /LD %release_incs32% dll/*.cpp dll/*.cc %release_libs32% /link %common_win_linker_args_32% /DLL /OUT:"%build_root_dir%\x32\steam_api.dll"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:compile_experimental_lib32
|
||||
echo // building lib experimental steam_api.dll - 32
|
||||
cl %common_compiler_args_32% %debug_info% %debug_info_format% %optimization_level% %release_defs% /DEMU_EXPERIMENTAL_BUILD /DCONTROLLER_SUPPORT /DEMU_OVERLAY /LD %release_incs32% /IImGui /Ioverlay_experimental dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/backends/imgui_impl_dx*.cpp ImGui/backends/imgui_impl_win32.cpp ImGui/backends/imgui_impl_vulkan.cpp ImGui/backends/imgui_impl_opengl3.cpp ImGui/backends/imgui_win_shader_blobs.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp overlay_experimental/System/*.cpp %release_libs32% /link %common_win_linker_args_32% /DLL /OUT:"%experimental_dir%\x32\steam_api.dll"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:compile_experimental_client32
|
||||
echo // building lib experimental steamclient.dll - 32
|
||||
cl %common_compiler_args_32% %debug_info% %debug_info_format% %optimization_level% %release_defs% /DEMU_EXPERIMENTAL_BUILD /LD %release_incs32% steamclient.cpp %release_libs32% /link %common_win_linker_args_32% /DLL /OUT:"%experimental_dir%\x32\steamclient.dll"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:compile_experimentalclient_32
|
||||
echo // building lib steamclient.dll - 32
|
||||
cl %common_compiler_args_32% %debug_info% %debug_info_format% %optimization_level% %release_defs% /DEMU_EXPERIMENTAL_BUILD /DCONTROLLER_SUPPORT /DEMU_OVERLAY /DSTEAMCLIENT_DLL /LD %release_incs32% /IImGui /Ioverlay_experimental dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/backends/imgui_impl_dx*.cpp ImGui/backends/imgui_impl_win32.cpp ImGui/backends/imgui_impl_vulkan.cpp ImGui/backends/imgui_impl_opengl3.cpp ImGui/backends/imgui_win_shader_blobs.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp overlay_experimental/System/*.cpp %release_libs32% /link %common_win_linker_args_32% /DLL /OUT:"%steamclient_dir%\steamclient.dll"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:compile_experimentalclient_ldr
|
||||
echo // building executable steamclient_loader.exe - 32
|
||||
:: common_win_linker_args_32 isn't a mistake, the entry is wWinMain
|
||||
:: check this table: https://learn.microsoft.com/en-us/cpp/build/reference/entry-entry-point-symbol#remarks
|
||||
cl %common_compiler_args_32% %debug_info% %debug_info_format% %optimization_level% %release_defs% %release_incs32% steamclient_loader/*.cpp %release_libs32% user32.lib /link %common_win_linker_args_32% /OUT:"%steamclient_dir%\steamclient_loader.exe"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:compile_tool_itf
|
||||
echo // building tool generate_interfaces_file.exe - 32
|
||||
cl %common_compiler_args_32% %debug_info% %debug_info_format% %optimization_level% %release_defs% %release_incs32% generate_interfaces_file.cpp %release_libs32% /link %common_exe_linker_args_32% /OUT:"%find_interfaces_dir%\generate_interfaces_file.exe"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:compile_tool_lobby
|
||||
echo // building tool lobby_connect.exe - 32
|
||||
cl %common_compiler_args_32% %debug_info% %debug_info_format% %optimization_level% %release_defs% /DNO_DISK_WRITES /DLOBBY_CONNECT %release_incs32% lobby_connect.cpp dll/*.cpp dll/*.cc %release_libs32% Comdlg32.lib /link %common_exe_linker_args_32% /OUT:"%lobby_connect_dir%\lobby_connect.exe"
|
||||
exit /b %errorlevel%
|
||||
|
||||
|
||||
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: x64
|
||||
:compile_lib64
|
||||
echo // building lib steam_api64.dll - 64
|
||||
cl %common_compiler_args_64% %debug_info% %debug_info_format% %optimization_level% %release_defs% /LD %release_incs64% dll/*.cpp dll/*.cc %release_libs64% /link %common_win_linker_args_64% /DLL /OUT:"%build_root_dir%\x64\steam_api64.dll"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:compile_experimental_lib64
|
||||
echo // building lib experimental steam_api64.dll - 64
|
||||
cl %common_compiler_args_64% %debug_info% %debug_info_format% %optimization_level% %release_defs% /DEMU_EXPERIMENTAL_BUILD /DCONTROLLER_SUPPORT /DEMU_OVERLAY /LD %release_incs64% /IImGui /Ioverlay_experimental dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/backends/imgui_impl_dx*.cpp ImGui/backends/imgui_impl_win32.cpp ImGui/backends/imgui_impl_vulkan.cpp ImGui/backends/imgui_impl_opengl3.cpp ImGui/backends/imgui_win_shader_blobs.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp overlay_experimental/System/*.cpp %release_libs64% opengl32.lib /link %common_win_linker_args_64% /DLL /OUT:"%experimental_dir%\x64\steam_api64.dll"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:compile_experimental_client64
|
||||
echo // building lib experimental steamclient64.dll - 64
|
||||
cl %common_compiler_args_64% %debug_info% %debug_info_format% %optimization_level% %release_defs% /DEMU_EXPERIMENTAL_BUILD /LD %release_incs64% steamclient.cpp %release_libs64% /link %common_win_linker_args_64% /DLL /OUT:"%experimental_dir%\x64\steamclient64.dll"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:compile_experimentalclient_64
|
||||
echo // building lib steamclient64.dll - 64
|
||||
cl %common_compiler_args_64% %debug_info% %debug_info_format% %optimization_level% %release_defs% /DEMU_EXPERIMENTAL_BUILD /DCONTROLLER_SUPPORT /DEMU_OVERLAY /DSTEAMCLIENT_DLL /LD %release_incs64% /IImGui /Ioverlay_experimental dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/backends/imgui_impl_dx*.cpp ImGui/backends/imgui_impl_win32.cpp ImGui/backends/imgui_impl_vulkan.cpp ImGui/backends/imgui_impl_opengl3.cpp ImGui/backends/imgui_win_shader_blobs.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp overlay_experimental/System/*.cpp %release_libs64% opengl32.lib /link %common_win_linker_args_64% /DLL /OUT:"%steamclient_dir%\steamclient64.dll"
|
||||
exit /b %errorlevel%
|
||||
|
||||
|
||||
|
||||
:err_msg
|
||||
1>&2 echo [X] %~1
|
||||
exit /b
|
||||
|
||||
|
||||
:get_parallel_threads_count
|
||||
for /f "tokens=* delims=" %%A in ('echo %~1^| findstr /B /R /X "^[0-9][0-9]*$" 2^>nul') do (
|
||||
set /a PARALLEL_THREADS_OVERRIDE=%~1
|
||||
rem echo [?] Overriding parralel build jobs count with %~1
|
||||
exit /b 0
|
||||
)
|
||||
exit /b 1
|
||||
|
||||
|
||||
:end_script
|
||||
popd
|
||||
endlocal & (
|
||||
exit /b %last_code%
|
||||
)
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
pushd "%~dp0"
|
||||
|
||||
set /a last_code=0
|
||||
|
||||
set /a BUILD_LIB32=1
|
||||
set /a BUILD_LIB64=1
|
||||
|
||||
set /a BUILD_EXP_LIB32=1
|
||||
set /a BUILD_EXP_LIB64=1
|
||||
set /a BUILD_EXP_CLIENT32=1
|
||||
set /a BUILD_EXP_CLIENT64=1
|
||||
|
||||
set /a BUILD_EXPCLIENT32=1
|
||||
set /a BUILD_EXPCLIENT64=1
|
||||
set /a BUILD_EXPCLIENT_LDR=1
|
||||
|
||||
set /a BUILD_TOOL_FIND_ITFS=1
|
||||
set /a BUILD_TOOL_LOBBY=1
|
||||
|
||||
set /a BUILD_WINXP=0
|
||||
set /a BUILD_LOW_PERF=0
|
||||
|
||||
:: < 0: deduce, > 1: force
|
||||
set /a PARALLEL_THREADS_OVERRIDE=-1
|
||||
|
||||
:: 0 = release, 1 = debug, otherwise error
|
||||
set /a BUILD_TYPE=-1
|
||||
|
||||
:: get args
|
||||
:args_loop
|
||||
if "%~1"=="" (
|
||||
goto :args_loop_end
|
||||
) else if "%~1"=="-lib-32" (
|
||||
set /a BUILD_LIB32=0
|
||||
) else if "%~1"=="-lib-64" (
|
||||
set /a BUILD_LIB64=0
|
||||
) else if "%~1"=="-ex-lib-32" (
|
||||
set /a BUILD_EXP_LIB32=0
|
||||
) else if "%~1"=="-ex-lib-64" (
|
||||
set /a BUILD_EXP_LIB64=0
|
||||
) else if "%~1"=="-ex-client-32" (
|
||||
set /a BUILD_EXP_CLIENT32=0
|
||||
) else if "%~1"=="-ex-client-64" (
|
||||
set /a BUILD_EXP_CLIENT64=0
|
||||
) else if "%~1"=="-exclient-32" (
|
||||
set /a BUILD_EXPCLIENT32=0
|
||||
) else if "%~1"=="-exclient-64" (
|
||||
set /a BUILD_EXPCLIENT64=0
|
||||
) else if "%~1"=="-exclient-ldr" (
|
||||
set /a BUILD_EXPCLIENT_LDR=0
|
||||
) else if "%~1"=="-tool-itf" (
|
||||
set /a BUILD_TOOL_FIND_ITFS=0
|
||||
) else if "%~1"=="-tool-lobby" (
|
||||
set /a BUILD_TOOL_LOBBY=0
|
||||
) else if "%~1"=="+lowperf" (
|
||||
set /a BUILD_LOW_PERF=1
|
||||
) else if "%~1"=="-j" (
|
||||
call :get_parallel_threads_count %~2 || (
|
||||
call :err_msg "Invalid arg after -j, expected a number"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
shift /1
|
||||
) else if "%~1"=="release" (
|
||||
set /a BUILD_TYPE=0
|
||||
) else if "%~1"=="debug" (
|
||||
set /a BUILD_TYPE=1
|
||||
) else (
|
||||
call :err_msg "Invalid arg: %~1"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
shift /1
|
||||
goto :args_loop
|
||||
:args_loop_end
|
||||
|
||||
:: use 70%
|
||||
if defined NUMBER_OF_PROCESSORS (
|
||||
set /a build_threads=NUMBER_OF_PROCESSORS*70/100
|
||||
) else (
|
||||
set /a build_threads=2
|
||||
)
|
||||
|
||||
if %PARALLEL_THREADS_OVERRIDE% gtr 0 (
|
||||
set /a build_threads=PARALLEL_THREADS_OVERRIDE
|
||||
)
|
||||
|
||||
if %build_threads% lss 2 (
|
||||
set /a build_threads=2
|
||||
)
|
||||
|
||||
:: build type
|
||||
set "debug_info="
|
||||
set "debug_info_format="
|
||||
set "optimization_level="
|
||||
set "dbg_defs="
|
||||
set "build_folder="
|
||||
if %BUILD_TYPE% equ 0 (
|
||||
set "debug_info=/DEBUG:NONE"
|
||||
set "debug_info_format="
|
||||
set "optimization_level=/Ox /Oi /Ob2 /Ot /O2 /Oy-"
|
||||
set "dbg_defs=/DEMU_RELEASE_BUILD /DNDEBUG"
|
||||
set "build_folder=release"
|
||||
) else if %BUILD_TYPE% equ 1 (
|
||||
set "debug_info=/DEBUG:FULL"
|
||||
set "debug_info_format=/Z7"
|
||||
set "optimization_level=/Od"
|
||||
set "dbg_defs="
|
||||
set "build_folder=debug"
|
||||
) else (
|
||||
call :err_msg "You must specify any of: [release debug]"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
set "additional_compiler_args_32="
|
||||
set "additional_compiler_args_64="
|
||||
|
||||
set "additional_win_linker_args_32="
|
||||
set "additional_win_linker_args_64="
|
||||
|
||||
set "additional_exe_linker_args_32="
|
||||
set "additional_exe_linker_args_64="
|
||||
:: win xp stuff
|
||||
:: https://stackoverflow.com/a/29804473
|
||||
:: https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt
|
||||
:: XXXX THIS DOESN"T WORK XXXX
|
||||
:: XXXX emu code (networking) uses some win APIs available only starting from win Vista XXXX
|
||||
if %BUILD_WINXP% equ 1 (
|
||||
set "additional_compiler_args_32=%additional_compiler_args_32% /D_USING_V110_SDK71_ /DNTDDI_VERSION=0x05010000 /D_WIN32_WINNT=0x0501 /DWINVER=0x0501"
|
||||
set "additional_compiler_args_64=%additional_compiler_args_64% /D_USING_V110_SDK71_ /DNTDDI_VERSION=0x05010000 /D_WIN32_WINNT=0x0501 /DWINVER=0x0501"
|
||||
|
||||
set "additional_win_linker_args_32=%additional_win_linker_args_32% /SUBSYSTEM:WINDOWS,5.01"
|
||||
set "additional_win_linker_args_64=%additional_win_linker_args_64% /SUBSYSTEM:WINDOWS,5.02"
|
||||
|
||||
set "additional_exe_linker_args_32=%additional_exe_linker_args_32% /SUBSYSTEM:CONSOLE,5.01"
|
||||
set "additional_exe_linker_args_64=%additional_exe_linker_args_64% /SUBSYSTEM:CONSOLE,5.02"
|
||||
|
||||
set "build_folder=%build_folder%-win_xp"
|
||||
)
|
||||
|
||||
if %BUILD_LOW_PERF% equ 1 (
|
||||
echo [?] Adding low perf flags
|
||||
set "additional_compiler_args_32=%additional_compiler_args_32% /arch:IA32"
|
||||
|
||||
set "build_folder=%build_folder%-low_perf"
|
||||
)
|
||||
|
||||
|
||||
:: common stuff
|
||||
set "deps_dir=build-win-deps"
|
||||
set "build_root_dir=build-win\%build_folder%"
|
||||
set "build_temp_dir=build-win-temp"
|
||||
set "tools_dir=%build_root_dir%\tools"
|
||||
set "steamclient_dir=%build_root_dir%\experimental_steamclient"
|
||||
set "experimental_dir=%build_root_dir%\experimental"
|
||||
set "find_interfaces_dir=%tools_dir%\find_interfaces"
|
||||
set "lobby_connect_dir=%tools_dir%\lobby_connect"
|
||||
|
||||
set "common_compiler_args=/std:c++17 /MP%build_threads% /DYNAMICBASE /errorReport:none /nologo /utf-8 /EHsc /GF /GL- /GS /Fo%build_temp_dir%\ /Fe%build_temp_dir%\"
|
||||
set "common_compiler_args_32=%common_compiler_args% %additional_compiler_args_32%"
|
||||
set "common_compiler_args_64=%common_compiler_args% %additional_compiler_args_64%"
|
||||
|
||||
set "common_linker_args=/DYNAMICBASE /ERRORREPORT:NONE /NOLOGO"
|
||||
set "common_win_linker_args_32=%common_linker_args% %additional_win_linker_args_32%"
|
||||
set "common_win_linker_args_64=%common_linker_args% %additional_win_linker_args_64%"
|
||||
set "common_exe_linker_args_32=%common_linker_args% %additional_exe_linker_args_32%"
|
||||
set "common_exe_linker_args_64=%common_linker_args% %additional_exe_linker_args_64%"
|
||||
|
||||
set ssq_inc=/I"%deps_dir%\ssq\include"
|
||||
set ssq_lib32="%deps_dir%\ssq\build32\Release\ssq.lib"
|
||||
set ssq_lib64="%deps_dir%\ssq\build64\Release\ssq.lib"
|
||||
|
||||
set curl_inc32=/I"%deps_dir%\curl\install32\include"
|
||||
set curl_inc64=/I"%deps_dir%\curl\install64\include"
|
||||
set curl_lib32="%deps_dir%\curl\install32\lib\libcurl.lib"
|
||||
set curl_lib64="%deps_dir%\curl\install64\lib\libcurl.lib"
|
||||
|
||||
set protob_inc32=/I"%deps_dir%\protobuf\install32\include"
|
||||
set protob_inc64=/I"%deps_dir%\protobuf\install64\include"
|
||||
set protob_lib32="%deps_dir%\protobuf\install32\lib\libprotobuf-lite.lib"
|
||||
set protob_lib64="%deps_dir%\protobuf\install64\lib\libprotobuf-lite.lib"
|
||||
|
||||
set zlib_inc32=/I"%deps_dir%\zlib\install32\include"
|
||||
set zlib_inc64=/I"%deps_dir%\zlib\install64\include"
|
||||
set zlib_lib32="%deps_dir%\zlib\install32\lib\zlibstatic.lib"
|
||||
set zlib_lib64="%deps_dir%\zlib\install64\lib\zlibstatic.lib"
|
||||
|
||||
set release_incs_both=%ssq_inc% /Iutfcpp
|
||||
set release_incs32=%release_incs_both% %curl_inc32% %protob_inc32% %zlib_inc32%
|
||||
set release_incs64=%release_incs_both% %curl_inc64% %protob_inc64% %zlib_inc64%
|
||||
|
||||
set "common_defs=/DUTF_CPP_CPLUSPLUS=201703L /DCURL_STATICLIB /D_MT /DUNICODE /D_UNICODE"
|
||||
set "release_defs=%dbg_defs% %common_defs%"
|
||||
|
||||
:: copied from Visual Studio 2022
|
||||
set "CoreLibraryDependencies=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib"
|
||||
set "release_libs_both=%CoreLibraryDependencies% Ws2_32.lib Iphlpapi.lib Wldap32.lib Winmm.lib Bcrypt.lib"
|
||||
|
||||
set release_libs32=%release_libs_both% %ssq_lib32% %curl_lib32% %protob_lib32% %zlib_lib32%
|
||||
set release_libs64=%release_libs_both% %ssq_lib64% %curl_lib64% %protob_lib64% %zlib_lib64%
|
||||
|
||||
set "protoc_exe_32=%deps_dir%\protobuf\install32\bin\protoc.exe"
|
||||
set "protoc_exe_64=%deps_dir%\protobuf\install64\bin\protoc.exe"
|
||||
|
||||
if not exist "%deps_dir%\" (
|
||||
call :err_msg "Dependencies dir was not found"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
if not exist "%protoc_exe_32%" (
|
||||
call :err_msg "protobuff compiler wasn't found - 32"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
if not exist "%protoc_exe_64%" (
|
||||
call :err_msg "protobuff compiler wasn't found - 64"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
echo [?] All build operations will use %build_threads% parallel jobs
|
||||
|
||||
:: prepare folders
|
||||
echo // preparing build folders
|
||||
rmdir /s /q "%build_root_dir%\" >nul 2>&1
|
||||
mkdir "%build_root_dir%\x32"
|
||||
mkdir "%build_root_dir%\x64"
|
||||
|
||||
mkdir "%experimental_dir%\x32"
|
||||
mkdir "%experimental_dir%\x64"
|
||||
|
||||
mkdir "%steamclient_dir%"
|
||||
|
||||
mkdir "%find_interfaces_dir%"
|
||||
mkdir "%lobby_connect_dir%"
|
||||
|
||||
|
||||
:: x32 build
|
||||
setlocal
|
||||
|
||||
echo // cleaning up to build 32
|
||||
call build_win_clean.bat
|
||||
mkdir "%build_temp_dir%"
|
||||
|
||||
call build_win_set_env.bat 32 || (
|
||||
endlocal
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 32"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
echo // invoking protobuf compiler - 32
|
||||
"%protoc_exe_32%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
|
||||
set /a last_code+=errorlevel
|
||||
echo: & echo:
|
||||
|
||||
if %BUILD_LIB32% equ 1 (
|
||||
call :compile_lib32
|
||||
set /a last_code+=errorlevel
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
if %BUILD_EXP_LIB32% equ 1 (
|
||||
call :compile_experimental_lib32
|
||||
set /a last_code+=errorlevel
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
if %BUILD_EXP_CLIENT32% equ 1 (
|
||||
call :compile_experimental_client32
|
||||
set /a last_code+=errorlevel
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
if %BUILD_EXPCLIENT32% equ 1 (
|
||||
call :compile_experimentalclient_32
|
||||
set /a last_code+=errorlevel
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
:: steamclient_loader
|
||||
if %BUILD_EXPCLIENT_LDR% equ 1 (
|
||||
call :compile_experimentalclient_ldr
|
||||
set /a last_code+=errorlevel
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
:: tools (x32)
|
||||
if %BUILD_TOOL_FIND_ITFS% equ 1 (
|
||||
call :compile_tool_itf
|
||||
set /a last_code+=errorlevel
|
||||
echo: & echo:
|
||||
)
|
||||
if %BUILD_TOOL_LOBBY% equ 1 (
|
||||
call :compile_tool_lobby
|
||||
set /a last_code+=errorlevel
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
endlocal & set /a last_code=%last_code%
|
||||
|
||||
|
||||
:: some times the next build will fail, a timeout solved it
|
||||
timeout /nobreak /t 5
|
||||
|
||||
|
||||
:: x64 build
|
||||
setlocal
|
||||
|
||||
echo // cleaning up to build 64
|
||||
call build_win_clean.bat
|
||||
mkdir "%build_temp_dir%"
|
||||
|
||||
call build_win_set_env.bat 64 || (
|
||||
endlocal
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 64"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
echo // invoking protobuf compiler - 64
|
||||
"%protoc_exe_64%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
|
||||
set /a last_code+=errorlevel
|
||||
echo: & echo:
|
||||
|
||||
if %BUILD_LIB64% equ 1 (
|
||||
call :compile_lib64
|
||||
set /a last_code+=errorlevel
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
if %BUILD_EXP_LIB64% equ 1 (
|
||||
call :compile_experimental_lib64
|
||||
set /a last_code+=errorlevel
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
if %BUILD_EXP_CLIENT64% equ 1 (
|
||||
call :compile_experimental_client64
|
||||
set /a last_code+=errorlevel
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
if %BUILD_EXPCLIENT64% equ 1 (
|
||||
call :compile_experimentalclient_64
|
||||
set /a last_code+=errorlevel
|
||||
echo: & echo:
|
||||
)
|
||||
|
||||
endlocal & set /a last_code=%last_code%
|
||||
|
||||
|
||||
:: copy configs + examples
|
||||
echo // copying readmes + files examples
|
||||
xcopy /y /s "files_example\*" "%build_root_dir%\"
|
||||
copy /y steamclient_loader\ColdClientLoader.ini "%steamclient_dir%\"
|
||||
copy /y Readme_release.txt "%build_root_dir%\Readme.txt"
|
||||
copy /y Readme_experimental.txt "%experimental_dir%\Readme.txt"
|
||||
copy /y Readme_experimental_steamclient.txt "%steamclient_dir%\Readme.txt"
|
||||
copy /y Readme_generate_interfaces.txt "%find_interfaces_dir%\Readme.txt"
|
||||
copy /y Readme_lobby_connect.txt "%lobby_connect_dir%\Readme.txt"
|
||||
|
||||
|
||||
:: cleanup
|
||||
echo // cleaning up
|
||||
call build_win_clean.bat
|
||||
for %%A in ("ilk" "lib" "exp") do (
|
||||
del /f /s /q "%build_root_dir%\*.%%~A" >nul 2>&1
|
||||
)
|
||||
|
||||
|
||||
goto :end_script
|
||||
|
||||
|
||||
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: x32 + tools
|
||||
:compile_lib32
|
||||
echo // building lib steam_api.dll - 32
|
||||
cl %common_compiler_args_32% %debug_info% %debug_info_format% %optimization_level% %release_defs% /LD %release_incs32% dll/*.cpp dll/*.cc %release_libs32% /link %common_win_linker_args_32% /DLL /OUT:"%build_root_dir%\x32\steam_api.dll"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:compile_experimental_lib32
|
||||
echo // building lib experimental steam_api.dll - 32
|
||||
cl %common_compiler_args_32% %debug_info% %debug_info_format% %optimization_level% %release_defs% /DEMU_EXPERIMENTAL_BUILD /DCONTROLLER_SUPPORT /DEMU_OVERLAY /LD %release_incs32% /IImGui /Ioverlay_experimental dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/backends/imgui_impl_dx*.cpp ImGui/backends/imgui_impl_win32.cpp ImGui/backends/imgui_impl_vulkan.cpp ImGui/backends/imgui_impl_opengl3.cpp ImGui/backends/imgui_win_shader_blobs.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp overlay_experimental/System/*.cpp %release_libs32% /link %common_win_linker_args_32% /DLL /OUT:"%experimental_dir%\x32\steam_api.dll"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:compile_experimental_client32
|
||||
echo // building lib experimental steamclient.dll - 32
|
||||
cl %common_compiler_args_32% %debug_info% %debug_info_format% %optimization_level% %release_defs% /DEMU_EXPERIMENTAL_BUILD /LD %release_incs32% steamclient.cpp %release_libs32% /link %common_win_linker_args_32% /DLL /OUT:"%experimental_dir%\x32\steamclient.dll"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:compile_experimentalclient_32
|
||||
echo // building lib steamclient.dll - 32
|
||||
cl %common_compiler_args_32% %debug_info% %debug_info_format% %optimization_level% %release_defs% /DEMU_EXPERIMENTAL_BUILD /DCONTROLLER_SUPPORT /DEMU_OVERLAY /DSTEAMCLIENT_DLL /LD %release_incs32% /IImGui /Ioverlay_experimental dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/backends/imgui_impl_dx*.cpp ImGui/backends/imgui_impl_win32.cpp ImGui/backends/imgui_impl_vulkan.cpp ImGui/backends/imgui_impl_opengl3.cpp ImGui/backends/imgui_win_shader_blobs.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp overlay_experimental/System/*.cpp %release_libs32% /link %common_win_linker_args_32% /DLL /OUT:"%steamclient_dir%\steamclient.dll"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:compile_experimentalclient_ldr
|
||||
echo // building executable steamclient_loader.exe - 32
|
||||
:: common_win_linker_args_32 isn't a mistake, the entry is wWinMain
|
||||
:: check this table: https://learn.microsoft.com/en-us/cpp/build/reference/entry-entry-point-symbol#remarks
|
||||
cl %common_compiler_args_32% %debug_info% %debug_info_format% %optimization_level% %release_defs% %release_incs32% steamclient_loader/*.cpp %release_libs32% user32.lib /link %common_win_linker_args_32% /OUT:"%steamclient_dir%\steamclient_loader.exe"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:compile_tool_itf
|
||||
echo // building tool generate_interfaces_file.exe - 32
|
||||
cl %common_compiler_args_32% %debug_info% %debug_info_format% %optimization_level% %release_defs% %release_incs32% generate_interfaces_file.cpp %release_libs32% /link %common_exe_linker_args_32% /OUT:"%find_interfaces_dir%\generate_interfaces_file.exe"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:compile_tool_lobby
|
||||
echo // building tool lobby_connect.exe - 32
|
||||
cl %common_compiler_args_32% %debug_info% %debug_info_format% %optimization_level% %release_defs% /DNO_DISK_WRITES /DLOBBY_CONNECT %release_incs32% lobby_connect.cpp dll/*.cpp dll/*.cc %release_libs32% Comdlg32.lib /link %common_exe_linker_args_32% /OUT:"%lobby_connect_dir%\lobby_connect.exe"
|
||||
exit /b %errorlevel%
|
||||
|
||||
|
||||
|
||||
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: x64
|
||||
:compile_lib64
|
||||
echo // building lib steam_api64.dll - 64
|
||||
cl %common_compiler_args_64% %debug_info% %debug_info_format% %optimization_level% %release_defs% /LD %release_incs64% dll/*.cpp dll/*.cc %release_libs64% /link %common_win_linker_args_64% /DLL /OUT:"%build_root_dir%\x64\steam_api64.dll"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:compile_experimental_lib64
|
||||
echo // building lib experimental steam_api64.dll - 64
|
||||
cl %common_compiler_args_64% %debug_info% %debug_info_format% %optimization_level% %release_defs% /DEMU_EXPERIMENTAL_BUILD /DCONTROLLER_SUPPORT /DEMU_OVERLAY /LD %release_incs64% /IImGui /Ioverlay_experimental dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/backends/imgui_impl_dx*.cpp ImGui/backends/imgui_impl_win32.cpp ImGui/backends/imgui_impl_vulkan.cpp ImGui/backends/imgui_impl_opengl3.cpp ImGui/backends/imgui_win_shader_blobs.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp overlay_experimental/System/*.cpp %release_libs64% opengl32.lib /link %common_win_linker_args_64% /DLL /OUT:"%experimental_dir%\x64\steam_api64.dll"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:compile_experimental_client64
|
||||
echo // building lib experimental steamclient64.dll - 64
|
||||
cl %common_compiler_args_64% %debug_info% %debug_info_format% %optimization_level% %release_defs% /DEMU_EXPERIMENTAL_BUILD /LD %release_incs64% steamclient.cpp %release_libs64% /link %common_win_linker_args_64% /DLL /OUT:"%experimental_dir%\x64\steamclient64.dll"
|
||||
exit /b %errorlevel%
|
||||
|
||||
:compile_experimentalclient_64
|
||||
echo // building lib steamclient64.dll - 64
|
||||
cl %common_compiler_args_64% %debug_info% %debug_info_format% %optimization_level% %release_defs% /DEMU_EXPERIMENTAL_BUILD /DCONTROLLER_SUPPORT /DEMU_OVERLAY /DSTEAMCLIENT_DLL /LD %release_incs64% /IImGui /Ioverlay_experimental dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/backends/imgui_impl_dx*.cpp ImGui/backends/imgui_impl_win32.cpp ImGui/backends/imgui_impl_vulkan.cpp ImGui/backends/imgui_impl_opengl3.cpp ImGui/backends/imgui_win_shader_blobs.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp overlay_experimental/System/*.cpp %release_libs64% opengl32.lib /link %common_win_linker_args_64% /DLL /OUT:"%steamclient_dir%\steamclient64.dll"
|
||||
exit /b %errorlevel%
|
||||
|
||||
|
||||
|
||||
:err_msg
|
||||
1>&2 echo [X] %~1
|
||||
exit /b
|
||||
|
||||
|
||||
:get_parallel_threads_count
|
||||
for /f "tokens=* delims=" %%A in ('echo %~1^| findstr /B /R /X "^[0-9][0-9]*$" 2^>nul') do (
|
||||
set /a PARALLEL_THREADS_OVERRIDE=%~1
|
||||
rem echo [?] Overriding parralel build jobs count with %~1
|
||||
exit /b 0
|
||||
)
|
||||
exit /b 1
|
||||
|
||||
|
||||
:end_script
|
||||
popd
|
||||
endlocal & (
|
||||
exit /b %last_code%
|
||||
)
|
||||
|
@ -1,349 +1,375 @@
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
pushd "%~dp0"
|
||||
|
||||
set "deps_dir=build-win-deps"
|
||||
set "third_party_dir=third-party"
|
||||
set "extractor=%third_party_dir%\7za-win\7za.exe"
|
||||
set "mycmake=%~dp0%third_party_dir%\cmake-3.27.7-windows-x86_64\bin\cmake.exe"
|
||||
|
||||
if not exist "%extractor%" (
|
||||
call :err_msg "Couldn't find extraction tool"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
if not exist "%mycmake%" (
|
||||
call :err_msg "Couldn't find cmake"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
:: < 0: deduce, > 1: force
|
||||
set /a PARALLEL_THREADS_OVERRIDE=-1
|
||||
|
||||
set "VERBOSITY="
|
||||
|
||||
:: get args
|
||||
:args_loop
|
||||
if "%~1"=="" (
|
||||
goto :args_loop_end
|
||||
) else if "%~1"=="-j" (
|
||||
call :get_parallel_threads_count %~2 || (
|
||||
call :err_msg "Invalid arg after -j, expected a number"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
shift /1
|
||||
) else if "%~1"=="-verbose" (
|
||||
set "VERBOSITY=-v"
|
||||
) else (
|
||||
call :err_msg "Invalid arg: %~1"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
shift /1
|
||||
goto :args_loop
|
||||
:args_loop_end
|
||||
|
||||
:: use 70%
|
||||
if defined NUMBER_OF_PROCESSORS (
|
||||
set /a jobs_count=NUMBER_OF_PROCESSORS*70/100
|
||||
) else (
|
||||
set /a jobs_count=2
|
||||
)
|
||||
|
||||
if %PARALLEL_THREADS_OVERRIDE% gtr 0 (
|
||||
set /a jobs_count=PARALLEL_THREADS_OVERRIDE
|
||||
)
|
||||
|
||||
if %jobs_count% lss 2 (
|
||||
set /a jobs_count=2
|
||||
)
|
||||
|
||||
set /a last_code=0
|
||||
|
||||
call :extract_all_deps
|
||||
|
||||
:: ############## common CMAKE args ##############
|
||||
:: https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS_CONFIG.html#variable:CMAKE_%3CLANG%3E_FLAGS_%3CCONFIG%3E
|
||||
set cmake_common_args=-G "Visual Studio 17 2022" -S .
|
||||
set cmake_common_defs=-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_STANDARD_REQUIRED=ON -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_C_STANDARD=17 -DCMAKE_CXX_STANDARD=17 -DCMAKE_POSITION_INDEPENDENT_CODE=True -DBUILD_SHARED_LIBS=OFF -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded "-DCMAKE_C_FLAGS_RELEASE=/MT /std:c++17 /std:c17 /D_MT" "-DCMAKE_CXX_FLAGS_RELEASE=/MT /std:c++17 /std:c17 /D_MT"
|
||||
set "recreate_32=rmdir /s /q build32\ 1>nul 2>&1 & rmdir /s /q install32\ 1>nul 2>&1 & mkdir build32\ && mkdir install32\"
|
||||
set "recreate_64=rmdir /s /q build64\ 1>nul 2>&1 & rmdir /s /q install64\ 1>nul 2>&1 & mkdir build64\ && mkdir install64\"
|
||||
set cmake_gen32="%mycmake%" %cmake_common_args% -A Win32 -B build32 -DCMAKE_INSTALL_PREFIX=install32 %cmake_common_defs%
|
||||
set cmake_gen64="%mycmake%" %cmake_common_args% -A x64 -B build64 -DCMAKE_INSTALL_PREFIX=install64 %cmake_common_defs%
|
||||
set cmake_build32="%mycmake%" --build build32 --config Release --parallel %jobs_count% %VERBOSITY%
|
||||
set cmake_build64="%mycmake%" --build build64 --config Release --parallel %jobs_count% %VERBOSITY%
|
||||
|
||||
:: "-DCMAKE_C_STANDARD_LIBRARIES=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib" "-DCMAKE_CXX_STANDARD_LIBRARIES=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib"
|
||||
|
||||
:: -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded" "-DMSVC_RUNTIME_LIBRARY=MultiThreaded"
|
||||
|
||||
:: "-DCMAKE_C_STANDARD_LIBRARIES=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib"
|
||||
:: "-DCMAKE_C_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG"
|
||||
|
||||
:: "-DCMAKE_CXX_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG"
|
||||
:: "-DCMAKE_CXX_STANDARD_LIBRARIES=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib"
|
||||
|
||||
:: "-DCMAKE_C_STANDARD_LIBRARIES=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib" "-DCMAKE_C_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG"
|
||||
|
||||
:: "-DCMAKE_CXX_STANDARD_LIBRARIES=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib"
|
||||
:: "-DCMAKE_CXX_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG"
|
||||
|
||||
:: "-DCMAKE_C_STANDARD_LIBRARIES=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib" "-DCMAKE_CXX_STANDARD_LIBRARIES=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib"
|
||||
|
||||
echo // [?] All CMAKE builds will use %jobs_count% parallel jobs
|
||||
|
||||
:: ############## build ssq ##############
|
||||
echo // building ssq lib
|
||||
pushd "%deps_dir%\ssq"
|
||||
|
||||
setlocal
|
||||
call "%~dp0build_win_set_env.bat" 32 || (
|
||||
endlocal
|
||||
popd
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 32"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
%recreate_32%
|
||||
%cmake_gen32%
|
||||
%cmake_build32%
|
||||
endlocal
|
||||
|
||||
setlocal
|
||||
call "%~dp0build_win_set_env.bat" 64 || (
|
||||
endlocal
|
||||
popd
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 64"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
%recreate_64%
|
||||
%cmake_gen64%
|
||||
%cmake_build64%
|
||||
endlocal
|
||||
|
||||
popd
|
||||
echo: & echo:
|
||||
|
||||
|
||||
:: ############## build zlib ##############
|
||||
echo // building zlib lib
|
||||
pushd "%deps_dir%\zlib"
|
||||
|
||||
setlocal
|
||||
call "%~dp0build_win_set_env.bat" 32 || (
|
||||
endlocal
|
||||
popd
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 32"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
%recreate_32%
|
||||
%cmake_gen32%
|
||||
%cmake_build32% --target install
|
||||
endlocal
|
||||
|
||||
setlocal
|
||||
call "%~dp0build_win_set_env.bat" 64 || (
|
||||
endlocal
|
||||
popd
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 64"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
%recreate_64%
|
||||
%cmake_gen64%
|
||||
%cmake_build64% --target install
|
||||
endlocal
|
||||
|
||||
popd
|
||||
echo: & echo:
|
||||
|
||||
|
||||
:: ############## zlib is painful ##############
|
||||
:: lib curl uses the default search paths, even when ZLIB_INCLUDE_DIR and ZLIB_LIBRARY_RELEASE are defined
|
||||
:: check thir CMakeLists.txt line #573
|
||||
:: optional_dependency(ZLIB)
|
||||
:: if(ZLIB_FOUND)
|
||||
:: set(HAVE_LIBZ ON)
|
||||
:: set(USE_ZLIB ON)
|
||||
::
|
||||
:: # Depend on ZLIB via imported targets if supported by the running
|
||||
:: # version of CMake. This allows our dependents to get our dependencies
|
||||
:: # transitively.
|
||||
:: if(NOT CMAKE_VERSION VERSION_LESS 3.4)
|
||||
:: list(APPEND CURL_LIBS ZLIB::ZLIB) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< evil
|
||||
:: else()
|
||||
:: list(APPEND CURL_LIBS ${ZLIB_LIBRARIES})
|
||||
:: include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
:: endif()
|
||||
:: list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS})
|
||||
:: endif()
|
||||
:: we have to set the ZLIB_ROOT so that it is prepended to the search list
|
||||
:: we have to set ZLIB_LIBRARY NOT ZLIB_LIBRARY_RELEASE in order to override the FindZlib module
|
||||
:: we also should set ZLIB_USE_STATIC_LIBS since we want to force static builds
|
||||
:: https://github.com/Kitware/CMake/blob/a6853135f569f0b040a34374a15a8361bb73901b/Modules/FindZLIB.cmake#L98C4-L98C13
|
||||
set wild_zlib_32=-DZLIB_USE_STATIC_LIBS=ON "-DZLIB_ROOT=%~dp0%deps_dir%\zlib\install32" "-DZLIB_INCLUDE_DIR=%~dp0%deps_dir%\zlib\install32\include" "-DZLIB_LIBRARY=%~dp0%deps_dir%\zlib\install32\lib\zlibstatic.lib"
|
||||
set wild_zlib_64=-DZLIB_USE_STATIC_LIBS=ON "-DZLIB_ROOT=%~dp0%deps_dir%\zlib\install64" "-DZLIB_INCLUDE_DIR=%~dp0%deps_dir%\zlib\install64\include" "-DZLIB_LIBRARY=%~dp0%deps_dir%\zlib\install64\lib\zlibstatic.lib"
|
||||
|
||||
|
||||
:: ############## build curl ##############
|
||||
echo // building curl lib
|
||||
pushd "%deps_dir%\curl"
|
||||
|
||||
:: CURL_STATICLIB
|
||||
set "curl_common_defs=-DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_CURL=OFF -DBUILD_STATIC_LIBS=ON -DCURL_USE_OPENSSL=OFF -DCURL_ZLIB=ON -DENABLE_UNICODE=ON -DCURL_STATIC_CRT=ON"
|
||||
|
||||
setlocal
|
||||
call "%~dp0build_win_set_env.bat" 32 || (
|
||||
endlocal
|
||||
popd
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 32"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
%recreate_32%
|
||||
%cmake_gen32% %curl_common_defs% %wild_zlib_32% "-DCMAKE_SHARED_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install32\lib\zlibstatic.lib" "-DCMAKE_MODULE_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install32\lib\zlibstatic.lib" "-DCMAKE_EXE_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install32\lib\zlibstatic.lib"
|
||||
%cmake_build32% --target install
|
||||
endlocal
|
||||
|
||||
setlocal
|
||||
call "%~dp0build_win_set_env.bat" 64 || (
|
||||
endlocal
|
||||
popd
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 64"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
%recreate_64%
|
||||
%cmake_gen64% %curl_common_defs% %wild_zlib_64% "-DCMAKE_SHARED_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install64\lib\zlibstatic.lib" "-DCMAKE_MODULE_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install64\lib\zlibstatic.lib" "-DCMAKE_EXE_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install64\lib\zlibstatic.lib"
|
||||
%cmake_build64% --target install
|
||||
endlocal
|
||||
|
||||
popd
|
||||
echo: & echo:
|
||||
|
||||
|
||||
:: ############## build protobuf ##############
|
||||
echo // building protobuf lib
|
||||
pushd "%deps_dir%\protobuf"
|
||||
|
||||
set "proto_common_defs=-Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_WITH_ZLIB=ON"
|
||||
|
||||
setlocal
|
||||
call "%~dp0build_win_set_env.bat" 32 || (
|
||||
endlocal
|
||||
popd
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 32"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
%recreate_32%
|
||||
%cmake_gen32% %proto_common_defs% %wild_zlib_32% "-DCMAKE_SHARED_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install32\lib\zlibstatic.lib" "-DCMAKE_MODULE_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install32\lib\zlibstatic.lib" "-DCMAKE_EXE_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install32\lib\zlibstatic.lib"
|
||||
%cmake_build32% --target install
|
||||
endlocal
|
||||
|
||||
setlocal
|
||||
call "%~dp0build_win_set_env.bat" 64 || (
|
||||
endlocal
|
||||
popd
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 64"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
%recreate_64%
|
||||
%cmake_gen64% %proto_common_defs% %wild_zlib_64% "-DCMAKE_SHARED_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install64\lib\zlibstatic.lib" "-DCMAKE_MODULE_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install64\lib\zlibstatic.lib" "-DCMAKE_EXE_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install64\lib\zlibstatic.lib"
|
||||
%cmake_build64% --target install
|
||||
endlocal
|
||||
|
||||
popd
|
||||
echo: & echo:
|
||||
|
||||
|
||||
goto :end_script
|
||||
|
||||
|
||||
:extract_all_deps
|
||||
set /a list=-1
|
||||
for /f "tokens=1 delims=:" %%A in ('findstr /B /L /N /C:"deps_to_extract=[" "%~f0" 2^>nul') do (
|
||||
set /a "list=%%~A"
|
||||
)
|
||||
if "%list%"=="-1" (
|
||||
call :err_msg "Couldn't find list of tools to extract inside thif batch script"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
rmdir /s /q "%deps_dir%"
|
||||
mkdir "%deps_dir%"
|
||||
for /f "usebackq eol=; skip=%list% tokens=1,2 delims=|" %%A in ("%~f0") do (
|
||||
if "%%~A"=="]" (
|
||||
goto :extract_all_deps_end
|
||||
)
|
||||
|
||||
echo // Extracting archive "%third_party_dir%\%%~A" to "%deps_dir%\%%~B"
|
||||
for /f "usebackq tokens=* delims=" %%Z in ('"%%~nA"') do (
|
||||
if /i "%%~xZ%%~xA"==".tar.gz" (
|
||||
"%extractor%" x "%third_party_dir%\%%~A" -so | "%extractor%" x -si -ttar -y -aoa -o"%deps_dir%\%%~B" || (
|
||||
call :err_msg "Extraction failed"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
) else (
|
||||
"%extractor%" x "%third_party_dir%\%%~A" -y -aoa -o"%deps_dir%\%%~B" || (
|
||||
call :err_msg "Extraction failed"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
for /f "tokens=* delims=" %%C in ('dir /b /a:d "%deps_dir%\%%~B\" 2^>nul') do (
|
||||
echo // Flattening dir "%deps_dir%\%%~B\%%~C" by moving everything inside it to "%deps_dir%\%%~B"
|
||||
robocopy /E /MOVE /MT4 /NS /NC /NFL /NDL /NP /NJH /NJS "%deps_dir%\%%~B\%%~C" "%deps_dir%\%%~B"
|
||||
if ERRORLEVEL 8 (
|
||||
call :err_msg "Failed to flatten dir of dep"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
if exist "%deps_dir%\%%~B\%%~C" (
|
||||
echo // Removing nested dir "%deps_dir%\%%~B\%%~C"
|
||||
rmdir /s /q "%deps_dir%\%%~B\%%~C"
|
||||
)
|
||||
)
|
||||
|
||||
)
|
||||
:extract_all_deps_end
|
||||
exit /b
|
||||
|
||||
:err_msg
|
||||
1>&2 echo [X] %~1
|
||||
exit /b
|
||||
|
||||
:get_parallel_threads_count
|
||||
for /f "tokens=* delims=" %%A in ('echo %~1^| findstr /B /R /X "^[0-9][0-9]*$" 2^>nul') do (
|
||||
set /a PARALLEL_THREADS_OVERRIDE=%~1
|
||||
rem echo [?] Overriding parralel build jobs count with %~1
|
||||
exit /b 0
|
||||
)
|
||||
exit /b 1
|
||||
|
||||
:end_script
|
||||
popd
|
||||
endlocal & (
|
||||
exit /b %last_code%
|
||||
)
|
||||
|
||||
|
||||
deps_to_extract=[
|
||||
v3.0.0.tar.gz|ssq
|
||||
zlib-1.3.tar.gz|zlib
|
||||
curl-8.4.0.tar.gz|curl
|
||||
v21.12.tar.gz|protobuf
|
||||
]
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
pushd "%~dp0"
|
||||
|
||||
set "deps_dir=build-win-deps"
|
||||
set "third_party_dir=third-party"
|
||||
set "third_party_deps_dir=%third_party_dir%\deps\win"
|
||||
set "third_party_common_dir=%third_party_dir%\deps\common\src"
|
||||
set "extractor=%third_party_deps_dir%\7za-win\7za.exe"
|
||||
set "mycmake=%~dp0%third_party_deps_dir%\cmake-3.27.7-windows-x86_64\bin\cmake.exe"
|
||||
|
||||
set /a last_code=0
|
||||
|
||||
if not exist "%extractor%" (
|
||||
call :err_msg "Couldn't find extraction tool"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
if not exist "%mycmake%" (
|
||||
call :err_msg "Couldn't find cmake"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
:: < 0: deduce, > 1: force
|
||||
set /a PARALLEL_THREADS_OVERRIDE=-1
|
||||
|
||||
set "VERBOSITY="
|
||||
|
||||
:: get args
|
||||
:args_loop
|
||||
if "%~1"=="" (
|
||||
goto :args_loop_end
|
||||
) else if "%~1"=="-j" (
|
||||
call :get_parallel_threads_count %~2 || (
|
||||
call :err_msg "Invalid arg after -j, expected a number"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
shift /1
|
||||
) else if "%~1"=="-verbose" (
|
||||
set "VERBOSITY=-v"
|
||||
) else (
|
||||
call :err_msg "Invalid arg: %~1"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
shift /1
|
||||
goto :args_loop
|
||||
:args_loop_end
|
||||
|
||||
:: use 70%
|
||||
if defined NUMBER_OF_PROCESSORS (
|
||||
set /a jobs_count=NUMBER_OF_PROCESSORS*70/100
|
||||
) else (
|
||||
set /a jobs_count=2
|
||||
)
|
||||
|
||||
if %PARALLEL_THREADS_OVERRIDE% gtr 0 (
|
||||
set /a jobs_count=PARALLEL_THREADS_OVERRIDE
|
||||
)
|
||||
|
||||
if %jobs_count% lss 2 (
|
||||
set /a jobs_count=2
|
||||
)
|
||||
|
||||
call :extract_all_deps
|
||||
|
||||
:: ############## common CMAKE args ##############
|
||||
:: https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS_CONFIG.html#variable:CMAKE_%3CLANG%3E_FLAGS_%3CCONFIG%3E
|
||||
set cmake_common_args=-G "Visual Studio 17 2022" -S .
|
||||
set cmake_common_defs=-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_STANDARD_REQUIRED=ON -DCMAKE_CXX_STANDARD_REQUIRED=ON -DCMAKE_C_STANDARD=17 -DCMAKE_CXX_STANDARD=17 -DCMAKE_POSITION_INDEPENDENT_CODE=True -DBUILD_SHARED_LIBS=OFF -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded "-DCMAKE_C_FLAGS_RELEASE=/MT /std:c++17 /std:c17 /D_MT" "-DCMAKE_CXX_FLAGS_RELEASE=/MT /std:c++17 /std:c17 /D_MT"
|
||||
set "recreate_32=rmdir /s /q build32\ 1>nul 2>&1 & rmdir /s /q install32\ 1>nul 2>&1 & mkdir build32\ && mkdir install32\"
|
||||
set "recreate_64=rmdir /s /q build64\ 1>nul 2>&1 & rmdir /s /q install64\ 1>nul 2>&1 & mkdir build64\ && mkdir install64\"
|
||||
set cmake_gen32="%mycmake%" %cmake_common_args% -A Win32 -B build32 -DCMAKE_INSTALL_PREFIX=install32 %cmake_common_defs%
|
||||
set cmake_gen64="%mycmake%" %cmake_common_args% -A x64 -B build64 -DCMAKE_INSTALL_PREFIX=install64 %cmake_common_defs%
|
||||
set cmake_build32="%mycmake%" --build build32 --config Release --parallel %jobs_count% %VERBOSITY%
|
||||
set cmake_build64="%mycmake%" --build build64 --config Release --parallel %jobs_count% %VERBOSITY%
|
||||
set "clean_gen32=if exist build32\ rmdir /s /q build32"
|
||||
set "clean_gen64=if exist build64\ rmdir /s /q build64"
|
||||
|
||||
:: "-DCMAKE_C_STANDARD_LIBRARIES=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib" "-DCMAKE_CXX_STANDARD_LIBRARIES=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib"
|
||||
|
||||
:: -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded" "-DMSVC_RUNTIME_LIBRARY=MultiThreaded"
|
||||
|
||||
:: "-DCMAKE_C_STANDARD_LIBRARIES=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib"
|
||||
:: "-DCMAKE_C_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG"
|
||||
|
||||
:: "-DCMAKE_CXX_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG"
|
||||
:: "-DCMAKE_CXX_STANDARD_LIBRARIES=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib"
|
||||
|
||||
:: "-DCMAKE_C_STANDARD_LIBRARIES=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib" "-DCMAKE_C_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG"
|
||||
|
||||
:: "-DCMAKE_CXX_STANDARD_LIBRARIES=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib"
|
||||
:: "-DCMAKE_CXX_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG"
|
||||
|
||||
:: "-DCMAKE_C_STANDARD_LIBRARIES=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib" "-DCMAKE_CXX_STANDARD_LIBRARIES=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib"
|
||||
|
||||
echo // [?] All CMAKE builds will use %jobs_count% parallel jobs
|
||||
|
||||
:: ############## build ssq ##############
|
||||
echo // building ssq lib
|
||||
pushd "%deps_dir%\ssq"
|
||||
|
||||
setlocal
|
||||
call "%~dp0build_win_set_env.bat" 32 || (
|
||||
endlocal
|
||||
popd
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 32"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
%recreate_32%
|
||||
%cmake_gen32%
|
||||
set /a _exit=errorlevel
|
||||
%cmake_build32%
|
||||
set /a _exit+=errorlevel
|
||||
endlocal & set /a last_code+=%_exit%
|
||||
|
||||
setlocal
|
||||
call "%~dp0build_win_set_env.bat" 64 || (
|
||||
endlocal
|
||||
popd
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 64"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
%recreate_64%
|
||||
%cmake_gen64%
|
||||
set /a _exit=errorlevel
|
||||
%cmake_build64%
|
||||
set /a _exit+=errorlevel
|
||||
endlocal & set /a last_code+=%_exit%
|
||||
|
||||
popd
|
||||
echo: & echo:
|
||||
|
||||
|
||||
:: ############## build zlib ##############
|
||||
echo // building zlib lib
|
||||
pushd "%deps_dir%\zlib"
|
||||
|
||||
setlocal
|
||||
call "%~dp0build_win_set_env.bat" 32 || (
|
||||
endlocal
|
||||
popd
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 32"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
%recreate_32%
|
||||
%cmake_gen32%
|
||||
set /a _exit=errorlevel
|
||||
%cmake_build32% --target install
|
||||
set /a _exit+=errorlevel
|
||||
%clean_gen32%
|
||||
endlocal & set /a last_code+=%_exit%
|
||||
|
||||
setlocal
|
||||
call "%~dp0build_win_set_env.bat" 64 || (
|
||||
endlocal
|
||||
popd
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 64"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
%recreate_64%
|
||||
%cmake_gen64%
|
||||
set /a _exit=errorlevel
|
||||
%cmake_build64% --target install
|
||||
set /a _exit+=errorlevel
|
||||
%clean_gen64%
|
||||
endlocal & set /a last_code+=%_exit%
|
||||
|
||||
popd
|
||||
echo: & echo:
|
||||
|
||||
|
||||
:: ############## zlib is painful ##############
|
||||
:: lib curl uses the default search paths, even when ZLIB_INCLUDE_DIR and ZLIB_LIBRARY_RELEASE are defined
|
||||
:: check thir CMakeLists.txt line #573
|
||||
:: optional_dependency(ZLIB)
|
||||
:: if(ZLIB_FOUND)
|
||||
:: set(HAVE_LIBZ ON)
|
||||
:: set(USE_ZLIB ON)
|
||||
::
|
||||
:: # Depend on ZLIB via imported targets if supported by the running
|
||||
:: # version of CMake. This allows our dependents to get our dependencies
|
||||
:: # transitively.
|
||||
:: if(NOT CMAKE_VERSION VERSION_LESS 3.4)
|
||||
:: list(APPEND CURL_LIBS ZLIB::ZLIB) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< evil
|
||||
:: else()
|
||||
:: list(APPEND CURL_LIBS ${ZLIB_LIBRARIES})
|
||||
:: include_directories(${ZLIB_INCLUDE_DIRS})
|
||||
:: endif()
|
||||
:: list(APPEND CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS})
|
||||
:: endif()
|
||||
:: we have to set the ZLIB_ROOT so that it is prepended to the search list
|
||||
:: we have to set ZLIB_LIBRARY NOT ZLIB_LIBRARY_RELEASE in order to override the FindZlib module
|
||||
:: we also should set ZLIB_USE_STATIC_LIBS since we want to force static builds
|
||||
:: https://github.com/Kitware/CMake/blob/a6853135f569f0b040a34374a15a8361bb73901b/Modules/FindZLIB.cmake#L98C4-L98C13
|
||||
set wild_zlib_32=-DZLIB_USE_STATIC_LIBS=ON "-DZLIB_ROOT=%~dp0%deps_dir%\zlib\install32" "-DZLIB_INCLUDE_DIR=%~dp0%deps_dir%\zlib\install32\include" "-DZLIB_LIBRARY=%~dp0%deps_dir%\zlib\install32\lib\zlibstatic.lib"
|
||||
set wild_zlib_64=-DZLIB_USE_STATIC_LIBS=ON "-DZLIB_ROOT=%~dp0%deps_dir%\zlib\install64" "-DZLIB_INCLUDE_DIR=%~dp0%deps_dir%\zlib\install64\include" "-DZLIB_LIBRARY=%~dp0%deps_dir%\zlib\install64\lib\zlibstatic.lib"
|
||||
|
||||
|
||||
:: ############## build curl ##############
|
||||
echo // building curl lib
|
||||
pushd "%deps_dir%\curl"
|
||||
|
||||
:: CURL_STATICLIB
|
||||
set "curl_common_defs=-DBUILD_CURL_EXE=OFF -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_CURL=OFF -DBUILD_STATIC_LIBS=ON -DCURL_USE_OPENSSL=OFF -DCURL_ZLIB=ON -DENABLE_UNICODE=ON -DCURL_STATIC_CRT=ON"
|
||||
|
||||
setlocal
|
||||
call "%~dp0build_win_set_env.bat" 32 || (
|
||||
endlocal
|
||||
popd
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 32"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
%recreate_32%
|
||||
%cmake_gen32% %curl_common_defs% %wild_zlib_32% "-DCMAKE_SHARED_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install32\lib\zlibstatic.lib" "-DCMAKE_MODULE_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install32\lib\zlibstatic.lib" "-DCMAKE_EXE_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install32\lib\zlibstatic.lib"
|
||||
set /a _exit=errorlevel
|
||||
%cmake_build32% --target install
|
||||
set /a _exit+=errorlevel
|
||||
%clean_gen32%
|
||||
endlocal & set /a last_code+=%_exit%
|
||||
|
||||
setlocal
|
||||
call "%~dp0build_win_set_env.bat" 64 || (
|
||||
endlocal
|
||||
popd
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 64"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
%recreate_64%
|
||||
%cmake_gen64% %curl_common_defs% %wild_zlib_64% "-DCMAKE_SHARED_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install64\lib\zlibstatic.lib" "-DCMAKE_MODULE_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install64\lib\zlibstatic.lib" "-DCMAKE_EXE_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install64\lib\zlibstatic.lib"
|
||||
set /a _exit=errorlevel
|
||||
%cmake_build64% --target install
|
||||
set /a _exit+=errorlevel
|
||||
%clean_gen64%
|
||||
endlocal & set /a last_code+=%_exit%
|
||||
|
||||
popd
|
||||
echo: & echo:
|
||||
|
||||
|
||||
:: ############## build protobuf ##############
|
||||
echo // building protobuf lib
|
||||
pushd "%deps_dir%\protobuf"
|
||||
|
||||
set "proto_common_defs=-Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_WITH_ZLIB=ON"
|
||||
|
||||
setlocal
|
||||
call "%~dp0build_win_set_env.bat" 32 || (
|
||||
endlocal
|
||||
popd
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 32"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
%recreate_32%
|
||||
%cmake_gen32% %proto_common_defs% %wild_zlib_32% "-DCMAKE_SHARED_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install32\lib\zlibstatic.lib" "-DCMAKE_MODULE_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install32\lib\zlibstatic.lib" "-DCMAKE_EXE_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install32\lib\zlibstatic.lib"
|
||||
set /a _exit=errorlevel
|
||||
%cmake_build32% --target install
|
||||
set /a _exit+=errorlevel
|
||||
%clean_gen32%
|
||||
endlocal & set /a last_code+=%_exit%
|
||||
|
||||
setlocal
|
||||
call "%~dp0build_win_set_env.bat" 64 || (
|
||||
endlocal
|
||||
popd
|
||||
call :err_msg "Couldn't find Visual Studio or build tools - 64"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
%recreate_64%
|
||||
%cmake_gen64% %proto_common_defs% %wild_zlib_64% "-DCMAKE_SHARED_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install64\lib\zlibstatic.lib" "-DCMAKE_MODULE_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install64\lib\zlibstatic.lib" "-DCMAKE_EXE_LINKER_FLAGS_INIT=%~dp0%deps_dir%\zlib\install64\lib\zlibstatic.lib"
|
||||
set /a _exit=errorlevel
|
||||
%cmake_build64% --target install
|
||||
set /a _exit+=errorlevel
|
||||
%clean_gen64%
|
||||
endlocal & set /a last_code+=%_exit%
|
||||
|
||||
popd
|
||||
echo: & echo:
|
||||
|
||||
|
||||
goto :end_script
|
||||
|
||||
|
||||
:extract_all_deps
|
||||
set /a list=-1
|
||||
for /f "tokens=1 delims=:" %%A in ('findstr /B /L /N /C:"deps_to_extract=[" "%~f0" 2^>nul') do (
|
||||
set /a "list=%%~A"
|
||||
)
|
||||
if "%list%"=="-1" (
|
||||
call :err_msg "Couldn't find list of tools to extract inside thif batch script"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
rmdir /s /q "%deps_dir%"
|
||||
mkdir "%deps_dir%"
|
||||
for /f "usebackq eol=; skip=%list% tokens=1,2 delims=|" %%A in ("%~f0") do (
|
||||
if "%%~A"=="]" (
|
||||
goto :extract_all_deps_end
|
||||
)
|
||||
|
||||
echo // Extracting archive "%third_party_common_dir%\%%~A" to "%deps_dir%\%%~B"
|
||||
for /f "usebackq tokens=* delims=" %%Z in ('"%%~nA"') do (
|
||||
if /i "%%~xZ%%~xA"==".tar.gz" (
|
||||
"%extractor%" x "%third_party_common_dir%\%%~A" -so | "%extractor%" x -si -ttar -y -aoa -o"%deps_dir%\%%~B" || (
|
||||
call :err_msg "Extraction failed"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
) else (
|
||||
"%extractor%" x "%third_party_common_dir%\%%~A" -y -aoa -o"%deps_dir%\%%~B" || (
|
||||
call :err_msg "Extraction failed"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
for /f "tokens=* delims=" %%C in ('dir /b /a:d "%deps_dir%\%%~B\" 2^>nul') do (
|
||||
echo // Flattening dir "%deps_dir%\%%~B\%%~C" by moving everything inside it to "%deps_dir%\%%~B"
|
||||
robocopy /E /MOVE /MT4 /NS /NC /NFL /NDL /NP /NJH /NJS "%deps_dir%\%%~B\%%~C" "%deps_dir%\%%~B"
|
||||
if ERRORLEVEL 8 (
|
||||
call :err_msg "Failed to flatten dir of dep"
|
||||
set /a last_code=1
|
||||
goto :end_script
|
||||
)
|
||||
|
||||
if exist "%deps_dir%\%%~B\%%~C" (
|
||||
echo // Removing nested dir "%deps_dir%\%%~B\%%~C"
|
||||
rmdir /s /q "%deps_dir%\%%~B\%%~C"
|
||||
)
|
||||
)
|
||||
|
||||
)
|
||||
:extract_all_deps_end
|
||||
exit /b
|
||||
|
||||
:err_msg
|
||||
1>&2 echo [X] %~1
|
||||
exit /b
|
||||
|
||||
:get_parallel_threads_count
|
||||
for /f "tokens=* delims=" %%A in ('echo %~1^| findstr /B /R /X "^[0-9][0-9]*$" 2^>nul') do (
|
||||
set /a PARALLEL_THREADS_OVERRIDE=%~1
|
||||
rem echo [?] Overriding parralel build jobs count with %~1
|
||||
exit /b 0
|
||||
)
|
||||
exit /b 1
|
||||
|
||||
:end_script
|
||||
popd
|
||||
endlocal & (
|
||||
exit /b %last_code%
|
||||
)
|
||||
|
||||
|
||||
deps_to_extract=[
|
||||
v3.0.0.tar.gz|ssq
|
||||
zlib-1.3.tar.gz|zlib
|
||||
curl-8.4.0.tar.gz|curl
|
||||
v21.12.tar.gz|protobuf
|
||||
]
|
||||
|
@ -1,62 +1,70 @@
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
pushd "%~dp0"
|
||||
|
||||
:: Put in the base path in which Visual Studio is installed, examples:
|
||||
::set "vs_static_path=C:\Program Files\Microsoft Visual Studio\2022\BuildTools"
|
||||
::set "vs_static_path=C:\Program Files\Microsoft Visual Studio\2022\Community"
|
||||
::set "vs_static_path=C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
|
||||
set "vs_static_path="
|
||||
|
||||
set "third_party_dir=third-party"
|
||||
|
||||
set "arch="
|
||||
if "%~1"=="32" (
|
||||
set "arch=32"
|
||||
) else if "%~1"=="64" (
|
||||
set "arch=64"
|
||||
) else (
|
||||
call :err_msg "First arg may be any of [32 64]"
|
||||
goto :end_script_with_err
|
||||
)
|
||||
|
||||
|
||||
set "my_vs_path=%vs_static_path%"
|
||||
if "%my_vs_path%"=="" (
|
||||
for /f "tokens=* delims=" %%A in ('"%third_party_dir%\vswhere.exe" -prerelease -latest -nocolor -nologo -property installationPath 2^>nul') do (
|
||||
set "my_vs_path=%%~A\VC\Auxiliary\Build"
|
||||
)
|
||||
)
|
||||
|
||||
if not exist "%my_vs_path%\vcvars%arch%.bat" (
|
||||
set "my_vs_path="
|
||||
)
|
||||
|
||||
if "%my_vs_path%"=="" (
|
||||
call :err_msg "Visual Studio couldn't be found, set its path in the script %~nx0"
|
||||
goto :end_script_with_err
|
||||
)
|
||||
|
||||
echo:
|
||||
echo Using Visual Studio found in: "%my_vs_path%"
|
||||
popd
|
||||
endlocal & (
|
||||
call "%my_vs_path%\vcvars%arch%.bat" && (
|
||||
exit /b 0
|
||||
) || (
|
||||
1>&2 echo [X] Visual Studio script "vcvars%arch%.bat" failed
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
:err_msg
|
||||
1>&2 echo [X] %~1
|
||||
exit /b
|
||||
|
||||
:end_script_with_err
|
||||
popd
|
||||
endlocal & (
|
||||
exit /b 1
|
||||
)
|
||||
@echo off
|
||||
|
||||
setlocal
|
||||
pushd "%~dp0"
|
||||
|
||||
:: Put in the base path in which Visual Studio is installed, examples:
|
||||
::set "vs_static_path=C:\Program Files\Microsoft Visual Studio\2022\BuildTools"
|
||||
::set "vs_static_path=C:\Program Files\Microsoft Visual Studio\2022\Community"
|
||||
::set "vs_static_path=C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
|
||||
set "vs_static_path="
|
||||
|
||||
set "third_party_dir=third-party"
|
||||
set "third_party_common_dir=%third_party_dir%\common\win"
|
||||
|
||||
if not exist "%third_party_common_dir%\vswhere\vswhere.exe" (
|
||||
call :err_msg "vswhere.exe wasn't found in third-party folder"
|
||||
goto :end_script_with_err
|
||||
)
|
||||
|
||||
set "arch="
|
||||
if "%~1"=="32" (
|
||||
set "arch=32"
|
||||
) else if "%~1"=="64" (
|
||||
set "arch=64"
|
||||
) else (
|
||||
call :err_msg "First arg may be any of [32 64]"
|
||||
goto :end_script_with_err
|
||||
)
|
||||
|
||||
|
||||
set "my_vs_path=%vs_static_path%"
|
||||
if "%my_vs_path%"=="" (
|
||||
for /f "tokens=* delims=" %%A in ('"%third_party_common_dir%\vswhere\vswhere.exe" -prerelease -latest -nocolor -nologo -property installationPath 2^>nul') do (
|
||||
set "my_vs_path=%%~A\VC\Auxiliary\Build"
|
||||
)
|
||||
)
|
||||
|
||||
if not exist "%my_vs_path%\vcvars%arch%.bat" (
|
||||
set "my_vs_path="
|
||||
)
|
||||
|
||||
if "%my_vs_path%"=="" (
|
||||
call :err_msg "Visual Studio couldn't be found, set its path in the script %~nx0"
|
||||
goto :end_script_with_err
|
||||
)
|
||||
|
||||
echo:
|
||||
echo Using Visual Studio found in: "%my_vs_path%"
|
||||
popd
|
||||
endlocal & (
|
||||
call "%my_vs_path%\vcvars%arch%.bat" && (
|
||||
echo: & echo:
|
||||
exit /b 0
|
||||
) || (
|
||||
1>&2 echo [X] Visual Studio script "vcvars%arch%.bat" failed
|
||||
echo: & echo:
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
:err_msg
|
||||
1>&2 echo [X] %~1
|
||||
exit /b
|
||||
|
||||
:end_script_with_err
|
||||
popd
|
||||
endlocal & (
|
||||
exit /b 1
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user