git: 679a1b0ca082 - main - www/nginx-devel: add QuickJS engine to NGINX JavaScript module

From: Sergey A. Osokin <osa_at_FreeBSD.org>
Date: Tue, 09 Jul 2024 13:11:36 UTC
The branch main has been updated by osa:

URL: https://cgit.FreeBSD.org/ports/commit/?id=679a1b0ca0828c1f38dd039e2b0b098bcb7981b4

commit 679a1b0ca0828c1f38dd039e2b0b098bcb7981b4
Author:     Sergey A. Osokin <osa@FreeBSD.org>
AuthorDate: 2024-07-09 13:10:38 +0000
Commit:     Sergey A. Osokin <osa@FreeBSD.org>
CommitDate: 2024-07-09 13:10:38 +0000

    www/nginx-devel: add QuickJS engine to NGINX JavaScript module
    
    Bump PORTREVISION.
---
 www/nginx-devel/Makefile                           | 17 +++++++++++++----
 www/nginx-devel/Makefile.extmod                    |  4 ++++
 www/nginx-devel/Makefile.options.desc              |  1 +
 www/nginx-devel/files/extra-patch-njs-auto-quickjs | 15 +++++++++++++++
 4 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/www/nginx-devel/Makefile b/www/nginx-devel/Makefile
index 1822f967f882..cfaa5e821710 100644
--- a/www/nginx-devel/Makefile
+++ b/www/nginx-devel/Makefile
@@ -1,6 +1,6 @@
 PORTNAME?=	nginx
 PORTVERSION=	1.27.0
-PORTREVISION=	4
+PORTREVISION=	5
 CATEGORIES=	www
 MASTER_SITES=	https://nginx.org/download/ \
 		LOCAL/osa
@@ -78,7 +78,8 @@ OPTIONS_GROUP_MAILGRP=	MAIL MAIL_IMAP MAIL_POP3 MAIL_SMTP MAIL_SSL
 OPTIONS_GROUP_STREAMGRP=	STREAM STREAM_REALIP STREAM_SSL \
 	STREAM_SSL_PREREAD
 
-OPTIONS_DEFINE=		DEBUG DEBUGLOG DSO FILE_AIO IPV6 NJS NJS_XML OTEL THREADS WWW
+OPTIONS_DEFINE=		DEBUG DEBUGLOG DSO FILE_AIO IPV6 NJS NJS_QJS NJS_XML \
+		OTEL THREADS WWW
 OPTIONS_DEFAULT?=	DSO FILE_AIO HTTP HTTP_ADDITION HTTP_AUTH_REQ HTTP_CACHE \
 		HTTP_DAV HTTP_FLV HTTP_GUNZIP_FILTER HTTP_GZIP_STATIC HTTP_MP4 \
 		HTTP_RANDOM_INDEX HTTP_REALIP HTTP_SECURE_LINK HTTP_SLICE HTTP_SSL \
@@ -251,9 +252,14 @@ CONFIGURE_ARGS+=	--with-ld-opt="-L ${LOCALBASE}/lib -lpcre"
 LIB_DEPENDS+=		libpcre.so:devel/pcre
 .endif
 
-.if ${PORT_OPTIONS:MNJS} && empty(PORT_OPTIONS:MNJS_XML)
+.if ${PORT_OPTIONS:MNJS}
+. if empty(PORT_OPTIONS:MNJS_QJS)
+NJS_CONFIGURE_ARGS+=	--no-quickjs
+. endif
+. if empty(PORT_OPTIONS:MNJS_XML)
 CONFIGURE_ENV+=		NJS_LIBXSLT=NO
-NJS_CONFIGURE_ARGS=	--no-libxml2
+NJS_CONFIGURE_ARGS+=	--no-libxml2
+. endif
 .endif
 
 pre-everything::
@@ -305,6 +311,9 @@ post-patch-HTTP_TARANTOOL-on:
 post-patch-ICONV-on:
 	@${REINPLACE_CMD} 's!%%PREFIX%%!${LOCALBASE}!g' ${WRKSRC_iconv}/config
 
+post-patch-NJS_QJS-on:
+	@${REINPLACE_CMD} 's!%%PREFIX%%!${LOCALBASE}!g' ${WRKSRC_njs}/auto/quickjs
+
 post-patch-PASSENGER-on:
 	@${REINPLACE_CMD} \
 		'168,170s!true!false!' \
diff --git a/www/nginx-devel/Makefile.extmod b/www/nginx-devel/Makefile.extmod
index 451c958e3d9f..64690014313a 100644
--- a/www/nginx-devel/Makefile.extmod
+++ b/www/nginx-devel/Makefile.extmod
@@ -244,6 +244,10 @@ NJS_GH_TUPLE=		nginx:njs:0.8.5:njs
 NJS_VARS=		DSO_EXTMODS+=njs NJS_SUBDIR=/nginx
 NJS_IMPLIES=		STREAM
 
+NJS_QJS_IMPLIES=	HTTP NJS
+NJS_QJS_LIB_DEPENDS=	libquickjs.so:lang/quickjs
+NJS_QJS_EXTRA_PATCHES=	${PATCHDIR}/extra-patch-njs-auto-quickjs
+
 NJS_XML_IMPLIES=	HTTP NJS
 NJS_XML_LIB_DEPENDS=	libxml2.so:textproc/libxml2 \
 			libxslt.so:textproc/libxslt
diff --git a/www/nginx-devel/Makefile.options.desc b/www/nginx-devel/Makefile.options.desc
index f2b3924b69f8..c22809086c9f 100644
--- a/www/nginx-devel/Makefile.options.desc
+++ b/www/nginx-devel/Makefile.options.desc
@@ -89,6 +89,7 @@ MEMC_DESC=			3rd party memc (memcached) module
 MODSECURITY3_DESC=		3rd party modsecurity3 module
 NAXSI_DESC=			3rd party naxsi module
 NJS_DESC=			Enable javascript (NJS) module
+NJS_QJS_DESC=			Enable QuickJS engine in NJS module
 NJS_XML_DESC=			Enable XML functionality in NJS module
 OTEL_DESC=			Enable OpenTELemetry module
 PASSENGER_DESC=			3rd party passenger module
diff --git a/www/nginx-devel/files/extra-patch-njs-auto-quickjs b/www/nginx-devel/files/extra-patch-njs-auto-quickjs
new file mode 100644
index 000000000000..742b880b2059
--- /dev/null
+++ b/www/nginx-devel/files/extra-patch-njs-auto-quickjs
@@ -0,0 +1,15 @@
+--- ../njs-0.8.5/auto/quickjs.orig	2024-06-25 13:40:20.000000000 -0400
++++ ../njs-0.8.5/auto/quickjs	2024-07-08 14:45:08.895107000 -0400
+@@ -47,9 +46,9 @@
+     fi
+ 
+     if [ $njs_found = no ]; then
+-        njs_feature="QuickJS library -I/usr/include/quickjs/ -L/usr/lib/quickjs/ -lquickjs"
+-        njs_feature_incs="/usr/include/quickjs/"
+-        njs_feature_libs="-L/usr/lib/quickjs/ -lquickjs -lm -ldl -lpthread"
++        njs_feature="QuickJS library -I%%PREFIX%%/include/quickjs/ -L%%PREFIX%%/lib/quickjs/ -lquickjs"
++        njs_feature_incs="%%PREFIX%%/include/quickjs/"
++        njs_feature_libs="-L%%PREFIX%%/lib -lquickjs -lm -ldl -lpthread"
+ 
+         . auto/feature
+     fi