]> git.kaiwu.me - njs.git/commitdiff
Configure: allow explicit QuickJS library selection
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 22 Oct 2026 00:36:28 +0000 (17:36 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Thu, 22 Oct 2026 21:25:01 +0000 (14:25 -0700)
Independent configure runs can select different QuickJS libraries.
Allow callers to pass the selected headers and linker options without
falling back to another library.

auto/help
auto/options
auto/quickjs

index 7f647054d87eabc6d2a4d939d467f93e78fe4227..6c51582f64d48d444e19232b8f4f732bff5e001f 100644 (file)
--- a/auto/help
+++ b/auto/help
@@ -51,5 +51,8 @@ default: "$NJS_LD_OPT"
   --no-zlib                 disables zlib discovery. When this option is
                             enabled zlib dependant code is not built as a
                             part of libnjs.a.
+  --quickjs-inc=DIRS        sets QuickJS include directories;
+                            requires --quickjs-lib.
+  --quickjs-lib=OPTIONS     sets QuickJS linker options.
   --with-quickjs            requires QuickJS engine.
 END
index 6e58be1e2a4569456adb8222d557d55633c7bba4..a98983bb68af035fd2caae05e0090ee91c930271 100644 (file)
@@ -18,6 +18,8 @@ NJS_ADDR2LINE=NO
 
 NJS_QUICKJS=NO
 NJS_TRY_QUICKJS=YES
+NJS_QUICKJS_LIB=
+NJS_QUICKJS_INCS=
 NJS_OPENSSL=YES
 NJS_LIBXML2=YES
 NJS_ZLIB=YES
@@ -56,6 +58,8 @@ do
         --debug-generator=*)             NJS_DEBUG_GENERATOR="$value"        ;;
 
         --no-quickjs)                    NJS_TRY_QUICKJS=NO                  ;;
+        --quickjs-lib=*)                 NJS_QUICKJS_LIB="$value"            ;;
+        --quickjs-inc=*)                 NJS_QUICKJS_INCS="$value"           ;;
         --no-openssl)                    NJS_OPENSSL=NO                      ;;
         --no-libxml2)                    NJS_LIBXML2=NO                      ;;
         --no-zlib)                       NJS_ZLIB=NO                         ;;
@@ -86,6 +90,13 @@ do
 
 done
 
+if [ -n "$NJS_QUICKJS_INCS" ] && [ -z "$NJS_QUICKJS_LIB" ]; then
+    echo
+    echo "$0: error: --quickjs-inc requires --quickjs-lib."
+    echo
+    exit 1
+fi
+
 if [ "$NJS_DEBUG_MEMORY" = "YES" ]; then
     NJS_DEBUG=YES
 fi
index 80e79b2c66809ee944f90eeba5e7791b64927ac3..5a118de0c7c8d9882aef8f05d2f097bf34b4aba8 100644 (file)
@@ -3,7 +3,6 @@
 # Copyright (C) NGINX, Inc.
 
 
-NJS_QUICKJS_LIB=
 NJS_HAVE_QUICKJS=NO
 NJS_QUICKJS_DEFAULT_INCS="src $NJS_BUILD_DIR"
 
@@ -13,7 +12,7 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
     njs_feature="QuickJS library -lquickjs.lto"
     njs_feature_name=NJS_HAVE_QUICKJS
     njs_feature_run=yes
-    njs_feature_incs="$NJS_QUICKJS_DEFAULT_INCS"
+    njs_feature_incs="$NJS_QUICKJS_DEFAULT_INCS $NJS_QUICKJS_INCS"
     njs_feature_libs="-lquickjs.lto -lm -ldl -lpthread"
     njs_feature_test="#include <quickjs_compat.h>
 
@@ -24,8 +23,20 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
                           JS_FreeRuntime(rt);
                           return 0;
                      }"
+    if [ -n "$NJS_QUICKJS_LIB" ]; then
+        njs_feature="QuickJS library $NJS_QUICKJS_LIB"
+        njs_feature_libs="$NJS_QUICKJS_LIB"
+    fi
+
     . auto/feature
 
+    if [ -n "$NJS_QUICKJS_LIB" -a $njs_found = no ]; then
+        echo
+        echo $0: error: the specified QuickJS library is not working.
+        echo
+        exit 1
+    fi
+
     if [ $njs_found = no ]; then
         njs_feature="QuickJS library -lquickjs"
         njs_feature_libs="-lquickjs -lm -ldl -lpthread"