From: Dmitry Volyntsev Date: Thu, 22 Oct 2026 00:37:10 +0000 (-0700) Subject: Modules: isolate engine builds from the standalone CLI X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=6e22e91c7204e0aca0a223577696ca18602a8650;p=njs.git Modules: isolate engine builds from the standalone CLI 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. --- diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml index fb2771ae..9490645d 100644 --- a/.github/workflows/check-pr.yml +++ b/.github/workflows/check-pr.yml @@ -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 diff --git a/nginx/config b/nginx/config index 7b34163d..654d6704 100644 --- a/nginx/config +++ b/nginx/config @@ -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" diff --git a/nginx/config.make b/nginx/config.make index 404a622b..d55987cb 100644 --- a/nginx/config.make +++ b/nginx/config.make @@ -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