Skip to content

Commit

Permalink
internal: implement ga-sdk-cpp vcpkg port (skyrim-multiplayer#2145)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pospelove authored Aug 30, 2024
1 parent feef2b0 commit 1d27373
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 0 deletions.
68 changes: 68 additions & 0 deletions overlay_ports/ga-sdk-cpp/CMakelists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
cmake_minimum_required(VERSION 3.15)
project(ga-sdk-cpp)

add_definitions("-DGUID_WINDOWS")

add_library(ga-sdk-cpp
source/gameanalytics/GADevice.cpp
source/gameanalytics/GADevice.h
source/gameanalytics/GAEvents.cpp
source/gameanalytics/GAEvents.h
source/gameanalytics/GAHTTPApi.cpp
source/gameanalytics/GAHTTPApi.h
source/gameanalytics/GALogger.cpp
source/gameanalytics/GALogger.h
source/gameanalytics/GAState.cpp
source/gameanalytics/GAState.h
source/gameanalytics/GAStore.cpp
source/gameanalytics/GAStore.h
source/gameanalytics/GAThreading.cpp
source/gameanalytics/GAThreading.h
source/gameanalytics/GAUncaughtExceptionHandler.cpp
source/gameanalytics/GAUncaughtExceptionHandler.h
source/gameanalytics/GAUtilities.cpp
source/gameanalytics/GAUtilities.h
source/gameanalytics/GAValidator.cpp
source/gameanalytics/GAValidator.h
source/gameanalytics/GameAnalytics.cpp
source/gameanalytics/GameAnalytics.h
source/gameanalytics/GameAnalyticsExtern.cpp
source/gameanalytics/GameAnalyticsExtern.h
source/dependencies/crypto/aes.cpp
source/dependencies/crypto/aes.h
source/dependencies/crypto/hmac_sha2.c
source/dependencies/crypto/hmac_sha2.h
source/dependencies/crypto/md5.cpp
source/dependencies/crypto/md5.h
source/dependencies/crypto/sha2.c
source/dependencies/crypto/sha2.h

source/dependencies/stacktrace/stacktrace/call_stack.hpp
source/dependencies/stacktrace/stacktrace/call_stack_msvc.cpp
source/dependencies/stacktrace/stacktrace/stack_exception.hpp

source/dependencies/crossguid/guid.cpp
source/dependencies/crossguid/guid.h

source/dependencies/stackwalker/StackWalker.cpp
source/dependencies/stackwalker/StackWalker.h

)
target_include_directories(ga-sdk-cpp PUBLIC source/gameanalytics)
target_include_directories(ga-sdk-cpp PUBLIC source/dependencies/crypto)
target_include_directories(ga-sdk-cpp PUBLIC source/dependencies/stacktrace)
target_include_directories(ga-sdk-cpp PUBLIC source/dependencies/crossguid)
target_include_directories(ga-sdk-cpp PUBLIC source/dependencies/miniz)
target_include_directories(ga-sdk-cpp PUBLIC source/dependencies/stackwalker)

find_package(RapidJSON CONFIG REQUIRED)
set(RAPID_JSON_DIR ${RAPIDJSON_INCLUDE_DIRS})
target_include_directories(ga-sdk-cpp PUBLIC ${RAPID_JSON_DIR})

# install
install(TARGETS ga-sdk-cpp
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
20 changes: 20 additions & 0 deletions overlay_ports/ga-sdk-cpp/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO Pospelove/GA-SDK-CPP
REF 93b65d9f122794673c9d65382671d18dd7a599f3
SHA512 0ba69a33886eed8e4be15b09d3f21ef4428c0e8375f4af1e0cf892a68e3c9af2022215c406a8426640ae3e23902384314d4e42feadadab2d7769ee9ce37a5fdd
HEAD_REF patch-1
PATCHES void.patch
)

# copy cmakrlists.txt
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")

# add missing includes
file(READ "${SOURCE_PATH}/source/gameanalytics/GADevice.cpp" GADevice_cpp)
file(WRITE "${SOURCE_PATH}/source/gameanalytics/GADevice.cpp" "#include <tchar.h>\n#include <iostream>\n${GADevice_cpp}")

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
)
vcpkg_cmake_install()
18 changes: 18 additions & 0 deletions overlay_ports/ga-sdk-cpp/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "ga-sdk-cpp",
"version-string": "",
"homepage": "https://docs.gameanalytics.com/integrations/sdk/cpp",
"description": "GameAnalytics SDK for C++",
"supports": "windows",
"dependencies": [
"curl",
"openssl",
"rapidjson",
"sqlite3",
"zf-log",
{
"name": "vcpkg-cmake",
"host": true
}
]
}
22 changes: 22 additions & 0 deletions overlay_ports/ga-sdk-cpp/void.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/source/gameanalytics/GADevice.cpp b/source/gameanalytics/GADevice.cpp
index 5af4f16c..83bfbe6c 100644
--- a/source/gameanalytics/GADevice.cpp
+++ b/source/gameanalytics/GADevice.cpp
@@ -486,7 +486,7 @@ namespace gameanalytics
#endif

snprintf(GADevice::_deviceModel, sizeof(GADevice::_deviceModel), "%s", modelName.c_str());
- return true;
+ return;
}

std::cout << "Found device name:" << GADevice::_deviceModel;
@@ -570,7 +570,7 @@ namespace gameanalytics
CoUninitialize();

snprintf(GADevice::_deviceModel, sizeof(GADevice::_deviceModel), "%s", _com_util::ConvertBSTRToString(model));
- #elif
+ #else
return;
#endif // GA_USE_WBEM_SERVICES

13 changes: 13 additions & 0 deletions overlay_ports/zf-log/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO wonder-mice/zf_log
REF 5a3f2b46c3f62b97e2b33fbdb9d391abb64644f7
SHA512 bd81805105e17e4330d030493227074f09f3ffd8b42048eecdade93b72335b2ddcb0707bca5b52ff34852743535b0c3ad071b84fbfb8fa9b77280222a654e69c
HEAD_REF master
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/zf_log/")
17 changes: 17 additions & 0 deletions overlay_ports/zf-log/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "zf-log",
"version-string": "",
"homepage": "https://github.com/wonder-mice/zf_log",
"description": "Core logging library for C/ObjC/C++",
"supports": "windows",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
4 changes: 4 additions & 0 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
"name": "libarchive",
"platform": "windows",
"features": []
},
{
"name": "ga-sdk-cpp",
"platform": "windows"
}
],
"features": {
Expand Down

0 comments on commit 1d27373

Please sign in to comment.