mirror of
https://github.com/yuzu-emu/discord-rpc.git
synced 2024-11-27 19:54:16 +01:00
Start on dllification
This commit is contained in:
parent
120fe1b069
commit
1e971e1161
@ -1,24 +1,42 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
// clang-format off
|
||||
|
||||
#if defined(DISCORD_DYNAMIC_LIB)
|
||||
# if defined(_WIN32)
|
||||
# if defined(DISCORD_BUILDING_SDK)
|
||||
# define DISCORD_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define DISCORD_EXPORT __declspec(dllimport)
|
||||
# endif
|
||||
# else
|
||||
# define DISCORD_EXPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
#else
|
||||
# define DISCORD_EXPORT
|
||||
#endif
|
||||
|
||||
// clang-format on
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct DiscordRichPresence {
|
||||
const char* state; /* max 128 bytes */
|
||||
const char* state; /* max 128 bytes */
|
||||
const char* details; /* max 128 bytes */
|
||||
int64_t startTimestamp;
|
||||
int64_t endTimestamp;
|
||||
const char* largeImageKey; /* max 32 bytes */
|
||||
const char* largeImageKey; /* max 32 bytes */
|
||||
const char* largeImageText; /* max 128 bytes */
|
||||
const char* smallImageKey; /* max 32 bytes */
|
||||
const char* smallImageKey; /* max 32 bytes */
|
||||
const char* smallImageText; /* max 128 bytes */
|
||||
const char* partyId; /* max 128 bytes */
|
||||
const char* partyId; /* max 128 bytes */
|
||||
int partySize;
|
||||
int partyMax;
|
||||
const char* matchSecret; /* max 128 bytes */
|
||||
const char* joinSecret; /* max 128 bytes */
|
||||
const char* matchSecret; /* max 128 bytes */
|
||||
const char* joinSecret; /* max 128 bytes */
|
||||
const char* spectateSecret; /* max 128 bytes */
|
||||
int8_t instance;
|
||||
} DiscordRichPresence;
|
||||
@ -31,20 +49,20 @@ typedef struct DiscordEventHandlers {
|
||||
void (*spectateGame)(const char* spectateSecret);
|
||||
} DiscordEventHandlers;
|
||||
|
||||
void Discord_Initialize(const char* applicationId,
|
||||
DiscordEventHandlers* handlers,
|
||||
int autoRegister);
|
||||
void Discord_Shutdown();
|
||||
DISCORD_EXPORT void Discord_Initialize(const char* applicationId,
|
||||
DiscordEventHandlers* handlers,
|
||||
int autoRegister);
|
||||
DISCORD_EXPORT void Discord_Shutdown();
|
||||
|
||||
/* checks for incoming messages, dispatches callbacks */
|
||||
void Discord_RunCallbacks();
|
||||
DISCORD_EXPORT void Discord_RunCallbacks();
|
||||
|
||||
/* If you disable the lib starting its own io thread, you'll need to call this from your own */
|
||||
#ifdef DISCORD_DISABLE_IO_THREAD
|
||||
void Discord_UpdateConnection();
|
||||
DISCORD_EXPORT void Discord_UpdateConnection();
|
||||
#endif
|
||||
|
||||
void Discord_UpdatePresence(const DiscordRichPresence* presence);
|
||||
DISCORD_EXPORT void Discord_UpdatePresence(const DiscordRichPresence* presence);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
@ -1,26 +1,38 @@
|
||||
include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||
|
||||
option(ENABLE_IO_THREAD "Start up a separate I/O thread, otherwise I'd need to call an update function" ON)
|
||||
option(BUILD_DYNAMIC_LIB "Build library as a DLL" OFF)
|
||||
|
||||
if (${ENABLE_IO_THREAD} EQUAL OFF)
|
||||
add_definitions(-DDISCORD_DISABLE_IO_THREAD)
|
||||
endif (${ENABLE_IO_THREAD} EQUAL OFF)
|
||||
|
||||
if (${BUILD_DYNAMIC_LIB} EQUAL ON)
|
||||
set(RPC_LIBRARY_TYPE DYNAMIC)
|
||||
else(${BUILD_DYNAMIC_LIB} EQUAL ON)
|
||||
set(RPC_LIBRARY_TYPE STATIC)
|
||||
endif(${BUILD_DYNAMIC_LIB} EQUAL ON)
|
||||
|
||||
set(BASE_RPC_SRC ${PROJECT_SOURCE_DIR}/include/discord-rpc.h discord-rpc.cpp discord-register.cpp rpc_connection.h rpc_connection.cpp serialization.h serialization.cpp connection.h backoff.h)
|
||||
|
||||
if(WIN32)
|
||||
add_library(discord-rpc STATIC ${BASE_RPC_SRC} connection_win.cpp)
|
||||
add_library(discord-rpc ${RPC_LIBRARY_TYPE} ${BASE_RPC_SRC} connection_win.cpp)
|
||||
target_compile_options(discord-rpc PRIVATE /W4)
|
||||
endif(WIN32)
|
||||
|
||||
if(UNIX)
|
||||
add_library(discord-rpc STATIC ${BASE_RPC_SRC} connection_unix.cpp)
|
||||
add_library(discord-rpc ${RPC_LIBRARY_TYPE} ${BASE_RPC_SRC} connection_unix.cpp)
|
||||
target_link_libraries(discord-rpc PUBLIC pthread)
|
||||
target_compile_options(discord-rpc PRIVATE -g -Wall)
|
||||
endif(UNIX)
|
||||
|
||||
target_include_directories(discord-rpc PRIVATE ${RAPIDJSON}/include)
|
||||
|
||||
if (${BUILD_DYNAMIC_LIB} EQUAL ON)
|
||||
target_compile_definitions(discord-rpc PUBLIC -DDISCORD_DYNAMIC_LIB)
|
||||
target_compile_definitions(discord-rpc PRIVATE -DDISCORD_BUILDING_SDK)
|
||||
endif(${BUILD_DYNAMIC_LIB} EQUAL ON)
|
||||
|
||||
add_dependencies(discord-rpc clangformat)
|
||||
|
||||
# install
|
||||
|
Loading…
Reference in New Issue
Block a user