From 73ea3c20cc574152bd06f40091b9aadb82c8b260 Mon Sep 17 00:00:00 2001 From: otavepto <153766569+otavepto@users.noreply.github.com> Date: Thu, 30 May 2024 01:01:47 +0300 Subject: [PATCH] remove all bash/batch deps build scripts --- build_linux_deps.sh | 459 ------------------------------------ build_win_deps.bat | 530 ------------------------------------------ build_win_set_env.bat | 69 ------ 3 files changed, 1058 deletions(-) delete mode 100644 build_linux_deps.sh delete mode 100644 build_win_deps.bat delete mode 100644 build_win_set_env.bat diff --git a/build_linux_deps.sh b/build_linux_deps.sh deleted file mode 100644 index b5f23c8c..00000000 --- a/build_linux_deps.sh +++ /dev/null @@ -1,459 +0,0 @@ -#!/usr/bin/env bash - - -############## helpful commands ############## -### to read header of .elf file -#readelf -h install32/lib/libcurl.a - -### list all options availble in a CMAKE project, everything prefixed with CMAKE_ are specific to CMAKE system -#cmake -LAH - -### list all exports in a shared lib -# https://linux.die.net/man/1/nm -#nm -D --defined-only libsteam.so | grep " T " - -# common stuff -script_dir=$( cd -- "$( dirname -- "${0}" )" &> /dev/null && pwd ) -deps_dir="$script_dir/build/deps/linux" -third_party_dir="$script_dir/third-party" -third_party_deps_dir="$third_party_dir/deps/linux" -third_party_common_dir="$third_party_dir/deps/common" -mycmake="$third_party_deps_dir/cmake/bin/cmake" - -deps_archives=( - "libssq/libssq.tar.gz" - "zlib/zlib.tar.gz" - "curl/curl.tar.gz" - "protobuf/protobuf.tar.gz" - "mbedtls/mbedtls.tar.gz" - "ingame_overlay/ingame_overlay.tar.gz" -) - -# < 0: deduce, > 1: force -PARALLEL_THREADS_OVERRIDE=-1 -VERBOSITY='' -INSTALL_PACKAGES=1 -INSTALL_PACKAGES_ONLY=0 - -for (( i=1; i<=$#; i++ )); do - var="${!i}" - if [[ "$var" = "-j" ]]; then - i=$((i+1)) - PARALLEL_THREADS_OVERRIDE="${!i}" - [[ "$PARALLEL_THREADS_OVERRIDE" =~ ^[0-9]+$ ]] || { - echo "[X] Invalid arg after -j, expected a number" >&2; - exit 1; - } - #echo "[?] Overriding parralel build jobs count with $PARALLEL_THREADS_OVERRIDE" - elif [[ "$var" = "-verbose" ]]; then - VERBOSITY='-v' - elif [[ "$var" = "-packages_skip" ]]; then - INSTALL_PACKAGES=0 - elif [[ "$var" = "-packages_only" ]]; then - INSTALL_PACKAGES_ONLY=1 - else - echo "[X] Invalid arg: $var" >&2 - exit 1 - fi -done - - -last_code=0 - - -############## required packages ############## -echo // installing required packages - -all_packages=( - "coreutils" # echo, printf, etc... - "tar" # we need to extract packages - "build-essential" - "gcc-multilib" # needed for 32-bit builds - "g++-multilib" - "clang" - "libglx-dev" # needed for overlay build (header files such as GL/glx.h) - "libgl-dev" # needed for overlay build (header files such as GL/gl.h) - "binutils" # (optional) contains the tool 'readelf' mainly, and other usefull binary stuff -) - -if [[ "$INSTALL_PACKAGES" -ne 0 ]]; then - if [ "$(id -u)" -ne 0 ]; then - # if sudo exist, use sudo. - if type sudo > /dev/null 2>&1; then - apt_run() { sudo apt "$@" -y || exit $? ; } - else - echo "Please run as root, install sudo or pass '-packages_skip' argument." >&2 - exit 1 - fi - else - apt_run() { apt "$@" -y || exit $? ; } - fi - - apt_run update - last_code=$((last_code + $?)) - - for dep in "${all_packages[@]}"; do - apt_run install "$dep" - last_code=$((last_code + $?)) - done - - # exit early if we should install packages only, used by CI mainly - [[ "$INSTALL_PACKAGES_ONLY" -ne 0 ]] && exit $last_code -else - echo "Package installation skipped, please be sure the follow packages correspond to your distro is installed." - echo "${all_packages[*]}" -fi - -echo; echo; - - -[[ -f "$mycmake" ]] || { - echo "[X] Couldn't find cmake" >&2; - exit 1; -} - -# use 70% -build_threads="$(( $(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 0) * 70 / 100 ))" -[[ $PARALLEL_THREADS_OVERRIDE -gt 0 ]] && build_threads="$PARALLEL_THREADS_OVERRIDE" -[[ $build_threads -lt 1 ]] && build_threads=1 - - -############## 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_POSITION_INDEPENDENT_CODE=True -DBUILD_SHARED_LIBS=OFF" -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/" - - -echo =========================== -echo Tools will be installed in: "$deps_dir" -echo Building with $build_threads threads -echo =========================== -echo // Recreating dir... -rm -r -f "$deps_dir" -sleep 1 -mkdir -p "$deps_dir" || { - echo "Couldn't create dir \"$deps_dir\"" >&2; - exit 1; -} - -echo; echo - - -############## copy CMAKE toolchains to the home directory -echo // creating CMAKE toolchains in "$deps_dir" -cat > "$deps_dir/32-bit-toolchain.cmake" << EOL -# cmake -G "xx" ... -DCMAKE_TOOLCHAIN_FILE=/.../64bit.toolchain -# https://github.com/google/boringssl/blob/master/util/32-bit-toolchain.cmake -# https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html#toolchain-files -# https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html#cross-compiling-for-a-microcontroller -# the name of the target operating system -set(CMAKE_SYSTEM_NAME Linux) - -# which compilers to use for C and C++ -set(CMAKE_C_COMPILER clang) -set(CMAKE_CXX_COMPILER clang++) - -set(CMAKE_C_FLAGS_INIT "-m32") -set(CMAKE_CXX_FLAGS_INIT "-m32") -EOL - -cat > "$deps_dir/64-bit-toolchain.cmake" << EOL -# cmake -G "xx" ... -DCMAKE_TOOLCHAIN_FILE=/.../64bit.toolchain -# https://github.com/google/boringssl/blob/master/util/32-bit-toolchain.cmake -# https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html#toolchain-files -# https://cmake.org/cmake/help/book/mastering-cmake/chapter/Cross%20Compiling%20With%20CMake.html#cross-compiling-for-a-microcontroller -# the name of the target operating system -set(CMAKE_SYSTEM_NAME Linux) - -# which compilers to use for C and C++ -set(CMAKE_C_COMPILER clang) -set(CMAKE_CXX_COMPILER clang++) -EOL - -echo; echo; - -chmod 777 "$mycmake" - - -# the artificial delays "sleep 3" are here because on Windows WSL the -# explorer or search indexer keeps a handle open and causes an error here -echo // extracting archives -dotglob_state="$( shopt -p dotglob )" -for f in "${deps_archives[@]}"; do - src_arch="$third_party_common_dir/$f" - [[ -f "$src_arch" ]] || { - echo "[X] archive '"$src_arch"' not found"; - exit 1; - } - - target_dir="$deps_dir/$( dirname "$f" )" - mkdir -p "$target_dir" - - echo - extracting archive "'$f'" into "'$target_dir'" - tar -zxf "$src_arch" -C "$target_dir" - sleep 2 - - echo - flattening dir "'$target_dir'" by moving everything in a subdir outside - shopt -s dotglob - for i in {1..10}; do - mv "$target_dir"/*/** "$target_dir/" && { break; } || { sleep 1; } - done - eval $dotglob_state - sleep 2 - - chmod -R 777 "$target_dir" - sleep 1 - - echo; -done - - -############## build ssq ############## -echo // building ssq lib -pushd "$deps_dir/libssq" - -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; - - -############## build zlib ############## -echo // building zlib lib -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; - - -############## 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 -wild_zlib_32=( - "-DZLIB_USE_STATIC_LIBS=ON" - "-DZLIB_ROOT='$deps_dir/zlib/install32'" - "-DZLIB_INCLUDE_DIR='$deps_dir/zlib/install32/include'" - "-DZLIB_LIBRARY='$deps_dir/zlib/install32/lib/libz.a'" -) -wild_zlib_64=( - "-DZLIB_USE_STATIC_LIBS=ON" - "-DZLIB_ROOT='$deps_dir/zlib/install64'" - "-DZLIB_INCLUDE_DIR='$deps_dir/zlib/install64/include'" - "-DZLIB_LIBRARY='$deps_dir/zlib/install64/lib/libz.a'" -) - - -############## build curl ############## -echo // building curl lib -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 -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBPSL=OFF -DUSE_LIBIDN2=OFF -DCURL_DISABLE_LDAP=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; - - -############## build protobuf ############## -echo // building protobuf lib -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; - - -############## build mbedtls ############## -echo // building mbedtls lib -pushd "$deps_dir/mbedtls" - -# AES-NI on mbedtls v3.5.x: -# https://github.com/Mbed-TLS/mbedtls/issues/8400 -# https://github.com/Mbed-TLS/mbedtls/issues/8334 -# clang/gcc compiler flags ref: -# https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#index-mmmx -# instruction set details -# https://en.wikipedia.org/wiki/CLMUL_instruction_set -# https://en.wikipedia.org/wiki/AES_instruction_set -# https://en.wikipedia.org/wiki/SSE2 - -mbedtls_common_defs="-DUSE_STATIC_MBEDTLS_LIBRARY=ON -DUSE_SHARED_MBEDTLS_LIBRARY=OFF -DENABLE_TESTING=OFF -DENABLE_PROGRAMS=OFF -DLINK_WITH_PTHREAD=ON" - -eval $recreate_32 -CFLAGS='-mpclmul -msse2 -maes' eval $cmake_gen32 $mbedtls_common_defs -last_code=$((last_code + $?)) -eval $cmake_build32 --target install -last_code=$((last_code + $?)) -eval $clean_gen32 - -eval $recreate_64 -eval $cmake_gen64 $mbedtls_common_defs -last_code=$((last_code + $?)) -eval $cmake_build64 --target install -last_code=$((last_code + $?)) -eval $clean_gen64 - -popd -echo; echo; - - -############## build ingame_overlay ############## -echo // building ingame_overlay lib -pushd "$deps_dir/ingame_overlay" - -_imgui_cfg_file="$(pwd)/imconfig.imcfg" -cat > "$_imgui_cfg_file" << EOL -#pragma once -#define ImTextureID ImU64 -EOL - -ingame_overlay_common_defs="'-DIMGUI_USER_CONFIG=$_imgui_cfg_file' -DINGAMEOVERLAY_USE_SYSTEM_LIBRARIES=OFF -DINGAMEOVERLAY_USE_SPDLOG=OFF -DINGAMEOVERLAY_BUILD_TESTS=OFF" - -echo; echo "// building ingame_overlay [System dep x32]" -pushd "deps/System" -eval $recreate_32 -eval $cmake_gen32 "-DCMAKE_CXX_FLAGS_RELEASE='-include cstdint -include cinttypes'" -DBUILD_SYSTEMLIB_TESTS=OFF -last_code=$((last_code + $?)) -eval $cmake_build32 --target install -last_code=$((last_code + $?)) -eval $clean_gen32 -popd - -echo; echo "// building ingame_overlay [mini_detour dep x32]" -pushd "deps/mini_detour" -eval $recreate_32 -eval $cmake_gen32 -DBUILD_MINIDETOUR_TESTS=OFF -last_code=$((last_code + $?)) -eval $cmake_build32 --target install -last_code=$((last_code + $?)) -eval $clean_gen32 -popd - -echo; echo "// building ingame_overlay [main lib x32]" -eval $recreate_32 -eval $cmake_gen32 "-DCMAKE_CXX_FLAGS_RELEASE='-include cstdint -include cinttypes'" $ingame_overlay_common_defs -last_code=$((last_code + $?)) -eval $cmake_build32 --target install -last_code=$((last_code + $?)) -eval $clean_gen32 - -echo; echo "// building ingame_overlay [System dep x64]" -pushd "deps/System" -eval $recreate_64 -eval $cmake_gen64 "-DCMAKE_CXX_FLAGS_RELEASE='-include cstdint -include cinttypes'" -DBUILD_SYSTEMLIB_TESTS=OFF -last_code=$((last_code + $?)) -eval $cmake_build64 --target install -last_code=$((last_code + $?)) -eval $clean_gen64 -popd - -echo; echo "// building ingame_overlay [mini_detour dep x64]" -pushd "deps/mini_detour" -eval $recreate_64 -eval $cmake_gen64 -DBUILD_MINIDETOUR_TESTS=OFF -last_code=$((last_code + $?)) -eval $cmake_build64 --target install -last_code=$((last_code + $?)) -eval $clean_gen64 -popd - -echo; echo "// building ingame_overlay [main lib x64]" -eval $recreate_64 -eval $cmake_gen64 "-DCMAKE_CXX_FLAGS_RELEASE='-include cstdint -include cinttypes'" $ingame_overlay_common_defs -last_code=$((last_code + $?)) -eval $cmake_build64 --target install -last_code=$((last_code + $?)) -eval $clean_gen64 - -popd -echo; echo; - - -echo; -if [[ $last_code = 0 ]]; then - echo "[GG] no failures" -else - echo "[XX] general failure" >&2 -fi - -exit $last_code diff --git a/build_win_deps.bat b/build_win_deps.bat deleted file mode 100644 index f717a538..00000000 --- a/build_win_deps.bat +++ /dev/null @@ -1,530 +0,0 @@ -@echo off - -setlocal -pushd "%~dp0" - -set "deps_dir=build\deps\win" -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" -set "extractor=%third_party_deps_dir%\7za\7za.exe" -set "mycmake=%~dp0%third_party_deps_dir%\cmake\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 1 ( - set /a jobs_count=1 -) - - -:: ############## 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_POSITION_INDEPENDENT_CODE=True -DBUILD_SHARED_LIBS=OFF -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded "-DCMAKE_C_FLAGS_RELEASE=/MT /D_MT" "-DCMAKE_CXX_FLAGS_RELEASE=/MT /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" - - -call :extract_all_deps || ( - set /a last_code=1 - goto :end_script -) - - -echo // [?] All CMAKE builds will use %jobs_count% parallel jobs - -:: ############## build ssq ############## -echo // building ssq lib -pushd "%deps_dir%\libssq" - -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=%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=%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=%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=%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 -DCURL_USE_LIBSSH2=OFF -DCURL_USE_LIBPSL=OFF -DUSE_LIBIDN2=OFF -DCURL_DISABLE_LDAP=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=%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=%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=%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=%last_code%+%_exit% - -popd -echo: & echo: - - -:: ############## build mbedtls ############## -echo // building mbedtls lib -pushd "%deps_dir%\mbedtls" - -set "mbedtls_common_defs=-DUSE_STATIC_MBEDTLS_LIBRARY=ON -DUSE_SHARED_MBEDTLS_LIBRARY=OFF -DMSVC_STATIC_RUNTIME=ON -DENABLE_TESTING=OFF -DENABLE_PROGRAMS=OFF" - -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% %mbedtls_common_defs% -set /a _exit=%errorlevel% -%cmake_build32% --target install -set /a _exit+=%errorlevel% -%clean_gen32% -endlocal & set /a last_code=%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% %mbedtls_common_defs% -set /a _exit=%errorlevel% -%cmake_build64% --target install -set /a _exit+=%errorlevel% -%clean_gen64% -endlocal & set /a last_code=%last_code%+%_exit% - -popd -echo: & echo: - - -:: ############## build ingame_overlay ############## -echo // building ingame_overlay lib -pushd "%deps_dir%\ingame_overlay" - -:: fixes 32-bit compilation of DX12 -set "_imgui_cfg_file=%cd%\imconfig.imcfg" -1>"%_imgui_cfg_file%" ( - echo #pragma once - echo #define ImTextureID ImU64 -) -set ingame_overlay_common_defs="-DIMGUI_USER_CONFIG=%_imgui_cfg_file:\=/%" -DINGAMEOVERLAY_USE_SYSTEM_LIBRARIES=OFF -DINGAMEOVERLAY_USE_SPDLOG=OFF -DINGAMEOVERLAY_BUILD_TESTS=OFF - -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 -) - -echo: -echo // building ingame_overlay [System dep x32] -pushd "deps\System" -%recreate_32% -%cmake_gen32% -DBUILD_SYSTEMLIB_TESTS=OFF -set /a _exit=%errorlevel% -%cmake_build32% --target install -set /a _exit+=%errorlevel% -%clean_gen32% -popd - -echo: -echo // building ingame_overlay [mini_detour dep x32] -pushd "deps\mini_detour" -%recreate_32% -%cmake_gen32% -DBUILD_MINIDETOUR_TESTS=OFF -set /a _exit+=%errorlevel% -%cmake_build32% --target install -set /a _exit+=%errorlevel% -%clean_gen32% -popd - -echo: -echo // building ingame_overlay [main lib x32] -%recreate_32% -%cmake_gen32% %ingame_overlay_common_defs% -set /a _exit+=%errorlevel% -%cmake_build32% --target install -set /a _exit+=%errorlevel% -%clean_gen32% -endlocal & set /a last_code=%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 -) - -echo: -echo // building ingame_overlay [System dep x64] -pushd "deps\System" -%recreate_64% -%cmake_gen64% -DBUILD_SYSTEMLIB_TESTS=OFF -set /a _exit=%errorlevel% -%cmake_build64% --target install -set /a _exit+=%errorlevel% -%clean_gen64% -popd - -echo: -echo // building ingame_overlay [mini_detour dep x64] -pushd "deps\mini_detour" -%recreate_64% -%cmake_gen64% -DBUILD_MINIDETOUR_TESTS=OFF -set /a _exit+=%errorlevel% -%cmake_build64% --target install -set /a _exit+=%errorlevel% -%clean_gen64% -popd - -echo: -echo // building ingame_overlay [main lib x64] -%recreate_64% -%cmake_gen64% %ingame_overlay_common_defs% -set /a _exit+=%errorlevel% -%cmake_build64% --target install -set /a _exit+=%errorlevel% -%clean_gen64% -endlocal & set /a last_code=%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" - exit /b 1 - ) - - echo // Recreating dir... - rmdir /s /q "%deps_dir%" - mkdir "%deps_dir%" - for /f "usebackq eol=; skip=%list% tokens=1,* delims=\" %%A in ("%~f0") do ( - if "%%~A"=="]" ( - goto :extract_all_deps_end - ) - - echo // Extracting archive "%%~B" to "%deps_dir%\%%~A" - if not exist "%third_party_common_dir%\%%~A\%%~B" ( - call :err_msg "File not found" - exit /b 1 - ) - for /f "usebackq tokens=* delims=" %%Z in ('"%%~nB"') do ( - if /i "%%~xZ%%~xB"==".tar.gz" ( - "%extractor%" x "%third_party_common_dir%\%%~A\%%~B" -so | "%extractor%" x -si -ttar -y -aoa -o"%deps_dir%\%%~A" || ( - call :err_msg "Extraction failed" - exit /b 1 - ) - ) else ( - "%extractor%" x "%third_party_common_dir%\%%~A\%%~B" -y -aoa -o"%deps_dir%\%%~A" || ( - call :err_msg "Extraction failed" - exit /b 1 - ) - ) - ) - - for /f "tokens=* delims=" %%C in ('dir /b /a:d "%deps_dir%\%%~A\" 2^>nul') do ( - echo // Flattening dir "%deps_dir%\%%~A\%%~C" by moving everything inside it to "%deps_dir%\%%~A" - robocopy /E /MOVE /MT4 /NS /NC /NFL /NDL /NP /NJH /NJS "%deps_dir%\%%~A\%%~C" "%deps_dir%\%%~A" - if ERRORLEVEL 8 ( - call :err_msg "Failed to flatten dir of dep" - exit /b 1 - ) - - if exist "%deps_dir%\%%~A\%%~C" ( - echo // Removing nested dir "%deps_dir%\%%~A\%%~C" - rmdir /s /q "%deps_dir%\%%~A\%%~C" - ) - ) - - ) -:extract_all_deps_end -exit /b 0 - -: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 -echo: -if %last_code% equ 0 ( - echo [GG] no failures -) else ( - 1>&2 echo [XX] general failure -) -popd -endlocal & ( - exit /b %last_code% -) - - -deps_to_extract=[ -libssq\libssq.tar.gz -zlib\zlib.tar.gz -curl\curl.tar.gz -protobuf\protobuf.tar.gz -mbedtls\mbedtls.tar.gz -ingame_overlay\ingame_overlay.tar.gz -] diff --git a/build_win_set_env.bat b/build_win_set_env.bat deleted file mode 100644 index 5cf14176..00000000 --- a/build_win_set_env.bat +++ /dev/null @@ -1,69 +0,0 @@ -@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 "vswhere_exe=third-party\common\win\vswhere\vswhere.exe" - -if not exist "%vswhere_exe%" ( - call :err_msg "vswhere.exe wasn't found" - 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 ('"%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 -)