@@ -250,21 +250,30 @@ ngx_rust_module () {
250
250
ngx_module_libs_saved=$ngx_module_libs
251
251
ngx_module_libs=" $ngx_rust_obj $ngx_module_libs $RUST_LIBS "
252
252
253
- # Module deps are usually added to the object file targets, but we don't have any
254
- LINK_DEPS=" $LINK_DEPS $ngx_rust_obj "
255
-
256
- eval ${ngx_addon_id} _RUST_TARGETS=\"\$ ${ngx_addon_id} _RUST_TARGETS \
257
- $ngx_rust_target_type :$ngx_rust_target_name \"
258
-
259
253
if [ -n " $ngx_rust_target_features " ]; then
260
254
eval ${ngx_addon_id} _RUST_FEATURES=\"\$ ${ngx_addon_id} _RUST_FEATURES \
261
255
$ngx_rust_target_features \"
262
256
fi
263
257
264
- . auto/module
258
+ . auto/module
259
+
260
+ ngx_rust_target=$ngx_rust_target_type :$ngx_rust_target_name
261
+
262
+ # module deps are usually added to the object file targets, but we don't have any
263
+
264
+ if [ " $ngx_module_link " = DYNAMIC ]; then
265
+ # remember the dynamic module name and generate dependency later
266
+ ngx_rust_target=$ngx_rust_target :$ngx_module
267
+ else
268
+ # add dependency to the binary target
269
+ LINK_DEPS=" $LINK_DEPS $ngx_rust_obj "
270
+ fi
271
+
272
+ eval ${ngx_addon_id} _RUST_TARGETS=\"\$ ${ngx_addon_id} _RUST_TARGETS \
273
+ $ngx_rust_target \"
265
274
266
- ngx_module_deps=$ngx_module_deps_saved
267
- ngx_module_libs=$ngx_module_libs_saved
275
+ ngx_module_deps=$ngx_module_deps_saved
276
+ ngx_module_libs=$ngx_module_libs_saved
268
277
}
269
278
270
279
@@ -278,8 +287,9 @@ ngx_rust_make_modules () {
278
287
eval ngx_rust_targets=" \$ ${ngx_addon_id} _RUST_TARGETS"
279
288
280
289
for target in $ngx_rust_targets ; do
281
- ngx_rust_target_type=${target%%:* }
282
- ngx_rust_target_name=${target#*: }
290
+ IFS=' :' read -r ngx_rust_target_type ngx_rust_target_name ngx_rust_module_name << END
291
+ $target
292
+ END
283
293
284
294
ngx_rust_make_module
285
295
done
@@ -316,4 +326,14 @@ $ngx_rust_obj:
316
326
$ngx_rustc_module_opt $NGX_RUSTC_OPT
317
327
318
328
END
329
+
330
+ # Ensure that the "auto"-generated dynamic module target depends on the
331
+ # static library. Normally this is achieved by attaching ADDON_DEPS to
332
+ # the module object files, but we don't have any suitable C sources.
333
+
334
+ if [ -n " $ngx_rust_module_name " ]; then
335
+ cat << END >> $NGX_MAKEFILE
336
+ $NGX_OBJS$ngx_dirsep$ngx_rust_module_name$ngx_modext : $ngx_rust_obj
337
+ END
338
+ fi
319
339
}
0 commit comments