Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 59 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,38 @@ See the full [CHANGELOG](./CHANGELOG) for detailed version history.
How to build
------------

Run `setup.py` with the required argument for your platform:
Run `setup.py` with the required arguments for your platform:

```sh
python setup.py --platform {linux_x64,linux_x86,osx,win32,win64,uwp} [--cfg {Release,Debug}] [--build] [--test] [--coverage]
python setup.py --platform {linux_x64,linux_x86,osx,win32,win64,uwp} [--cfg {Release,Debug}] [--compiler {gcc,clang}] [--shared] [--build] [--test] [--coverage]
```

The following arguments are supported:
| Argument | Values | Description |
|---|---|---|
| `--platform` | `linux_x64`, `linux_x86`, `osx`, `win32`, `win64`, `uwp` | Target platform (**required**) |
| `--cfg` | `Release`, `Debug` | Build configuration (default: `Debug`) |
| `--compiler` | `gcc`, `clang` | Compiler selection — **Linux only** (default: `clang`) |
| `--shared` | — | Build a shared library (`.dll`/`.so`/`.dylib`) instead of a static library |
| `--build` | — | Execute the build step |
| `--test` | — | Execute the test step (not available with `--shared`) |
| `--coverage` | — | Generate code coverage report (not available with `--shared`) |

* `linux_x64`
* `linux_x86`
* `osx`
* `win32`
* `win64`
#### Examples

The generated project can be found inside the `build` folder.
Static library (default):
```sh
python setup.py --platform osx --cfg Release --build --test
```

Shared library (e.g. for Unity native plugin):
```sh
python setup.py --platform win64 --cfg Release --shared --build
python setup.py --platform osx --cfg Release --shared --build
python setup.py --platform linux_x64 --cfg Release --shared --build
python setup.py --platform linux_x64 --compiler gcc --cfg Release --shared --build
```

The generated project and build artifacts can be found inside the `build` folder. Packaged output (library + headers) is placed in `build/package/`.

Lib Dependencies
----------------
Expand All @@ -59,23 +76,54 @@ Lib Dependencies
Usage of the SDK
----------------

Remember to include the GameAnalytics header file wherever you are using the SDK:
### Static library (C++ API)

Include the GameAnalytics header file wherever you are using the SDK:

``` c++
#include "GameAnalytics/GameAnalytics.h"
```

### Shared library / Unity native plugin (C API)

When building with `--shared` / `-DGA_SHARED_LIB=ON`, the SDK exposes a C API via `GameAnalyticsExtern.h`. This is the intended integration path for Unity (P/Invoke) and other managed runtimes.

Include the header in your native wrapper:
```c
#include "GameAnalytics/GameAnalyticsExtern.h"
```

From Unity C#, import via `[DllImport]`:
```csharp
[DllImport("GameAnalytics")]
private static extern void gameAnalytics_initialize(string gameKey, string gameSecret);
```

> **Note:** Always call `gameAnalytics_freeString(ptr)` on any `const char*` returned by the C API to avoid memory leaks.

### Custom log handler
If you want to use your own custom log handler here is how it is done:

**C++ API:**
``` c++
void logHandler(const char *message, gameanalytics::EGALoggerMessageType type)
void logHandler(std::string const& message, gameanalytics::EGALoggerMessageType type)
{
// add your logging in here
}

gameanalytics::GameAnalytics::configureCustomLogHandler(logHandler);
```

**C API (shared lib):**
```c
void myLogHandler(const char* message, GALoggerMessageType type)
{
// add your logging in here
}

gameAnalytics_configureCustomLogHandler(myLogHandler);
```

### Configuration

Example:
Expand Down
2 changes: 1 addition & 1 deletion source/gameanalytics/GACommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace gameanalytics
class GAState;
}

constexpr const char* GA_VERSION_STR = "cpp 5.1.0";
constexpr const char* GA_VERSION_STR = "cpp 5.2.0";

constexpr int MAX_CUSTOM_FIELDS_COUNT = 50;
constexpr int MAX_CUSTOM_FIELDS_KEY_LENGTH = 64;
Expand Down
Loading