Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libdatachannel] Add new port #13704

Merged
merged 15 commits into from
Nov 23, 2020
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
110 changes: 110 additions & 0 deletions ports/libdatachannel/fix-for-vcpkg.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bed634b..fced56e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -112,28 +112,18 @@ set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)

set(CMAKE_POLICY_DEFAULT_CMP0048 NEW)
-add_subdirectory(deps/plog)
-
-option(sctp_build_programs 0)
-option(sctp_build_shared_lib 0)
-add_subdirectory(deps/usrsctp EXCLUDE_FROM_ALL)
-if (MSYS OR MINGW)
- target_compile_definitions(usrsctp PUBLIC -DSCTP_STDINT_INCLUDE=<stdint.h>)
-endif()
-if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
- target_compile_options(usrsctp PRIVATE -Wno-error=format-truncation)
-endif()
-add_library(Usrsctp::Usrsctp ALIAS usrsctp)
+find_library(USRSCTP_LIBRARY usrsctp REQUIRED)
+find_path(PLOG_INCLUDE_DIRS "plog/Appenders/AndroidAppender.h")

if (NO_WEBSOCKET)
- add_library(datachannel SHARED
+ add_library(datachannel
${LIBDATACHANNEL_SOURCES})
add_library(datachannel-static STATIC EXCLUDE_FROM_ALL
${LIBDATACHANNEL_SOURCES})
target_compile_definitions(datachannel PUBLIC RTC_ENABLE_WEBSOCKET=0)
target_compile_definitions(datachannel-static PUBLIC RTC_ENABLE_WEBSOCKET=0)
else()
- add_library(datachannel SHARED
+ add_library(datachannel
${LIBDATACHANNEL_SOURCES}
${LIBDATACHANNEL_WEBSOCKET_SOURCES})
add_library(datachannel-static STATIC EXCLUDE_FROM_ALL
@@ -150,17 +140,17 @@ set_target_properties(datachannel-static PROPERTIES
VERSION ${PROJECT_VERSION}
CXX_STANDARD 17)

-target_include_directories(datachannel PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
+target_include_directories(datachannel PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
target_include_directories(datachannel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/rtc)
target_include_directories(datachannel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
-target_link_libraries(datachannel PUBLIC Threads::Threads plog::plog)
-target_link_libraries(datachannel PRIVATE Usrsctp::Usrsctp)
+target_include_directories(datachannel PRIVATE ${PLOG_INCLUDE_DIRS})
+target_link_libraries(datachannel PUBLIC Threads::Threads ${USRSCTP_LIBRARY})

target_include_directories(datachannel-static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_include_directories(datachannel-static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/rtc)
target_include_directories(datachannel-static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
-target_link_libraries(datachannel-static PUBLIC Threads::Threads plog::plog)
-target_link_libraries(datachannel-static PRIVATE Usrsctp::Usrsctp)
+target_include_directories(datachannel-static PRIVATE ${PLOG_INCLUDE_DIRS})
+target_link_libraries(datachannel-static PUBLIC Threads::Threads ${USRSCTP_LIBRARY})

if(WIN32)
target_link_libraries(datachannel PRIVATE ws2_32) # winsock2
@@ -224,11 +214,11 @@ if (USE_NICE OR NOT USE_JUICE)
target_link_libraries(datachannel PRIVATE LibNice::LibNice)
target_link_libraries(datachannel-static PRIVATE LibNice::LibNice)
else()
- add_subdirectory(deps/libjuice EXCLUDE_FROM_ALL)
+ find_package(libjuice CONFIG REQUIRED)
target_compile_definitions(datachannel PRIVATE USE_NICE=0)
target_compile_definitions(datachannel-static PRIVATE USE_NICE=0)
- target_link_libraries(datachannel PRIVATE LibJuice::LibJuiceStatic)
- target_link_libraries(datachannel-static PRIVATE LibJuice::LibJuiceStatic)
+ target_link_libraries(datachannel PRIVATE LibJuice::juice)
+ target_link_libraries(datachannel-static PRIVATE LibJuice::juice)
endif()

if(RSA_KEY_BITS_2048)
@@ -244,7 +234,11 @@ endif()
add_library(LibDataChannel::LibDataChannel ALIAS datachannel)
add_library(LibDataChannel::LibDataChannelStatic ALIAS datachannel-static)

-install(TARGETS datachannel LIBRARY DESTINATION lib)
+install(TARGETS datachannel EXPORT libdatachannel-config
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+)
install(FILES ${LIBDATACHANNEL_HEADERS} DESTINATION include/rtc)

if(NOT MSVC)
@@ -306,3 +300,8 @@ if(NOT NO_EXAMPLES AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
add_subdirectory(examples/copy-paste-capi)
endif()

+install(
+ EXPORT libdatachannel-config
+ NAMESPACE LibDatachannel::
+ DESTINATION share/cmake/libdatachannel
+)
diff --git a/src/tcptransport.hpp b/src/tcptransport.hpp
index 1447835..1c92686 100644
--- a/src/tcptransport.hpp
+++ b/src/tcptransport.hpp
@@ -29,7 +29,7 @@
#include <thread>

// Use the socket defines from libjuice
-#include "../deps/libjuice/src/socket.h"
+#include <juice/src/socket.h>

namespace rtc {

34 changes: 34 additions & 0 deletions ports/libdatachannel/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO paullouisageneau/libdatachannel
REF v0.10.1
SHA512 195f564776b2a7ab6fe3a838d55be7fa03b72a5f08faaba5ddefac59ae1fff28f3ee0b9ed5dc17a7ef9155a1d30a61f8c593f2a108f60e415ffd213188e081bd
HEAD_REF master
PATCHES
fix-for-vcpkg.patch
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
INVERTED_FEATURES
ws NO_WEBSOCKET
srtp NO_MEDIA
)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
${FEATURE_OPTIONS}
-DUSE_SYSTEM_SRTP=ON
-DNO_EXAMPLES=ON
-DNO_TESTS=ON
)

vcpkg_install_cmake()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

vcpkg_fixup_cmake_targets(CONFIG_PATH share/cmake/libdatachannel)
vcpkg_fixup_pkgconfig()

file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
26 changes: 26 additions & 0 deletions ports/libdatachannel/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "libdatachannel",
"version-string": "v0.10.1",
"description": "libdatachannel is a standalone implementation of WebRTC Data Channels, WebRTC Media Transport, and WebSockets in C++17 with C bindings for POSIX platforms (including GNU/Linux, Android, and Apple macOS) and Microsoft Windows.",
"homepage": "https://github.com/paullouisageneau/libdatachannel",
"dependencies": [
"libjuice",
"openssl",
"plog",
"usrsctp"
],
"default-features": [
"ws"
],
"features": {
"srtp": {
"description": "Use Cisco's libSRTP for media transport.",
"dependencies": [
"libsrtp"
]
},
strega-nil marked this conversation as resolved.
Show resolved Hide resolved
"ws": {
"description": "Web Socket support"
}
}
}