From 5b93dabe795b5417a209262da1ad87bbee1dbb05 Mon Sep 17 00:00:00 2001 From: Nemirtingas <9432037+Nemirtingas@users.noreply.github.com> Date: Fri, 23 Oct 2020 09:32:18 +0200 Subject: [PATCH] [libjuice] Add new port (#13703) * libjuice port * Various fix from pr. * Remove unused code * Update to v0.5.2 * Add the private include file for datachannel * Smaller patch for vcpkg * Update ports/libjuice/CONTROL Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com> * Update scripts/ci.baseline.txt Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com> * Update libjuice to support uwp ? * Add nettle include path * Fix the nettle library name Co-authored-by: Nemirtingas Co-authored-by: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com> Co-authored-by: NancyLi1013 --- ports/libjuice/CONTROL | 8 ++++ ports/libjuice/fix-for-vcpkg.patch | 68 ++++++++++++++++++++++++++++++ ports/libjuice/portfile.cmake | 31 ++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 ports/libjuice/CONTROL create mode 100644 ports/libjuice/fix-for-vcpkg.patch create mode 100644 ports/libjuice/portfile.cmake diff --git a/ports/libjuice/CONTROL b/ports/libjuice/CONTROL new file mode 100644 index 00000000000..5901d8d74fa --- /dev/null +++ b/ports/libjuice/CONTROL @@ -0,0 +1,8 @@ +Source: libjuice +Version: 0.5.2 +Homepage: https://github.com/paullouisageneau/libjuice +Description: The library is a simplified implementation of the Interactive Connectivity Establishment (ICE) protocol in C for POSIX platforms (including Linux and Apple macOS) and Microsoft Windows. + +Feature: nettle +Build-Depends: nettle +Description: Use nettle for HMAC computation instead of the Builtin diff --git a/ports/libjuice/fix-for-vcpkg.patch b/ports/libjuice/fix-for-vcpkg.patch new file mode 100644 index 00000000000..6bbfd837f05 --- /dev/null +++ b/ports/libjuice/fix-for-vcpkg.patch @@ -0,0 +1,68 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index be72a2a..8a631e8 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -41,6 +41,9 @@ set(LIBJUICE_SOURCES + set(LIBJUICE_HEADERS + ${CMAKE_CURRENT_SOURCE_DIR}/include/juice/juice.h + ) ++set(LIBJUICE_PRIVATE_HEADERS ++ ${CMAKE_CURRENT_SOURCE_DIR}/src/socket.h ++) + + set(TESTS_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/test/main.c +@@ -54,10 +57,10 @@ set(TESTS_SOURCES + set(THREADS_PREFER_PTHREAD_FLAG ON) + find_package(Threads REQUIRED) + +-add_library(juice SHARED ${LIBJUICE_SOURCES}) ++add_library(juice ${LIBJUICE_SOURCES}) + set_target_properties(juice PROPERTIES VERSION ${PROJECT_VERSION}) + +-target_include_directories(juice PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) ++target_include_directories(juice PUBLIC $ $) + target_include_directories(juice PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include/juice) + target_include_directories(juice PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src) + target_link_libraries(juice PUBLIC Threads::Threads) +@@ -77,10 +80,14 @@ endif() + + if (USE_NETTLE) + find_package(Nettle REQUIRED) ++ find_path(NETTLE_INCLUDE_PATH "nettle/hmac.h" REQUIRED) ++ target_include_directories(juice PRIVATE ${NETTLE_INCLUDE_PATH}) ++ target_include_directories(juice-static PRIVATE ${NETTLE_INCLUDE_PATH}) ++ + target_compile_definitions(juice PRIVATE USE_NETTLE=1) +- target_link_libraries(juice PRIVATE Nettle::Nettle) ++ target_link_libraries(juice PRIVATE nettle) + target_compile_definitions(juice-static PRIVATE USE_NETTLE=1) +- target_link_libraries(juice-static PRIVATE Nettle::Nettle) ++ target_link_libraries(juice-static PRIVATE nettle) + else() + target_compile_definitions(juice PRIVATE USE_NETTLE=0) + target_compile_definitions(juice-static PRIVATE USE_NETTLE=0) +@@ -100,8 +107,13 @@ endif() + add_library(LibJuice::LibJuice ALIAS juice) + add_library(LibJuice::LibJuiceStatic ALIAS juice-static) + +-install(TARGETS juice LIBRARY DESTINATION lib) ++install(TARGETS juice EXPORT libjuice-config ++ RUNTIME DESTINATION bin ++ LIBRARY DESTINATION lib ++ ARCHIVE DESTINATION lib ++) + install(FILES ${LIBJUICE_HEADERS} DESTINATION include/juice) ++install(FILES ${LIBJUICE_PRIVATE_HEADERS} DESTINATION include/juice/src) + + if(NOT MSVC) + target_compile_options(juice PRIVATE -Wall -Wextra) +@@ -128,3 +140,8 @@ if(NOT NO_TESTS) + target_link_libraries(juice-tests juice) + endif() + ++install( ++ EXPORT libjuice-config ++ NAMESPACE LibJuice:: ++ DESTINATION share/cmake/libjuice ++) diff --git a/ports/libjuice/portfile.cmake b/ports/libjuice/portfile.cmake new file mode 100644 index 00000000000..68770243fe5 --- /dev/null +++ b/ports/libjuice/portfile.cmake @@ -0,0 +1,31 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO paullouisageneau/libjuice + REF 92fc9e7a9d8cd19a5c5d59cbc0a11cc9f684483b + SHA512 80e9898c51bc98a60ca317030bc5394fda412c2bc822adc656f88bfa60b42501d4945a8692771afb8241ec7994fbe48c3e8360f919a0859cfb47288fd3292dd4 + HEAD_REF master + PATCHES + fix-for-vcpkg.patch +) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + nettle USE_NETTLE +) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA + OPTIONS + ${FEATURE_OPTIONS} + -DNO_TESTS=ON +) + +vcpkg_install_cmake() + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +vcpkg_fixup_cmake_targets(CONFIG_PATH share/cmake/libjuice) +vcpkg_fixup_pkgconfig() + +file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)