Skip to content

Commit

Permalink
Chatterinoify the repo (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
pajlada authored Jan 26, 2024
1 parent 73efc0f commit 091301e
Show file tree
Hide file tree
Showing 35 changed files with 168 additions and 77 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
-DCMAKE_BUILD_TYPE=RelWithDebInfo `
-DCMAKE_TOOLCHAIN_FILE="conan_toolchain.cmake" `
-DEVENTSUB_BUILD_EXAMPLE=On `
..
../example
set cl=/MP
nmake /S /NOLOGO
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
CXXFLAGS=-fno-sized-deallocation cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DEVENTSUB_BUILD_EXAMPLE=On \
..
../example
make -j"$(nproc)"
shell: bash
env:
Expand All @@ -154,6 +154,6 @@ jobs:
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.15 \
-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl \
-DEVENTSUB_BUILD_EXAMPLE=On \
..
../example
make -j"$(sysctl -n hw.logicalcpu)"
shell: bash
12 changes: 2 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,23 @@ cmake_policy(SET CMP0087 NEW) # evaluates generator expressions in `install(CODE
cmake_policy(SET CMP0091 NEW) # select MSVC runtime library through `CMAKE_MSVC_RUNTIME_LIBRARY`
include(FeatureSummary)

option(EVENTSUB_BUILD_EXAMPLE "Build example application" OFF)
set(TWITCH_EVENTSUB_WS_LIBRARY_TYPE "OBJECT" CACHE STRING "What type of library to build this as (defaults to OBJECT)")

list(APPEND CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/cmake"
)

project(eventsub VERSION 0.1.0)
project(twitch-eventsub-ws VERSION 0.1.0)

# Find boost on the system
find_package(Boost REQUIRED OPTIONAL_COMPONENTS json)

# Find OpenSSL on the system
find_package(OpenSSL REQUIRED)

find_package(Threads REQUIRED)

find_library(LIBRT rt)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_subdirectory(src)

if (EVENTSUB_BUILD_EXAMPLE)
add_subdirectory(example)
endif ()

feature_summary(WHAT ALL)
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
update-deserializations: update-payloads update-messages

update-payloads:
@./ast/venv/bin/python3 ./ast/generate-and-replace-dir.py ./include/eventsub/payloads
@./ast/venv/bin/python3 ./ast/generate-and-replace-dir.py ./include/twitch-eventsub-ws/payloads

update-messages:
@./ast/venv/bin/python3 ./ast/generate-and-replace-dir.py ./include/eventsub/messages
@./ast/venv/bin/python3 ./ast/generate-and-replace-dir.py ./include/twitch-eventsub-ws/messages
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# twitch-eventsub-ws

This library implements some of [Twitch's EventSub](https://dev.twitch.tv/docs/eventsub/) topics for use in [Chatterino 2](https://github.com/Chatterino/chatterino2)

Topic generation is done in the `ast` directory

The example can be built like this:

```sh
mkdir build
cd build
cmake ../example
cmake --build .
```
2 changes: 1 addition & 1 deletion ast/generate-and-replace-dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def main():

header_path = path.path
source_path = re.sub(r"\.hpp$", ".cpp", header_path)
source_path = re.sub(r"include[/\\]eventsub[/\\]", "src/", source_path)
source_path = re.sub(r"include[/\\]twitch-eventsub-ws[/\\]", "src/", source_path)

if not os.path.isfile(source_path):
log.warning(f"Header file {header_path} did not have a matching source file at {source_path}")
Expand Down
30 changes: 20 additions & 10 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
set(EXECUTABLE_PROJECT "${PROJECT_NAME}-example")
cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0087 NEW) # evaluates generator expressions in `install(CODE/SCRIPT)`
cmake_policy(SET CMP0091 NEW) # select MSVC runtime library through `CMAKE_MSVC_RUNTIME_LIBRARY`

add_executable(${EXECUTABLE_PROJECT} main.cpp)
project(twitch-eventsub-ws-example VERSION 0.1.0)

target_link_libraries(${EXECUTABLE_PROJECT}
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_executable(${PROJECT_NAME} main.cpp)

add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/.." twitch-eventsub-ws)

find_library(LIBRT rt)
find_package(Threads REQUIRED)

target_link_libraries(${PROJECT_NAME}
PUBLIC

Threads::Threads
${PROJECT_NAME}
twitch-eventsub-ws
)

# Set the output of TARGET to be
Expand All @@ -25,19 +37,17 @@ function(set_target_directory_hierarchy TARGET)
)
endfunction()

set_target_directory_hierarchy(${EXECUTABLE_PROJECT})

target_include_directories(${EXECUTABLE_PROJECT} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
set_target_directory_hierarchy(${PROJECT_NAME})

# See https://github.com/boostorg/beast/issues/2661
target_compile_definitions(${EXECUTABLE_PROJECT} PRIVATE BOOST_ASIO_DISABLE_CONCEPTS)
target_compile_definitions(${PROJECT_NAME} PRIVATE BOOST_ASIO_DISABLE_CONCEPTS)

if (MSVC)
target_compile_options(${EXECUTABLE_PROJECT} PUBLIC /EHsc /bigobj)
target_compile_options(${PROJECT_NAME} PUBLIC /EHsc /bigobj)
endif ()

if (LIBRT)
target_link_libraries(${EXECUTABLE_PROJECT}
target_link_libraries(${PROJECT_NAME}
PUBLIC
${LIBRT}
)
Expand Down
4 changes: 2 additions & 2 deletions example/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "eventsub/listener.hpp"
#include "eventsub/session.hpp"
#include "twitch-eventsub-ws/listener.hpp"
#include "twitch-eventsub-ws/session.hpp"

#include <boost/asio/io_context.hpp>
#include <boost/asio/ssl.hpp>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "eventsub/date.h"
#include "twitch-eventsub-ws/date.h"

#include <boost/json.hpp>

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#pragma once

#include "eventsub/messages/metadata.hpp"
#include "eventsub/payloads/channel-ban-v1.hpp"
#include "eventsub/payloads/channel-chat-message-v1.hpp"
#include "eventsub/payloads/channel-chat-notification-v1.hpp"
#include "eventsub/payloads/channel-update-v1.hpp"
#include "eventsub/payloads/session-welcome.hpp"
#include "eventsub/payloads/stream-offline-v1.hpp"
#include "eventsub/payloads/stream-online-v1.hpp"
#include "twitch-eventsub-ws/messages/metadata.hpp"
#include "twitch-eventsub-ws/payloads/channel-ban-v1.hpp"
#include "twitch-eventsub-ws/payloads/channel-chat-message-v1.hpp"
#include "twitch-eventsub-ws/payloads/channel-chat-notification-v1.hpp"
#include "twitch-eventsub-ws/payloads/channel-update-v1.hpp"
#include "twitch-eventsub-ws/payloads/session-welcome.hpp"
#include "twitch-eventsub-ws/payloads/stream-offline-v1.hpp"
#include "twitch-eventsub-ws/payloads/stream-online-v1.hpp"

namespace eventsub {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "eventsub/errors.hpp"
#include "twitch-eventsub-ws/errors.hpp"

#include <boost/json.hpp>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "eventsub/payloads/subscription.hpp"
#include "twitch-eventsub-ws/payloads/subscription.hpp"

#include <boost/json.hpp>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "eventsub/payloads/subscription.hpp"
#include "twitch-eventsub-ws/payloads/subscription.hpp"

#include <boost/json.hpp>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "eventsub/payloads/subscription.hpp"
#include "twitch-eventsub-ws/payloads/subscription.hpp"

#include <boost/json.hpp>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "eventsub/payloads/subscription.hpp"
#include "twitch-eventsub-ws/payloads/subscription.hpp"

#include <boost/json.hpp>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "eventsub/errors.hpp"
#include "twitch-eventsub-ws/errors.hpp"

#include <boost/json.hpp>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "eventsub/payloads/subscription.hpp"
#include "twitch-eventsub-ws/payloads/subscription.hpp"

#include <boost/json.hpp>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "eventsub/payloads/subscription.hpp"
#include "twitch-eventsub-ws/payloads/subscription.hpp"

#include <boost/json.hpp>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "eventsub/payloads/subscription.hpp"
#include "twitch-eventsub-ws/payloads/subscription.hpp"

#include <boost/json.hpp>

Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ set(SOURCE_FILES
messages/metadata.cpp
)

add_library(${PROJECT_NAME} OBJECT ${SOURCE_FILES})
message(STATUS "Building ${PROJECT_NAME} as a '${TWITCH_EVENTSUB_WS_LIBRARY_TYPE}' library")
add_library(${PROJECT_NAME} ${TWITCH_EVENTSUB_WS_LIBRARY_TYPE} ${SOURCE_FILES})

# Generate source groups for use in IDEs
# source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${SOURCE_FILES})
Expand Down
2 changes: 1 addition & 1 deletion src/chrono.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "eventsub/chrono.hpp"
#include "twitch-eventsub-ws/chrono.hpp"

namespace eventsub {

Expand Down
4 changes: 2 additions & 2 deletions src/messages/metadata.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "eventsub/messages/metadata.hpp"
#include "twitch-eventsub-ws/messages/metadata.hpp"

#include "eventsub/errors.hpp"
#include "twitch-eventsub-ws/errors.hpp"

#include <boost/json.hpp>

Expand Down
6 changes: 3 additions & 3 deletions src/payloads/channel-ban-v1.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "eventsub/payloads/channel-ban-v1.hpp"
#include "twitch-eventsub-ws/payloads/channel-ban-v1.hpp"

#include "eventsub/chrono.hpp"
#include "eventsub/errors.hpp"
#include "twitch-eventsub-ws/chrono.hpp"
#include "twitch-eventsub-ws/errors.hpp"

#include <boost/json.hpp>

Expand Down
Loading

0 comments on commit 091301e

Please sign in to comment.