From 7ad4fc1fdfd6e97a97a3d9da36449420714b5785 Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Wed, 14 Oct 2020 06:43:33 +0200 Subject: [PATCH 1/6] Change includes for nlohmann libs. --- build_steamos.sh | 12 ++++++------ build_win_debug_experimental.bat | 4 ++-- build_win_debug_experimental_steamclient.bat | 4 ++-- build_win_lobby_connect.bat | 2 +- build_win_release.bat | 4 ++-- build_win_release_experimental.bat | 4 ++-- build_win_release_experimental_steamclient.bat | 4 ++-- dll/common_includes.h | 13 ++++++++++++- {json => nlohmann}/fifo_map.hpp | 0 {json => nlohmann}/json.hpp | 0 10 files changed, 29 insertions(+), 18 deletions(-) rename {json => nlohmann}/fifo_map.hpp (100%) rename {json => nlohmann}/json.hpp (100%) diff --git a/build_steamos.sh b/build_steamos.sh index 0e75fc0..2b11706 100644 --- a/build_steamos.sh +++ b/build_steamos.sh @@ -7,10 +7,10 @@ mkdir -p linux/tools cp scripts/find_interfaces.sh linux/tools/ cp scripts/steamclient_loader.sh linux/tools/ ../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 -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 -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 -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. -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. -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 -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++ -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++ -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 -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. -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. -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -lpthread -ldl -std=c++11 && echo built64_steamclient diff --git a/build_win_debug_experimental.bat b/build_win_debug_experimental.bat index ef997bc..4022fa0 100755 --- a/build_win_debug_experimental.bat +++ b/build_win_debug_experimental.bat @@ -4,13 +4,13 @@ call build_set_protobuf_directories.bat "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto call build_env_x86.bat 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 steamnetworkingsockets.cpp /EHsc /MP12 /link /OUT:steamnetworkingsockets.dll "%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto call build_env_x64.bat 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 steamnetworkingsockets.cpp /EHsc /MP12 /link /OUT:steamnetworkingsockets64.dll diff --git a/build_win_debug_experimental_steamclient.bat b/build_win_debug_experimental_steamclient.bat index 49b22b4..9798bc0 100644 --- a/build_win_debug_experimental_steamclient.bat +++ b/build_win_debug_experimental_steamclient.bat @@ -3,9 +3,9 @@ call build_set_protobuf_directories.bat "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto call build_env_x86.bat cl dll/rtlgenrandom.c dll/rtlgenrandom.def -cl /LD /IImGui /Iglew\include /I%PROTOBUF_X86_DIRECTORY%\include\ /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DEMU_EXPERIMENTAL_BUILD /DGLEW_STATIC /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:steamclient.dll +cl /LD /I. /IImGui /Iglew\include /I%PROTOBUF_X86_DIRECTORY%\include\ /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DEMU_EXPERIMENTAL_BUILD /DGLEW_STATIC /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:steamclient.dll cl /LD steamnetworkingsockets.cpp /EHsc /MP12 /link /OUT:steamnetworkingsockets.dll call build_env_x64.bat cl dll/rtlgenrandom.c dll/rtlgenrandom.def -cl /LD /IImGui /Iglew\include /I%PROTOBUF_X64_DIRECTORY%\include\ /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DEMU_EXPERIMENTAL_BUILD /DGLEW_STATIC /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:steamclient64.dll +cl /LD /I. /IImGui /Iglew\include /I%PROTOBUF_X64_DIRECTORY%\include\ /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DEMU_EXPERIMENTAL_BUILD /DGLEW_STATIC /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:steamclient64.dll cl /LD steamnetworkingsockets.cpp /EHsc /MP12 /link /OUT:steamnetworkingsockets64.dll diff --git a/build_win_lobby_connect.bat b/build_win_lobby_connect.bat index 27c83e5..7777fd4 100755 --- a/build_win_lobby_connect.bat +++ b/build_win_lobby_connect.bat @@ -6,7 +6,7 @@ call build_set_protobuf_directories.bat "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto call build_env_x86.bat 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\*.exp copy Readme_lobby_connect.txt release\lobby_connect\Readme.txt diff --git a/build_win_release.bat b/build_win_release.bat index 79e7804..028ba88 100755 --- a/build_win_release.bat +++ b/build_win_release.bat @@ -10,12 +10,12 @@ call build_set_protobuf_directories.bat "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto call build_env_x86.bat 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 call build_env_x64.bat 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 xcopy /s files_example\* release\ call build_win_release_experimental.bat diff --git a/build_win_release_experimental.bat b/build_win_release_experimental.bat index d3ab784..5b199f2 100755 --- a/build_win_release_experimental.bat +++ b/build_win_release_experimental.bat @@ -6,11 +6,11 @@ call build_set_protobuf_directories.bat "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto call build_env_x86.bat 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 "%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto call build_env_x64.bat 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 copy Readme_experimental.txt release\experimental\Readme.txt diff --git a/build_win_release_experimental_steamclient.bat b/build_win_release_experimental_steamclient.bat index 22566d4..d006e74 100644 --- a/build_win_release_experimental_steamclient.bat +++ b/build_win_release_experimental_steamclient.bat @@ -6,11 +6,11 @@ call build_set_protobuf_directories.bat "%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto call build_env_x86.bat 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 cl steamclient_loader/*.cpp advapi32.lib user32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental_steamclient\steamclient_loader.exe copy steamclient_loader\ColdClientLoader.ini release\experimental_steamclient\ call build_env_x64.bat 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 diff --git a/dll/common_includes.h b/dll/common_includes.h index 4096a14..0bbedd8 100644 --- a/dll/common_includes.h +++ b/dll/common_includes.h @@ -40,6 +40,16 @@ #define __LINUX__ #endif +#if defined(__APPLE__) + #if defined(__x86_64__) + #define __APPLE_64__ + #define __64BITS__ + #else + #define __APPLE_32__ + #define __32BITS__ + #endif +#endif + #if defined(__WINDOWS__) #define STEAM_WIN32 #ifndef NOMINMAX @@ -145,7 +155,8 @@ #include // Other libs includes -#include "../json/json.hpp" +#include +#include #include "../controller/gamepad.h" // Steamsdk includes diff --git a/json/fifo_map.hpp b/nlohmann/fifo_map.hpp similarity index 100% rename from json/fifo_map.hpp rename to nlohmann/fifo_map.hpp diff --git a/json/json.hpp b/nlohmann/json.hpp similarity index 100% rename from json/json.hpp rename to nlohmann/json.hpp From 0a4fdf1f6994f9ce0a8b549efe5d27c8469b0d37 Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Wed, 14 Oct 2020 06:44:04 +0200 Subject: [PATCH 2/6] Use cross-compilation docker images. --- .gitlab-ci.yml | 262 +++++++++--- CMakeLists.txt | 479 ++++++++++++++-------- vcpkg_triplets/x64-linux-goldberg.cmake | 7 + vcpkg_triplets/x64-macosx-goldberg.cmake | 16 + vcpkg_triplets/x64-windows-goldberg.cmake | 11 + vcpkg_triplets/x86-linux-goldberg.cmake | 7 + vcpkg_triplets/x86-macosx-goldberg.cmake | 16 + vcpkg_triplets/x86-windows-goldberg.cmake | 11 + 8 files changed, 582 insertions(+), 227 deletions(-) create mode 100644 vcpkg_triplets/x64-linux-goldberg.cmake create mode 100644 vcpkg_triplets/x64-macosx-goldberg.cmake create mode 100644 vcpkg_triplets/x64-windows-goldberg.cmake create mode 100644 vcpkg_triplets/x86-linux-goldberg.cmake create mode 100644 vcpkg_triplets/x86-macosx-goldberg.cmake create mode 100644 vcpkg_triplets/x86-windows-goldberg.cmake diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 423fa20..b05bd42 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,6 +4,204 @@ stages: - 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[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[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[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[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[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[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 + + artifacts: + paths: + - release/ + - debug/ + expire_in: 1 day + protobuf_static_steamos: stage: dependencies image: tianon/steamos @@ -39,6 +237,8 @@ build_steamos: image: tianon/steamos dependencies: - protobuf_static_steamos + needs: + - protobuf_static_steamos before_script: - apt update && apt -y install gcc-4.9 g++-4.9 git libtool g++-4.9-multilib gcc-4.9-multilib @@ -57,6 +257,8 @@ build_steamos: build_windows: stage: build image: fedora:29 + needs: + - protobuf_static_steamos script: - dnf -y install wine wget p7zip sed dos2unix @@ -94,66 +296,6 @@ build_windows: - release/ 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: stage: deploy image: fedora diff --git a/CMakeLists.txt b/CMakeLists.txt index e180f9c..01a5bda 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,33 +4,182 @@ cmake_minimum_required(VERSION 3.6) # Set the project name project(goldberg_emulator) -if(MSVC) - # Set static environment (results in static compile flags) if Visual Studio is used (dynamic by default) - # Officially recommended solution: https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-can-i-build-my-msvc-application-with-a-static-runtime - # Should be replaced by a better solution in the future: https://gitlab.kitware.com/cmake/cmake/merge_requests/3211 - foreach(flag_var - CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE - CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) - if(${flag_var} MATCHES "/MD") - string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") - endif(${flag_var} MATCHES "/MD") - endforeach(flag_var) - - # Disable MSVC++ warning C4996: 'may be unsafe/disable deprecation' - add_definitions(-D_CRT_SECURE_NO_WARNINGS) +# Workaround because cross-compiling with CMake + vcpkg fucks up this variable +# making the 'find_*' functions/macros somehow fail to find the right arch. +# There are conditions like +# CMAKE_SIZEOF_VOID_P = "4" then look for i386 libraries... +# or +# CMAKE_SIZEOF_VOID_P = "8" then look for x86_64 libraries... +if(X86 AND NOT X64) + set(CMAKE_SIZEOF_VOID_P "4") +elseif(X64 AND NOT X86) + set(CMAKE_SIZEOF_VOID_P "8") +else() + message(FATAL_ERROR "Please define either -DX86=ON or -DX64=ON") endif() -# Add option to enable experimental build -option(EMU_EXPERIMENTAL_BUILD "Enable experimental build" OFF) +if(WIN32) # Setup some variables for Windows build + 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_REQUIRED ON) 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) -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 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 message(STATUS "PROTO_SRCS = ${PROTO_SRCS}") 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 file(GLOB DLL_SRC_SHARED @@ -77,166 +198,165 @@ file(GLOB DETOURS_SRC_SHARED 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 the target add_library(${LIB_STEAM_API} - SHARED + SHARED $<$:${DETOURS_SRC_SHARED}> $<$,$>:${OVERLAY_EXPERIMENTAL_SRC_SHARED}> - ${DLL_SRC_SHARED} - ${PROTO_SRCS} - ${PROTO_HDRS} + ${DLL_SRC_SHARED} + ${PROTO_SRCS} + ${PROTO_HDRS} ) # Include the required directories -target_include_directories(${LIB_STEAM_API} - PRIVATE - ${PROTOBUF_INCLUDE_DIRS} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/ImGui - ${CMAKE_CURRENT_SOURCE_DIR}/glew/include +target_include_directories( + ${LIB_STEAM_API} + PRIVATE + ${CMAKE_CURRENT_BINARY_DIR} + ${STB_INCLUDE_DIRS} + + overlay_experimental ) # Link the required libraries target_link_libraries(${LIB_STEAM_API} PRIVATE - protobuf::libprotobuf + Threads::Threads + protobuf::libprotobuf-lite + #nlohmann_json::nlohmann_json doesn't work + nlohmann-fifo-map::nlohmann-fifo-map + + $<$>:GLEW::GLEW> + + $<$:comdlg32> + $<$:advapi32> + $<$:shell32> + $<$:user32> $<$:ws2_32> $<$:iphlpapi> $<$,$,$>:opengl32.lib> - $<$,$,$>:Winmm.lib> + $<$,$,$>:winmm.lib> + + # For library UNIX loading + $<$>:dl> + # For overlay opengl + $<$,$>>:GL> ) # Add target compile definitions target_compile_definitions(${LIB_STEAM_API} PRIVATE + GLEW_NO_GLU + STBI_NO_SIMD + $<$:EMU_RELEASE_BUILD> - $<$:EMU_RELEASE_BUILD> + $<$:EMU_RELEASE_BUILD> $<$:EMU_RELEASE_BUILD> $<$:EMU_RELEASE_BUILD> $<$:EMU_EXPERIMENTAL_BUILD> $<$: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? ######################################################## +if(UNIX) + SET_TARGET_PROPERTIES(${LIB_STEAMCLIENT} PROPERTIES PREFIX "") +endif() + # Setup the target add_library(${LIB_STEAMCLIENT} SHARED - steamclient.cpp + $<$:${DETOURS_SRC_SHARED}> + $<$,$>:${OVERLAY_EXPERIMENTAL_SRC_SHARED}> + ${DLL_SRC_SHARED} + ${PROTO_SRCS} + ${PROTO_HDRS} +) + +# 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 + + $<$>:GLEW::GLEW> + + $<$:comdlg32> + $<$:advapi32> + $<$:shell32> + $<$:user32> + $<$:ws2_32> + $<$:iphlpapi> + $<$,$,$>:opengl32.lib> + $<$,$,$>:winmm.lib> + + # For library UNIX loading + $<$>:dl> + # For overlay opengl + $<$,$>>:GL> ) # Add target compile definitions target_compile_definitions(${LIB_STEAMCLIENT} PRIVATE + GLEW_NO_GLU + STBI_NO_SIMD + STEAMCLIENT_DLL + $<$:EMU_RELEASE_BUILD> - $<$:EMU_RELEASE_BUILD> + $<$:EMU_RELEASE_BUILD> $<$:EMU_RELEASE_BUILD> $<$:EMU_RELEASE_BUILD> $<$:EMU_EXPERIMENTAL_BUILD> + $<$: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 the target -add_library(${LIB_STEAMNETWORKINGSOCKETS} +add_library(steamnetworkingsockets SHARED steamnetworkingsockets.cpp ) # Add target compile definitions -target_compile_definitions(${LIB_STEAMNETWORKINGSOCKETS} +target_compile_definitions(steamnetworkingsockets PRIVATE $<$:EMU_RELEASE_BUILD> - $<$:EMU_RELEASE_BUILD> + $<$:EMU_RELEASE_BUILD> $<$:EMU_RELEASE_BUILD> $<$:EMU_RELEASE_BUILD> $<$:EMU_EXPERIMENTAL_BUILD> ) -# Setup install rules for the target -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() +set_target_properties(steamnetworkingsockets PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) ########################################################################### # Setup for the lobby_connect(64).exe / lobby_connect ########################################################################### # Setup the target -add_executable(${BIN_LOBBY_CONNECT} +add_executable(lobby_connect lobby_connect.cpp $<$:${DETOURS_SRC_SHARED}> ${DLL_SRC_SHARED} @@ -244,76 +364,101 @@ add_executable(${BIN_LOBBY_CONNECT} ${PROTO_HDRS} ) -target_include_directories(${BIN_LOBBY_CONNECT} +target_include_directories(lobby_connect PRIVATE - ${PROTOBUF_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} ) # Link the required libraries -target_link_libraries(${BIN_LOBBY_CONNECT} +target_link_libraries(lobby_connect PRIVATE - protobuf::libprotobuf + Threads::Threads + protobuf::libprotobuf-lite + #nlohmann_json::nlohmann_json doesn't work + nlohmann-fifo-map::nlohmann-fifo-map + + $<$:comdlg32> + $<$:advapi32> + $<$:shell32> + $<$:user32> $<$:ws2_32> $<$:iphlpapi> - $<$:comdlg32> - ${CMAKE_DL_LIBS} + + # For library UNIX loading + $<$>:dl> + -debug:none ) # Add target compile definitions -target_compile_definitions(${BIN_LOBBY_CONNECT} +target_compile_definitions(lobby_connect PRIVATE NO_DISK_WRITES LOBBY_CONNECT $<$:EMU_RELEASE_BUILD> - $<$:EMU_RELEASE_BUILD> + $<$:EMU_RELEASE_BUILD> $<$:EMU_RELEASE_BUILD> $<$:EMU_RELEASE_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 the target -add_executable(${BIN_GENERATE_INTERFACES_FILE} +add_executable( + generate_interfaces generate_interfaces_file.cpp ) # Link the required libraries -target_link_libraries(${BIN_GENERATE_INTERFACES_FILE} +target_link_libraries( + generate_interfaces PRIVATE -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 - ${BIN_GENERATE_INTERFACES_FILE} - RUNTIME DESTINATION tools/ + generate_interfaces + 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 scripts/find_interfaces.sh scripts/find_interfaces.ps1 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 @@ -322,10 +467,10 @@ install(FILES files_example/steam_interfaces.EXAMPLE.txt $<$:${PROJECT_SOURCE_DIR}/Readme_experimental.txt> $<$:${PROJECT_SOURCE_DIR}/Readme_debug.txt> - DESTINATION ./ + DESTINATION ${OUT_DIR} ) install(DIRECTORY files_example/steam_settings.EXAMPLE - DESTINATION ./ + DESTINATION ${OUT_DIR} ) diff --git a/vcpkg_triplets/x64-linux-goldberg.cmake b/vcpkg_triplets/x64-linux-goldberg.cmake new file mode 100644 index 0000000..8b552de --- /dev/null +++ b/vcpkg_triplets/x64-linux-goldberg.cmake @@ -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) \ No newline at end of file diff --git a/vcpkg_triplets/x64-macosx-goldberg.cmake b/vcpkg_triplets/x64-macosx-goldberg.cmake new file mode 100644 index 0000000..f2ff6d9 --- /dev/null +++ b/vcpkg_triplets/x64-macosx-goldberg.cmake @@ -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++") \ No newline at end of file diff --git a/vcpkg_triplets/x64-windows-goldberg.cmake b/vcpkg_triplets/x64-windows-goldberg.cmake new file mode 100644 index 0000000..6d968cb --- /dev/null +++ b/vcpkg_triplets/x64-windows-goldberg.cmake @@ -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") \ No newline at end of file diff --git a/vcpkg_triplets/x86-linux-goldberg.cmake b/vcpkg_triplets/x86-linux-goldberg.cmake new file mode 100644 index 0000000..41dcd27 --- /dev/null +++ b/vcpkg_triplets/x86-linux-goldberg.cmake @@ -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) \ No newline at end of file diff --git a/vcpkg_triplets/x86-macosx-goldberg.cmake b/vcpkg_triplets/x86-macosx-goldberg.cmake new file mode 100644 index 0000000..c76cefa --- /dev/null +++ b/vcpkg_triplets/x86-macosx-goldberg.cmake @@ -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++") \ No newline at end of file diff --git a/vcpkg_triplets/x86-windows-goldberg.cmake b/vcpkg_triplets/x86-windows-goldberg.cmake new file mode 100644 index 0000000..c8c9c36 --- /dev/null +++ b/vcpkg_triplets/x86-windows-goldberg.cmake @@ -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") \ No newline at end of file From bf012e639093193c69c1998696ecfe0425abf6e9 Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Wed, 14 Oct 2020 06:44:44 +0200 Subject: [PATCH 3/6] Implementations for MacOS support. --- dll/base.cpp | 56 ++++++++-------------------- dll/common_includes.h | 19 ++++++++-- dll/network.cpp | 85 ++++++++++++++----------------------------- dll/wrap.cpp | 13 ++----- 4 files changed, 61 insertions(+), 112 deletions(-) diff --git a/dll/base.cpp b/dll/base.cpp index d451206..4e48a32 100644 --- a/dll/base.cpp +++ b/dll/base.cpp @@ -150,44 +150,18 @@ bool check_timedout(std::chrono::high_resolution_clock::time_point old, double t return false; } -#ifdef __LINUX__ -std::string get_lib_path() { - std::string dir = "/proc/self/map_files"; - DIR *dp; - int i = 0; - struct dirent *ep; - dp = opendir (dir.c_str()); - uintptr_t p = (uintptr_t)&get_lib_path; +#if defined(__LINUX__) || defined(__APPLE__) +std::string get_lib_path() +{ + std::string library_path = "./"; - if (dp != NULL) - { - while ((ep = readdir (dp))) { - 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; - } - } - } + Dl_info infos; + dladdr((void*)&get_lib_path, &infos); + library_path = infos.dli_fname; - i++; - } - } - - (void) closedir (dp); - } - - return "."; + return library_path; } + #endif std::string get_full_lib_path() @@ -222,10 +196,10 @@ std::string get_full_program_path() std::string get_current_path() { std::string path; -#if defined(STEAM_WIN32) +#if defined(__WINDOWS__) char *buffer = _getcwd( NULL, 0 ); -#else - char *buffer = get_current_dir_name(); +#elif defined(__LINUX__) || defined(__APPLE__) + char *buffer = getcwd( NULL, 0 ); #endif if (buffer) { path = buffer; @@ -239,10 +213,10 @@ std::string get_current_path() std::string canonical_path(std::string path) { std::string output; -#if defined(STEAM_WIN32) +#if defined(__WINDOWS__) char *buffer = _fullpath(NULL, path.c_str(), 0); -#else - char *buffer = canonicalize_file_name(path.c_str()); +#elif defined(__LINUX__) || defined(__APPLE__) + char *buffer = realpath(path.c_str(), NULL); #endif if (buffer) { diff --git a/dll/common_includes.h b/dll/common_includes.h index 0bbedd8..2364fbf 100644 --- a/dll/common_includes.h +++ b/dll/common_includes.h @@ -69,8 +69,6 @@ #include // Include winsock2 before this, or winsock2 iphlpapi will be unavailable #include - #define MSG_NOSIGNAL 0 - #define SystemFunction036 NTAPI SystemFunction036 #include #undef SystemFunction036 @@ -96,7 +94,15 @@ #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 + #include + #endif + #include // getifaddrs #include #include @@ -109,7 +115,6 @@ #include #include - #include #include #include @@ -124,7 +129,13 @@ #define PRINT_DEBUG(...) {FILE *t = fopen("STEAM_LOG.txt", "a"); fprintf(t, __VA_ARGS__); fclose(t);} #endif #define PATH_SEPARATOR "/" + #endif + +#ifndef MSG_NOSIGNAL + #define MSG_NOSIGNAL 0 +#endif + //#define PRINT_DEBUG(...) fprintf(stdout, __VA_ARGS__) #ifdef EMU_RELEASE_BUILD #define PRINT_DEBUG(...) diff --git a/dll/network.cpp b/dll/network.cpp index 2de7de3..8e202ff 100644 --- a/dll/network.cpp +++ b/dll/network.cpp @@ -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) { - /* Not sure how many platforms this will run on, - * so it's wrapped in __linux for now. - * Definitely won't work like this on Windows... - */ - number_broadcasts = 0; - sock_t sock = 0; + ifaddrs* ifaces_list; - if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) - return; + number_broadcasts = 0; + if (getifaddrs(&ifaces_list) == 0) + { + const sockaddr_in* sock_addr; + for (ifaddrs* pIface = ifaces_list; pIface != nullptr; pIface = pIface->ifa_next) + { + if (pIface->ifa_addr->sa_family == AF_INET) + { + sock_addr = reinterpret_cast(pIface->ifa_addr); + if (sock_addr->sin_addr.s_addr != 0 && pIface->ifa_netmask != nullptr) + { + uint32_t ip = reinterpret_cast(pIface->ifa_addr)->sin_addr.s_addr; + uint32_t mask = reinterpret_cast(pIface->ifa_netmask)->sin_addr.s_addr; - /* Configure ifconf for the ioctl call. */ - struct ifreq i_faces[MAX_BROADCASTS]; - memset(i_faces, 0, sizeof(struct ifreq) * MAX_BROADCASTS); - - struct ifconf ifconf; - ifconf.ifc_buf = (char *)i_faces; - ifconf.ifc_len = sizeof(i_faces); - - 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->port = port; - number_broadcasts++; - } - - close(sock); + IP_PORT *ip_port = &broadcasts[number_broadcasts++]; + ip_port->ip = ip | ~mask; + ip_port->port = port; + } + } + // IPV6 + //else if (pIface->ifa_addr->sa_family == AF_INET6) + //{ + // const sockaddr_in6* addr = reinterpret_cast(pIface->ifa_addr);)); + //} + } + freeifaddrs(ifaces_list); + } } #endif diff --git a/dll/wrap.cpp b/dll/wrap.cpp index 50defc7..d8279f9 100644 --- a/dll/wrap.cpp +++ b/dll/wrap.cpp @@ -15,19 +15,12 @@ License along with the Goldberg Emulator; if not, see . */ -#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 "dll.h" +#if defined(__LINUX__) +#define STEAM_API_FUNCTIONS_IMPL + #define PATH_SEPARATOR_CHAR '/' #define STEAM_PATH_CACHE_SIZE 4096 From 1af9715decc046cc7dc6f39ebc6f2e3564167a88 Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Wed, 14 Oct 2020 06:53:57 +0200 Subject: [PATCH 4/6] Fix prefix --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 01a5bda..235e76e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -265,10 +265,6 @@ target_compile_definitions(${LIB_STEAM_API} # Setup for the steamclient(64).dll / libsteamclient.so? ######################################################## -if(UNIX) - SET_TARGET_PROPERTIES(${LIB_STEAMCLIENT} PROPERTIES PREFIX "") -endif() - # Setup the target add_library(${LIB_STEAMCLIENT} SHARED @@ -279,6 +275,10 @@ add_library(${LIB_STEAMCLIENT} ${PROTO_HDRS} ) +if(UNIX) + SET_TARGET_PROPERTIES(${LIB_STEAMCLIENT} PROPERTIES PREFIX "") +endif() + # Include the required directories target_include_directories( ${LIB_STEAMCLIENT} From bda70f5fd1db764b44df398ed7471b40f3d5aeb7 Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Wed, 14 Oct 2020 08:05:13 +0200 Subject: [PATCH 5/6] Add Big-O libsteam_api. Big-O are libraries on MacOS that contains both 32 and 64bits variants. --- .gitlab-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b05bd42..61166c8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -195,6 +195,7 @@ build:macosx: - 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: From 91031df89b6ac408727f9f7872766e9dcd41a1cc Mon Sep 17 00:00:00 2001 From: Nemirtingas Date: Wed, 14 Oct 2020 13:21:40 +0200 Subject: [PATCH 6/6] Build curl with only core http and https. --- .gitlab-ci.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 61166c8..763b63a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,14 +15,14 @@ static:linux:deps: - 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[openssl]:${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[openssl]:${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 @@ -50,14 +50,14 @@ static:windows:deps: - 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[winssl]:${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[winssl]:${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 @@ -85,13 +85,13 @@ static:macosx:deps: - 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[openssl]:${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[openssl]:${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