Merge branch 'use_cross_compilers_and_vcpkg' into 'master'

Use cross compilers and vcpkg

See merge request Mr_Goldberg/goldberg_emulator!35
Nemirtingas 2021-01-19 06:33:50 +00:00
commit 43c808ad83
20 changed files with 671 additions and 355 deletions

View File

@ -4,6 +4,205 @@ stages:
- deploy - deploy
- page_deploy - page_deploy
static:linux:deps:
stage: dependencies
image: nemirtingas/linux_vcpkg:ubuntu18
#when: manual
script:
- apt update && apt -y install libgl1-mesa-dev libgl1-mesa-dev:i386
- cp -f vcpkg_triplets/*.cmake /vcpkg/triplets/
- VCPKG_PATH=$(pwd)/vcpkg
- TRIPLET=x86-linux-goldberg
- vcpkg "--x-install-root=${VCPKG_PATH}" install protobuf[zlib]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install curl[core,openssl]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install stb:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install glew:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-json:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-fifo-map:${TRIPLET} || exit 1
- TRIPLET=x64-linux-goldberg
- vcpkg "--x-install-root=${VCPKG_PATH}" install protobuf[zlib]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install curl[core,openssl]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install stb:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install glew:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-json:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-fifo-map:${TRIPLET} || exit 1
- exit 0
cache:
key: static-linux-deps-cache
paths:
- vcpkg
artifacts:
paths:
- vcpkg
expire_in: 1 day
static:windows:deps:
stage: dependencies
image: nemirtingas/windowscross_vcpkg:msvc2019
#when: manual
script:
- VCPKG_PATH=$(pwd)/vcpkg
- cp -f vcpkg_triplets/*.cmake /vcpkg/triplets/
- TRIPLET=x64-linux
- vcpkg "--x-install-root=${VCPKG_PATH}" install protobuf:${TRIPLET} || exit 1
- TRIPLET=x86-windows-goldberg
- vcpkg "--x-install-root=${VCPKG_PATH}" install protobuf[zlib]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install curl[core,winssl]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install stb:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install glew:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-json:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-fifo-map:${TRIPLET} || exit 1
- TRIPLET=x64-windows-goldberg
- vcpkg "--x-install-root=${VCPKG_PATH}" install protobuf[zlib]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install curl[core,winssl]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install stb:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install glew:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-json:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-fifo-map:${TRIPLET} || exit 1
- exit 0
cache:
key: static-windows-deps-cache
paths:
- vcpkg
artifacts:
paths:
- vcpkg
expire_in: 1 day
static:macosx:deps:
stage: dependencies
image: nemirtingas/osxcross_vcpkg:SDK10.13
#when: manual
script:
- VCPKG_PATH=$(pwd)/vcpkg
- cp -f vcpkg_triplets/*.cmake /vcpkg/triplets/
- TRIPLET=x64-linux
- vcpkg "--x-install-root=${VCPKG_PATH}" install protobuf:${TRIPLET} || exit 1
- TRIPLET=x86-macosx-goldberg
- vcpkg "--x-install-root=${VCPKG_PATH}" install protobuf[zlib]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install curl[core,openssl]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install stb:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-json:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-fifo-map:${TRIPLET} || exit 1
- TRIPLET=x64-macosx-goldberg
- vcpkg "--x-install-root=${VCPKG_PATH}" install protobuf[zlib]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install curl[core,openssl]:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install stb:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-json:${TRIPLET} || exit 1
- vcpkg "--x-install-root=${VCPKG_PATH}" install nlohmann-fifo-map:${TRIPLET} || exit 1
- exit 0
cache:
key: static-macosx-deps-cache
paths:
- vcpkg/
artifacts:
paths:
- vcpkg/
expire_in: 1 day
build:linux:
stage: build
image: nemirtingas/linux_vcpkg:ubuntu18
dependencies:
- static:linux:deps
needs:
- static:linux:deps
script:
- apt update && apt -y install libgl1-mesa-dev libgl1-mesa-dev:i386
- cp -f vcpkg_triplets/*.cmake /vcpkg/triplets/
- VCPKG_PATH=$(pwd)/vcpkg
- TOOLCHAIN="/vcpkg/scripts/buildsystems/vcpkg.cmake"
- TRIPLET=x86-linux-goldberg
- OUT=linux32/Release
- cmake -G Ninja -Wno-dev -DX86=ON -DCMAKE_BUILD_TYPE=Release "-DVCPKG_TARGET_TRIPLET=${TRIPLET}" "-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}" "-D_VCPKG_INSTALLED_DIR=${VCPKG_PATH}" -S . -B "${OUT}"
- cmake --build "${OUT}"
- cmake --install "${OUT}"
- TRIPLET=x64-linux-goldberg
- OUT=linux64/Release
- cmake -G Ninja -Wno-dev -DX64=ON -DCMAKE_BUILD_TYPE=Release "-DVCPKG_TARGET_TRIPLET=${TRIPLET}" "-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}" "-D_VCPKG_INSTALLED_DIR=${VCPKG_PATH}" -S . -B "${OUT}"
- cmake --build "${OUT}"
- cmake --install "${OUT}"
- exit 0
artifacts:
paths:
- release/
- debug/
expire_in: 1 day
build:windows:
stage: build
image: nemirtingas/windowscross_vcpkg:msvc2019
dependencies:
- static:windows:deps
needs:
- static:windows:deps
script:
- cp -f vcpkg_triplets/*.cmake /vcpkg/triplets/
- VCPKG_PATH=$(pwd)/vcpkg
- TOOLCHAIN="/vcpkg/scripts/buildsystems/vcpkg.cmake"
- CHAINLOAD="/clang_windows_sdk/clang-cl-msvc.cmake"
- export HOST_ARCH=x86
- TRIPLET=x86-windows-goldberg
- OUT=win32/Release
- cmake -G Ninja -Wno-dev -DX86=ON -DCMAKE_BUILD_TYPE=Release "-DVCPKG_TARGET_TRIPLET=${TRIPLET}" "-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${CHAINLOAD}" "-D_VCPKG_INSTALLED_DIR=${VCPKG_PATH}" -S . -B "${OUT}"
- cmake --build "${OUT}"
- cmake --install "${OUT}"
- export HOST_ARCH=x64
- TRIPLET=x64-windows-goldberg
- OUT=win64/Release
- cmake -G Ninja -Wno-dev -DX64=ON -DCMAKE_BUILD_TYPE=Release "-DVCPKG_TARGET_TRIPLET=${TRIPLET}" "-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${CHAINLOAD}" "-D_VCPKG_INSTALLED_DIR=${VCPKG_PATH}" -S . -B "${OUT}"
- cmake --build "${OUT}"
- cmake --install "${OUT}"
artifacts:
paths:
- release/
- debug/
expire_in: 1 day
build:macosx:
stage: build
image: nemirtingas/osxcross_vcpkg:SDK10.13
dependencies:
- static:macosx:deps
needs:
- static:macosx:deps
script:
- cp -f vcpkg_triplets/*.cmake /vcpkg/triplets/
- VCPKG_PATH=$(pwd)/vcpkg
- TOOLCHAIN="/vcpkg/scripts/buildsystems/vcpkg.cmake"
- CHAINLOAD="/osxcross/target/toolchain.cmake"
- export OSXCROSS_HOST=i386-apple-${OSXCROSS_TARGET}
- TRIPLET=x86-macosx-goldberg
- OUT=macosx32/Release
- cmake -G Ninja -Wno-dev -DX86=ON -DCMAKE_BUILD_TYPE=Release "-DVCPKG_TARGET_TRIPLET=${TRIPLET}" "-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${CHAINLOAD}" "-D_VCPKG_INSTALLED_DIR=${VCPKG_PATH}" -S . -B "${OUT}"
- cmake --build "${OUT}"
- cmake --install "${OUT}"
- export OSXCROSS_HOST=x86_64-apple-${OSXCROSS_TARGET}
- TRIPLET=x64-macosx-goldberg
- OUT=macosx64/Release
- cmake -G Ninja -Wno-dev -DX64=ON -DCMAKE_BUILD_TYPE=Release "-DVCPKG_TARGET_TRIPLET=${TRIPLET}" "-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN}" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${CHAINLOAD}" "-D_VCPKG_INSTALLED_DIR=${VCPKG_PATH}" -S . -B "${OUT}"
- cmake --build "${OUT}"
- cmake --install "${OUT}"
- mkdir release/macosx
- x86_64-apple-${OSXCROSS_TARGET}-lipo -create release/macosx*/steamclient.dylib -output release/macosx/steamclient.dylib
- x86_64-apple-${OSXCROSS_TARGET}-lipo -create release/macosx*/libsteam_api.dylib -output release/macosx/libsteam_api.dylib
artifacts:
paths:
- release/
- debug/
expire_in: 1 day
protobuf_static_steamos: protobuf_static_steamos:
stage: dependencies stage: dependencies
image: tianon/steamos image: tianon/steamos
@ -39,6 +238,8 @@ build_steamos:
image: tianon/steamos image: tianon/steamos
dependencies: dependencies:
- protobuf_static_steamos - protobuf_static_steamos
needs:
- protobuf_static_steamos
before_script: before_script:
- apt update && apt -y install gcc-4.9 g++-4.9 git libtool g++-4.9-multilib gcc-4.9-multilib - apt update && apt -y install gcc-4.9 g++-4.9 git libtool g++-4.9-multilib gcc-4.9-multilib
@ -57,6 +258,8 @@ build_steamos:
build_windows: build_windows:
stage: build stage: build
image: fedora:29 image: fedora:29
needs:
- protobuf_static_steamos
script: script:
- dnf -y install wine wget p7zip sed dos2unix - dnf -y install wine wget p7zip sed dos2unix
@ -94,66 +297,6 @@ build_windows:
- release/ - release/
expire_in: 1 day expire_in: 1 day
build_cmake_linux:
stage: build
image: ubuntu
when: manual
before_script:
- export DEBIAN_FRONTEND=noninteractive
- apt update -y
- apt install build-essential cmake libprotobuf-dev protobuf-compiler ninja-build -y
script:
- mkdir cmake-builds && cd cmake-builds
- mkdir x64-release && cd x64-release
- cmake ../../ -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" && ninja
- cd ..
# - mkdir x64-experimental-release && cd x64-experimental-release
# - cmake ../../ -G "Ninja" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" -DEMU_EXPERIMENTAL_BUILD:BOOL=ON && ninja
# - cd ..
artifacts:
paths:
- cmake-builds/
expire_in: 1 day
build_cmake_windows:
stage: build
image: fedora:29
when: manual
before_script:
- dnf -y install wine wget p7zip sed dos2unix unzip
- wget 'https://gitlab.com/Mr_Goldberg/goldberg_emulator/uploads/48db8f434a193aae872279dc4f5dde6a/sdk_standalone.7z'
- 7za x sdk_standalone.7z -osdk_standalone
- wget 'https://github.com/Kitware/CMake/releases/download/v3.15.0-rc1/cmake-3.15.0-rc1-win64-x64.zip'
- 7za x cmake-3.15.0-rc1-win64-x64.zip
- wget 'https://gitlab.com/Mr_Goldberg/goldberg_emulator/uploads/0119304e030098b4821d73170fe52084/protobuf_x64-windows-static.7z'
- 7za x protobuf_x64-windows-static.7z -oprotobuf_x64-windows-static
script:
- export WINEDEBUG=-all
- wine cmd /c
- mkdir cmake-builds && cd cmake-builds
- mkdir x64-release && cd x64-release
- echo call .\\..\\..\\sdk_standalone\\set_vars64.bat >> cmake-build.bat
- echo .\\..\\..\\cmake-3.15.0-rc1-win64-x64\\bin\\cmake.exe ..\\.. -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" -DCMAKE_PREFIX_PATH="protobuf_x64-windows-static" -DProtobuf_PROTOC_EXECUTABLE:STRING="./../../protobuf_x64-windows-static/tools/protobuf/protoc.exe" >> cmake-build.bat
- echo nmake.exe >> cmake-build.bat
- wine cmd /c cmake-build.bat
- cd ..
- mkdir x64-experimental-release && cd x64-experimental-release
- echo call .\\..\\..\\sdk_standalone\\set_vars64.bat >> cmake-build.bat
- echo .\\..\\..\\cmake-3.15.0-rc1-win64-x64\\bin\\cmake.exe ..\\.. -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE:STRING="RelWithDebInfo" -DEMU_EXPERIMENTAL_BUILD=ON -DEMU_OVERLAY=ON -DCMAKE_PREFIX_PATH="protobuf_x64-windows-static" -DProtobuf_PROTOC_EXECUTABLE:STRING="./../../protobuf_x64-windows-static/tools/protobuf/protoc.exe" >> cmake-build.bat
- echo nmake.exe >> cmake-build.bat
- wine cmd /c cmake-build.bat
- cd ..
artifacts:
paths:
- cmake-builds/
expire_in: 1 day
deploy_all: deploy_all:
stage: deploy stage: deploy
image: fedora image: fedora

