]> git.kaiwu.me - njs.git/commitdiff
Modules: isolate engine builds from the standalone CLI
authorDmitry Volyntsev <xeioex@nginx.com>
Thu, 22 Oct 2026 00:37:10 +0000 (17:37 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Thu, 22 Oct 2026 21:25:01 +0000 (14:25 -0700)
nginx and the CLI share build artifacts and configuration.  Building
nginx replaces the CLI Makefile, while rebuilding the CLI can leave
nginx linking libraries compiled with incompatible flags.

Building nginx no longer changes the CLI configuration or libraries.
Rebuilding the CLI no longer breaks subsequent nginx builds.

.github/workflows/check-pr.yml
nginx/config
nginx/config.make

index fb2771aea42141ed2cc99a8d68dea1b9c4b3ae88..9490645da56c5a719d7dd0731255706a5caa00f2 100644 (file)
@@ -176,7 +176,6 @@ 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
index 7b34163d14c474d1525843dbbbacfe73f3695d77..654d67040ed1042831f1ceb806091dea3876946a 100644 (file)
@@ -5,6 +5,11 @@ NJS_LIBXSLT=${NJS_LIBXSLT:-YES}
 NJS_ZLIB=${NJS_ZLIB:-YES}
 NJS_QUICKJS=${NJS_QUICKJS:-YES}
 
+NJS_BUILD_DIR="$(pwd)/$NGX_OBJS/njs"
+case "$NGX_OBJS" in
+    /*) NJS_BUILD_DIR="$NGX_OBJS/njs" ;;
+esac
+
 NJS_DEPS="$ngx_addon_dir/ngx_js.h \
     $ngx_addon_dir/ngx_js_form.h \
     $ngx_addon_dir/ngx_js_http.h \
@@ -26,7 +31,7 @@ NJS_XSLT_LIB=
 NJS_ZLIB_LIB=
 NJS_QUICKJS_LIB=
 NJS_QUICKJS_INC=
-NJS_QUICKJS_DEFAULT_INCS="$ngx_addon_dir/../src $ngx_addon_dir/../build"
+NJS_QUICKJS_DEFAULT_INCS="$ngx_addon_dir/../src"
 NJS_HAVE_QUICKJS=
 
 if [ $NJS_QUICKJS != NO ]; then
@@ -152,18 +157,18 @@ if [ $NJS_ZLIB != NO ]; then
 fi
 
 
-NJS_ENGINE_DEP="$ngx_addon_dir/../build/libnjs.a"
-NJS_ENGINE_LIB="$ngx_addon_dir/../build/libnjs.a"
+NJS_ENGINE_DEP="$NJS_BUILD_DIR/libnjs.a"
+NJS_ENGINE_LIB="$NJS_BUILD_DIR/libnjs.a"
 if [ "$NJS_HAVE_QUICKJS" = "YES" ];  then
-    NJS_ENGINE_DEP="$ngx_addon_dir/../build/libqjs.a"
-    NJS_ENGINE_LIB="$ngx_addon_dir/../build/libnjs.a $ngx_addon_dir/../build/libqjs.a"
+    NJS_ENGINE_DEP="$NJS_BUILD_DIR/libqjs.a"
+    NJS_ENGINE_LIB="$NJS_ENGINE_LIB $NJS_BUILD_DIR/libqjs.a"
     QJS_SRCS="$QJS_SRCS $ngx_addon_dir/ngx_qjs_fetch.c"
 fi
 
 if [ $HTTP != NO ]; then
     ngx_module_type=HTTP_AUX_FILTER
     ngx_module_name="ngx_http_js_module ngx_http_js_core_module"
-    ngx_module_incs="$ngx_addon_dir/../src $ngx_addon_dir/../build \
+    ngx_module_incs="$ngx_addon_dir/../src $NJS_BUILD_DIR \
                      $NJS_QUICKJS_INC"
     ngx_module_deps="$NJS_ENGINE_DEP $NJS_DEPS $QJS_DEPS"
     ngx_module_srcs="$ngx_addon_dir/ngx_http_js_module.c $NJS_SRCS $QJS_SRCS"
@@ -180,7 +185,7 @@ fi
 if [ $STREAM != NO ]; then
     ngx_module_type=STREAM
     ngx_module_name="ngx_stream_js_module ngx_stream_js_core_module"
-    ngx_module_incs="$ngx_addon_dir/../src $ngx_addon_dir/../build \
+    ngx_module_incs="$ngx_addon_dir/../src $NJS_BUILD_DIR \
                      $NJS_QUICKJS_INC"
     ngx_module_deps="$NJS_ENGINE_DEP $NJS_DEPS $QJS_DEPS"
     ngx_module_srcs="$ngx_addon_dir/ngx_stream_js_module.c $NJS_SRCS $QJS_SRCS"
index 404a622b47c80e47f0f0590bc3940ec55eb1f8a5..d55987cb0c4b9ff764e873e7aade40fa9e8bdbba 100644 (file)
@@ -1,17 +1,20 @@
 cat << END                                            >> $NGX_MAKEFILE
 
-$ngx_addon_dir/../build/libnjs.a: $NGX_MAKEFILE
+$NJS_BUILD_DIR/libnjs.a: $NGX_MAKEFILE
        cd $ngx_addon_dir/.. \\
-       && if [ -f build/Makefile ]; then \$(MAKE) clean; fi \\
        && CFLAGS="\$(CFLAGS)" CC="\$(CC)" ./configure --no-openssl \\
-               --no-libxml2 --no-zlib --no-pcre --no-quickjs --ld-opt="$NGX_LD_OPT" \\
-       && \$(MAKE) libnjs
+               --no-libxml2 --no-zlib --no-pcre --no-quickjs \\
+               --no-root-makefile --build-dir="$NJS_BUILD_DIR" \\
+               --ld-opt="$NGX_LD_OPT" \\
+       && \$(MAKE) -f $NJS_BUILD_DIR/Makefile libnjs
 
-$ngx_addon_dir/../build/libqjs.a: $NGX_MAKEFILE
+$NJS_BUILD_DIR/libqjs.a: $NGX_MAKEFILE
        cd $ngx_addon_dir/.. \\
-       && if [ -f build/Makefile ]; then \$(MAKE) clean; fi \\
        && CFLAGS="\$(CFLAGS)" CC="\$(CC)" ./configure --no-openssl \\
-               --no-libxml2 --no-zlib --no-pcre --ld-opt="$NGX_LD_OPT" \\
-       && \$(MAKE) libnjs libqjs
+               --no-libxml2 --no-zlib --no-pcre --with-quickjs \\
+               --no-root-makefile --build-dir="$NJS_BUILD_DIR" \\
+               --quickjs-inc="$NJS_QUICKJS_INC" \\
+               --quickjs-lib="$NJS_QUICKJS_LIB" --ld-opt="$NGX_LD_OPT" \\
+       && \$(MAKE) -f $NJS_BUILD_DIR/Makefile libnjs libqjs
 
 END