net-libs/usockets: version bump to 0.8.1

enable tests
tests fail with asio but pass with either
libuv or no flag (default epoll)

Package-Manager: Portage-3.0.28, Repoman-3.0.3
Signed-off-by: Aisha Tammy <gentoo@aisha.cc>
This commit is contained in:
Aisha Tammy
2021-10-24 23:51:27 -04:00
parent 9eea32bdc7
commit 3c722132a9
8 changed files with 206 additions and 147 deletions

View File

@@ -1 +1 @@
DIST usockets-0.7.1_p20210909.tar.gz 65495 BLAKE2B 23aeb6ec3c330926aa375f0dedf4eb0e63f89fd833145cc3af47936de8ffa2139273710eee7019c2f5c12d7715746a38a6b64a3e48a349a2893599116ca623d8 SHA512 29bac37a75172cdb2881b27d142972a235470e8e0ec85e98c1bfd5f587ab1f777001e69a57bfc46b87a74bf73f4a166300e42e9f0ed908810bcf5c46290abdce
DIST usockets-0.8.1_p20211023.tar.gz 66346 BLAKE2B 1833d1d3981fd5cf7f48794b183426341d7dd0b36654a528335c61a2495a59e54bad6f634ec14ccf8b33895091cc48306d7d7b90031888ba661a2db8019f30e9 SHA512 146c130731ac8f071f339e71c8cd45f319e837d333a36c6f578a2d7d9546267660ad0d3f82505d3f5d33b0494ec26b2d7b7eba3756d62ecc883b1afbf6c5bfb2

View File