View File

@ -4,33 +4,182 @@ cmake_minimum_required(VERSION 3.6)
# Set the project name # Set the project name
project(goldberg_emulator) project(goldberg_emulator)
if(MSVC) # Workaround because cross-compiling with CMake + vcpkg fucks up this variable
# Set static environment (results in static compile flags) if Visual Studio is used (dynamic by default) # making the 'find_*' functions/macros somehow fail to find the right arch.
# Officially recommended solution: https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-can-i-build-my-msvc-application-with-a-static-runtime # There are conditions like
# Should be replaced by a better solution in the future: https://gitlab.kitware.com/cmake/cmake/merge_requests/3211 # CMAKE_SIZEOF_VOID_P = "4" then look for i386 libraries...
foreach(flag_var # or
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE # CMAKE_SIZEOF_VOID_P = "8" then look for x86_64 libraries...
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) if(X86 AND NOT X64)
if(${flag_var} MATCHES "/MD") set(CMAKE_SIZEOF_VOID_P "4")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") elseif(X64 AND NOT X86)
endif(${flag_var} MATCHES "/MD") set(CMAKE_SIZEOF_VOID_P "8")
endforeach(flag_var) else()
message(FATAL_ERROR "Please define either -DX86=ON or -DX64=ON")
# Disable MSVC++ warning C4996: 'may be unsafe/disable deprecation'
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif() endif()
# Add option to enable experimental build if(WIN32) # Setup some variables for Windows build
option(EMU_EXPERIMENTAL_BUILD "Enable experimental build" OFF) if(MSVC) # If building with MSVC
add_definitions(-D_CRT_SECURE_NO_WARNINGS) # Disable warning about strncpy_s and his friends
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:\"msvcrtd.lib\"") # Disable this linkage
#set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:\"msvcrtd.lib\"") # Disable this linkage
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) # Force to only build Debug & Release projects
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
endif()
if(X64)
set(LIB_STEAM_API steam_api64)
set(LIB_STEAMCLIENT steamclient64)
set(OUT_DIR win64)
elseif(X86)
set(LIB_STEAM_API steam_api)
set(LIB_STEAMCLIENT steamclient)
set(OUT_DIR win32)
else()
message(FATAL_ERROR "Arch unknown")
endif()
file(
GLOB
OVERLAY_EXPERIMENTAL_SRC_SHARED
overlay_experimental/*.cpp
overlay_experimental/windows/*.cpp
ImGui/*.cpp
ImGui/impls/*.cpp
ImGui/impls/windows/*.cpp
)
set(overlay_includes
overlay/
overlay/windows/
)
elseif(APPLE)
if(X64)
# Global flags for building steamapi (64bits)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m64")
#set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -m64")
set(OUT_DIR macosx64)
elseif(X86)
# Global flags for building steamapi (32bits)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
#set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -m32")
set(OUT_DIR macosx32)
else()
message(FATAL_ERROR "Arch unknown")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
set(LIB_STEAM_API steam_api)
set(LIB_STEAMCLIENT steamclient)
file(
GLOB
OVERLAY_EXPERIMENTAL_SRC_SHARED
overlay/*.cpp
)
set(overlay_includes
overlay/
)
elseif(UNIX)
if(X64)
# Global flags for building steamapi (64bits)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m64")
#set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -m64")
set(OUT_DIR linux64)
elseif(X86)
# Global flags for building steamapi (32bits)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
#set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} -m32")
set(OUT_DIR linux32)
else()
message(FATAL_ERROR "Arch unknown")
endif()
set(LIB_STEAM_API steam_api)
set(LIB_STEAMCLIENT steamclient)
file(
GLOB
OVERLAY_EXPERIMENTAL_SRC_SHARED
overlay_experimental/*.cpp
overlay_experimental/linux/*.cpp
ImGui/*.cpp
ImGui/impls/*.cpp
ImGui/impls/linux/*.cpp
)
set(overlay_includes
overlay/
overlay/linux/
)
else()
message(FATAL_ERROR "No CMake for other platforms")
endif()
# Set CXX standard
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
# Find the protobuf compiler and libraries set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Add option to enable experimental build
option(EMU_EXPERIMENTAL_BUILD "Enable experimental build" OFF)
if(EMU_EXPERIMENTAL_BUILD)
if(APPLE)
set(EMU_OVERLAY OFF)
else()
option(EMU_OVERLAY "Enable the emulator overlay" ON)
endif()
else()
set(EMU_OVERLAY OFF)
endif()
set(Protobuf_USE_STATIC_LIBS ON)
include(FindProtobuf) include(FindProtobuf)
find_package(Protobuf 3.1.0 REQUIRED) find_package(Threads REQUIRED)
find_package(Protobuf CONFIG REQUIRED)
find_package(CURL CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(nlohmann-fifo-map CONFIG REQUIRED)
find_path(STB_INCLUDE_DIRS "stb.h")
if(NOT WIN32)
find_package(OpenSSL REQUIRED)
endif()
if(NOT APPLE)
find_package(GLEW REQUIRED)
endif()
# Generate the .h and .cxx files for dll/net.proto # Generate the .h and .cxx files for dll/net.proto
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS dll/net.proto) protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS dll/net.proto)
@ -38,34 +187,6 @@ protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS dll/net.proto)
# Print path to generated files # Print path to generated files
message(STATUS "PROTO_SRCS = ${PROTO_SRCS}") message(STATUS "PROTO_SRCS = ${PROTO_SRCS}")
message(STATUS "PROTO_HDRS = ${PROTO_HDRS}") message(STATUS "PROTO_HDRS = ${PROTO_HDRS}")
message(STATUS "PROTOBUF_INCLUDE_DIRS = ${PROTOBUF_INCLUDE_DIRS}")
message(STATUS "PROTOBUF_LIBRARIES = ${PROTOBUF_LIBRARIES}")
message(STATUS "PROTOBUF_PROTOC_EXECUTABLE = ${PROTOBUF_PROTOC_EXECUTABLE}")
# Setup the lib/exe names for the targets
if(WIN32)
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(LIB_STEAM_API steam_api64)
set(LIB_STEAMCLIENT steamclient64)
set(LIB_STEAMNETWORKINGSOCKETS steamnetworkingsockets64)
set(BIN_LOBBY_CONNECT lobby_connect64)
set(BIN_GENERATE_INTERFACES_FILE generate_interfaces_file64)
else()
set(LIB_STEAM_API steam_api)
set(LIB_STEAMCLIENT steamclient)
set(LIB_STEAMNETWORKINGSOCKETS steamnetworkingsockets)
set(BIN_LOBBY_CONNECT lobby_connect)
set(BIN_GENERATE_INTERFACES_FILE generate_interfaces_file)
endif()
elseif(UNIX AND NOT APPLE)
set(LIB_STEAM_API steam_api)
set(LIB_STEAMCLIENT steamclient)
set(LIB_STEAMNETWORKINGSOCKETS steamnetworkingsockets)
set(BIN_LOBBY_CONNECT lobby_connect)
set(BIN_GENERATE_INTERFACES_FILE generate_interfaces_file)
else()
message(FATAL_ERROR "Other platforms not supported...")
endif()
# Gather the files that are shared between multiple targets # Gather the files that are shared between multiple targets
file(GLOB DLL_SRC_SHARED file(GLOB DLL_SRC_SHARED
@ -77,26 +198,6 @@ file(GLOB DETOURS_SRC_SHARED
detours/*.cpp detours/*.cpp
) )
if(WIN32)
file(GLOB OVERLAY_EXPERIMENTAL_SRC_SHARED
overlay_experimental/*.cpp
overlay_experimental/windows/*.cpp
ImGui/*.cpp
ImGui/impls/*.cpp
ImGui/impls/windows/*.cpp
glew/glew.c
)
elseif(UNIX)
file(GLOB OVERLAY_EXPERIMENTAL_SRC_SHARED
overlay_experimental/*.cpp
overlay_experimental/linux/*.cpp
ImGui/*.cpp
ImGui/impls/*.cpp
ImGui/impls/linux/*.cpp
glew/glew.c
)
endif()
################################################### ###################################################
# Setup for the steam_api(64).dll / libsteam_api.so # Setup for the steam_api(64).dll / libsteam_api.so
################################################### ###################################################
@ -112,49 +213,54 @@ add_library(${LIB_STEAM_API}
) )
# Include the required directories # Include the required directories
target_include_directories(${LIB_STEAM_API} target_include_directories(
${LIB_STEAM_API}
PRIVATE PRIVATE
${PROTOBUF_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/ImGui ${STB_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/glew/include
overlay_experimental
) )
# Link the required libraries # Link the required libraries
target_link_libraries(${LIB_STEAM_API} target_link_libraries(${LIB_STEAM_API}
PRIVATE PRIVATE
protobuf::libprotobuf Threads::Threads
protobuf::libprotobuf-lite
#nlohmann_json::nlohmann_json doesn't work
nlohmann-fifo-map::nlohmann-fifo-map
$<$<NOT:$<BOOL:${APPLE}>>:GLEW::GLEW>
$<$<BOOL:${WIN32}>:comdlg32>
$<$<BOOL:${WIN32}>:advapi32>
$<$<BOOL:${WIN32}>:shell32>
$<$<BOOL:${WIN32}>:user32>
$<$<BOOL:${WIN32}>:ws2_32> $<$<BOOL:${WIN32}>:ws2_32>
$<$<BOOL:${WIN32}>:iphlpapi> $<$<BOOL:${WIN32}>:iphlpapi>
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:opengl32.lib> $<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:opengl32.lib>
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:Winmm.lib> $<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:winmm.lib>
# For library UNIX loading
$<$<NOT:$<BOOL:${WIN32}>>:dl>
# For overlay opengl
$<$<AND:$<BOOL:${UNIX}>,$<NOT:$<BOOL:${APPLE}>>>:GL>
) )
# Add target compile definitions # Add target compile definitions
target_compile_definitions(${LIB_STEAM_API} target_compile_definitions(${LIB_STEAM_API}
PRIVATE PRIVATE
GLEW_NO_GLU
STBI_NO_SIMD
$<$<CONFIG:>:EMU_RELEASE_BUILD> $<$<CONFIG:>:EMU_RELEASE_BUILD>
$<$<CONFIG:Release>:EMU_RELEASE_BUILD> $<$<CONFIG:Release>:EMU_RELEASE_BUILD>
$<$<CONFIG:RelWithDebInfo>:EMU_RELEASE_BUILD> $<$<CONFIG:RelWithDebInfo>:EMU_RELEASE_BUILD>
$<$<CONFIG:MinSizeRel>:EMU_RELEASE_BUILD> $<$<CONFIG:MinSizeRel>:EMU_RELEASE_BUILD>
$<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:EMU_EXPERIMENTAL_BUILD> $<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:EMU_EXPERIMENTAL_BUILD>
$<$<BOOL:${EMU_OVERLAY}>:EMU_OVERLAY> $<$<BOOL:${EMU_OVERLAY}>:EMU_OVERLAY>
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:GLEW_STATIC>
) )
# Install the target
if(WIN32)
install(TARGETS
${LIB_STEAM_API}
RUNTIME DESTINATION ./
)
else()
install(TARGETS
${LIB_STEAM_API}
LIBRARY DESTINATION ./
)
endif()
######################################################## ########################################################
# Setup for the steamclient(64).dll / libsteamclient.so? # Setup for the steamclient(64).dll / libsteamclient.so?
######################################################## ########################################################
@ -162,49 +268,79 @@ endif()
# Setup the target # Setup the target
add_library(${LIB_STEAMCLIENT} add_library(${LIB_STEAMCLIENT}
SHARED SHARED
steamclient.cpp $<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:${DETOURS_SRC_SHARED}>
$<$<AND:$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:${OVERLAY_EXPERIMENTAL_SRC_SHARED}>
${DLL_SRC_SHARED}
${PROTO_SRCS}
${PROTO_HDRS}
)
if(UNIX)
SET_TARGET_PROPERTIES(${LIB_STEAMCLIENT} PROPERTIES PREFIX "")
endif()
# Include the required directories
target_include_directories(
${LIB_STEAMCLIENT}
PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${STB_INCLUDE_DIRS}
overlay_experimental
)
# Link the required libraries
target_link_libraries(${LIB_STEAMCLIENT}
PRIVATE
Threads::Threads
protobuf::libprotobuf-lite
#nlohmann_json::nlohmann_json doesn't work
nlohmann-fifo-map::nlohmann-fifo-map
$<$<NOT:$<BOOL:${APPLE}>>:GLEW::GLEW>
$<$<BOOL:${WIN32}>:comdlg32>
$<$<BOOL:${WIN32}>:advapi32>
$<$<BOOL:${WIN32}>:shell32>
$<$<BOOL:${WIN32}>:user32>
$<$<BOOL:${WIN32}>:ws2_32>
$<$<BOOL:${WIN32}>:iphlpapi>
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:opengl32.lib>
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${EMU_EXPERIMENTAL_BUILD}>,$<BOOL:${EMU_OVERLAY}>>:winmm.lib>
# For library UNIX loading
$<$<NOT:$<BOOL:${WIN32}>>:dl>
# For overlay opengl
$<$<AND:$<BOOL:${UNIX}>,$<NOT:$<BOOL:${APPLE}>>>:GL>
) )
# Add target compile definitions # Add target compile definitions
target_compile_definitions(${LIB_STEAMCLIENT} target_compile_definitions(${LIB_STEAMCLIENT}
PRIVATE PRIVATE
GLEW_NO_GLU
STBI_NO_SIMD
STEAMCLIENT_DLL
$<$<CONFIG:>:EMU_RELEASE_BUILD> $<$<CONFIG:>:EMU_RELEASE_BUILD>
$<$<CONFIG:Release>:EMU_RELEASE_BUILD> $<$<CONFIG:Release>:EMU_RELEASE_BUILD>
$<$<CONFIG:RelWithDebInfo>:EMU_RELEASE_BUILD> $<$<CONFIG:RelWithDebInfo>:EMU_RELEASE_BUILD>
$<$<CONFIG:MinSizeRel>:EMU_RELEASE_BUILD> $<$<CONFIG:MinSizeRel>:EMU_RELEASE_BUILD>
$<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:EMU_EXPERIMENTAL_BUILD> $<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:EMU_EXPERIMENTAL_BUILD>
$<$<BOOL:${EMU_OVERLAY}>:EMU_OVERLAY>
) )
# Install the target
if(WIN32)
install(TARGETS
${LIB_STEAMCLIENT}
RUNTIME DESTINATION ./
)
else()
install(TARGETS
${LIB_STEAMCLIENT}
LIBRARY DESTINATION ./
)
endif()
if(NOT WIN32)
message(STATUS "Target library 'steamclient' is only suported for windows at this time... Disabling Build ALL inclusion for this target")
set_target_properties(${LIB_STEAMCLIENT} PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
endif()
############################################################################## ##############################################################################
# Setup for the steamnetworkingsockets(64).dll / libsteamnetworkingsockets.so? # Setup for the steamnetworkingsockets(64).dll / libsteamnetworkingsockets.so?
############################################################################## ##############################################################################
# Setup the target # Setup the target
add_library(${LIB_STEAMNETWORKINGSOCKETS} add_library(steamnetworkingsockets
SHARED SHARED
steamnetworkingsockets.cpp steamnetworkingsockets.cpp
) )
# Add target compile definitions # Add target compile definitions
target_compile_definitions(${LIB_STEAMNETWORKINGSOCKETS} target_compile_definitions(steamnetworkingsockets
PRIVATE PRIVATE
$<$<CONFIG:>:EMU_RELEASE_BUILD> $<$<CONFIG:>:EMU_RELEASE_BUILD>
$<$<CONFIG:Release>:EMU_RELEASE_BUILD> $<$<CONFIG:Release>:EMU_RELEASE_BUILD>
@ -213,30 +349,14 @@ target_compile_definitions(${LIB_STEAMNETWORKINGSOCKETS}
$<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:EMU_EXPERIMENTAL_BUILD> $<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:EMU_EXPERIMENTAL_BUILD>
) )
# Setup install rules for the target set_target_properties(steamnetworkingsockets PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
if(WIN32)
install(TARGETS
${LIB_STEAMNETWORKINGSOCKETS}
RUNTIME DESTINATION ./
)
else()
install(TARGETS
${LIB_STEAMNETWORKINGSOCKETS}
LIBRARY DESTINATION ./
)
endif()
if(NOT WIN32)
message(STATUS "Target library 'steamnetworkingsockets' is only supported for windows at this time... Disabling Build ALL inclusion for this target")
set_target_properties(${LIB_STEAMNETWORKINGSOCKETS} PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1)
endif()
########################################################################### ###########################################################################
# Setup for the lobby_connect(64).exe / lobby_connect # Setup for the lobby_connect(64).exe / lobby_connect
########################################################################### ###########################################################################
# Setup the target # Setup the target
add_executable(${BIN_LOBBY_CONNECT} add_executable(lobby_connect
lobby_connect.cpp lobby_connect.cpp
$<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:${DETOURS_SRC_SHARED}> $<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:${DETOURS_SRC_SHARED}>
${DLL_SRC_SHARED} ${DLL_SRC_SHARED}
@ -244,25 +364,34 @@ add_executable(${BIN_LOBBY_CONNECT}
${PROTO_HDRS} ${PROTO_HDRS}
) )
target_include_directories(${BIN_LOBBY_CONNECT} target_include_directories(lobby_connect
PRIVATE PRIVATE
${PROTOBUF_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}
) )
# Link the required libraries # Link the required libraries
target_link_libraries(${BIN_LOBBY_CONNECT} target_link_libraries(lobby_connect
PRIVATE PRIVATE
protobuf::libprotobuf Threads::Threads
protobuf::libprotobuf-lite
#nlohmann_json::nlohmann_json doesn't work
nlohmann-fifo-map::nlohmann-fifo-map
$<$<BOOL:${WIN32}>:comdlg32>
$<$<BOOL:${WIN32}>:advapi32>
$<$<BOOL:${WIN32}>:shell32>
$<$<BOOL:${WIN32}>:user32>
$<$<BOOL:${WIN32}>:ws2_32> $<$<BOOL:${WIN32}>:ws2_32>
$<$<BOOL:${WIN32}>:iphlpapi> $<$<BOOL:${WIN32}>:iphlpapi>
$<$<BOOL:${WIN32}>:comdlg32>
${CMAKE_DL_LIBS} # For library UNIX loading
$<$<NOT:$<BOOL:${WIN32}>>:dl>
-debug:none -debug:none
) )
# Add target compile definitions # Add target compile definitions
target_compile_definitions(${BIN_LOBBY_CONNECT} target_compile_definitions(lobby_connect
PRIVATE PRIVATE
NO_DISK_WRITES NO_DISK_WRITES
LOBBY_CONNECT LOBBY_CONNECT
@ -273,47 +402,63 @@ target_compile_definitions(${BIN_LOBBY_CONNECT}
$<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:EMU_EXPERIMENTAL_BUILD> $<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:EMU_EXPERIMENTAL_BUILD>
) )
# Setup install rules for the target
install(TARGETS
${BIN_LOBBY_CONNECT}
RUNTIME DESTINATION lobby_connect/
)
########################################################################### ###########################################################################
# Setup for the generate_interfaces_file(64).exe / generate_interfaces_file # Setup for the generate_interfaces_file(64).exe / generate_interfaces_file
########################################################################### ###########################################################################
# Setup the target # Setup the target
add_executable(${BIN_GENERATE_INTERFACES_FILE} add_executable(
generate_interfaces
generate_interfaces_file.cpp generate_interfaces_file.cpp
) )
# Link the required libraries # Link the required libraries
target_link_libraries(${BIN_GENERATE_INTERFACES_FILE} target_link_libraries(
generate_interfaces
PRIVATE PRIVATE
-debug:none -debug:none
) )
# Setup install rules for the target
###########################################################################
# Installation setup
###########################################################################
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(OUT_DIR debug/${OUT_DIR})
else()
set(OUT_DIR release/${OUT_DIR})
endif()
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR})
# emulators
install(
TARGETS ${LIB_STEAM_API} ${LIB_STEAMCLIENT}
RUNTIME DESTINATION ${OUT_DIR}
LIBRARY DESTINATION ${OUT_DIR}
)
# generate_interfaces
install(TARGETS install(TARGETS
${BIN_GENERATE_INTERFACES_FILE} generate_interfaces
RUNTIME DESTINATION tools/ RUNTIME DESTINATION ${OUT_DIR}/tools/generate_interfaces
) )
###########################################################################
# Installation setup for non target files and directories
###########################################################################
install(FILES
Readme_lobby_connect.txt
DESTINATION lobby_connect/
)
install(FILES install(FILES
scripts/find_interfaces.sh scripts/find_interfaces.sh
scripts/find_interfaces.ps1 scripts/find_interfaces.ps1
Readme_generate_interfaces.txt Readme_generate_interfaces.txt
DESTINATION tools/ DESTINATION ${OUT_DIR}/tools/generate_interfaces
)
# lobby_connect
install(TARGETS
lobby_connect
RUNTIME DESTINATION ${OUT_DIR}/tools/lobby_connect
)
install(FILES
Readme_lobby_connect.txt
DESTINATION ${OUT_DIR}/tools/lobby_connect
) )
install(FILES install(FILES
@ -322,10 +467,10 @@ install(FILES
files_example/steam_interfaces.EXAMPLE.txt files_example/steam_interfaces.EXAMPLE.txt
$<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:${PROJECT_SOURCE_DIR}/Readme_experimental.txt> $<$<BOOL:${EMU_EXPERIMENTAL_BUILD}>:${PROJECT_SOURCE_DIR}/Readme_experimental.txt>
$<$<CONFIG:Debug>:${PROJECT_SOURCE_DIR}/Readme_debug.txt> $<$<CONFIG:Debug>:${PROJECT_SOURCE_DIR}/Readme_debug.txt>
DESTINATION ./ DESTINATION ${OUT_DIR}
) )
install(DIRECTORY install(DIRECTORY
files_example/steam_settings.EXAMPLE files_example/steam_settings.EXAMPLE
DESTINATION ./ DESTINATION ${OUT_DIR}
) )

View File

@ -7,10 +7,10 @@ mkdir -p linux/tools
cp scripts/find_interfaces.sh linux/tools/ cp scripts/find_interfaces.sh linux/tools/
cp scripts/steamclient_loader.sh linux/tools/ cp scripts/steamclient_loader.sh linux/tools/
../protobuf/prefix_x86/bin/protoc -I./dll/ --cpp_out=./dll/ ./dll/*.proto ../protobuf/prefix_x86/bin/protoc -I./dll/ --cpp_out=./dll/ ./dll/*.proto
g++ -m32 -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DCONTROLLER_SUPPORT -s -o linux/x86/libsteam_api.so dll/*.cpp dll/*.cc controller/*.c -Wno-return-type -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -lpthread -ldl -std=c++11 && echo built32 g++ -m32 -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DCONTROLLER_SUPPORT -s -o linux/x86/libsteam_api.so dll/*.cpp dll/*.cc controller/*.c -Wno-return-type -I. -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -lpthread -ldl -std=c++11 && echo built32
g++ -m32 -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DNO_DISK_WRITES -DLOBBY_CONNECT -s -o linux/lobby_connect/lobby_connect_x86 lobby_connect.cpp dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -lpthread -ldl -std=c++11 && echo built_lobby_connect32 g++ -m32 -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DNO_DISK_WRITES -DLOBBY_CONNECT -s -o linux/lobby_connect/lobby_connect_x86 lobby_connect.cpp dll/*.cpp dll/*.cc -Wno-return-type -I. -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -lpthread -ldl -std=c++11 && echo built_lobby_connect32
g++ -m32 -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DSTEAMCLIENT_DLL -DNDEBUG -DCONTROLLER_SUPPORT -s -o linux/x86/steamclient.so dll/*.cpp dll/*.cc controller/*.c -Wno-return-type -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -lpthread -ldl -std=c++11 && echo built32_steamclient g++ -m32 -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DSTEAMCLIENT_DLL -DNDEBUG -DCONTROLLER_SUPPORT -s -o linux/x86/steamclient.so dll/*.cpp dll/*.cc controller/*.c -Wno-return-type -I. -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -lpthread -ldl -std=c++11 && echo built32_steamclient
../protobuf/prefix/bin/protoc -I./dll/ --cpp_out=./dll/ ./dll/*.proto ../protobuf/prefix/bin/protoc -I./dll/ --cpp_out=./dll/ ./dll/*.proto
g++ -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DCONTROLLER_SUPPORT -s -o linux/x86_64/libsteam_api.so dll/*.cpp dll/*.cc controller/*.c -Wno-return-type -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -lpthread -ldl -std=c++11 && echo built64 g++ -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DCONTROLLER_SUPPORT -s -o linux/x86_64/libsteam_api.so dll/*.cpp dll/*.cc controller/*.c -Wno-return-type -I. -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -lpthread -ldl -std=c++11 && echo built64
g++ -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DNO_DISK_WRITES -DLOBBY_CONNECT -s -o linux/lobby_connect/lobby_connect_x64 lobby_connect.cpp dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -lpthread -ldl -std=c++11 && echo built_lobby_connect64 g++ -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DNO_DISK_WRITES -DLOBBY_CONNECT -s -o linux/lobby_connect/lobby_connect_x64 lobby_connect.cpp dll/*.cpp dll/*.cc -Wno-return-type -I. -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -lpthread -ldl -std=c++11 && echo built_lobby_connect64
g++ -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DSTEAMCLIENT_DLL -DNDEBUG -DCONTROLLER_SUPPORT -s -o linux/x86_64/steamclient.so dll/*.cpp dll/*.cc controller/*.c -Wno-return-type -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -lpthread -ldl -std=c++11 && echo built64_steamclient g++ -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DSTEAMCLIENT_DLL -DNDEBUG -DCONTROLLER_SUPPORT -s -o linux/x86_64/steamclient.so dll/*.cpp dll/*.cc controller/*.c -Wno-return-type -I. -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -lpthread -ldl -std=c++11 && echo built64_steamclient

View File

@ -4,11 +4,11 @@ call build_set_protobuf_directories.bat
"%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
call build_env_x86.bat call build_env_x86.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /LD /IImGui /Iglew\include /I%PROTOBUF_X86_DIRECTORY%\include\ /DGLEW_STATIC /DEMU_EXPERIMENTAL_BUILD /DCONTROLLER_SUPPORT /DEMU_OVERLAY dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X86_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /link /OUT:steam_api.dll cl /LD /I. /IImGui /Iglew\include /I%PROTOBUF_X86_DIRECTORY%\include\ /DGLEW_STATIC /DEMU_EXPERIMENTAL_BUILD /DCONTROLLER_SUPPORT /DEMU_OVERLAY dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X86_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /link /OUT:steam_api.dll
cl /LD steamclient.cpp /EHsc /MP12 /link /OUT:steamclient.dll cl /LD steamclient.cpp /EHsc /MP12 /link /OUT:steamclient.dll
"%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
call build_env_x64.bat call build_env_x64.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /LD /IImGui /Iglew\include /I%PROTOBUF_X64_DIRECTORY%\include\ /DGLEW_STATIC /DEMU_EXPERIMENTAL_BUILD /DCONTROLLER_SUPPORT /DEMU_OVERLAY dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X64_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /link /OUT:steam_api64.dll cl /LD /I. /IImGui /Iglew\include /I%PROTOBUF_X64_DIRECTORY%\include\ /DGLEW_STATIC /DEMU_EXPERIMENTAL_BUILD /DCONTROLLER_SUPPORT /DEMU_OVERLAY dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X64_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /link /OUT:steam_api64.dll
cl /LD steamclient.cpp /EHsc /MP12 /link /OUT:steamclient64.dll cl /LD steamclient.cpp /EHsc /MP12 /link /OUT:steamclient64.dll

View File

@ -6,7 +6,7 @@ call build_set_protobuf_directories.bat
"%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
call build_env_x86.bat call build_env_x86.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /DNO_DISK_WRITES /DLOBBY_CONNECT /DEMU_RELEASE_BUILD /DNDEBUG /I%PROTOBUF_X86_DIRECTORY%\include\ lobby_connect.cpp dll/*.cpp dll/*.cc "%PROTOBUF_X86_LIBRARY%" Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Comdlg32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\lobby_connect\lobby_connect.exe cl /DNO_DISK_WRITES /DLOBBY_CONNECT /DEMU_RELEASE_BUILD /DNDEBUG /I. /I%PROTOBUF_X86_DIRECTORY%\include\ lobby_connect.cpp dll/*.cpp dll/*.cc "%PROTOBUF_X86_LIBRARY%" Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Comdlg32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\lobby_connect\lobby_connect.exe
del /Q /S release\lobby_connect\*.lib del /Q /S release\lobby_connect\*.lib
del /Q /S release\lobby_connect\*.exp del /Q /S release\lobby_connect\*.exp
copy Readme_lobby_connect.txt release\lobby_connect\Readme.txt copy Readme_lobby_connect.txt release\lobby_connect\Readme.txt

View File

@ -10,12 +10,12 @@ call build_set_protobuf_directories.bat
"%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
call build_env_x86.bat call build_env_x86.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /LD /DEMU_RELEASE_BUILD /DNDEBUG /I%PROTOBUF_X86_DIRECTORY%\include\ dll/*.cpp dll/*.cc "%PROTOBUF_X86_LIBRARY%" Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\steam_api.dll cl /LD /DEMU_RELEASE_BUILD /DNDEBUG /I. /I%PROTOBUF_X86_DIRECTORY%\include\ dll/*.cpp dll/*.cc "%PROTOBUF_X86_LIBRARY%" Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\steam_api.dll
"%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
call build_env_x64.bat call build_env_x64.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /LD /DEMU_RELEASE_BUILD /DNDEBUG /I%PROTOBUF_X64_DIRECTORY%\include\ dll/*.cpp dll/*.cc "%PROTOBUF_X64_LIBRARY%" Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\steam_api64.dll cl /LD /DEMU_RELEASE_BUILD /DNDEBUG /I. /I%PROTOBUF_X64_DIRECTORY%\include\ dll/*.cpp dll/*.cc "%PROTOBUF_X64_LIBRARY%" Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\steam_api64.dll
copy Readme_release.txt release\Readme.txt copy Readme_release.txt release\Readme.txt
xcopy /s files_example\* release\ xcopy /s files_example\* release\
call build_win_release_experimental.bat call build_win_release_experimental.bat

View File

@ -6,11 +6,11 @@ call build_set_protobuf_directories.bat
"%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
call build_env_x86.bat call build_env_x86.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DGLEW_STATIC /DCONTROLLER_SUPPORT /DEMU_OVERLAY /DNDEBUG /IImGui /Iglew\include /I%PROTOBUF_X86_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X86_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental\steam_api.dll cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DGLEW_STATIC /DCONTROLLER_SUPPORT /DEMU_OVERLAY /DNDEBUG /I. /IImGui /Iglew\include /I%PROTOBUF_X86_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X86_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental\steam_api.dll
cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DNDEBUG steamclient.cpp /EHsc /MP12 /Ox /link /OUT:release\experimental\steamclient.dll cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DNDEBUG steamclient.cpp /EHsc /MP12 /Ox /link /OUT:release\experimental\steamclient.dll
"%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
call build_env_x64.bat call build_env_x64.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DGLEW_STATIC /DCONTROLLER_SUPPORT /DEMU_OVERLAY /DNDEBUG /IImGui /Iglew\include /I%PROTOBUF_X64_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X64_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental\steam_api64.dll cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DGLEW_STATIC /DCONTROLLER_SUPPORT /DEMU_OVERLAY /DNDEBUG /I. /IImGui /Iglew\include /I%PROTOBUF_X64_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X64_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental\steam_api64.dll
cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DNDEBUG steamclient.cpp /EHsc /MP12 /Ox /link /OUT:release\experimental\steamclient64.dll cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DNDEBUG steamclient.cpp /EHsc /MP12 /Ox /link /OUT:release\experimental\steamclient64.dll
copy Readme_experimental.txt release\experimental\Readme.txt copy Readme_experimental.txt release\experimental\Readme.txt

View File

@ -6,11 +6,11 @@ call build_set_protobuf_directories.bat
"%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
call build_env_x86.bat call build_env_x86.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DEMU_OVERLAY /DGLEW_STATIC /IImGui /Iglew\include /DNDEBUG /I%PROTOBUF_X86_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X86_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental_steamclient\steamclient.dll cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DEMU_OVERLAY /DGLEW_STATIC /I. /IImGui /Iglew\include /DNDEBUG /I%PROTOBUF_X86_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X86_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental_steamclient\steamclient.dll
"%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto "%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
cl steamclient_loader/*.cpp advapi32.lib user32.lib /EHsc /MP12 /Od /link /debug:none /OUT:release\experimental_steamclient\steamclient_loader.exe cl steamclient_loader/*.cpp advapi32.lib user32.lib /EHsc /MP12 /Od /link /debug:none /OUT:release\experimental_steamclient\steamclient_loader.exe
copy steamclient_loader\ColdClientLoader.ini release\experimental_steamclient\ copy steamclient_loader\ColdClientLoader.ini release\experimental_steamclient\
call build_env_x64.bat call build_env_x64.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DEMU_OVERLAY /DGLEW_STATIC /IImGui /Iglew\include /DNDEBUG /I%PROTOBUF_X64_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X64_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental_steamclient\steamclient64.dll cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DEMU_OVERLAY /DGLEW_STATIC /I. /IImGui /Iglew\include /DNDEBUG /I%PROTOBUF_X64_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c ImGui/*.cpp ImGui/impls/*.cpp ImGui/impls/windows/*.cpp overlay_experimental/*.cpp overlay_experimental/windows/*.cpp "%PROTOBUF_X64_LIBRARY%" glew\glew.c opengl32.lib Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Winmm.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental_steamclient\steamclient64.dll
copy Readme_experimental_steamclient.txt release\experimental_steamclient\Readme.txt copy Readme_experimental_steamclient.txt release\experimental_steamclient\Readme.txt

View File

@ -150,44 +150,18 @@ bool check_timedout(std::chrono::high_resolution_clock::time_point old, double t
return false; return false;
} }
#ifdef __LINUX__ #if defined(__LINUX__) || defined(__APPLE__)
std::string get_lib_path() { std::string get_lib_path()
std::string dir = "/proc/self/map_files"; {
DIR *dp; std::string library_path = "./";
int i = 0;
struct dirent *ep;
dp = opendir (dir.c_str());
uintptr_t p = (uintptr_t)&get_lib_path;
if (dp != NULL) Dl_info infos;
{ dladdr((void*)&get_lib_path, &infos);
while ((ep = readdir (dp))) { library_path = infos.dli_fname;
if (memcmp(ep->d_name, ".", 2) != 0 && memcmp(ep->d_name, "..", 3) != 0) {
char *upper = NULL;
uintptr_t lower_bound = strtoull(ep->d_name, &upper, 16);
if (lower_bound) {
++upper;
uintptr_t upper_bound = strtoull(upper, &upper, 16);
if (upper_bound && (lower_bound < p && p < upper_bound)) {
std::string path = dir + PATH_SEPARATOR + ep->d_name;
char link[PATH_MAX] = {};
if (readlink(path.c_str(), link, sizeof(link)) > 0) {
std::string lib_path = link;
(void) closedir (dp);
return link;
}
}
}
i++; return library_path;
}
}
(void) closedir (dp);
}
return ".";
} }
#endif #endif
std::string get_full_lib_path() std::string get_full_lib_path()
@ -222,10 +196,10 @@ std::string get_full_program_path()
std::string get_current_path() std::string get_current_path()
{ {
std::string path; std::string path;
#if defined(STEAM_WIN32) #if defined(__WINDOWS__)
char *buffer = _getcwd( NULL, 0 ); char *buffer = _getcwd( NULL, 0 );
#else #elif defined(__LINUX__) || defined(__APPLE__)
char *buffer = get_current_dir_name(); char *buffer = getcwd( NULL, 0 );
#endif #endif
if (buffer) { if (buffer) {
path = buffer; path = buffer;
@ -239,10 +213,10 @@ std::string get_current_path()
std::string canonical_path(std::string path) std::string canonical_path(std::string path)
{ {
std::string output; std::string output;
#if defined(STEAM_WIN32) #if defined(__WINDOWS__)
char *buffer = _fullpath(NULL, path.c_str(), 0); char *buffer = _fullpath(NULL, path.c_str(), 0);
#else #elif defined(__LINUX__) || defined(__APPLE__)
char *buffer = canonicalize_file_name(path.c_str()); char *buffer = realpath(path.c_str(), NULL);
#endif #endif
if (buffer) { if (buffer) {

View File

@ -40,6 +40,16 @@
#define __LINUX__ #define __LINUX__
#endif #endif
#if defined(__APPLE__)
#if defined(__x86_64__)
#define __APPLE_64__
#define __64BITS__
#else
#define __APPLE_32__
#define __32BITS__
#endif
#endif
#if defined(__WINDOWS__) #if defined(__WINDOWS__)
#define STEAM_WIN32 #define STEAM_WIN32
#ifndef NOMINMAX #ifndef NOMINMAX
@ -59,8 +69,6 @@
#include <iphlpapi.h> // Include winsock2 before this, or winsock2 iphlpapi will be unavailable #include <iphlpapi.h> // Include winsock2 before this, or winsock2 iphlpapi will be unavailable
#include <shlobj.h> #include <shlobj.h>
#define MSG_NOSIGNAL 0
#define SystemFunction036 NTAPI SystemFunction036 #define SystemFunction036 NTAPI SystemFunction036
#include <ntsecapi.h> #include <ntsecapi.h>
#undef SystemFunction036 #undef SystemFunction036
@ -84,7 +92,15 @@
#endif #endif
#endif #endif
#elif defined(__LINUX__) #elif defined(__LINUX__) || defined(__APPLE__)
#if defined(__LINUX__)
// Insert here Linux specific headers
#else
// Insert here MacOS specific headers
#include <sys/sysctl.h>
#include <mach-o/dyld_images.h>
#endif
#include <ifaddrs.h>// getifaddrs
#include <arpa/inet.h> #include <arpa/inet.h>
#include <sys/types.h> #include <sys/types.h>
@ -97,7 +113,6 @@
#include <sys/time.h> #include <sys/time.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <linux/netdevice.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
@ -112,7 +127,13 @@
#define PRINT_DEBUG(...) {FILE *t = fopen("STEAM_LOG.txt", "a"); fprintf(t, __VA_ARGS__); fclose(t);} #define PRINT_DEBUG(...) {FILE *t = fopen("STEAM_LOG.txt", "a"); fprintf(t, __VA_ARGS__); fclose(t);}
#endif #endif
#define PATH_SEPARATOR "/" #define PATH_SEPARATOR "/"
#endif #endif
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL 0
#endif
//#define PRINT_DEBUG(...) fprintf(stdout, __VA_ARGS__) //#define PRINT_DEBUG(...) fprintf(stdout, __VA_ARGS__)
#ifdef EMU_RELEASE_BUILD #ifdef EMU_RELEASE_BUILD
#define PRINT_DEBUG(...) #define PRINT_DEBUG(...)
@ -143,7 +164,8 @@
#include <stdio.h> #include <stdio.h>
// Other libs includes // Other libs includes
#include "../json/json.hpp" #include <nlohmann/json.hpp>
#include <nlohmann/fifo_map.hpp>
#include "../controller/gamepad.h" #include "../controller/gamepad.h"
// Steamsdk includes // Steamsdk includes

View File

@ -120,68 +120,39 @@ static void get_broadcast_info(uint16 port)
} }
} }
#elif defined(__linux__) #elif defined(__LINUX__) || defined(__APPLE__)
static void get_broadcast_info(uint16 port) static void get_broadcast_info(uint16 port)
{ {
/* Not sure how many platforms this will run on, ifaddrs* ifaces_list;
* so it's wrapped in __linux for now.
* Definitely won't work like this on Windows...
*/
number_broadcasts = 0; number_broadcasts = 0;
sock_t sock = 0; if (getifaddrs(&ifaces_list) == 0)
{
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) const sockaddr_in* sock_addr;
return; for (ifaddrs* pIface = ifaces_list; pIface != nullptr; pIface = pIface->ifa_next)
{
/* Configure ifconf for the ioctl call. */ if (pIface->ifa_addr->sa_family == AF_INET)
struct ifreq i_faces[MAX_BROADCASTS]; {
memset(i_faces, 0, sizeof(struct ifreq) * MAX_BROADCASTS); sock_addr = reinterpret_cast<const sockaddr_in*>(pIface->ifa_addr);
if (sock_addr->sin_addr.s_addr != 0 && pIface->ifa_netmask != nullptr)
struct ifconf ifconf; {
ifconf.ifc_buf = (char *)i_faces; uint32_t ip = reinterpret_cast<const sockaddr_in*>(pIface->ifa_addr)->sin_addr.s_addr;
ifconf.ifc_len = sizeof(i_faces); uint32_t mask = reinterpret_cast<const sockaddr_in*>(pIface->ifa_netmask)->sin_addr.s_addr;
if (ioctl(sock, SIOCGIFCONF, &ifconf) < 0) {
close(sock);
return;
}
/* ifconf.ifc_len is set by the ioctl() to the actual length used;
* on usage of the complete array the call should be repeated with
* a larger array, not done (640kB and 16 interfaces shall be
* enough, for everybody!)
*/
int i, count = ifconf.ifc_len / sizeof(struct ifreq);
for (i = 0; i < count; i++) {
/* there are interfaces with are incapable of broadcast */
if (ioctl(sock, SIOCGIFBRDADDR, &i_faces[i]) < 0)
continue;
/* moot check: only AF_INET returned (backwards compat.) */
if (i_faces[i].ifr_broadaddr.sa_family != AF_INET)
continue;
struct sockaddr_in *sock4 = (struct sockaddr_in *)&i_faces[i].ifr_broadaddr;
if (number_broadcasts >= MAX_BROADCASTS) {
close(sock);
return;
}
IP_PORT *ip_port = &broadcasts[number_broadcasts];
ip_port->ip = sock4->sin_addr.s_addr;
if (ip_port->ip == 0) {
continue;
}
IP_PORT *ip_port = &broadcasts[number_broadcasts++];
ip_port->ip = ip | ~mask;
ip_port->port = port; ip_port->port = port;
number_broadcasts++;
} }
}
close(sock); // IPV6
//else if (pIface->ifa_addr->sa_family == AF_INET6)
//{
// const sockaddr_in6* addr = reinterpret_cast<const sockaddr_in6*>(pIface->ifa_addr);));
//}
}
freeifaddrs(ifaces_list);
}
} }
#endif #endif

View File

@ -15,19 +15,12 @@
License along with the Goldberg Emulator; if not, see License along with the Goldberg Emulator; if not, see
<http://www.gnu.org/licenses/>. */ <http://www.gnu.org/licenses/>. */
#if defined(WIN64) || defined(_WIN64) || defined(__MINGW64__)
#define __WINDOWS_64__
#elif defined(WIN32) || defined(_WIN32) || defined(__MINGW32__)
#define __WINDOWS_32__
#endif
#if defined(__WINDOWS_32__) || defined(__WINDOWS_64__)
// Nothing to be done here
#else
#define STEAM_API_FUNCTIONS_IMPL
#include "base.h" #include "base.h"
#include "dll.h" #include "dll.h"
#if defined(__LINUX__)
#define STEAM_API_FUNCTIONS_IMPL
#define PATH_SEPARATOR_CHAR '/' #define PATH_SEPARATOR_CHAR '/'
#define STEAM_PATH_CACHE_SIZE 4096 #define STEAM_PATH_CACHE_SIZE 4096

View File

@ -0,0 +1,7 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)
set(VCPKG_CMAKE_SYSTEM_NAME Linux)

View File

@ -0,0 +1,16 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)
set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
set(ENV{OSXCROSS_HOST} "x86_64-apple-$ENV{OSXCROSS_TARGET}")
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE /osxcross/target/toolchain.cmake)
set(ENV{VCPKG_TOOLCHAIN} "/vcpkg/scripts/toolchains/osx.cmake")
set(VCPKG_C_FLAGS "-stdlib=libc++")
set(VCPKG_CXX_FLAGS "-stdlib=libc++")

View File

@ -0,0 +1,11 @@
set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)
set(ENV{HOST_ARCH} ${VCPKG_TARGET_ARCHITECTURE})
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE /clang_windows_sdk/clang-cl-msvc.cmake)
set(ENV{VCPKG_TOOLCHAIN} "/vcpkg/scripts/toolchains/windows.cmake")

View File

@ -0,0 +1,7 @@
set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)
set(VCPKG_CMAKE_SYSTEM_NAME Linux)

View File

@ -0,0 +1,16 @@
set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)
set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
set(ENV{OSXCROSS_HOST} "i386-apple-$ENV{OSXCROSS_TARGET}")
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE /osxcross/target/toolchain.cmake)
set(ENV{VCPKG_TOOLCHAIN} "/vcpkg/scripts/toolchains/osx.cmake")
set(VCPKG_C_FLAGS "-stdlib=libc++")
set(VCPKG_CXX_FLAGS "-stdlib=libc++")

View File

@ -0,0 +1,11 @@
set(VCPKG_TARGET_ARCHITECTURE x86)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_BUILD_TYPE release)
set(ENV{HOST_ARCH} ${VCPKG_TARGET_ARCHITECTURE})
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE /clang_windows_sdk/clang-cl-msvc.cmake)
set(ENV{VCPKG_TOOLCHAIN} "/vcpkg/scripts/toolchains/windows.cmake")