git: 9b44be3b710b - main - net/brynet: New port: Header-only cross-platform C++ TCP network library

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Mon, 07 Nov 2022 08:04:31 UTC
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=9b44be3b710b380eb2c5bfa8b9870f4dc961df8f

commit 9b44be3b710b380eb2c5bfa8b9870f4dc961df8f
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2022-11-07 06:52:27 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2022-11-07 08:04:27 +0000

    net/brynet: New port: Header-only cross-platform C++ TCP network library
---
 net/Makefile                                       |  1 +
 net/brynet/Makefile                                | 28 +++++++++++++
 net/brynet/distinfo                                |  3 ++
 .../files/patch-include_brynet_base_Platform.hpp   | 11 +++++
 .../patch-include_brynet_net_CurrentThread.hpp     | 31 ++++++++++++++
 .../files/patch-include_brynet_net_EventLoop.hpp   | 14 +++++++
 net/brynet/pkg-descr                               |  2 +
 net/brynet/pkg-plist                               | 48 ++++++++++++++++++++++
 8 files changed, 138 insertions(+)

diff --git a/net/Makefile b/net/Makefile
index a27797afb95c..6804034f2554 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -63,6 +63,7 @@
     SUBDIR += bosh-cli
     SUBDIR += bounce
     SUBDIR += bredbandskollen
+    SUBDIR += brynet
     SUBDIR += bsdec2-image-upload
     SUBDIR += bsdrcmds
     SUBDIR += bwi-firmware-kmod
diff --git a/net/brynet/Makefile b/net/brynet/Makefile
new file mode 100644
index 000000000000..582577373686
--- /dev/null
+++ b/net/brynet/Makefile
@@ -0,0 +1,28 @@
+PORTNAME=	brynet
+DISTVERSIONPREFIX=	v
+DISTVERSION=	1.12.1-4
+DISTVERSIONSUFFIX=	-g2e7d54d
+CATEGORIES=	net devel
+
+MAINTAINER=	yuri@FreeBSD.org
+COMMENT=	Header-only cross-platform C++ TCP network library
+WWW=		https://github.com/IronsDu/brynet
+
+LICENSE=	MIT
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+USES=		cmake:testing compiler:c++17-lang
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	IronsDu
+
+CMAKE_OFF=	brynet_BUILD_EXAMPLES brynet_BUILD_TESTS
+CMAKE_TESTING_ON=	brynet_BUILD_TESTS # tests are built but not run, see https://github.com/IronsDu/brynet/issues/130
+
+NO_BUILD=	yes
+NO_ARCH=	yes
+
+pre-patch:
+	@${FIND} ${WRKSRC} -name "*.hpp" | ${XARGS} ${REINPLACE_CMD} -i '' -e 's/defined BRYNET_PLATFORM_DARWIN/& || defined BRYNET_PLATFORM_FREEBSD/'
+
+.include <bsd.port.mk>
diff --git a/net/brynet/distinfo b/net/brynet/distinfo
new file mode 100644
index 000000000000..f6e96e136ec6
--- /dev/null
+++ b/net/brynet/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1667801389
+SHA256 (IronsDu-brynet-v1.12.1-4-g2e7d54d_GH0.tar.gz) = cde787bf10b9496b2af04d89d10d79a466d9bd14cde5cf495e6f70c1d4cf9210
+SIZE (IronsDu-brynet-v1.12.1-4-g2e7d54d_GH0.tar.gz) = 232439
diff --git a/net/brynet/files/patch-include_brynet_base_Platform.hpp b/net/brynet/files/patch-include_brynet_base_Platform.hpp
new file mode 100644
index 000000000000..4c178deab84e
--- /dev/null
+++ b/net/brynet/files/patch-include_brynet_base_Platform.hpp
@@ -0,0 +1,11 @@
+--- include/brynet/base/Platform.hpp.orig	2022-11-07 05:36:34 UTC
++++ include/brynet/base/Platform.hpp
+@@ -5,6 +5,8 @@
+ #pragma comment(lib, "ws2_32")
+ #elif defined __APPLE_CC__ || defined __APPLE__
+ #define BRYNET_PLATFORM_DARWIN
++#elif defined __FreeBSD__
++#define BRYNET_PLATFORM_FREEBSD
+ #else
+ #define BRYNET_PLATFORM_LINUX
+ #endif
diff --git a/net/brynet/files/patch-include_brynet_net_CurrentThread.hpp b/net/brynet/files/patch-include_brynet_net_CurrentThread.hpp
new file mode 100644
index 000000000000..9b31c50db90a
--- /dev/null
+++ b/net/brynet/files/patch-include_brynet_net_CurrentThread.hpp
@@ -0,0 +1,31 @@
+--- include/brynet/net/CurrentThread.hpp.orig	2022-11-07 05:56:13 UTC
++++ include/brynet/net/CurrentThread.hpp
+@@ -23,7 +23,11 @@ namespace brynet { namespace net { namespace current_t
+ #ifdef BRYNET_PLATFORM_WINDOWS
+ using THREAD_ID_TYPE = DWORD;
+ #elif defined BRYNET_PLATFORM_LINUX || defined BRYNET_PLATFORM_DARWIN || defined BRYNET_PLATFORM_FREEBSD
++#  if defined BRYNET_PLATFORM_FREEBSD
++using THREAD_ID_TYPE = pthread_t;
++#  else
+ using THREAD_ID_TYPE = int;
++#  endif
+ #endif
+ 
+ static THREAD_ID_TYPE& tid()
+@@ -41,12 +45,16 @@ static THREAD_ID_TYPE& tid()
+ #elif defined BRYNET_PLATFORM_LINUX
+         cachedTid = static_cast<pid_t>(::syscall(SYS_gettid));
+ #elif defined BRYNET_PLATFORM_DARWIN || defined BRYNET_PLATFORM_FREEBSD
++#  if defined BRYNET_PLATFORM_FREEBSD
++        cachedTid = pthread_self();
++#  else
+         // warning: 'syscall' is deprecated:
+         // first deprecated in macOS 10.12 - syscall(2) is unsupported;
+         // please switch to a supported interface.
+         uint64_t tid64;
+         pthread_threadid_np(NULL, &tid64);
+         cachedTid = (pid_t) tid64;
++#  endif
+ #endif
+     }
+ 
diff --git a/net/brynet/files/patch-include_brynet_net_EventLoop.hpp b/net/brynet/files/patch-include_brynet_net_EventLoop.hpp
new file mode 100644
index 000000000000..26ead00fbb2b
--- /dev/null
+++ b/net/brynet/files/patch-include_brynet_net_EventLoop.hpp
@@ -0,0 +1,14 @@
+--- include/brynet/net/EventLoop.hpp.orig	2022-11-07 05:58:53 UTC
++++ include/brynet/net/EventLoop.hpp
+@@ -72,7 +72,11 @@ class EventLoop : public brynet::base::NonCopyable (pu
+         mIsInBlock = true;
+ 
+         reAllocEventSize(1024);
++#if defined BRYNET_PLATFORM_FREEBSD
++        mSelfThreadID = nullptr;
++#else
+         mSelfThreadID = -1;
++#endif
+         mTimer = std::make_shared<brynet::base::TimerMgr>();
+         mSelfThreadIDIsInitialized.store(false);
+     }
diff --git a/net/brynet/pkg-descr b/net/brynet/pkg-descr
new file mode 100644
index 000000000000..d536220cf3fc
--- /dev/null
+++ b/net/brynet/pkg-descr
@@ -0,0 +1,2 @@
+Brynet is a header-only cross platform high performance TCP network library
+using C++11.
diff --git a/net/brynet/pkg-plist b/net/brynet/pkg-plist
new file mode 100644
index 000000000000..7b39dd6973a0
--- /dev/null
+++ b/net/brynet/pkg-plist
@@ -0,0 +1,48 @@
+include/brynet/Version.hpp
+include/brynet/base/Any.hpp
+include/brynet/base/AppStatus.hpp
+include/brynet/base/Array.hpp
+include/brynet/base/Buffer.hpp
+include/brynet/base/CPP_VERSION.hpp
+include/brynet/base/Noexcept.hpp
+include/brynet/base/NonCopyable.hpp
+include/brynet/base/Packet.hpp
+include/brynet/base/Platform.hpp
+include/brynet/base/Stack.hpp
+include/brynet/base/Timer.hpp
+include/brynet/base/WaitGroup.hpp
+include/brynet/base/crypto/Base64.hpp
+include/brynet/base/crypto/SHA1.hpp
+include/brynet/base/endian/Endian.hpp
+include/brynet/net/AsyncConnector.hpp
+include/brynet/net/Channel.hpp
+include/brynet/net/CurrentThread.hpp
+include/brynet/net/EventLoop.hpp
+include/brynet/net/Exception.hpp
+include/brynet/net/ListenThread.hpp
+include/brynet/net/Poller.hpp
+include/brynet/net/PromiseReceive.hpp
+include/brynet/net/SSLHelper.hpp
+include/brynet/net/SendableMsg.hpp
+include/brynet/net/Socket.hpp
+include/brynet/net/SocketLibFunction.hpp
+include/brynet/net/SocketLibTypes.hpp
+include/brynet/net/TcpConnection.hpp
+include/brynet/net/TcpService.hpp
+include/brynet/net/detail/ConnectionOption.hpp
+include/brynet/net/detail/ConnectorDetail.hpp
+include/brynet/net/detail/ConnectorWorkInfo.hpp
+include/brynet/net/detail/IOLoopData.hpp
+include/brynet/net/detail/ListenThreadDetail.hpp
+include/brynet/net/detail/TCPServiceDetail.hpp
+include/brynet/net/detail/WakeupChannel.hpp
+include/brynet/net/http/HttpFormat.hpp
+include/brynet/net/http/HttpParser.hpp
+include/brynet/net/http/HttpService.hpp
+include/brynet/net/http/WebSocketFormat.hpp
+include/brynet/net/http/http_parser.h
+include/brynet/net/port/Win.hpp
+include/brynet/net/wrapper/ConnectionBuilder.hpp
+include/brynet/net/wrapper/HttpConnectionBuilder.hpp
+include/brynet/net/wrapper/HttpServiceBuilder.hpp
+include/brynet/net/wrapper/ServiceBuilder.hpp