forked from Kong/ngx_wasm_module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config
486 lines (387 loc) · 15.2 KB
/
config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
ngx_addon_name=ngx_wasmx_module
ngx_found=no
ngx_wasm_runtime_name=${NGX_WASM_RUNTIME:-wasmtime}
case $ngx_wasm_runtime_name in
wasmtime)
ngx_wasm_runtime_srcs="$ngx_addon_dir/src/wasm/wrt/ngx_wrt_wasmtime.c"
ngx_wasm_runtime_post_libs="-ldl -lm -lpthread"
ngx_feature_name="NGX_WASM_HAVE_WASMTIME"
ngx_feature_incs="#include <wasm.h>
#include <wasmtime.h>"
;;
wasmer)
ngx_wasm_runtime_srcs="$ngx_addon_dir/src/wasm/wrt/ngx_wrt_wasmer.c"
ngx_wasm_runtime_post_libs="-ldl -lm -lpthread"
ngx_wasm_cargo_lib_name=ngx_wasm_rs
ngx_wasm_cargo_lib_dir=$ngx_addon_dir/lib/ngx-wasm-rs
ngx_wasm_cargo_mandatory=no
ngx_wasm_cargo_flags=""
ngx_wasm_cargo_crate_type="cdylib"
ngx_wasm_cargo_defines="NGX_WASM_BACKTRACE"
ngx_wasm_cargo_feature_incs="#include <ngx_wasm_backtrace.h>"
ngx_feature_name="NGX_WASM_HAVE_WASMER"
ngx_feature_incs="#include <wasmer.h>"
;;
v8)
ngx_wasm_runtime_srcs="$ngx_addon_dir/src/wasm/wrt/ngx_wrt_v8.c"
ngx_wasm_runtime_lib_name="wee8"
ngx_wasm_runtime_pre_libs="-lv8bridge"
if [ "$NGX_SYSTEM" = "Darwin" ]; then
ngx_wasm_runtime_post_libs="-ldl -lm -lpthread -lstdc++"
else
ngx_wasm_runtime_post_libs="-ldl -lm -lpthread -lstdc++ -latomic"
fi
ngx_wasm_cargo_lib_name=ngx_wasm_rs
ngx_wasm_cargo_lib_dir=$ngx_addon_dir/lib/ngx-wasm-rs
ngx_wasm_cargo_mandatory=yes
ngx_wasm_cargo_flags="--features wat"
ngx_wasm_cargo_defines="NGX_WASM_BACKTRACE NGX_WASM_WAT"
ngx_wasm_cargo_feature_incs="#include <ngx_wasm_wat.h>"
ngx_feature_name="NGX_WASM_HAVE_V8"
ngx_feature_incs="#include <wasm.h>"
;;
*)
echo "$0: error: $ngx_addon_name does not support the \"$ngx_wasm_runtime_name\" runtime."
echo "Supported runtimes: wasmtime, wasmer, v8."
echo
exit 1
esac
# auto/runtime
ngx_wasm_runtime_inc=$NGX_CC_OPT
ngx_wasm_runtime_lib=
ngx_wasm_runtime_opt=$NGX_LD_OPT
. $ngx_addon_dir/auto/runtime
if [ -n "$NGX_WASM_RUNTIME_INC" -o -n "$NGX_WASM_RUNTIME_LIB" ]; then
ngx_wasm_runtime_inc="-I $NGX_WASM_RUNTIME_INC"
ngx_wasm_runtime_lib="-L$NGX_WASM_RUNTIME_LIB"
ngx_wasm_runtime_opt=$NGX_WASM_RUNTIME_LD_OPT
. $ngx_addon_dir/auto/runtime
fi
ngx_wasm_runtime_inc="-I /usr/local/opt/include"
ngx_wasm_runtime_lib="-L/usr/local/opt/lib"
ngx_wasm_runtime_opt=
. $ngx_addon_dir/auto/runtime
ngx_wasm_runtime_inc="-I /usr/local/include"
ngx_wasm_runtime_lib="-L/usr/local/lib"
ngx_wasm_runtime_opt=
. $ngx_addon_dir/auto/runtime
if [ $ngx_found = no ]; then
echo "$0: error: $ngx_addon_name could not find the \"$ngx_wasm_runtime_name\" library."
echo "You can set the NGX_WASM_RUNTIME_INC, NGX_WASM_RUNTIME_LIB, and NGX_WASM_RUNTIME_LD_OPT environment variables."
echo
exit 1
fi
ngx_wasm_runtime_path=$ngx_feature_path
ngx_wasm_runtime_libs=$ngx_feature_libs
have=NGX_WASM_RUNTIME value="\"$ngx_wasm_runtime_name\"" . auto/define
# auto/cargo (ngx_wasm_rs)
if [ "$ngx_wasm_cargo_lib_name" = ngx_wasm_rs ]; then
if [ "$NGX_WASM_CARGO" != 0 ]; then
. $ngx_addon_dir/auto/cargo
if [ $ngx_found = yes ]; then
ngx_wasm_runtime_path="$ngx_wasm_runtime_path $ngx_feature_path"
ngx_wasm_runtime_libs="$ngx_wasm_runtime_libs $ngx_feature_libs"
fi
fi
if echo -n "$ngx_wasm_runtime_libs\n$NGX_LD_OPT" | grep -q "ngx-wasm-rs"; then
for d in $ngx_wasm_cargo_defines; do
have=$d value=1 . auto/define
done
elif [ $ngx_wasm_cargo_mandatory = yes ]; then
echo "$0: error: $ngx_addon_name with $NGX_WASM_RUNTIME requires lib$ngx_wasm_cargo_lib_name - aborting."
echo
exit 1
fi
fi
###############################################################################
# wasmx
NGX_WASMX_INCS="\
$ngx_addon_dir/src \
$ngx_addon_dir/src/common \
$ngx_addon_dir/src/common/proxy_wasm \
$ngx_addon_dir/src/common/shm \
$ngx_addon_dir/src/common/metrics \
$ngx_addon_dir/src/common/lua"
NGX_WASMX_DEPS="\
$ngx_addon_dir/src/ngx_wasmx.h \
$ngx_addon_dir/src/common/ngx_wa_readers.h \
$ngx_addon_dir/src/common/ngx_wasm_subsystem.h \
$ngx_addon_dir/src/common/ngx_wasm_socket_tcp.h \
$ngx_addon_dir/src/common/ngx_wasm_socket_tcp_readers.h \
$ngx_addon_dir/src/common/shm/ngx_wa_shm.h \
$ngx_addon_dir/src/common/shm/ngx_wa_shm_kv.h \
$ngx_addon_dir/src/common/shm/ngx_wa_shm_queue.h \
$ngx_addon_dir/src/common/metrics/ngx_wa_metrics.h \
$ngx_addon_dir/src/common/proxy_wasm/ngx_proxy_wasm.h \
$ngx_addon_dir/src/common/proxy_wasm/ngx_proxy_wasm_maps.h \
$ngx_addon_dir/src/common/proxy_wasm/ngx_proxy_wasm_properties.h"
NGX_WASMX_SRCS="\
$ngx_addon_dir/src/ngx_wasmx.c \
$ngx_addon_dir/src/common/ngx_wa_readers.c \
$ngx_addon_dir/src/common/ngx_wasm_subsystem.c \
$ngx_addon_dir/src/common/ngx_wasm_socket_tcp.c \
$ngx_addon_dir/src/common/ngx_wasm_socket_tcp_readers.c \
$ngx_addon_dir/src/common/shm/ngx_wa_shm.c \
$ngx_addon_dir/src/common/shm/ngx_wa_shm_kv.c \
$ngx_addon_dir/src/common/shm/ngx_wa_shm_queue.c \
$ngx_addon_dir/src/common/metrics/ngx_wa_metrics.c \
$ngx_addon_dir/src/common/metrics/ngx_wa_histogram.c \
$ngx_addon_dir/src/common/proxy_wasm/ngx_proxy_wasm.c \
$ngx_addon_dir/src/common/proxy_wasm/ngx_proxy_wasm_host.c \
$ngx_addon_dir/src/common/proxy_wasm/ngx_proxy_wasm_maps.c \
$ngx_addon_dir/src/common/proxy_wasm/ngx_proxy_wasm_properties.c \
$ngx_addon_dir/src/common/proxy_wasm/ngx_proxy_wasm_util.c"
# wasm
NGX_WASM_INCS="\
$NGX_WASMX_INCS \
$ngx_wasm_runtime_path \
$ngx_addon_dir/src/wasm \
$ngx_addon_dir/src/wasm/wrt \
$ngx_addon_dir/src/wasm/vm \
$ngx_addon_dir/src/wasm/wasi"
NGX_WASM_DEPS="\
$NGX_WASMX_DEPS \
$ngx_addon_dir/src/wasm/ngx_wasm.h \
$ngx_addon_dir/src/wasm/wrt/ngx_wrt.h \
$ngx_addon_dir/src/wasm/ngx_wasm_ops.h \
$ngx_addon_dir/src/wasm/vm/ngx_wavm.h \
$ngx_addon_dir/src/wasm/vm/ngx_wavm_host.h \
$ngx_addon_dir/src/wasm/wasi/ngx_wasi.h"
NGX_WASM_SRCS="\
$NGX_WASMX_SRCS \
$ngx_wasm_runtime_srcs \
$ngx_addon_dir/src/wasm/ngx_wasm_ops.c \
$ngx_addon_dir/src/wasm/ngx_wasm_util.c \
$ngx_addon_dir/src/wasm/ngx_wasm_directives.c \
$ngx_addon_dir/src/wasm/wrt/ngx_wrt_utils.c \
$ngx_addon_dir/src/wasm/vm/ngx_wavm.c \
$ngx_addon_dir/src/wasm/vm/ngx_wavm_host.c \
$ngx_addon_dir/src/wasm/wasi/ngx_wasi_preview1_host.c"
NGX_WASM_CORE_SRCS="\
$ngx_addon_dir/src/wasm/ngx_wasm_core_module.c \
$ngx_addon_dir/src/wasm/ngx_wasm_core_host.c"
# ipc
NGX_IPC_INCS="\
$ngx_addon_dir/src/ipc"
NGX_IPC_DEPS="\
$ngx_addon_dir/src/ipc/ngx_ipc.h"
NGX_IPC_SRCS="\
$ngx_addon_dir/src/ipc/ngx_ipc.c"
NGX_IPC_CORE_SRCS="\
$ngx_addon_dir/src/ipc/ngx_ipc_core_module.c"
# http
NGX_HTTP_WASM_INCS="\
$ngx_addon_dir/src/http \
$ngx_addon_dir/src/http/proxy_wasm"
NGX_HTTP_WASM_DEPS="\
$ngx_addon_dir/src/http/ngx_http_wasm.h \
$ngx_addon_dir/src/http/ngx_http_wasm_util.h \
$ngx_addon_dir/src/http/ngx_http_wasm_headers.h \
$ngx_addon_dir/src/http/ngx_http_wasm_trailers.h \
$ngx_addon_dir/src/http/proxy_wasm/ngx_http_proxy_wasm.h \
$ngx_addon_dir/src/http/proxy_wasm/ngx_http_proxy_wasm_dispatch.h"
NGX_HTTP_WASM_SRCS="\
$ngx_addon_dir/src/http/ngx_http_wasm_module.c \
$ngx_addon_dir/src/http/ngx_http_wasm_directives.c \
$ngx_addon_dir/src/http/ngx_http_wasm_local_response.c \
$ngx_addon_dir/src/http/ngx_http_wasm_headers.c \
$ngx_addon_dir/src/http/ngx_http_wasm_headers_request.c \
$ngx_addon_dir/src/http/ngx_http_wasm_headers_response.c \
$ngx_addon_dir/src/http/ngx_http_wasm_trailers_response.c \
$ngx_addon_dir/src/http/ngx_http_wasm_headers_shims.c \
$ngx_addon_dir/src/http/ngx_http_wasm_host.c \
$ngx_addon_dir/src/http/ngx_http_wasm_util.c \
$ngx_addon_dir/src/http/ngx_http_wasm_escape.c \
$ngx_addon_dir/src/http/proxy_wasm/ngx_http_proxy_wasm.c \
$ngx_addon_dir/src/http/proxy_wasm/ngx_http_proxy_wasm_dispatch.c"
NGX_HTTP_WASM_FILTER_SRCS="\
$ngx_addon_dir/src/http/ngx_http_wasm_filter_module.c"
# stream
NGX_STREAM_WASM_INCS="\
$ngx_addon_dir/src/stream \
$ngx_addon_dir/src/stream/proxy_wasm"
NGX_STREAM_WASM_DEPS="\
$ngx_addon_dir/src/stream/ngx_stream_wasm.h \
$ngx_addon_dir/src/stream/proxy_wasm/ngx_stream_proxy_wasm.h"
NGX_STREAM_WASM_SRCS="\
$ngx_addon_dir/src/stream/ngx_stream_wasm_module.c"
# debug
NGX_WASM_DEBUG_SRCS="\
$ngx_addon_dir/src/common/debug/ngx_wasm_debug_module.c"
# ssl
if [ $HTTP_SSL = YES -o $STREAM_SSL = YES ]; then
NGX_WASM_DEPS="\
$NGX_WASM_DEPS \
$ngx_addon_dir/src/common/ngx_wasm_ssl.h"
NGX_WASM_SRCS="\
$NGX_WASM_SRCS \
$ngx_addon_dir/src/common/ngx_wasm_ssl.c"
fi
# lua
if [ -n "$HTTP_LUA_DEPS" ]; then
if [ $HTTP = YES ]; then
# ../build/ngx_lua-x.y.z/src/ngx_http_lua_util.h
ngx_lua_dir=$(find .. -maxdepth 1 -type d -name 'ngx_lua-*')
NGX_HTTP_WASM_INCS="$NGX_HTTP_WASM_INCS $ngx_lua_dir/src"
fi
if [ $STREAM = YES ]; then
# ../build/ngx_stream_lua-x.y.z/src/ngx_stream_lua_util.h
ngx_stream_lua_dir=$(find .. -maxdepth 1 -type d -name 'ngx_stream_lua-*')
NGX_STREAM_WASM_INCS="$NGX_STREAM_WASM_INCS $ngx_stream_lua_dir/src"
fi
NGX_WASM_DEPS="\
$NGX_WASM_DEPS \
$ngx_addon_dir/src/common/lua/ngx_wasm_lua.h \
$ngx_addon_dir/src/common/lua/ngx_wasm_lua_ffi.h \
$ngx_addon_dir/src/common/lua/ngx_wasm_lua_resolver.h"
NGX_WASM_SRCS="\
$NGX_WASM_SRCS \
$ngx_addon_dir/src/common/lua/ngx_wasm_lua.c \
$ngx_addon_dir/src/common/lua/ngx_wasm_lua_ffi.c \
$ngx_addon_dir/src/common/lua/ngx_wasm_lua_resolver.c"
have=NGX_WASM_LUA value=1 . auto/define
fi
###############################################################################
if [ "$ngx_module_link" = DYNAMIC ]; then
ngx_module_order="$ngx_addon_name \
ngx_wasm_core_module"
ngx_module_type=CORE
ngx_module_name=$ngx_addon_name
ngx_module_incs="$NGX_WASM_INCS"
ngx_module_deps="$NGX_WASM_DEPS"
ngx_module_srcs="$NGX_WASM_SRCS $NGX_WASM_CORE_SRCS"
ngx_module_libs=$ngx_wasm_runtime_libs
if [ $NGX_DEBUG = YES ]; then
ngx_module_order="$ngx_module_order \
ngx_wasm_debug_module"
ngx_module_srcs="$ngx_module_srcs $NGX_WASM_DEBUG_SRCS"
fi
if [ $NGX_IPC != 0 ]; then
ngx_module_order="$ngx_module_order \
ngx_ipc_core_module"
ngx_module_incs="$ngx_module_incs $NGX_IPC_INCS"
ngx_module_deps="$ngx_module_deps $NGX_IPC_DEPS"
ngx_module_srcs="$ngx_module_srcs $NGX_IPC_SRCS $NGX_IPC_CORE_SRCS"
have=NGX_WA_IPC value=1 . auto/define
fi
else
# addon
ngx_module_type=CORE
ngx_module_name=$ngx_addon_name
ngx_module_incs="$NGX_WASM_INCS"
ngx_module_deps="$NGX_WASM_DEPS"
ngx_module_srcs="$NGX_WASM_SRCS"
ngx_module_libs=
if [ $NGX_IPC != 0 ]; then
ngx_module_incs="$ngx_module_incs $NGX_IPC_INCS"
ngx_module_deps="$ngx_module_deps $NGX_IPC_DEPS"
ngx_module_srcs="$ngx_module_srcs $NGX_IPC_SRCS $NGX_IPC_CORE_SRCS"
fi
. auto/module
ngx_module_type=WASM
ngx_module_name=ngx_wasm_core_module
ngx_module_incs="$NGX_WASM_INCS"
ngx_module_deps="$NGX_WASM_DEPS"
ngx_module_srcs="$NGX_WASM_CORE_SRCS"
ngx_module_libs=$ngx_wasm_runtime_libs
. auto/module
if [ $NGX_IPC != 0 ]; then
ngx_module_type=IPC
ngx_module_name=ngx_ipc_core_module
ngx_module_incs="$NGX_IPC_INCS"
ngx_module_deps="$NGX_IPC_DEPS"
ngx_module_srcs="$NGX_IPC_CORE_SRCS"
ngx_module_libs=
. auto/module
have=NGX_WA_IPC value=1 . auto/define
fi
if [ $NGX_DEBUG = YES ]; then
ngx_module_type=WASM
ngx_module_name=ngx_wasm_debug_module
ngx_module_incs="$NGX_WASM_INCS"
ngx_module_deps="$NGX_WASM_DEPS"
ngx_module_srcs="$NGX_WASM_DEBUG_SRCS"
ngx_module_libs=
. auto/module
fi
fi
###############################################################################
if [ $HTTP = YES ]; then
if [ "$ngx_module_link" = DYNAMIC ]; then
ngx_module_order="$ngx_module_order \
ngx_http_wasm_module \
ngx_http_wasm_filter_module"
ngx_module_incs="$ngx_module_incs \
$NGX_HTTP_WASM_INCS"
ngx_module_deps="$ngx_module_deps \
$NGX_HTTP_WASM_DEPS"
ngx_module_srcs="$ngx_module_srcs \
$NGX_HTTP_WASM_SRCS \
$NGX_HTTP_WASM_FILTER_SRCS"
if [ $NGX_DEBUG = YES ]; then
ngx_module_order="$ngx_module_order \
ngx_http_wasm_debug_filter_module"
fi
else
# addon
ngx_module_type=HTTP
ngx_module_name=ngx_http_wasm_module
ngx_module_incs="$NGX_HTTP_WASM_INCS"
ngx_module_deps="$NGX_HTTP_WASM_DEPS"
ngx_module_srcs="$NGX_HTTP_WASM_SRCS"
ngx_module_libs=
. auto/module
ngx_module_type=HTTP_FILTER
ngx_module_name=ngx_http_wasm_filter_module
ngx_module_incs="$NGX_HTTP_WASM_INCS"
ngx_module_deps="$NGX_HTTP_WASM_DEPS"
ngx_module_srcs="$NGX_HTTP_WASM_FILTER_SRCS"
ngx_module_libs=
. auto/module
if [ $NGX_DEBUG = YES ]; then
ngx_module_type=HTTP_FILTER
ngx_module_name=ngx_http_wasm_debug_filter_module
ngx_module_incs="$NGX_HTTP_WASM_INCS"
ngx_module_deps="$NGX_HTTP_WASM_DEPS"
ngx_module_srcs="$NGX_WASM_DEBUG_SRCS"
ngx_module_libs=
. auto/module
fi
fi
have=NGX_WASM_HTTP value=1 . auto/define
fi
if [ $STREAM = YES ]; then
if [ "$ngx_module_link" = DYNAMIC ]; then
ngx_module_incs="$ngx_module_incs \
$NGX_STREAM_WASM_INCS"
ngx_module_deps="$ngx_module_deps \
$NGX_STREAM_WASM_DEPS"
ngx_module_srcs="$ngx_module_srcs \
$NGX_STREAM_WASM_SRCS"
else
# addon
ngx_module_type=STREAM
ngx_module_name=ngx_stream_wasm_module
ngx_module_incs="$NGX_STREAM_WASM_INCS"
ngx_module_deps="$NGX_STREAM_WASM_DEPS"
ngx_module_srcs="$NGX_STREAM_WASM_SRCS"
ngx_module_libs=
. auto/module
fi
have=NGX_WASM_STREAM value=1 . auto/define
fi
###############################################################################
if [ "$ngx_module_link" = DYNAMIC ]; then
# ngx_wasmx_module.so (dynamic module)
. auto/module
# add other modules into this bundled one
ngx_wasmx_module_MODULES=$ngx_module_order
have=NGX_WASM_DYNAMIC_MODULE value=1 . auto/define
else
# addon
# bypass auto/make which does not recognize custom $*_MODULES variables
CORE_MODULES="$CORE_MODULES $WASM_MODULES"
# initialize after the event module (connections initializer)
EVENT_MODULES="$EVENT_MODULES $IPC_MODULES"
fi
# vim:ft=sh ts=4 sts=4 sw=4: