From 8ae59b5b1329a51875abc71d528da93d9c3e8972 Mon Sep 17 00:00:00 2001 From: Kai Pastor Date: Fri, 9 Aug 2024 06:50:28 +0200 Subject: [PATCH] [libdatachannel] Update, cleanup (#40337) --- ports/libdatachannel/dependencies.diff | 63 +++++++++++++++++++++++ ports/libdatachannel/fix-for-vcpkg.patch | 30 ----------- ports/libdatachannel/fix_dependency.patch | 40 -------------- ports/libdatachannel/fix_srtp.patch | 13 ----- ports/libdatachannel/library-linkage.diff | 22 ++++++++ ports/libdatachannel/portfile.cmake | 39 ++++---------- ports/libdatachannel/uwp-warnings.patch | 19 +++---- ports/libdatachannel/vcpkg.json | 2 +- versions/baseline.json | 2 +- versions/l-/libdatachannel.json | 5 ++ 10 files changed, 111 insertions(+), 124 deletions(-) create mode 100644 ports/libdatachannel/dependencies.diff delete mode 100644 ports/libdatachannel/fix-for-vcpkg.patch delete mode 100644 ports/libdatachannel/fix_dependency.patch delete mode 100644 ports/libdatachannel/fix_srtp.patch create mode 100644 ports/libdatachannel/library-linkage.diff diff --git a/ports/libdatachannel/dependencies.diff b/ports/libdatachannel/dependencies.diff new file mode 100644 index 00000000000000..01ea420c1b92a6 --- /dev/null +++ b/ports/libdatachannel/dependencies.diff @@ -0,0 +1,63 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 8a61757..b35e4b1 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -234,7 +234,7 @@ set(THREADS_PREFER_PTHREAD_FLAG TRUE) + find_package(Threads REQUIRED) + + if(USE_SYSTEM_PLOG) +- find_package(plog REQUIRED) ++ find_package(plog CONFIG REQUIRED) + else() + set(CMAKE_POLICY_DEFAULT_CMP0048 NEW) + add_subdirectory(deps/plog EXCLUDE_FROM_ALL) +@@ -245,7 +245,8 @@ if(SCTP_DEBUG) + endif() + + if(USE_SYSTEM_USRSCTP) +- find_package(Usrsctp REQUIRED) ++ find_package(unofficial-usrsctp CONFIG REQUIRED) ++ add_library(Usrsctp::Usrsctp ALIAS unofficial::usrsctp::usrsctp) + else() + option(sctp_build_shared_lib OFF) + option(sctp_build_programs OFF) +@@ -331,7 +332,7 @@ else() + target_compile_definitions(datachannel PUBLIC RTC_ENABLE_MEDIA=1) + target_compile_definitions(datachannel-static PUBLIC RTC_ENABLE_MEDIA=1) + if(USE_SYSTEM_SRTP) +- find_package(libSRTP REQUIRED) ++ find_package(libSRTP CONFIG REQUIRED) + if(NOT TARGET libSRTP::srtp2) + add_library(libSRTP::srtp2 UNKNOWN IMPORTED) + set_target_properties(libSRTP::srtp2 PROPERTIES +@@ -475,8 +476,9 @@ install( + ) + + # Export config ++configure_file(cmake/LibDataChannelConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/cmake/LibDataChannelConfig.cmake @ONLY) + install( +- FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/LibDataChannelConfig.cmake ++ FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/LibDataChannelConfig.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/LibDataChannel + ) + +diff --git a/cmake/LibDataChannelConfig.cmake b/cmake/LibDataChannelConfig.cmake +index cb2b884..d0b77ca 100644 +--- a/cmake/LibDataChannelConfig.cmake ++++ b/cmake/LibDataChannelConfig.cmake +@@ -1,2 +1,15 @@ ++if(NOT "@BUILD_SHARED_LIBS@") ++ include(CMakeFindDependencyMacro) ++ set(THREADS_PREFER_PTHREAD_FLAG ON) ++ find_dependency(Threads) ++ find_dependency(plog CONFIG) ++ find_dependency(unofficial-usrsctp CONFIG) ++ if(NOT "@NO_MEDIA@") ++ find_dependency(libSRTP CONFIG) ++ endif() ++ find_dependency(OpenSSL) ++ find_dependency(LibJuice) ++endif() ++ + include("${CMAKE_CURRENT_LIST_DIR}/LibDataChannelTargets.cmake") + diff --git a/ports/libdatachannel/fix-for-vcpkg.patch b/ports/libdatachannel/fix-for-vcpkg.patch deleted file mode 100644 index 2b5f27f80dc297..00000000000000 --- a/ports/libdatachannel/fix-for-vcpkg.patch +++ /dev/null @@ -1,30 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index a3837943..2c34d7fb 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -446,11 +446,25 @@ if(WARNINGS_AS_ERRORS) - endif() - endif() - -+if(DATACHANNEL_STATIC_LINKAGE) -+set_target_properties(datachannel PROPERTIES EXCLUDE_FROM_ALL 1) -+set_target_properties(datachannel-static PROPERTIES EXCLUDE_FROM_ALL 0) -+ -+install(TARGETS datachannel-static EXPORT LibDataChannelTargets -+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} -+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} -+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} -+) -+else() -+set_target_properties(datachannel PROPERTIES EXCLUDE_FROM_ALL 0) -+set_target_properties(datachannel-static PROPERTIES EXCLUDE_FROM_ALL 1) -+ - install(TARGETS datachannel EXPORT LibDataChannelTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - ) -+endif() - - install(FILES ${LIBDATACHANNEL_HEADERS} - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rtc diff --git a/ports/libdatachannel/fix_dependency.patch b/ports/libdatachannel/fix_dependency.patch deleted file mode 100644 index 88e44dcd988f71..00000000000000 --- a/ports/libdatachannel/fix_dependency.patch +++ /dev/null @@ -1,40 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index f604628..1610166 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -239,7 +239,7 @@ set(THREADS_PREFER_PTHREAD_FLAG TRUE) - find_package(Threads REQUIRED) - - if(USE_SYSTEM_PLOG) -- find_package(plog REQUIRED) -+ find_package(plog CONFIG REQUIRED) - else() - set(CMAKE_POLICY_DEFAULT_CMP0048 NEW) - add_subdirectory(deps/plog EXCLUDE_FROM_ALL) -@@ -250,7 +250,7 @@ if(SCTP_DEBUG) - endif() - - if(USE_SYSTEM_USRSCTP) -- find_package(Usrsctp REQUIRED) -+ find_package(unofficial-usrsctp CONFIG REQUIRED) - else() - option(sctp_build_shared_lib OFF) - option(sctp_build_programs OFF) -@@ -294,7 +294,7 @@ target_include_directories(datachannel PUBLIC - 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 PRIVATE Threads::Threads) --target_link_libraries(datachannel PRIVATE Usrsctp::Usrsctp plog::plog) -+target_link_libraries(datachannel PRIVATE unofficial::usrsctp::usrsctp plog::plog) - - target_include_directories(datachannel-static PUBLIC - $ -@@ -302,7 +302,7 @@ target_include_directories(datachannel-static PUBLIC - 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 PRIVATE Threads::Threads) --target_link_libraries(datachannel-static PRIVATE Usrsctp::Usrsctp plog::plog) -+target_link_libraries(datachannel-static PRIVATE unofficial::usrsctp::usrsctp plog::plog) - - if(WIN32) - target_link_libraries(datachannel PUBLIC ws2_32) # winsock2 diff --git a/ports/libdatachannel/fix_srtp.patch b/ports/libdatachannel/fix_srtp.patch deleted file mode 100644 index 0e321eac96a758..00000000000000 --- a/ports/libdatachannel/fix_srtp.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index ca0f12e5..8e0e665f 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -326,7 +326,7 @@ else() - target_compile_definitions(datachannel PUBLIC RTC_ENABLE_MEDIA=1) - target_compile_definitions(datachannel-static PUBLIC RTC_ENABLE_MEDIA=1) - if(USE_SYSTEM_SRTP) -- find_package(libSRTP REQUIRED) -+ find_package(libSRTP CONFIG REQUIRED) - if(NOT TARGET libSRTP::srtp2) - add_library(libSRTP::srtp2 UNKNOWN IMPORTED) - set_target_properties(libSRTP::srtp2 PROPERTIES diff --git a/ports/libdatachannel/library-linkage.diff b/ports/libdatachannel/library-linkage.diff new file mode 100644 index 00000000000000..cf14cb42536259 --- /dev/null +++ b/ports/libdatachannel/library-linkage.diff @@ -0,0 +1,22 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b35e4b1..1b5190b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -457,11 +457,17 @@ if(WARNINGS_AS_ERRORS) + endif() + endif() + ++if(BUILD_SHARED_LIBS) + install(TARGETS datachannel EXPORT LibDataChannelTargets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + ) ++else() ++ set_target_properties(datachannel PROPERTIES EXCLUDE_FROM_ALL 1) ++ set_target_properties(datachannel-static PROPERTIES EXCLUDE_FROM_ALL 0) ++ install(TARGETS datachannel-static EXPORT LibDataChannelTargets) ++endif() + + install(FILES ${LIBDATACHANNEL_HEADERS} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rtc diff --git a/ports/libdatachannel/portfile.cmake b/ports/libdatachannel/portfile.cmake index 45844f048bdf33..cb3345cb5630ca 100644 --- a/ports/libdatachannel/portfile.cmake +++ b/ports/libdatachannel/portfile.cmake @@ -1,28 +1,21 @@ -set(PATCHES fix-for-vcpkg.patch) - -if(VCPKG_TARGET_IS_UWP) - list(APPEND PATCHES uwp-warnings.patch) -endif() - vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH REPO paullouisageneau/libdatachannel REF "v${VERSION}" - SHA512 67119f6d1280593696f71dc550ceba1076066d0f55ebf10b527bf1c75e5e9571be18e5d9732e43a2aa4d5106a49a0676e70938d35d3eb4005cf17612f8836c52 + SHA512 fd0d66bb932e29abc01e9f1a8b16ccb79012a7e3901e2e0f882f56ab2f090260945e1556c85ad07ef897b8c70fcdd44cdeead9955a9bca7afe1dda8900c473cc HEAD_REF master PATCHES - ${PATCHES} - fix_dependency.patch + dependencies.diff + library-linkage.diff + uwp-warnings.patch ) -file(REMOVE "${SOURCE_PATH}/cmake/Modules/FindLibJuice.cmake") -string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" DATACHANNEL_STATIC_LINKAGE) vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS FEATURES stdcall CAPI_STDCALL INVERTED_FEATURES - ws NO_WEBSOCKET - srtp NO_MEDIA + ws NO_WEBSOCKET + srtp NO_MEDIA ) vcpkg_cmake_configure( @@ -32,30 +25,16 @@ vcpkg_cmake_configure( -DPREFER_SYSTEM_LIB=ON -DNO_EXAMPLES=ON -DNO_TESTS=ON - -DDATACHANNEL_STATIC_LINKAGE=${DATACHANNEL_STATIC_LINKAGE} ) vcpkg_cmake_install() - -vcpkg_cmake_config_fixup(PACKAGE_NAME LibDataChannel CONFIG_PATH lib/cmake/LibDataChannel) +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/LibDataChannel) vcpkg_fixup_pkgconfig() -if(srtp IN_LIST FEATURES) - set(FIND_DEP_SRTP "find_dependency(libSRTP CONFIG)") +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/rtc/common.hpp" "#ifdef RTC_STATIC" "#if 1") endif() -file(READ "${CURRENT_PACKAGES_DIR}/share/LibDataChannel/LibDataChannelConfig.cmake" DATACHANNEL_CONFIG) -file(WRITE "${CURRENT_PACKAGES_DIR}/share/LibDataChannel/LibDataChannelConfig.cmake" " -include(CMakeFindDependencyMacro) -find_dependency(Threads) -find_dependency(OpenSSL) -find_dependency(LibJuice) -find_dependency(plog CONFIG) -find_dependency(unofficial-usrsctp CONFIG) -${FIND_DEP_SRTP} -${DATACHANNEL_CONFIG}") - - file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share") vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/ports/libdatachannel/uwp-warnings.patch b/ports/libdatachannel/uwp-warnings.patch index 75bddb5d698c64..23d23dd3141a85 100644 --- a/ports/libdatachannel/uwp-warnings.patch +++ b/ports/libdatachannel/uwp-warnings.patch @@ -1,14 +1,15 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 2c34d7fb..1bedd212 100644 +index 1b5190b..763b49e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -446,6 +446,9 @@ if(WARNINGS_AS_ERRORS) - endif() +@@ -315,6 +315,10 @@ target_link_libraries(datachannel-static PRIVATE Usrsctp::Usrsctp plog::plog) + if(WIN32) + target_link_libraries(datachannel PUBLIC ws2_32) # winsock2 + target_link_libraries(datachannel-static PUBLIC ws2_32) # winsock2 ++ if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") ++ target_compile_options(datachannel PRIVATE /wd4996) ++ target_compile_options(datachannel-static PRIVATE /wd4996) ++ endif() endif() -+target_compile_options(datachannel PRIVATE /wd4996) -+target_compile_options(datachannel-static PRIVATE /wd4996) -+ - if(DATACHANNEL_STATIC_LINKAGE) - set_target_properties(datachannel PROPERTIES EXCLUDE_FROM_ALL 1) - set_target_properties(datachannel-static PROPERTIES EXCLUDE_FROM_ALL 0) + if (NO_WEBSOCKET) diff --git a/ports/libdatachannel/vcpkg.json b/ports/libdatachannel/vcpkg.json index b65fe36f1f4b55..32534d9fa58ac9 100644 --- a/ports/libdatachannel/vcpkg.json +++ b/ports/libdatachannel/vcpkg.json @@ -1,6 +1,6 @@ { "name": "libdatachannel", - "version-semver": "0.21.1", + "version-semver": "0.21.2", "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", "license": "MPL-2.0", diff --git a/versions/baseline.json b/versions/baseline.json index 818306c6a401ef..70f5a8f6733ad9 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -4349,7 +4349,7 @@ "port-version": 0 }, "libdatachannel": { - "baseline": "0.21.1", + "baseline": "0.21.2", "port-version": 0 }, "libdatrie": { diff --git a/versions/l-/libdatachannel.json b/versions/l-/libdatachannel.json index 904935134333e8..cb5fd9f71ed323 100644 --- a/versions/l-/libdatachannel.json +++ b/versions/l-/libdatachannel.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "7ef5c0cdf31856f7b73f1498dd8055627608801c", + "version-semver": "0.21.2", + "port-version": 0 + }, { "git-tree": "f5218e93bae8971d509fd04910f9778004e58bce", "version-semver": "0.21.1",