[njs] Introduced libqjs.a.

noreply at nginx.com noreply at nginx.com
Wed Sep 4 00:59:02 UTC 2024


details:   https://github.com/nginx/njs/commit/82c5b5ad5ceff3f9f7d0cf62bf6cc74cac2c454d
branches:  master
commit:    82c5b5ad5ceff3f9f7d0cf62bf6cc74cac2c454d
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Tue, 23 Jul 2024 18:37:33 -0700
description:
Introduced libqjs.a.


---
 auto/make        | 48 ++++++++++++++++++++++++++++++++++++++++++------
 auto/qjs_module  |  2 +-
 auto/qjs_modules | 20 ++++++++------------
 auto/sources     |  8 ++++----
 4 files changed, 55 insertions(+), 23 deletions(-)

diff --git a/auto/make b/auto/make
index 4a77335b..cc3b022b 100644
--- a/auto/make
+++ b/auto/make
@@ -40,11 +40,9 @@ cat << END                                    >> $njs_modules_c
 
 END
 
-if [ $NJS_HAVE_QUICKJS = YES ]; then
-
 qjs_modules_c=$NJS_BUILD_DIR/qjs_modules.c
 
-NJS_LIB_SRCS="$NJS_LIB_SRCS $qjs_modules_c"
+QJS_LIB_SRCS="$QJS_LIB_SRCS $qjs_modules_c"
 
 cat << END                                    > $qjs_modules_c
 
@@ -70,13 +68,20 @@ cat << END                                    >> $qjs_modules_c
 };
 
 END
-fi
 
 njs_incs=`echo $NJS_LIB_INCS \
         | sed -e "s# *\([^ ]*\)#$njs_regex_cont-I\1#g"`
 njs_objs=`echo $NJS_LIB_SRCS \
         | sed -e "s# *\([^ ]*\.\)c#$NJS_BUILD_DIR/\1o$njs_regex_cont#g"`
 
+qjs_objs=`echo $QJS_LIB_SRCS \
+        | sed -e "s# *\([^ ]*\.\)c#$NJS_BUILD_DIR/\1o$njs_regex_cont#g"`
+
+QJS_LIB=""
+if [ $NJS_HAVE_QUICKJS = YES ]; then
+    QJS_LIB="$NJS_BUILD_DIR/libqjs.a"
+fi
+
 cat << END > $NJS_MAKEFILE
 
 # This file is auto-generated by configure
@@ -96,8 +101,10 @@ default: njs
 
 NJS_LIB_INCS = $njs_incs
 NJS_LIB_OBJS = $njs_objs
+QJS_LIB_OBJS = $qjs_objs
 
 libnjs: $NJS_BUILD_DIR/libnjs.a pc
+libqjs: $NJS_BUILD_DIR/libqjs.a
 
 $NJS_BUILD_DIR/libnjs.a:   \\
 	$NJS_BUILD_DIR/njs_auto_config.h \\
@@ -105,6 +112,13 @@ $NJS_BUILD_DIR/libnjs.a:   \\
 
 	\$(NJS_STATIC_LINK) $NJS_BUILD_DIR/libnjs.a \\
 		\$(NJS_LIB_OBJS)
+
+$NJS_BUILD_DIR/libqjs.a:   \\
+	$NJS_BUILD_DIR/njs_auto_config.h \\
+	\$(QJS_LIB_OBJS)
+
+	\$(NJS_STATIC_LINK) $NJS_BUILD_DIR/libqjs.a \\
+		\$(QJS_LIB_OBJS)
 END
 
 # object files.
@@ -131,17 +145,39 @@ END
 
 done
 
+for njs_src in $QJS_LIB_SRCS
+do
+    njs_obj="${njs_src%.c}.o"
+    njs_dep="${njs_src%.c}.dep"
+    njs_dep_flags=`njs_gen_dep_flags $njs_dep $njs_obj`
+    njs_dep_post=`njs_gen_dep_post $njs_dep $njs_obj`
+    cat << END >> $NJS_MAKEFILE
+
+$NJS_BUILD_DIR/$njs_obj: $njs_src
+	\$(NJS_CC) -c \$(NJS_LIB_INCS) \$(NJS_CFLAGS) \\
+		\$(NJS_LIB_AUX_CFLAGS) \\
+		-o $NJS_BUILD_DIR/$njs_obj \\
+		$njs_dep_flags \\
+		$njs_src
+		$njs_dep_post
+
+-include $NJS_BUILD_DIR/$njs_dep
+
+END
+
+done
+
 # njs cli.
 
 cat << END >> $NJS_MAKEFILE
 
 $NJS_BUILD_DIR/njs: \\
