diff --git a/.github/workflows/emu-build-all-macos.yml b/.github/workflows/emu-build-all-macos.yml deleted file mode 100644 index 9805bf0d..00000000 --- a/.github/workflows/emu-build-all-macos.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: Build all emu variants (macos) - -on: - workflow_call: - # needed since it allows this to become a reusable workflow - workflow_dispatch: - # allows manual trigger - -permissions: - contents: write - -jobs: - deps: - name: Restore or build deps - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-deps-macos.yml - - emu-regular-x64-release: - name: Regular x64 (release) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-macos.yml - with: - emu-variant: regular - debug: false - - emu-regular-x64-debug: - name: Regular x64 (debug) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-macos.yml - with: - emu-variant: regular - debug: true - - emu-exp-x64-release: - name: Experimental x64 (release) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-macos.yml - with: - emu-variant: exp - debug: false - - emu-exp-x64-debug: - name: Experimental x64 (debug) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-macos.yml - with: - emu-variant: exp - debug: true - - tools-x64-release: - name: Tools x64 (release) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-macos.yml - with: - emu-variant: tools - debug: false - - tools-x64-debug: - name: Tools x64 (debug) - needs: [ deps ] - if: ${{ !cancelled() }} - uses: ./.github/workflows/emu-build-variant-macos.yml - with: - emu-variant: tools - debug: true diff --git a/.github/workflows/emu-build-variant-macos.yml b/.github/workflows/emu-build-variant-macos.yml deleted file mode 100644 index 2255c555..00000000 --- a/.github/workflows/emu-build-variant-macos.yml +++ /dev/null @@ -1,116 +0,0 @@ -name: Build emu variant (macos) - -on: - workflow_call: - inputs: - emu-variant: - description: | - Which variant of the emu to build: - regular: build the regular version of the emu - exp: build the experimental version of the emu - tools: build the tools only - required: true - type: string - - debug: - description: | - build mode - true: build in debug mode - false: build in release mode - required: true - type: boolean - -permissions: - contents: write - -env: - DEPS_CACHE_KEY: emu-deps-macos - DEPS_CACHE_DIR: build/deps/macos - - PACKAGE_BASE_DIR: "build/package/macos" - THIRD_PARTY_BASE_DIR: 'third-party' - -jobs: - build: - runs-on: macos-13 - if: ${{ !cancelled() }} - - steps: -### setup build vars - - name: Setup build vars - shell: bash - run: | - echo "env file = '$GITHUB_ENV'" - echo "workspace = '${{ github.workspace }}'" - - build_switches="" - if [[ "${{ inputs.emu-variant }}" = "regular" ]]; then - build_switches="+lib-64 +client-64" - elif [[ "${{ inputs.emu-variant }}" = "exp" ]]; then - build_switches="+exp-lib-64 +exp-client-64" - elif [[ "${{ inputs.emu-variant }}" = "tools" ]]; then - build_switches="+tool-clientldr +tool-itf-64 +tool-lobby-64" - else - echo "[X] invalid emu variant '${{ inputs.emu-variant }}'" >&2 - exit 1 - fi - echo "build_switches=$build_switches" >>"$GITHUB_ENV" - - build_mode="" - if [[ "${{ inputs.debug }}" = "true" ]]; then - build_mode="debug" - else - build_mode="release" - fi - echo "build_mode=$build_mode" >>"$GITHUB_ENV" - - - name: Checkout branch - uses: actions/checkout@v4 - -### deps - - name: Restore deps - id: emu-deps-cache-step - uses: actions/cache@v4 - with: - key: ${{ env.DEPS_CACHE_KEY }} - path: ${{ env.DEPS_CACHE_DIR }} - -### macos comes with bash v3 - - name: Update bash - shell: bash - run: brew update && brew install bash - -## mandatory macos packages, installed via sudo apt install ... - - name: Install required packages - shell: bash - run: sudo chmod 777 build_macos_deps.sh && ./build_macos_deps.sh -verbose -packages_only - -## extra helpers/tools, these are not built inside the deps build dir - - name: Clone third-party build helpers (build/macos) - uses: actions/checkout@v4 - with: - ref: 'third-party/build/macos' - path: "${{env.THIRD_PARTY_BASE_DIR}}/build/macos" - -### fix folder permissions! not sure why this fails - # nested subdirs "build/macos/release" cause permission problems - - name: Give all permissions to repo folder - shell: bash - working-directory: ${{ github.workspace }} - run: sudo chmod -R 777 "${{ github.workspace }}" - -### build target(s) - - name: Build target(s) - shell: bash - working-directory: ${{ github.workspace }} - run: "sudo chmod 777 build_macos.sh && ./build_macos.sh -j 3 -verbose ${{ env.build_mode }} clean +build_str ${{ github.sha }} ${{ env.build_switches }}" - -### upload artifact/package to github Actions (for targets) - - name: Upload build package (for targets) - uses: actions/upload-artifact@v4 - with: - name: "emu-macos-${{ inputs.emu-variant }}-64-${{ env.build_mode }}-${{ github.sha }}" - path: "build/macos/" - if-no-files-found: 'error' - compression-level: 9 - retention-days: 1 diff --git a/.github/workflows/emu-deps-macos.yml b/.github/workflows/emu-deps-macos.yml deleted file mode 100644 index 631be5fa..00000000 --- a/.github/workflows/emu-deps-macos.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: Emu third-party dependencies (macos) - -on: - workflow_call: - # needed since it allows this to become a reusable workflow - workflow_dispatch: - # allows manual trigger - -permissions: - contents: write - -env: - DEPS_CACHE_KEY: emu-deps-macos - DEPS_CACHE_DIR: build/deps/macos - - PACKAGE_BASE_DIR: "build/package/macos" - THIRD_PARTY_BASE_DIR: 'third-party' - -jobs: - deps-build: - runs-on: macos-13 - if: ${{ !cancelled() }} - - steps: - - name: Lookup cache for deps - id: emu-deps-cache-step - uses: actions/cache@v4 - with: - key: ${{ env.DEPS_CACHE_KEY }} - path: ${{ env.DEPS_CACHE_DIR }} - - # we need branch because it has build scripts - - name: Checkout branch - if: steps.emu-deps-cache-step.outputs.cache-hit != 'true' - uses: actions/checkout@v4 - - - name: Clone third-party deps (deps/macos) - if: steps.emu-deps-cache-step.outputs.cache-hit != 'true' - uses: actions/checkout@v4 - with: - ref: 'third-party/deps/macos' - path: "${{env.THIRD_PARTY_BASE_DIR}}/deps/macos" - - - name: Clone third-party deps (deps/common) - if: steps.emu-deps-cache-step.outputs.cache-hit != 'true' - uses: actions/checkout@v4 - with: - ref: 'third-party/deps/common' - path: "${{env.THIRD_PARTY_BASE_DIR}}/deps/common" - -### fix folder permissions! not sure why this fails - # nested subdirs "build/macos/release" cause permission problems - - name: Give all permissions to repo folder - if: steps.emu-deps-cache-step.outputs.cache-hit != 'true' - shell: bash - working-directory: ${{ github.workspace }} - run: sudo chmod -R 777 "${{ github.workspace }}" - -### macos comes with bash v3 - - name: Update bash - if: steps.emu-deps-cache-step.outputs.cache-hit != 'true' - shell: bash - run: brew update && brew install bash - - - name: Build deps - if: steps.emu-deps-cache-step.outputs.cache-hit != 'true' - shell: bash - run: sudo chmod 777 build_macos_deps.sh && ./build_macos_deps.sh -verbose diff --git a/.gitmodules b/.gitmodules index 82d25b64..5b2208b7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -22,11 +22,3 @@ path = third-party/build/win url = ./ branch = third-party/build/win -[submodule "third-party/deps/macos"] - path = third-party/deps/macos - url = ./ - branch = third-party/deps/macos -[submodule "third-party/build/macos"] - path = third-party/build/macos - url = ./ - branch = third-party/build/macos diff --git a/build_macos.sh b/build_macos.sh deleted file mode 100644 index 4fed8b74..00000000 --- a/build_macos.sh +++ /dev/null @@ -1,528 +0,0 @@ -#!/usr/bin/env bash - -### make sure to cd to the emu src dir -required_files=( - "dll/dll.cpp" - "dll/steam_client.cpp" - "controller/gamepad.c" - "sdk/steam/isteamclient.h" -) - -for emu_file in "${required_files[@]}"; do - if [ ! -f "$emu_file" ]; then - echo "[X] Invalid emu directory, change directory to emu's src dir (missing file '$emu_file')" >&2 - exit 1 - fi -done - -BUILD_LIB64=0 -BUILD_EXP_LIB64=0 - -BUILD_CLIENT64=0 -BUILD_EXPT_CLIENT64=0 -BUILD_TOOL_CLIENT_LDR=0 - -BUILD_TOOL_FIND_ITFS64=0 -BUILD_TOOL_LOBBY64=0 - -BUILD_LIB_NET_SOCKETS_64=0 - -# < 0: deduce, > 1: force -PARALLEL_THREADS_OVERRIDE=-1 - -CMD_BUILD_STR='' - -# 0 = release, 1 = debug, otherwise error -BUILD_TYPE=-1 - -CLEAN_BUILD=0 - -VERBOSE=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" = "+build_str" ]]; then - i=$((i+1)) - CMD_BUILD_STR="${!i}" - [[ -z "$CMD_BUILD_STR" ]] && { - echo "[X] Expected a build string" >&2; - exit 1; - } - elif [[ "$var" = "+lib-64" ]]; then - BUILD_LIB64=1 - elif [[ "$var" = "+exp-lib-64" ]]; then - BUILD_EXP_LIB64=1 - elif [[ "$var" = "+client-64" ]]; then - BUILD_CLIENT64=1 - elif [[ "$var" = "+exp-client-64" ]]; then - BUILD_EXPT_CLIENT64=1 - elif [[ "$var" = "+tool-clientldr" ]]; then - BUILD_TOOL_CLIENT_LDR=1 - elif [[ "$var" = "+tool-itf-64" ]]; then - BUILD_TOOL_FIND_ITFS64=1 - elif [[ "$var" = "+tool-lobby-64" ]]; then - BUILD_TOOL_LOBBY64=1 - elif [[ "$var" = "+lib-netsockets-64" ]]; then - BUILD_LIB_NET_SOCKETS_64=1 - elif [[ "$var" = "-verbose" ]]; then - VERBOSE=1 - elif [[ "$var" = "clean" ]]; then - CLEAN_BUILD=1 - elif [[ "$var" = "release" ]]; then - BUILD_TYPE=0 - elif [[ "$var" = "debug" ]]; then - BUILD_TYPE=1 - else - echo "[X] Invalid arg: $var" >&2 - exit 1 - fi -done - -# 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 - -# build type -optimize_level="" -dbg_level="" -dbg_defs="" -linker_strip_dbg_symbols='' -build_folder="" -if [[ "$BUILD_TYPE" = "0" ]]; then - optimize_level="-O2" - dbg_level="-g0" - dbg_defs="-DEMU_RELEASE_BUILD -DNDEBUG" - linker_strip_dbg_symbols='-Wl,-S' - build_folder="release" -elif [[ "$BUILD_TYPE" = "1" ]]; then - optimize_level="-Og" - dbg_level="-g3" - dbg_defs="" - linker_strip_dbg_symbols="" - build_folder="debug" -else - echo "[X] You must specify any of: [release debug]" >&2 - exit 1 -fi - -build_root_dir="build/macos/$build_folder" -build_root_64="$build_root_dir/x64" -build_root_experimental="$build_root_dir/experimental" -build_root_tools="$build_root_dir/tools" - -# common stuff -deps_dir="build/deps/macos" -libs_dir="libs" -tools_dir='tools' -build_temp_dir="build/tmp/macos" -protoc_out_dir="dll/proto_gen/macos" -third_party_dir="third-party" -third_party_build_dir="$third_party_dir/build/macos" - -protoc_exe_64="$deps_dir/protobuf/install64/bin/protoc" - -parallel_exe="$third_party_build_dir/rush/rush" - -# https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html -common_compiler_args="-std=c++17 -fvisibility=hidden -fexceptions -fno-jump-tables -fno-char8_t" - -# third party dependencies (include folder + folder containing .a file) -ssq_inc="$deps_dir/libssq/include" -ssq_lib64="$deps_dir/libssq/build64" - -curl_inc64="$deps_dir/curl/install64/include" -curl_lib64="$deps_dir/curl/install64/lib" - -protob_inc64="$deps_dir/protobuf/install64/include" -protob_lib64="$deps_dir/protobuf/install64/lib" - -zlib_inc64="$deps_dir/zlib/install64/include" -zlib_lib64="$deps_dir/zlib/install64/lib" - -mbedtls_inc64="$deps_dir/mbedtls/install64/include" -mbedtls_lib64="$deps_dir/mbedtls/install64/lib" - -overlay_inc64="$deps_dir/ingame_overlay/install64/include" -overlay_lib64="$deps_dir/ingame_overlay/install64/lib" -overlay_sys_lib64="$deps_dir/ingame_overlay/deps/System/install64/lib" -overlay_detour_lib64="$deps_dir/ingame_overlay/deps/mini_detour/install64/lib" - -# directories to use for #include -release_incs_both=( - "$ssq_inc" - "$libs_dir" - "$protoc_out_dir" - "$libs_dir/utfcpp" - "controller" - "dll" - "sdk" - "overlay_experimental" - "crash_printer" - "helpers" -) -release_incs64=( - "${release_incs_both[@]}" - "$curl_inc64" - "$protob_inc64" - "$zlib_inc64" - "$mbedtls_inc64" -) - -# directories where libraries (.a or .dylib) will be looked up -release_libs_dir64=( - "$ssq_lib64" - "$curl_lib64" - "$protob_lib64" - "$zlib_lib64" - "$mbedtls_lib64" - - "$overlay_lib64" - "$overlay_sys_lib64" - "$overlay_detour_lib64" -) - -# libraries to link with, either static ".a" or dynamic ".dylib" (name only) -# if it's called libXYZ.a, then only write "XYZ" -# for static libs make sure to build a PIC lib -# each will be prefixed with -l, ex: -lpthread -release_libs=( - "pthread" - "dl" - "ssq" - "z" # libz library - "curl" - "protobuf-lite" - "mbedcrypto" -) - -# common source files used everywhere, just for convinience, you still have to provide a complete list later -release_src=( - "dll/*.cpp" - "$protoc_out_dir/*.cc" - "crash_printer/linux.cpp" - "helpers/common_helpers.cpp" -) - -emu_build_string="$CMD_BUILD_STR" -[[ -z "$emu_build_string" ]] && { - emu_build_string="$(date +'%m%d%Y-%H%M')" -} - -# https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html -# additional #defines -common_defs="-DGNUC -DUTF_CPP_CPLUSPLUS=201703L -DCURL_STATICLIB -D'EMU_BUILD_STRING=$emu_build_string'" -release_defs="$dbg_defs $common_defs" - -# errors to ignore during build -release_ignore_warn="-Wno-switch" - -[ ! -d "$deps_dir" ] && { - echo "[X] Dependencies dir \"$deps_dir\" was not found" >&2; - exit 1; -} - -[ ! -f "$protoc_exe_64" ] && { - echo "[X] protobuff compiler wasn't found - 64" >&2; - exit 1; -} - -[ ! -f "$parallel_exe" ] && { - echo "[X] tool to run parallel compilation jobs '$parallel_exe' wasn't found" >&2; - exit 1; -} - -chmod 777 "$parallel_exe" - -echo "[?] All build operations will use $build_threads parallel jobs" - -last_code=0 - -empty_arr=() - -function build_for () { - - local is_exe=$( [[ "$1" != 0 ]] && { echo 1; } || { echo 0; } ) - local out_filepath="${2:?'missing output filepath'}" - local -n all_src=$3 - local -n extra_inc_dirs=$4 - local extra_defs="$5" - local -n extra_libs=$6 - - [[ "${#all_src[@]}" = "0" ]] && { - echo [X] "No source files specified" >&2; - return 1; - } - - # https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html - local cpiler_pic_pie='-fPIC' - [[ $is_exe = 1 ]] && cpiler_pic_pie='-fPIE' - - # https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html - # https://www.baeldung.com/linux/library-convert-static-to-shared - local linker_pic_pie='-shared' - [[ $is_exe = 1 ]] && linker_pic_pie='-pie' - - local tmp_work_dir="${out_filepath##*/}" - tmp_work_dir="$build_temp_dir/${tmp_work_dir%.*}" - echo " -- Cleaning compilation directory '$tmp_work_dir/'" - rm -f -r "$tmp_work_dir" - mkdir -p "$tmp_work_dir" || { - echo [X] "Failed to create compilation directory" >&2; - return 1; - } - - local build_cmds=() - local -A objs_dirs=() - for src_file in $( echo "${all_src[@]}" ); do - [[ -f "$src_file" ]] || { - echo "[X] source file "$src_file" wasn't found" >&2; - return 1; - } - - # https://stackoverflow.com/a/9559024 - local obj_dir=$( [[ -d "${src_file%/*}" ]] && echo "${src_file%/*}" || echo '.' ) - obj_dir="$tmp_work_dir/$obj_dir" - - local obj_name="${src_file##*/}" - obj_name="${obj_name%.*}.o" - - build_cmds+=("$src_file<>$obj_dir/$obj_name") - objs_dirs["$obj_dir"]="$obj_dir" - - mkdir -p "$obj_dir" - done - - [[ "${#build_cmds[@]}" = "0" ]] && { - echo [X] "No valid source files were found" >&2; - return 1; - } - - local target_incs=() - local target_libs_dirs=() - target_incs=("${release_incs64[@]}") - target_libs_dirs=("${release_libs_dir64[@]}") - target_incs=( - "${target_incs[@]}" - "${extra_inc_dirs[@]}" - ) - # wrap each -ImyIncDir with single quotes -> '-ImyIncDir' - target_incs=("${target_incs[@]/#/\'-I}") - target_incs=("${target_incs[@]/%/\'}") - - echo " -- Compiling object files with $build_threads parallel jobs inside directory '$tmp_work_dir/'" - local build_cmd="clang++ -c -x c++ $common_compiler_args $cpiler_pic_pie $optimize_level $dbg_level $release_ignore_warn $release_defs $extra_defs ${target_incs[@]} '{1}' '-o{2}'" - - if [[ $VERBOSE = 1 ]]; then - printf '%s\n' "${build_cmds[@]}" | "$parallel_exe" --dry-run -j$build_threads -d '<>' -k "$build_cmd" - echo; - fi - - printf '%s\n' "${build_cmds[@]}" | "$parallel_exe" -j$build_threads -d '<>' -k "$build_cmd" - exit_code=$? - echo " -- Exit code = $exit_code" - echo; echo; - sleep 1 - [[ $exit_code = 0 ]] || { - rm -f -r "$tmp_work_dir"; - sleep 1 - return $exit_code; - } - - echo " -- Linking all object files from '$tmp_work_dir/' to produce '$out_filepath'" - local obj_files=() - for obj_file in $(echo "${objs_dirs[@]/%//*.o}" ); do - [[ -f "$obj_file" ]] && obj_files+=("$obj_file") - done - # if no files were added - [[ "${#obj_files[@]}" -gt 0 ]] || { - echo "[X] No files to link" >&2; - return 1; - } - - local out_dir="${out_filepath%/*}" - [[ "$out_dir" = "$out_filepath" ]] && out_dir='.' - mkdir -p "$out_dir" - - local target_libs=( - "${release_libs[@]}" - "${extra_libs[@]}" - ) - - # https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/developer_guide/gcc-using-libraries#gcc-using-libraries_using-both-static-dynamic-library-gcc - # https://linux.die.net/man/1/ld - if [[ $VERBOSE = 1 ]]; then - echo "clang++ $common_compiler_args $cpiler_pic_pie $optimize_level $dbg_level $linker_pic_pie $linker_strip_dbg_symbols -o" "$out_filepath" "${obj_files[@]}" "${target_libs_dirs[@]/#/-L}" "-Wl,--whole-archive -Wl,-Bstatic" "${target_libs[@]/#/-l}" "-Wl,-Bdynamic -Wl,--no-whole-archive -Wl,--exclude-libs,ALL" - echo; - fi - - clang++ $common_compiler_args $cpiler_pic_pie $optimize_level $dbg_level $linker_pic_pie $linker_strip_dbg_symbols -o "$out_filepath" "${obj_files[@]}" "${target_libs_dirs[@]/#/-L}" -Wl,--whole-archive -Wl,-Bstatic "${target_libs[@]/#/-l}" -Wl,-Bdynamic -Wl,--no-whole-archive -Wl,--exclude-libs,ALL - exit_code=$? - echo " -- Exit code = $exit_code" - echo; echo; - rm -f -r "$tmp_work_dir" - sleep 1 - return $exit_code - -} - -function cleanup () { - rm -f -r "$build_temp_dir" -} - -if [[ "$CLEAN_BUILD" = "1" ]]; then - echo // cleaning previous build - [[ -d "$build_root_dir" ]] && rm -f -r "$build_root_dir" - echo; echo; -fi - - -## tools -if [[ "$BUILD_TOOL_CLIENT_LDR" = "1" ]]; then - [[ -d "$build_root_tools/steamclient_loader/" ]] || mkdir -p "$build_root_tools/steamclient_loader/" - cp -f "$tools_dir"/steamclient_loader/linux/* "$build_root_tools/steamclient_loader/" - echo; echo; -fi - - -### x64 build -cleanup - -echo // invoking protobuf compiler - 64 -rm -f -r "$protoc_out_dir" -mkdir -p "$protoc_out_dir" -"$protoc_exe_64" ./dll/*.proto -I./dll/ --cpp_out="$protoc_out_dir/" -last_code=$((last_code + $?)) -echo; echo; - -if [[ "$BUILD_LIB64" = "1" ]]; then - echo // building shared lib libsteam_api.dylib - 64 - all_src_files=( - "${release_src[@]}" - "controller/*.c" - ) - build_for 0 "$build_root_64/libsteam_api.dylib" all_src_files empty_arr '-DCONTROLLER_SUPPORT' empty_arr - last_code=$((last_code + $?)) -fi - -if [[ "$BUILD_CLIENT64" = "1" ]]; then - echo // building shared lib steamclient.dylib - 64 - all_src_files=( - "${release_src[@]}" - "controller/*.c" - ) - build_for 0 "$build_root_64/steamclient.dylib" all_src_files empty_arr '-DCONTROLLER_SUPPORT -DSTEAMCLIENT_DLL' empty_arr - last_code=$((last_code + $?)) -fi - -if [[ "$BUILD_EXP_LIB64" = "1" ]]; then - echo // building shared lib experimental libsteam_api.dylib - 64 - all_src_files=( - "${release_src[@]}" - "controller/*.c" - "overlay_experimental/*.cpp" - ) - extra_incs=( - "$overlay_inc64" - ) - extra_link_libs=( - "ingame_overlay" - "system" # ingame_overlay dependency - "mini_detour" # ingame_overlay dependency - ) - build_for 0 "$build_root_experimental/x64/libsteam_api.dylib" all_src_files extra_incs '-DCONTROLLER_SUPPORT -DEMU_OVERLAY -DImTextureID=ImU64' extra_link_libs - last_code=$((last_code + $?)) -fi - -if [[ "$BUILD_EXPT_CLIENT64" = "1" ]]; then - echo // building shared lib experimental steamclient.dylib - 64 - all_src_files=( - "${release_src[@]}" - "controller/*.c" - "overlay_experimental/*.cpp" - ) - extra_incs=( - "$overlay_inc64" - ) - extra_link_libs=( - "ingame_overlay" - "system" # ingame_overlay dependency - "mini_detour" # ingame_overlay dependency - ) - build_for 0 "$build_root_experimental/x64/steamclient.dylib" all_src_files extra_incs '-DCONTROLLER_SUPPORT -DSTEAMCLIENT_DLL -DEMU_OVERLAY -DImTextureID=ImU64' extra_link_libs - last_code=$((last_code + $?)) -fi - -if [[ "$BUILD_TOOL_LOBBY64" = "1" ]]; then - echo // building executable lobby_connect_x64 - 64 - all_src_files=( - "${release_src[@]}" - "$tools_dir/lobby_connect/lobby_connect.cpp" - ) - build_for 1 "$build_root_tools/lobby_connect/lobby_connect_x64" all_src_files empty_arr '-DNO_DISK_WRITES -DLOBBY_CONNECT' empty_arr - last_code=$((last_code + $?)) -fi - -if [[ "$BUILD_TOOL_FIND_ITFS64" = "1" ]]; then - echo // building executable generate_interfaces_file_x64 - 64 - all_src_files=( - "$tools_dir/generate_interfaces/generate_interfaces.cpp" - ) - build_for 1 "$build_root_tools/find_interfaces/generate_interfaces_file_x64" all_src_files empty_arr '' empty_arr - last_code=$((last_code + $?)) -fi - -if [[ "$BUILD_LIB_NET_SOCKETS_64" = "1" ]]; then - echo // building shared lib steamnetworkingsockets64.dylib - 64 - all_src_files=( - "networking_sockets_lib/steamnetworkingsockets.cpp" - ) - build_for 0 "$build_root_dir/networking_sockets_lib/steamnetworkingsockets64.dylib" all_src_files empty_arr '' empty_arr - last_code=$((last_code + $?)) -fi - - -# cleanup -cleanup - - -# copy configs + examples -if [[ $last_code = 0 ]]; then - echo "// copying readmes + files examples" - mkdir -p "$build_root_dir/" - cp -f -r "post_build/steam_settings.EXAMPLE/" "$build_root_dir/" - cp -f "post_build/README.release.md" "$build_root_dir/" - cp -f "CHANGELOG.md" "$build_root_dir/" - if [[ $BUILD_TYPE = 1 ]]; then - cp -f "post_build/README.debug.md" "$build_root_dir/" - fi - if [[ -d "$build_root_tools/find_interfaces" ]]; then - mkdir -p "$build_root_tools/find_interfaces/" - cp -f "post_build/README.find_interfaces.md" "$build_root_tools/find_interfaces/" - fi - if [[ -d "$build_root_tools/lobby_connect" ]]; then - mkdir -p "$build_root_tools/lobby_connect/" - cp -f "post_build/README.lobby_connect.md" "$build_root_tools/lobby_connect/" - fi -else - echo "[X] Not copying readmes or files examples due to previous errors" >&2 -fi -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_macos_deps.sh b/build_macos_deps.sh deleted file mode 100644 index 6a7e4ebc..00000000 --- a/build_macos_deps.sh +++ /dev/null @@ -1,365 +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/macos" -third_party_dir="$script_dir/third-party" -third_party_deps_dir="$third_party_dir/deps/macos" -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=( - "binutils" # (optional) contains the tool 'readelf' mainly, and other usefull binary stuff - "coreutils" # echo, printf, etc... - "gcc@14" - "llvm@14" - # "libglade" # TODO needed ? - # "libglademm" # TODO needed ? -) - -if [[ "$INSTALL_PACKAGES" -ne 0 ]]; then - brew update - last_code=$((last_code + $?)) - - for dep in "${all_packages[@]}"; do - brew 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 - - export PATH="/usr/local/bin:$PATH" - export PATH="/usr/local/opt/llvm@14/bin:$PATH" - # export PATH="/usr/local/opt/llvm/bin:$PATH" - -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_C_STANDARD=17 -DCMAKE_CXX_STANDARD=17 -DCMAKE_POSITION_INDEPENDENT_CODE=True -DBUILD_SHARED_LIBS=OFF" -recreate_64="rm -f -r build64/ && rm -f -r install64/ && mkdir build64/ && mkdir install64/" -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_build64="'$mycmake' --build build64 --config Release --parallel $build_threads $VERBOSITY" -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/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 Darwin) - -# 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_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_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_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_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_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" - -# "-no_warning_for_no_symbols" fails on clang -sed -i '' 's/ -no_warning_for_no_symbols -c/ /' 'library/CMakeLists.txt' -sed -i '' 's/RLFLAGS = -no_warning_for_no_symbols -c/RLFLAGS = /' 'library/Makefile' - -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 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/dll/dll/common_includes.h b/dll/dll/common_includes.h index 98a0a3c9..a6b0b0c5 100644 --- a/dll/dll/common_includes.h +++ b/dll/dll/common_includes.h @@ -41,22 +41,11 @@ #define __LINUX__ #endif -// TODO fix this and include proper headers -#if defined(__APPLE__) && defined(__MACH__) - #define __MACOS__ -#endif - #if defined(__WINDOWS__) #define STEAM_WIN32 #ifndef NOMINMAX #define NOMINMAX #endif -#elif defined(__LINUX__) - #ifndef GNUC - #define GNUC - #endif -#else - #warning "Unrecognized OS" #endif #define STEAM_API_EXPORTS diff --git a/third-party/build/macos b/third-party/build/macos deleted file mode 160000 index 8d95aaa5..00000000 --- a/third-party/build/macos +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8d95aaa5e6d5dc3a955759fad34a5511a2a92692 diff --git a/third-party/deps/macos b/third-party/deps/macos deleted file mode 160000 index 9a3ba942..00000000 --- a/third-party/deps/macos +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9a3ba9422acaee506688eef7a17bd18f4ec856d1