Skip to content

Commit a6cb476

Browse files
authored
Linux Fixes (#5)
* created include folder for the public interface * fixed include * moved forward declaration of GAState to GACommon.h * updated header * fixes for linux * proper include path * catch parsing errors * separate public and private libs, add public interface to source
1 parent b96efa3 commit a6cb476

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

CMakeLists.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ FILE(GLOB_RECURSE CPP_SOURCES
5353
"${GA_SOURCE_DIR}/gameanalytics/*.h"
5454
"${GA_SOURCE_DIR}/gameanalytics/*.cpp"
5555

56+
"${INCLUDE_DIR}/*.h"
57+
"${INCLUDE_DIR}/*.cpp"
58+
5659
# Add dependencies
5760
"${DEPENDENCIES_DIR}/crossguid/*"
5861
"${DEPENDENCIES_DIR}/nlohmann/*"
@@ -67,12 +70,14 @@ FILE(GLOB_RECURSE CPP_SOURCES
6770
create_source_groups(CPP_SOURCES)
6871

6972
if(${GA_USE_PACKAGE})
73+
7074
find_package(CURL REQUIRED PATHS ${EXTERNALS_DIR}/curl)
7175
find_package(OpenSSL REQUIRED PATHS ${EXTERNALS_DIR}/openssl)
7276
set(LIBS CURL::libcurl)
77+
7378
else()
74-
add_definitions("-DUSE_OPENSSL -DCURL_STATICLIB")
75-
add_definitions("-DCRYPTOPP_DISABLE_ASM")
79+
80+
add_definitions("-DUSE_OPENSSL -DCURL_STATICLIB -DCRYPTOPP_DISABLE_ASM")
7681

7782
link_directories(
7883
"${EXTERNALS_DIR}/openssl/1.1.1d/libs/${PLATFORM}"
@@ -113,7 +118,7 @@ elseif(APPLE)
113118
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGUID_CFUUID")
114119
FILE(GLOB_RECURSE MACOS_SOURCES "${GA_SOURCE_DIR}/gameanalytics/Platform/*.mm")
115120
list(APPEND CPP_SOURCES ${MACOS_SOURCES})
116-
list(APPEND LIBS
121+
set(PUBLIC_LIBS
117122
"-framework CoreFoundation"
118123
"-framework Foundation"
119124
"-framework CoreServices"
@@ -131,4 +136,4 @@ if(${GA_BUILD_SAMPLE})
131136
endif()
132137

133138
add_library(GameAnalytics ${LIB_TYPE} ${CPP_SOURCES})
134-
target_link_libraries(GameAnalytics ${LIBS})
139+
target_link_libraries(GameAnalytics PRIVATE ${LIBS} PUBLIC ${PUBLIC_LIBS})

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Usage of the SDK
8585
Remember to include the GameAnalytics header file wherever you are using the SDK:
8686

8787
``` c++
88-
#include "GameAnalytics.h"
88+
#include "GameAnalytics/GameAnalytics.h"
8989
```
9090

9191
### Custom log handler

source/gameanalytics/GAUtilities.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,15 @@ namespace gameanalytics
7979

8080
inline json parseFields(std::string const& fields)
8181
{
82-
return fields.empty() ? json() : json::parse(fields);
82+
try
83+
{
84+
return fields.empty() ? json() : json::parse(fields);
85+
}
86+
catch(const std::exception& e)
87+
{
88+
(void)e;
89+
return json();
90+
}
8391
}
8492

8593
inline std::int64_t getTimestamp()
@@ -134,7 +142,6 @@ namespace gameanalytics
134142
}
135143
catch(const std::exception& e)
136144
{
137-
//logging::GALogger::d("Error with ws2s: %S", wstr.c_str());
138145
return "";
139146
}
140147
}
@@ -147,7 +154,6 @@ namespace gameanalytics
147154
}
148155
catch(const std::exception& e)
149156
{
150-
//logging::GALogger::d("Error with s2ws: %s", str.c_str());
151157
return L"";
152158
}
153159
}

source/gameanalytics/Platform/GALinux.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#if IS_LINUX
44

5+
#include "GAState.h"
6+
57
#include <execinfo.h>
68
#include <sys/sysctl.h>
79
#include <sys/utsname.h>
@@ -172,25 +174,25 @@ void gameanalytics::GAPlatformLinux::signalHandler(int sig, siginfo_t* info, voi
172174
}
173175
}
174176

175-
std::string gameanalytics::GAPlatformMacOS::getCpuModel() const
177+
std::string gameanalytics::GAPlatformLinux::getCpuModel() const
176178
{
177179
struct utsname systemInfo;
178180
uname(&systemInfo);
179181

180182
return systemInfo.machine;
181183
}
182184

183-
std::string gameanalytics::GAPlatformMacOS::getGpuModel() const
185+
std::string gameanalytics::GAPlatformLinux::getGpuModel() const
184186
{
185187
return UNKNOWN_VALUE;
186188
}
187189

188-
int gameanalytics::GAPlatformMacOS::getNumCpuCores() const
190+
int gameanalytics::GAPlatformLinux::getNumCpuCores() const
189191
{
190192
return (int)sysconf(_SC_NPROCESSORS_ONLN);
191193
}
192194

193-
int64_t gameanalytics::GAPlatformMacOS::getTotalDeviceMemory() const
195+
int64_t gameanalytics::GAPlatformLinux::getTotalDeviceMemory() const
194196
{
195197
struct sysinfo info = {};
196198
if(sysinfo(&info) == 0)
@@ -258,5 +260,4 @@ int64_t gameanalytics::GAPlatformLinux::getBootTime() const
258260
return currentTime.tv_sec - startTime.tv_sec;
259261
}
260262

261-
262263
#endif

0 commit comments

Comments
 (0)