Welcome! Log In Create A New Profile

Advanced

[njs] Modules: added options to disable parts dependant on 3rd party libs.

Dmitry Volyntsev
May 11, 2023 07:56PM
details: https://hg.nginx.org/njs/rev/1f84f3c34bb0
branches:
changeset: 2116:1f84f3c34bb0
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Wed May 10 22:36:53 2023 -0700
description:
Modules: added options to disable parts dependant on 3rd party libs.

The following environment variables are added: NJS_OPENSSL, NJS_LIBXSLT,
NJS_ZLIB. When a variable evaluates to "NO" the part of the module
related to the corresponsing library is disabled.

For example to disable libxslt related code:
NJS_LIBXSLT=NO ./configure .. --add-module=/path/to/njs/module

diffstat:

nginx/config | 43 +++++++++++++++++++++++++++++++++++++------
nginx/ngx_js.c | 6 ++++++
2 files changed, 43 insertions(+), 6 deletions(-)

diffs (89 lines):

diff -r a140e71b0fbf -r 1f84f3c34bb0 nginx/config
--- a/nginx/config Wed May 10 20:50:53 2023 -0700
+++ b/nginx/config Wed May 10 22:36:53 2023 -0700
@@ -1,13 +1,42 @@
ngx_addon_name="ngx_js_module"

+NJS_OPENSSL=${NJS_OPENSSL:-YES}
+NJS_LIBXSLT=${NJS_LIBXSLT:-YES}
+NJS_ZLIB=${NJS_ZLIB:-YES}
+
NJS_DEPS="$ngx_addon_dir/ngx_js.h \
$ngx_addon_dir/ngx_js_fetch.h"
NJS_SRCS="$ngx_addon_dir/ngx_js.c \
$ngx_addon_dir/ngx_js_fetch.c \
- $ngx_addon_dir/ngx_js_regex.c \
- $ngx_addon_dir/../external/njs_webcrypto_module.c
- $ngx_addon_dir/../external/njs_zlib_module.c
- $ngx_addon_dir/../external/njs_xml_module.c"
+ $ngx_addon_dir/ngx_js_regex.c"
+
+NJS_OPENSSL_LIB=
+NJS_XSLT_LIB=
+NJS_ZLIB_LIB=
+
+if [ $NJS_OPENSSL != NO ]; then
+ NJS_OPENSSL_LIB=OPENSSL
+ have=NJS_HAVE_OPENSSL . auto/have
+ NJS_SRCS="$NJS_SRCS $ngx_addon_dir/../external/njs_webcrypto_module.c"
+
+ echo " enabled webcrypto module"
+fi
+
+if [ $NJS_LIBXSLT != NO ]; then
+ NJS_XSLT_LIB=LIBXSLT
+ have=NJS_HAVE_XML . auto/have
+ NJS_SRCS="$NJS_SRCS $ngx_addon_dir/../external/njs_xml_module.c"
+
+ echo " enabled xml module"
+fi
+
+if [ $NJS_ZLIB != NO ]; then
+ NJS_ZLIB_LIB=ZLIB
+ have=NJS_HAVE_ZLIB . auto/have
+ NJS_SRCS="$NJS_SRCS $ngx_addon_dir/../external/njs_zlib_module.c"
+
+ echo " enabled zlib module"
+fi

if [ $HTTP != NO ]; then
ngx_module_type=HTTP_AUX_FILTER
@@ -15,7 +44,8 @@ if [ $HTTP != NO ]; then
ngx_module_incs="$ngx_addon_dir/../src $ngx_addon_dir/../build"
ngx_module_deps="$ngx_addon_dir/../build/libnjs.a $NJS_DEPS"
ngx_module_srcs="$ngx_addon_dir/ngx_http_js_module.c $NJS_SRCS"
- ngx_module_libs="PCRE OPENSSL ZLIB LIBXSLT $ngx_addon_dir/../build/libnjs.a -lm"
+ ngx_module_libs="PCRE $NJS_OPENSSL_LIB $NJS_XSLT_LIB $NJS_ZLIB_LIB \
+ $ngx_addon_dir/../build/libnjs.a -lm"

. auto/module

@@ -30,7 +60,8 @@ if [ $STREAM != NO ]; then
ngx_module_incs="$ngx_addon_dir/../src $ngx_addon_dir/../build"
ngx_module_deps="$ngx_addon_dir/../build/libnjs.a $NJS_DEPS"
ngx_module_srcs="$ngx_addon_dir/ngx_stream_js_module.c $NJS_SRCS"
- ngx_module_libs="PCRE OPENSSL ZLIB LIBXSLT $ngx_addon_dir/../build/libnjs.a -lm"
+ ngx_module_libs="PCRE $NJS_OPENSSL_LIB $NJS_XSLT_LIB $NJS_ZLIB_LIB \
+ $ngx_addon_dir/../build/libnjs.a -lm"

. auto/module
fi
diff -r a140e71b0fbf -r 1f84f3c34bb0 nginx/ngx_js.c
--- a/nginx/ngx_js.c Wed May 10 20:50:53 2023 -0700
+++ b/nginx/ngx_js.c Wed May 10 22:36:53 2023 -0700
@@ -88,9 +88,15 @@ static njs_external_t ngx_js_ext_core[]


njs_module_t *njs_js_addon_modules[] = {
+#ifdef NJS_HAVE_OPENSSL
&njs_webcrypto_module,
+#endif
+#ifdef NJS_HAVE_XML
&njs_xml_module,
+#endif
+#ifdef NJS_HAVE_ZLIB
&njs_zlib_module,
+#endif
NULL,
};

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Modules: added options to disable parts dependant on 3rd party libs.

Dmitry Volyntsev 255 May 11, 2023 07:56PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 175
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready