Skip to content

Commit c8af4ab

Browse files
Fix ubuntu clang version for UE compatibility & use default args for getremoteconfigasstring (#24)
* using default argument instead of duplicated function * Update Main.cpp * set ubuntu-24.04 and clang version to 16 * Update cmake.yml * Update cmake.yml * Update cmake.yml * Update CMakeLists.txt * Update cmake.yml * Update cmake.yml * Update CMakeLists.txt * Update CMakeLists.txt * Update CMakeLists.txt * Update CMakeLists.txt * Update CMakeLists.txt * Update CMakeLists.txt * Update CMakeLists.txt * Update CMakeLists.txt * Update guid.cpp * Update guid.cpp * Update CMakeLists.txt * try and fix libc++ compatibility issues for linux * Update cmake.yml * Update cmake.yml * Update GALinux.cpp * Update CMakeLists.txt * Update CMakeLists.txt * Update CMakeLists.txt * Update cmake.yml * use with older ubuntu 20.04 * Update cmake.yml * Update cmake.yml * Update cmake.yml Update CMakeLists.txt Update cmake.yml fix linux compilation issue * Update cmake.yml * Update CMakeLists.txt * expose identifiers * renamed getUserId --------- Co-authored-by: Dorin <[email protected]>
1 parent 2c2740c commit c8af4ab

File tree

8 files changed

+56
-10
lines changed

8 files changed

+56
-10
lines changed

.github/workflows/cmake.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,30 @@ jobs:
7171
run: |
7272
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
7373
74+
- name: Install Clang and Libraries
75+
if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'clang'
76+
run: |
77+
sudo apt-get update
78+
sudo apt-get install -y clang libc++-dev libc++abi-dev
79+
80+
- name: Set Clang 16 as Default
81+
if: matrix.os == 'ubuntu-24.04' && matrix.c_compiler == 'clang'
82+
run: |
83+
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-16 100
84+
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-16 100
85+
sudo update-alternatives --set clang /usr/bin/clang-16
86+
sudo update-alternatives --set clang++ /usr/bin/clang++-16
87+
88+
- name: Check Clang Settings
89+
if: matrix.os == 'ubuntu-latest' && matrix.c_compiler == 'clang'
90+
run: |
91+
clang --version
92+
clang++ --version
93+
echo "Checking clang headers..."
94+
clang++ -v -E -x c++ /dev/null
95+
echo "check lld..."
96+
ldd --version
97+
7498
- name: Configure CMake
7599
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
76100
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
@@ -83,7 +107,7 @@ jobs:
83107
84108
- name: Build
85109
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
86-
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
110+
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --verbose
87111

88112
- name: Test
89113
working-directory: ${{ steps.strings.outputs.build-output-dir }}

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ elseif(APPLE)
197197
elseif(LINUX)
198198
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGUID_STDLIB -std=c++17")
199199

200-
if(CLANG)
200+
if (CMAKE_CXX_COMPILER MATCHES "clang")
201+
message(STATUS "Detected Clang compiler: ${CMAKE_CXX_COMPILER}")
201202
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
202203
endif()
203204

@@ -209,7 +210,9 @@ endif()
209210

210211
add_library(GameAnalytics ${LIB_TYPE} ${CPP_SOURCES})
211212
target_link_libraries(GameAnalytics PRIVATE ${LIBS} PUBLIC ${PUBLIC_LIBS})
212-
213+
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
214+
message(STATUS "CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}")
215+
message(STATUS "CMAKE_SHARED_LINKER_FLAGS: ${CMAKE_SHARED_LINKER_FLAGS}")
213216
# --------------------------- Google Test Setup --------------------------- #
214217

215218
# Set Project Name

include/GameAnalytics/GameAnalytics.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,16 @@ namespace gameanalytics
102102
static void startSession();
103103
static void endSession();
104104

105-
static std::string getRemoteConfigsValueAsString(std::string const& key);
106-
static std::string getRemoteConfigsValueAsString(std::string const& key, std::string const& defaultValue);
105+
static std::string getRemoteConfigsValueAsString(std::string const& key, std::string const& defaultValue = "");
107106

108107
static bool isRemoteConfigsReady();
109108
static void addRemoteConfigsListener(const std::shared_ptr<IRemoteConfigsListener> &listener);
110109
static void removeRemoteConfigsListener(const std::shared_ptr<IRemoteConfigsListener> &listener);
111110

112111
static std::string getRemoteConfigsContentAsString();
113-
static std::string getRemoteConfigsContentAsJson();
112+
113+
static std::string getUserId();
114+
static std::string getExternalUserId();
114115

115116
static std::string getABTestingId();
116117
static std::string getABTestingVariantId();

sample/Main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <string>
22
#include <iostream>
33
#include <thread>
4+
#include <chrono>
45

56
#include "GameAnalytics/GameAnalytics.h"
67

source/gameanalytics/GAState.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,16 @@ namespace gameanalytics
6161
getInstance().cacheIdentifier();
6262
}
6363

64-
std::string GAState::getIdentifier()
64+
std::string GAState::getUserId()
6565
{
6666
return getInstance()._identifier;
6767
}
6868

69+
std::string GAState::getExternalUserId()
70+
{
71+
return getInstance()._externalUserId;
72+
}
73+
6974
bool GAState::isInitialized()
7075
{
7176
return getInstance()._initialized;
@@ -402,7 +407,7 @@ namespace gameanalytics
402407
out["event_uuid"] = utilities::GAUtilities::generateUUID();
403408

404409
// User identifier
405-
out["user_id"] = getInstance().getIdentifier();
410+
out["user_id"] = getUserId();
406411

407412
// remote configs configurations
408413
if(getInstance()._configurations.is_object() && !getInstance()._configurations.empty())

source/gameanalytics/GAState.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ namespace gameanalytics
141141
static std::string getRemoteConfigsContentAsString();
142142
static std::string getAbId();
143143
static std::string getAbVariantId();
144+
static std::string getUserId();
145+
static std::string getExternalUserId();
144146

145147
static json getValidatedCustomFields();
146148
static json getValidatedCustomFields(const json& withEventFields);
@@ -164,7 +166,6 @@ namespace gameanalytics
164166
addErrorEvent(severity, msg);
165167
}
166168

167-
std::string getIdentifier();
168169
void setDefaultUserId(std::string const& id);
169170
json& getSdkConfig();
170171
void cacheIdentifier();

source/gameanalytics/GameAnalytics.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ namespace gameanalytics
475475
{
476476
// Send to events
477477
json fieldsJson = utilities::parseFields(fields);
478-
events::GAEvents::addProgressionEvent(progressionStatus, progression01, progression02, progression03, score, false, fieldsJson, mergeFields);
478+
events::GAEvents::addProgressionEvent(progressionStatus, progression01, progression02, progression03, score, true, fieldsJson, mergeFields);
479479
}
480480
catch(const json::exception& e)
481481
{
@@ -763,6 +763,16 @@ namespace gameanalytics
763763
return state::GAState::getRemoteConfigsContentAsString();
764764
}
765765

766+
std::string GameAnalytics::getUserId()
767+
{
768+
return state::GAState::getUserId();
769+
}
770+
771+
std::string GameAnalytics::getExternalUserId()
772+
{
773+
return state::GAState::getExternalUserId();
774+
}
775+
766776
std::string GameAnalytics::getABTestingId()
767777
{
768778
return state::GAState::getAbId();

source/gameanalytics/Platform/GALinux.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "GAState.h"
66

7+
#include <sstream>
78
#include <errno.h>
89
#include <linux/unistd.h>
910
#include <linux/kernel.h>

0 commit comments

Comments
 (0)