]> git.kaiwu.me - njs.git/commitdiff
QuickJS: fix nginx configure with not configured njs module.
authorVadim Zhestikov <v.zhestikov@f5.com>
Fri, 29 Aug 2025 16:42:18 +0000 (09:42 -0700)
committerVadimZhestikov <108960056+VadimZhestikov@users.noreply.github.com>
Wed, 3 Sep 2025 16:28:54 +0000 (09:28 -0700)
This fixes issue #960 which was introduced in 8259f9a.

.github/workflows/check-pr.yml
auto/quickjs
external/njs_shell.c
nginx/config
src/qjs.h
src/quickjs_compat.h [new file with mode: 0644]

index 2be02e7b4607f69eb0d164f9a1b42b76e5c8c119..c75f3cbe9971b9f885e244c13eeedb63f6bb68a1 100644 (file)
@@ -134,7 +134,9 @@ jobs:
 
       - name: Configure and build nginx and njs modules with quickjs, asan, static modules
         run: |
+          $MAKE_UTILITY clean
           cd nginx-source
+          $MAKE_UTILITY clean
           $NGINX_CONFIGURE_CMD --with-cc-opt="$CC_OPT -I${{ github.workspace }}/quickjs -fsanitize=address -DNJS_DEBUG_MEMORY -DNGX_DEBUG_PALLOC -DNGX_DEBUG_MALLOC" --with-ld-opt="$LD_OPT -L${{ github.workspace }}/quickjs -fsanitize=address" --add-module=../nginx || cat objs/autoconf.err
           $MAKE_UTILITY -j$(nproc)
 
index cbf860a2c5961a38d702f25b05b9cb1068011cbd..8d6b544f9ca752d1e623d36220d0e26dbb2ddfac 100644 (file)
@@ -15,7 +15,7 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
     njs_feature_run=yes
     njs_feature_incs="$NJS_QUICKJS_DEFAULT_INCS"
     njs_feature_libs="-lquickjs.lto -lm -ldl -lpthread"
-    njs_feature_test="#include <qjs.h>
+    njs_feature_test="#include <quickjs_compat.h>
 
                       int main() {
                           JSRuntime *rt;
@@ -62,7 +62,7 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
 
         njs_feature="QuickJS JS_GetClassID()"
         njs_feature_name=NJS_HAVE_QUICKJS_GET_CLASS_ID
-        njs_feature_test="#include <qjs.h>
+        njs_feature_test="#include <quickjs_compat.h>
 
                           int main() {
                               (void) JS_GetClassID(JS_UNDEFINED);
@@ -80,7 +80,7 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
 
         njs_feature="QuickJS JS_NewTypedArray()"
         njs_feature_name=NJS_HAVE_QUICKJS_NEW_TYPED_ARRAY
-        njs_feature_test="#include <qjs.h>
+        njs_feature_test="#include <quickjs_compat.h>
 
                           int main() {
                               JSValue   ta, argv;
@@ -102,7 +102,7 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
 
         njs_feature="QuickJS JS_IsSameValue()"
         njs_feature_name=NJS_HAVE_QUICKJS_IS_SAME_VALUE
-        njs_feature_test="#include <qjs.h>
+        njs_feature_test="#include <quickjs_compat.h>
 
                           int main() {
                               JSRuntime *rt;
@@ -120,7 +120,7 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
 
         njs_feature="QuickJS JS_IsArray()"
         njs_feature_name=NJS_HAVE_QUICKJS_IS_ARRAY_SINGLE_ARG
-        njs_feature_test="#include <qjs.h>
+        njs_feature_test="#include <quickjs_compat.h>
 
                           int main() {
                               JSRuntime *rt;
@@ -138,7 +138,7 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
 
         njs_feature="QuickJS JS_AddIntrinsicBigInt()"
         njs_feature_name=NJS_HAVE_QUICKJS_ADD_INTRINSIC_BIG_INT
-        njs_feature_test="#include <qjs.h>
+        njs_feature_test="#include <quickjs_compat.h>
 
                           int main() {
                               JSRuntime *rt;
@@ -157,7 +157,7 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
         njs_feature="QuickJS version"
         njs_feature_name=NJS_QUICKJS_VERSION
         njs_feature_run=value
-        njs_feature_test="#include <qjs.h>
+        njs_feature_test="#include <quickjs_compat.h>
 
                           int main() {
 #if defined(QJS_VERSION_MAJOR)
index 75316339861ead5d36ef63a709d1683d6061816f..c2294f756a796233cee34be3a6ba0190a816d144 100644 (file)
@@ -13,6 +13,7 @@
 
 #if (NJS_HAVE_QUICKJS)
 #include <qjs.h>
+#include <pthread.h>
 #endif
 
 #if (!defined NJS_FUZZER_TARGET && defined NJS_HAVE_READLINE)
index 474be8f3a24a3ce317924dc0896b31939ed9eb92..3386dac08dd97bda9d88ce6247802a7c60a3068b 100644 (file)
@@ -31,7 +31,7 @@ if [ $NJS_QUICKJS != NO ]; then
     ngx_feature="QuickJS library -lquickjs.lto"
     ngx_feature_name=NJS_HAVE_QUICKJS
     ngx_feature_run=yes
-    ngx_feature_incs="#include <qjs.h>"
+    ngx_feature_incs="#include <quickjs_compat.h>"
     ngx_feature_path="$NJS_QUICKJS_DEFAULT_INCS"
     ngx_feature_libs="-lquickjs.lto -lm -ldl -lpthread"
     ngx_feature_test="JSRuntime *rt;
index 954cc23c9e7029dffefcf4768c6eaadd5cdaa120..cd5c25215ec5c627763f4a487e532e90976b0a74 100644 (file)
--- a/src/qjs.h
+++ b/src/qjs.h
 #include <njs_chb.h>
 #include <njs_utils.h>
 #include <njs_assert.h>
-
-#ifndef __has_warning
-#  define __has_warning(x) 0
-#endif
-
-#if (defined(__GNUC__) && (__GNUC__ >= 8))                                    \
-    || (defined(__clang__) && __has_warning("-Wcast-function-type"))
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcast-function-type"
-#endif
-
-#include <quickjs.h>
-
-#ifndef JS_BOOL
-#define JS_BOOL bool
-#endif
-
-#if (defined(__GNUC__) && (__GNUC__ >= 8))                                    \
-    || (defined(__clang__) && __has_warning("-Wcast-function-type"))
-#pragma GCC diagnostic pop
-#endif
-#include <pthread.h>
+#include <quickjs_compat.h>
 
 
 #define QJS_CORE_CLASS_ID_OFFSET    64
diff --git a/src/quickjs_compat.h b/src/quickjs_compat.h
new file mode 100644 (file)
index 0000000..3b7a618
--- /dev/null
@@ -0,0 +1,24 @@
+
+/*
+ * Copyright (C) F5, Inc.
+ */
+
+#ifndef __has_warning
+    #define __has_warning(x) 0
+#endif
+
+#if (defined(__GNUC__) && (__GNUC__ >= 8))                                    \
+    || (defined(__clang__) && __has_warning("-Wcast-function-type"))
+    #pragma GCC diagnostic push
+    #pragma GCC diagnostic ignored "-Wcast-function-type"
+
+    #include <quickjs.h>
+
+    #pragma GCC diagnostic pop
+#else
+    #include <quickjs.h>
+#endif
+
+#ifndef JS_BOOL
+    #define JS_BOOL bool
+#endif