@@ -1,138 +0,0 @@
diff --git a/Makefile b/Makefile
index b809ac0..857a1f7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,72 +1,69 @@
+DESTDIR ?=
+
+prefix ?= /usr
+exec_prefix ?= $(prefix)
+LIB ?= lib
+libdir ?= $(exec_prefix)/$(LIB)
+includedir ?= $(exec_prefix)/include
+
+PKG_CONFIG ?= pkg-config
+
+VERSION ?= 0.0
+LIBTARGET = libusockets.so.$(VERSION)
+
+REQUIRES =
+COMMON_FLAGS = -fPIC -Isrc
+
# WITH_OPENSSL=1 enables OpenSSL 1.1+ support or BoringSSL
# For now we need to link with C++ for OpenSSL support, but should be removed with time
ifeq ($(WITH_OPENSSL),1)
- override CFLAGS += -DLIBUS_USE_OPENSSL
- # With problems on macOS, make sure to pass needed LDFLAGS required to find these
- override LDFLAGS += -lssl -lcrypto -lstdc++
-else
- # WITH_WOLFSSL=1 enables WolfSSL 4.2.0 support (mutually exclusive with OpenSSL)
- ifeq ($(WITH_WOLFSSL),1)
- # todo: change these
- override CFLAGS += -DLIBUS_USE_WOLFSSL -I/usr/local/include
- override LDFLAGS += -L/usr/local/lib -lwolfssl
- else
- override CFLAGS += -DLIBUS_NO_SSL
- endif
+COMMON_FLAGS += -DLIBUS_USE_OPENSSL
+LDFLAGS += -lssl -lcrypto -lstdc++
+REQUIRES += libssl libcrypto
endif
# WITH_LIBUV=1 builds with libuv as event-loop
ifeq ($(WITH_LIBUV),1)
- override CFLAGS += -DLIBUS_USE_LIBUV
- override LDFLAGS += -luv
+COMMON_FLAGS += -DLIBUS_USE_LIBUV
+REQUIRES += libuv
endif
-# WITH_ASIO builds with boot asio event-loop
+# WITH_ASIO builds with boost asio event-loop
ifeq ($(WITH_ASIO),1)
- override CFLAGS += -DLIBUS_USE_ASIO
- override LDFLAGS += -lstdc++ -lpthread
- override CXXFLAGS += -pthread -DLIBUS_USE_ASIO
+COMMON_FLAGS += -pthread -DLIBUS_USE_ASIO
endif
-# WITH_GCD=1 builds with libdispatch as event-loop
-ifeq ($(WITH_GCD),1)
- override CFLAGS += -DLIBUS_USE_GCD
- override LDFLAGS += -framework CoreFoundation
-endif
-
-# WITH_ASAN builds with sanitizers
-ifeq ($(WITH_ASAN),1)
- override CFLAGS += -fsanitize=address -g
- override LDFLAGS += -fsanitize=address
-endif
-
-override CFLAGS += -std=c11 -Isrc
-override LDFLAGS += uSockets.a
+CFLAGS += -std=c11 $(COMMON_FLAGS)
+CXXFLAGS += -std=c++17 $(COMMON_FLAGS)
# By default we build the uSockets.a static library
default:
- rm -f *.o
- $(CC) $(CFLAGS) -flto -O3 -c src/*.c src/eventing/*.c src/crypto/*.c
+ $(CC) $(CFLAGS) -c src/*.c src/eventing/*.c src/crypto/*.c
# Also link in Boost Asio support
ifeq ($(WITH_ASIO),1)
- $(CXX) $(CXXFLAGS) -Isrc -std=c++14 -flto -O3 -c src/eventing/asio.cpp
+ $(CXX) $(CXXFLAGS) -c src/eventing/asio.cpp
endif
-
-# For now we do rely on C++17 for OpenSSL support but we will be porting this work to C11
ifeq ($(WITH_OPENSSL),1)
- $(CXX) $(CXXFLAGS) -std=c++17 -flto -O3 -c src/crypto/*.cpp
+ $(CXX) $(CXXFLAGS) -c src/crypto/*.cpp
endif
- $(AR) rvs uSockets.a *.o
-
-# Builds all examples
-.PHONY: examples
-examples: default
- for f in examples/*.c; do $(CC) -flto -O3 $(CFLAGS) -o $$(basename "$$f" ".c") "$$f" $(LDFLAGS); done
+ $(AR) rvs libusockets.a *.o
+ $(CXX) $(CXXFLAGS) -shared -o $(LIBTARGET) *.o -Wl,-soname,$(LIBTARGET) `$(PKG_CONFIG) --libs $(REQUIRES)` $(LDFLAGS)
+ sed -e "s:@PREFIX@:$(prefix):" -e "s:@REQUIRES@:$(REQUIRES):" \
+ -e "s:@LIB@:$(LIB):" -e "s:@VERSION@:$(VERSION):" libusockets.pc.in > libusockets.pc
-swift_examples:
- swiftc -O -I . examples/swift_http_server/main.swift uSockets.a -o swift_http_server
+install:
+ install -d "$(DESTDIR)$(libdir)/pkgconfig" "$(DESTDIR)$(includedir)"
+ install -m 644 src/libusockets.h "$(DESTDIR)$(includedir)/"
+ install -m 755 $(LIBTARGET) "$(DESTDIR)$(libdir)"
+ ln -sf $(LIBTARGET) "$(DESTDIR)$(libdir)/libusockets.so"
+ install -m 755 libusockets.a "$(DESTDIR)$(libdir)/"
+ install -m 644 libusockets.pc "$(DESTDIR)$(libdir)/pkgconfig/"
clean:
rm -f *.o
rm -f *.a
+ rm -f *.so
rm -rf .certs
+ rm -f libusockets.pc
+
+.PHONY: default install clean
diff --git a/libusockets.pc.in b/libusockets.pc.in
new file mode 100644
index 0000000..b818020
--- /dev/null
+++ b/libusockets.pc.in
@@ -0,0 +1,12 @@
+prefix=@PREFIX@
+libdir=${prefix}/@LIB@
+includedir=${prefix}/include
+
+Name: uSockets
+Version: @VERSION@
+Description: eventing, networking and crypto for async applications.
+URL: https://github.com/uNetworking/uSockets
+
+Cflags: -I${includedir}
+Libs: -L${libdir} -lusockets
+Requires.private: @REQUIRES@

View File

@@ -0,0 +1,141 @@
diff --git a/Makefile b/Makefile
index 16f613c..4bece6e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,87 +1,73 @@
-# WITH_BORINGSSL=1 enables BoringSSL support, linked statically (preferred over OpenSSL)
-# You need to call "make boringssl" before
-ifeq ($(WITH_BORINGSSL),1)
- override CFLAGS += -Iboringssl/include -pthread -DLIBUS_USE_OPENSSL
- override LDFLAGS += -pthread boringssl/build/ssl/libssl.a boringssl/build/crypto/libcrypto.a -lstdc++
-else
- # WITH_OPENSSL=1 enables OpenSSL 1.1+ support
- # For now we need to link with C++ for OpenSSL support, but should be removed with time
- ifeq ($(WITH_OPENSSL),1)
- override CFLAGS += -DLIBUS_USE_OPENSSL
- # With problems on macOS, make sure to pass needed LDFLAGS required to find these
- override LDFLAGS += -lssl -lcrypto -lstdc++
- else
- # WITH_WOLFSSL=1 enables WolfSSL 4.2.0 support (mutually exclusive with OpenSSL)
- ifeq ($(WITH_WOLFSSL),1)
- # todo: change these
- override CFLAGS += -DLIBUS_USE_WOLFSSL -I/usr/local/include
- override LDFLAGS += -L/usr/local/lib -lwolfssl
- else
- override CFLAGS += -DLIBUS_NO_SSL
- endif
- endif
+VERSION ?= 0.0
+
+PREFIX ?= /usr
+LIB ?= lib
+LIBDIR ?= $(PREFIX)/$(LIB)
+INCDIR ?= $(PREFIX)/include
+
+PKG_CONFIG ?= pkg-config
+
+LIBTARGET = libusockets.so
+LIBTARGETV = $(LIBTARGET).$(VERSION)
+
+REQUIRES =
+COMMON_FLAGS = -fPIC -Isrc
+
+# WITH_OPENSSL=1 enables OpenSSL 1.1+ support or BoringSSL
+# For now we need to link with C++ for OpenSSL support, but should be removed with time
+ifeq ($(WITH_OPENSSL),1)
+COMMON_FLAGS += -DLIBUS_USE_OPENSSL
+REQUIRES += libssl libcrypto
endif
# WITH_LIBUV=1 builds with libuv as event-loop
ifeq ($(WITH_LIBUV),1)
- override CFLAGS += -DLIBUS_USE_LIBUV
- override LDFLAGS += -luv
+COMMON_FLAGS += -DLIBUS_USE_LIBUV
+REQUIRES += libuv
endif
-# WITH_ASIO builds with boot asio event-loop
+# WITH_ASIO builds with boost asio event-loop
ifeq ($(WITH_ASIO),1)
- override CFLAGS += -DLIBUS_USE_ASIO
- override LDFLAGS += -lstdc++ -lpthread
- override CXXFLAGS += -pthread -DLIBUS_USE_ASIO
+COMMON_FLAGS += -pthread -DLIBUS_USE_ASIO
endif
-# WITH_GCD=1 builds with libdispatch as event-loop
-ifeq ($(WITH_GCD),1)
- override CFLAGS += -DLIBUS_USE_GCD
- override LDFLAGS += -framework CoreFoundation
-endif
-
-# WITH_ASAN builds with sanitizers
-ifeq ($(WITH_ASAN),1)
- override CFLAGS += -fsanitize=address -g
- override LDFLAGS += -fsanitize=address
-endif
-
-override CFLAGS += -std=c11 -Isrc
-override LDFLAGS += uSockets.a
+CFLAGS += -std=c11 $(COMMON_FLAGS)
+CXXFLAGS += -std=c++17 $(COMMON_FLAGS)
# By default we build the uSockets.a static library
default:
- rm -f *.o
- $(CC) $(CFLAGS) -flto -O3 -c src/*.c src/eventing/*.c src/crypto/*.c
+ $(CC) $(CFLAGS) -c src/*.c src/eventing/*.c src/crypto/*.c
# Also link in Boost Asio support
ifeq ($(WITH_ASIO),1)
- $(CXX) $(CXXFLAGS) -Isrc -std=c++14 -flto -O3 -c src/eventing/asio.cpp
+ $(CXX) $(CXXFLAGS) -c src/eventing/asio.cpp
endif
-
-# For now we do rely on C++17 for OpenSSL support but we will be porting this work to C11
ifeq ($(WITH_OPENSSL),1)
- $(CXX) $(CXXFLAGS) -std=c++17 -flto -O3 -c src/crypto/*.cpp
+ $(CXX) $(CXXFLAGS) -c src/crypto/*.cpp
endif
-ifeq ($(WITH_BORINGSSL),1)
- $(CXX) $(CXXFLAGS) -std=c++17 -flto -O3 -c src/crypto/*.cpp
-endif
- $(AR) rvs uSockets.a *.o
-
-# BoringSSL needs cmake and golang
-.PHONY: boringssl
-boringssl:
- cd boringssl && mkdir -p build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && make -j8
+ $(AR) rvs libusockets.a *.o
+ $(CXX) $(CXXFLAGS) -shared -o $(LIBTARGETV) *.o -Wl,-soname,$(LIBTARGET) `$(PKG_CONFIG) --libs $(REQUIRES)` $(LDFLAGS)
+ sed -e "s:@PREFIX@:$(PREFIX):" -e "s:@REQUIRES@:$(REQUIRES):" \
+ -e "s:@LIB@:$(LIB):" -e "s:@VERSION@:$(VERSION):" libusockets.pc.in > libusockets.pc
-# Builds all examples
-.PHONY: examples
-examples: default
- for f in examples/*.c; do $(CC) -flto -O3 $(CFLAGS) -o $$(basename "$$f" ".c") "$$f" $(LDFLAGS); done
+install:
+ install -d "$(DESTDIR)$(LIBDIR)/pkgconfig" "$(DESTDIR)$(INCDIR)"
+ install -m 644 src/libusockets.h "$(DESTDIR)$(INCDIR)/"
+ install -m 755 $(LIBTARGETV) "$(DESTDIR)$(LIBDIR)"
+ ln -sf $(LIBTARGETV) "$(DESTDIR)$(LIBDIR)/$(LIBTARGET)"
+ install -m 755 libusockets.a "$(DESTDIR)$(LIBDIR)/"
+ install -m 644 libusockets.pc "$(DESTDIR)$(LIBDIR)/pkgconfig/"
-swift_examples:
- swiftc -O -I . examples/swift_http_server/main.swift uSockets.a -o swift_http_server
+test:
+ rm -f localhost.pem localhost.crt
+ openssl req -x509 -out localhost.crt -keyout localhost.pem -newkey rsa:2048 -nodes -sha256 -subj '/CN=localhost' -extensions EXT -config localhost.conf
+ $(CXX) $(CXXFLAGS) examples/hammer_test.c libusockets.a -o hammer_test `$(PKG_CONFIG) --libs $(REQUIRES)` $(LDFLAGS)
+ ./hammer_test
clean:
rm -f *.o
rm -f *.a
+ rm -f *.so
rm -rf .certs
+ rm -f libusockets.pc
+
+.PHONY: default install clean

View File

@@ -0,0 +1,14 @@
diff --git a/localhost.conf b/localhost.conf
new file mode 100644
index 0000000..415c4ff
--- /dev/null
+++ b/localhost.conf
@@ -0,0 +1,8 @@
+[dn]
+CN=localhost
+[req]
+distinguished_name = dn
+[EXT]
+subjectAltName=DNS:localhost
+keyUsage=digitalSignature
+extendedKeyUsage=serverAuth

View File

@@ -0,0 +1,16 @@
diff --git a/examples/hammer_test.c b/examples/hammer_test.c
index 82cda2f..f5bbe5e 100644
--- a/examples/hammer_test.c
+++ b/examples/hammer_test.c
@@ -403,9 +403,8 @@ int main() {
// these are ignored for non-SSL
struct us_socket_context_options_t options = {};
- options.key_file_name = "/home/alexhultman/uWebSockets.js/misc/key.pem";
- options.cert_file_name = "/home/alexhultman/uWebSockets.js/misc/cert.pem";
- options.passphrase = "1234";
+ options.key_file_name = "localhost.pem";
+ options.cert_file_name = "localhost.crt";
http_context = us_create_socket_context(SSL, loop, sizeof(struct http_context), options);

View File

@@ -0,0 +1,18 @@
diff --git a/libusockets.pc.in b/libusockets.pc.in
new file mode 100644
index 0000000..b818020
--- /dev/null
+++ b/libusockets.pc.in
@@ -0,0 +1,12 @@
+prefix=@PREFIX@
+libdir=${prefix}/@LIB@
+includedir=${prefix}/include
+
+Name: uSockets
+Version: @VERSION@
+Description: eventing, networking and crypto for async applications.
+URL: https://github.com/uNetworking/uSockets
+
+Cflags: -I${includedir}
+Libs: -L${libdir} -lusockets
+Requires.private: @REQUIRES@

View File

@@ -12,7 +12,7 @@ if [[ ${PV} == 9999 ]]; then
inherit git-r3
EGIT_REPO_URI="https://github.com/uNetworking/uSockets.git"
else
COMMIT="c06112c89b4c1cf5a09b5f8daa2def756b925889"
COMMIT="c2c1bbfa1644f1f6eb7fc9375650f41c5f9b7b06"
SRC_URI="https://github.com/uNetworking/uSockets/archive/${COMMIT}.tar.gz -> ${P}.tar.gz"
KEYWORDS="~amd64 ~arm64 ~x86"
S="${WORKDIR}/uSockets-${COMMIT}"
@@ -20,8 +20,9 @@ fi
LICENSE="Apache-2.0"
SLOT="0"
IUSE="asio libuv +ssl"
REQUIRED_USE="?? ( asio libuv )"
IUSE="asio libuv +ssl test"
REQUIRED_USE="?? ( asio libuv ) test? ( ssl )"
RESTRICT="!test? ( test )"
DEPEND="
asio? ( dev-cpp/asio[ssl(+)?] )
@@ -31,7 +32,10 @@ DEPEND="
RDEPEND="${DEPEND}"
PATCHES=(
"${FILESDIR}/${PN}-0.7.1_p20210909-Makefile.patch"
"${FILESDIR}/${PN}-0.8.1_p20211023-Makefile.patch"
"${FILESDIR}/${PN}-0.8.1_p20211023-pkg-config.patch"
"${FILESDIR}/${PN}-0.8.1_p20211023-gen-ssl-config.patch"
"${FILESDIR}/${PN}-0.8.1_p20211023-hammer-test.patch"
)
src_configure() {

View File

@@ -12,7 +12,7 @@ if [[ ${PV} == 9999 ]]; then
inherit git-r3
EGIT_REPO_URI="https://github.com/uNetworking/uSockets.git"
else
COMMIT="c06112c89b4c1cf5a09b5f8daa2def756b925889"
COMMIT="c2c1bbfa1644f1f6eb7fc9375650f41c5f9b7b06"
SRC_URI="https://github.com/uNetworking/uSockets/archive/${COMMIT}.tar.gz -> ${P}.tar.gz"
KEYWORDS="~amd64 ~arm64 ~x86"
S="${WORKDIR}/uSockets-${COMMIT}"
@@ -20,8 +20,9 @@ fi
LICENSE="Apache-2.0"
SLOT="0"
IUSE="asio libuv +ssl"
REQUIRED_USE="?? ( asio libuv )"
IUSE="asio libuv +ssl test"
REQUIRED_USE="?? ( asio libuv ) test? ( ssl )"
RESTRICT="!test? ( test )"
DEPEND="
asio? ( dev-cpp/asio[ssl(+)?] )
@@ -31,7 +32,10 @@ DEPEND="
RDEPEND="${DEPEND}"
PATCHES=(
"${FILESDIR}/${PN}-0.7.1_p20210909-Makefile.patch"
"${FILESDIR}/${PN}-0.8.1_p20211023-Makefile.patch"
"${FILESDIR}/${PN}-0.8.1_p20211023-pkg-config.patch"
"${FILESDIR}/${PN}-0.8.1_p20211023-gen-ssl-config.patch"
"${FILESDIR}/${PN}-0.8.1_p20211023-hammer-test.patch"
)
src_configure() {