[udt] New port (#30348)

* [udt] New port

* update version database

* fix windows build

* update version database

* fix platform detection

* update version database

* fix windows build

* update version database

* fix patch

* update version database

* optimize defs

* update version database

* not support uwp

* update version database

* Fix find unofficial-udt

* update version database
This commit is contained in:
xiaozhuai, Weihang Ding
2023-03-29 04:34:18 +08:00
committed by GitHub
parent b185afd43b
commit fe367ac23e
7 changed files with 172 additions and 0 deletions

35
ports/udt/CMakeLists.txt Normal file
View File

@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(udt LANGUAGES CXX)
include(GNUInstallDirs)
file(GLOB UDT_HEADERS "src/*.h")
file(GLOB UDT_SOURCES "src/*.cpp")
add_library(udt ${UDT_HEADERS} ${UDT_SOURCES})
if(WIN32)
target_compile_definitions(udt PRIVATE -DWIN32)
if(MSVC)
target_compile_definitions(udt PRIVATE -DUDT_EXPORTS)
endif()
target_link_libraries(udt PRIVATE ws2_32)
elseif(UNIX AND NOT APPLE)
target_compile_definitions(udt PRIVATE -DLINUX)
elseif(APPLE)
target_compile_definitions(udt PRIVATE -DOSX)
endif()
target_include_directories(udt PUBLIC
"$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/udt>")
install(TARGETS udt EXPORT unofficial-udt)
install(
EXPORT unofficial-udt
FILE unofficial-udt-config.cmake
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/unofficial-udt"
NAMESPACE unofficial::udt::
)
install(FILES ${UDT_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/udt")

79
ports/udt/fix_defs.patch Normal file
View File

@@ -0,0 +1,79 @@
diff --git a/src/api.h b/src/api.h
index 24f1a02..db7b729 100644
--- a/src/api.h
+++ b/src/api.h
@@ -216,3 +216,3 @@ private:
pthread_key_t m_TLSError; // thread local error record (last error)
- #ifndef WIN32
+ #ifndef _WIN32
static void TLSDestroy(void* e) {if (NULL != e) delete (CUDTException*)e;}
@@ -248,3 +248,3 @@ private:
pthread_t m_GCThread;
- #ifndef WIN32
+ #ifndef _WIN32
static void* garbageCollect(void*);
diff --git a/src/common.h b/src/common.h
index 3782d61..205b090 100644
--- a/src/common.h
+++ b/src/common.h
@@ -44,3 +44,3 @@ written by
-#ifndef WIN32
+#ifndef _WIN32
#include <sys/time.h>
@@ -55,3 +55,3 @@ written by
-#ifdef WIN32
+#ifdef _WIN32
// Windows compability
diff --git a/src/packet.h b/src/packet.h
index 76cc951..216505a 100644
--- a/src/packet.h
+++ b/src/packet.h
@@ -46,3 +46,3 @@ written by
-#ifdef WIN32
+#ifdef _WIN32
struct iovec
diff --git a/src/queue.h b/src/queue.h
index 9feff18..1062a0c 100644
--- a/src/queue.h
+++ b/src/queue.h
@@ -399,3 +399,3 @@ public:
private:
-#ifndef WIN32
+#ifndef _WIN32
static void* worker(void* param);
@@ -459,3 +459,3 @@ public:
private:
-#ifndef WIN32
+#ifndef _WIN32
static void* worker(void* param);
diff --git a/src/udt.h b/src/udt.h
index 6436363..8e00091 100644
--- a/src/udt.h
+++ b/src/udt.h
@@ -44,3 +44,3 @@ written by
-#ifndef WIN32
+#ifndef _WIN32
#include <sys/types.h>
@@ -70,3 +70,3 @@ written by
-#ifdef WIN32
+#ifdef _WIN32
#ifndef __MINGW__
@@ -97,3 +97,3 @@ written by
-#ifdef WIN32
+#ifdef _WIN32
#ifndef __MINGW__
diff --git a/src/window.h b/src/window.h
index f118a26..565aeb6 100644
--- a/src/window.h
+++ b/src/window.h
@@ -44,3 +44,3 @@ written by
-#ifndef WIN32
+#ifndef _WIN32
#include <sys/time.h>

23
ports/udt/portfile.cmake Normal file
View File

@@ -0,0 +1,23 @@
vcpkg_from_sourceforge(
OUT_SOURCE_PATH SOURCE_PATH
REPO udt/udt
REF "${VERSION}"
FILENAME "udt.sdk.${VERSION}.tar.gz"
SHA512 fc555ce1ddde2a8bd92c8adf470fd69a9a35d0a679def32b6ddbb18d67dc8b7d9dd928d772dc8598f08b350130f1e90bb4be58c46252a0a79ecc99f61eca8a92
PATCHES
fix_defs.patch
)
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-udt)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

4
ports/udt/usage Normal file
View File

@@ -0,0 +1,4 @@
udt provides CMake targets:
find_package(unofficial-udt CONFIG REQUIRED)
target_link_libraries(main PRIVATE unofficial::udt::udt)

18
ports/udt/vcpkg.json Normal file
View File

@@ -0,0 +1,18 @@
{
"name": "udt",
"version": "4.11",
"description": "UDT is a reliable UDP based application level data transport protocol for distributed data intensive applications over wide area high-speed networks.",
"homepage": "https://udt.sourceforge.io/",
"license": null,
"supports": "!uwp",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}

View File

@@ -8024,6 +8024,10 @@
"baseline": "0.0.8",
"port-version": 0
},
"udt": {
"baseline": "4.11",
"port-version": 0
},
"umock-c": {
"baseline": "2022-01-21",
"port-version": 1

9
versions/u-/udt.json Normal file
View File

@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "8c91a2b4c4f5b0fafeef59b6abda5efd3f30adcc",
"version": "4.11",
"port-version": 0
}
]
}