Skip to content

Commit

Permalink
Configure: shared sources for addon modules.
Browse files Browse the repository at this point in the history
Addon modules, both dynamic and static, can now use shared source files.
Shared sources result in only one make rule even if specified several
times in different modules.
  • Loading branch information
mdounin committed Nov 10, 2020
1 parent 3030907 commit 23597e9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
3 changes: 2 additions & 1 deletion auto/make
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ fi
for ngx_module in $DYNAMIC_MODULES
do
eval ngx_module_srcs="\$${ngx_module}_SRCS"
eval ngx_module_shrd="\$${ngx_module}_SHRD"
eval eval ngx_module_libs="\\\"\$${ngx_module}_LIBS\\\""

eval ngx_module_modules="\$${ngx_module}_MODULES"
Expand Down Expand Up @@ -567,7 +568,7 @@ END
| sed -e "s/\(.*\.\)c/\1$ngx_objext/"`

ngx_module_objs=
for ngx_src in $ngx_module_srcs
for ngx_src in $ngx_module_srcs $ngx_module_shrd
do
case "$ngx_src" in
src/*)
Expand Down
44 changes: 42 additions & 2 deletions auto/module
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ if [ "$ngx_module_link" = DYNAMIC ]; then
done

DYNAMIC_MODULES="$DYNAMIC_MODULES $ngx_module"
eval ${ngx_module}_SRCS=\"$ngx_module_srcs\"

eval ${ngx_module}_MODULES=\"$ngx_module_name\"

Expand All @@ -31,6 +30,30 @@ if [ "$ngx_module_link" = DYNAMIC ]; then
eval ${ngx_module}_ORDER=\"$ngx_module_order\"
fi

srcs=
shrd=
for src in $ngx_module_srcs
do
found=no
for old in $DYNAMIC_MODULES_SRCS
do
if [ $src = $old ]; then
found=yes
break
fi
done

if [ $found = no ]; then
srcs="$srcs $src"
else
shrd="$shrd $src"
fi
done
eval ${ngx_module}_SRCS=\"$srcs\"
eval ${ngx_module}_SHRD=\"$shrd\"

DYNAMIC_MODULES_SRCS="$DYNAMIC_MODULES_SRCS $srcs"

if test -n "$ngx_module_incs"; then
CORE_INCS="$CORE_INCS $ngx_module_incs"
fi
Expand Down Expand Up @@ -107,7 +130,24 @@ elif [ "$ngx_module_link" = ADDON ]; then
eval ${ngx_module_type}_MODULES=\"\$${ngx_module_type}_MODULES \
$ngx_module_name\"

NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_module_srcs"
srcs=
for src in $ngx_module_srcs
do
found=no
for old in $NGX_ADDON_SRCS
do
if [ $src = $old ]; then
found=yes
break
fi
done

if [ $found = no ]; then
srcs="$srcs $src"
fi
done

NGX_ADDON_SRCS="$NGX_ADDON_SRCS $srcs"

if test -n "$ngx_module_incs"; then
eval ${ngx_var}_INCS=\"\$${ngx_var}_INCS $ngx_module_incs\"
Expand Down
1 change: 1 addition & 0 deletions auto/options
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ STREAM_UPSTREAM_ZONE=YES
STREAM_SSL_PREREAD=NO

DYNAMIC_MODULES=
DYNAMIC_MODULES_SRCS=

NGX_ADDONS=
NGX_ADDON_SRCS=
Expand Down

0 comments on commit 23597e9

Please sign in to comment.