-	$NJS_BUILD_DIR/libnjs.a \\
+	$NJS_BUILD_DIR/libnjs.a $QJS_LIB \\
 	external/njs_shell.c
 	\$(NJS_LINK) -o $NJS_BUILD_DIR/njs \$(NJS_LIB_INCS) \\
 		\$(NJS_CFLAGS) \$(NJS_LIB_AUX_CFLAGS)\\
 		external/njs_shell.c \\
-		$NJS_BUILD_DIR/libnjs.a \\
+		$NJS_BUILD_DIR/libnjs.a $QJS_LIB \\
 		$NJS_LD_OPT -lm $NJS_LIBS $NJS_LIB_AUX_LIBS $NJS_READLINE_LIB
 
 END
diff --git a/auto/qjs_module b/auto/qjs_module
index 38270481..baf9d792 100644
--- a/auto/qjs_module
+++ b/auto/qjs_module
@@ -2,5 +2,5 @@
 # Copyright (C) F5, Inc
 
 QJS_LIB_MODULES="$QJS_LIB_MODULES $njs_module_name"
-NJS_LIB_SRCS="$NJS_LIB_SRCS $njs_module_srcs"
+QJS_LIB_SRCS="$QJS_LIB_SRCS $njs_module_srcs"
 NJS_LIB_INCS="$NJS_LIB_INCS $njs_module_incs"
diff --git a/auto/qjs_modules b/auto/qjs_modules
index 9dde2efd..0216d376 100644
--- a/auto/qjs_modules
+++ b/auto/qjs_modules
@@ -1,20 +1,16 @@
 # Copyright (C) Dmitry Volyntsev
 # Copyright (C) F5, Inc
 
-if [ $NJS_HAVE_QUICKJS = YES ]; then
+njs_module_name=qjs_buffer_module
+njs_module_incs=
+njs_module_srcs=src/qjs_buffer.c
 
-    njs_module_name=qjs_buffer_module
+. auto/qjs_module
+
+if [ $NJS_ZLIB = YES -a $NJS_HAVE_ZLIB = YES ]; then
+    njs_module_name=qjs_zlib_module
     njs_module_incs=
-    njs_module_srcs=src/qjs_buffer.c
+    njs_module_srcs=external/qjs_zlib_module.c
 
     . auto/qjs_module
-
-    if [ $NJS_ZLIB = YES -a $NJS_HAVE_ZLIB = YES ]; then
-        njs_module_name=qjs_zlib_module
-        njs_module_incs=
-        njs_module_srcs=external/qjs_zlib_module.c
-
-        . auto/qjs_module
-    fi
-
 fi
diff --git a/auto/sources b/auto/sources
index ae208293..9b33eead 100644
--- a/auto/sources
+++ b/auto/sources
@@ -52,6 +52,10 @@ NJS_LIB_SRCS=" \
    src/njs_builtin.c \
 "
 
+QJS_LIB_SRCS=" \
+	src/qjs.c   \
+"
+
 NJS_LIB_TEST_SRCS=" \
    src/test/lvlhsh_unit_test.c \
    src/test/random_unit_test.c \
@@ -72,10 +76,6 @@ if [ "$NJS_HAVE_LIBBFD" = "YES" -a "$NJS_HAVE_DL_ITERATE_PHDR" = "YES" ]; then
 	NJS_LIB_SRCS="$NJS_LIB_SRCS src/njs_addr2line.c"
 fi
 
-if [ "$NJS_HAVE_QUICKJS" = "YES" ]; then
-	NJS_LIB_SRCS="$NJS_LIB_SRCS src/qjs.c"
-fi
-
 NJS_TS_SRCS=$(find ts/ -name "*.d.ts" -o -name "*.json")
 
 NJS_TEST_TS_SRCS=$(find test/ts/ -name "*.ts" -o -name "*.json")


More information about the nginx-devel mailing list