Skip to content

Commit b5a0576

Browse files
committed
Shell: added QuickJS engine support.
1 parent 822e450 commit b5a0576

File tree

13 files changed

+2596
-662
lines changed

13 files changed

+2596
-662
lines changed

auto/expect

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,31 @@ fi
2020
if [ $njs_found = yes -a $NJS_HAVE_READLINE = YES ]; then
2121
cat << END >> $NJS_MAKEFILE
2222

23-
shell_test: njs test/shell_test.exp
23+
shell_test_njs: njs test/shell_test.exp
2424
PATH=$NJS_BUILD_DIR:\$(PATH) LANG=C.UTF-8 TERM=screen \
2525
expect -f test/shell_test.exp
26+
PATH=$NJS_BUILD_DIR:\$(PATH) LANG=C.UTF-8 TERM=screen \
27+
expect -f test/shell_test_njs.exp
28+
END
29+
30+
if [ $NJS_HAVE_QUICKJS = YES ]; then
31+
cat << END >> $NJS_MAKEFILE
32+
33+
shell_test: shell_test_njs shell_test_quickjs
34+
35+
shell_test_quickjs: njs test/shell_test.exp
36+
PATH=$NJS_BUILD_DIR:\$(PATH) LANG=C.UTF-8 TERM=screen NJS_ENGINE=QuickJS \
37+
expect -f test/shell_test.exp
2638
END
2739

40+
else
41+
cat << END >> $NJS_MAKEFILE
42+
43+
shell_test: shell_test_njs
44+
END
45+
46+
fi
47+
2848
else
2949
echo " - expect tests are disabled"
3050

auto/make

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,7 @@ lib_test: $NJS_BUILD_DIR/njs_auto_config.h \\
241241
$NJS_BUILD_DIR/lvlhsh_unit_test
242242
$NJS_BUILD_DIR/unicode_unit_test
243243

244-
test262: njs
245-
244+
test262_njs: njs
246245
test/test262 --binary=$NJS_BUILD_DIR/njs
247246

248247
unit_test: $NJS_BUILD_DIR/njs_auto_config.h \\
@@ -265,6 +264,26 @@ dist:
265264
&& echo njs-\$(NJS_VER).tar.gz done
266265
END
267266

267+
if [ $NJS_HAVE_QUICKJS = YES ]; then
268+
cat << END >> $NJS_MAKEFILE
269+
270+
test262: njs test262_njs test262_quickjs
271+
272+
test262_quickjs: njs
273+
NJS_SKIP_LIST="test/js/promise_rejection_tracker_recursive.t.js \\
274+
test/js/async_exception_in_await.t.js" \\
275+
test/test262 --binary='$NJS_BUILD_DIR/njs -n QuickJS -m'
276+
END
277+
278+
else
279+
cat << END >> $NJS_MAKEFILE
280+
281+
test262: njs test262_njs
282+
END
283+
284+
fi
285+
286+
268287
njs_ts_deps=`echo $NJS_TS_SRCS \
269288
| sed -e "s# *\([^ ][^ ]*\)#\1$njs_regex_cont#g"`
270289

auto/options

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ NJS_DEBUG_GENERATOR=NO
1414
NJS_ADDRESS_SANITIZER=NO
1515
NJS_ADDR2LINE=NO
1616

17+
NJS_QUICKJS=YES
1718
NJS_OPENSSL=YES
1819
NJS_LIBXML2=YES
1920
NJS_ZLIB=YES
@@ -47,6 +48,7 @@ do
4748
--debug-opcode=*) NJS_DEBUG_OPCODE="$value" ;;
4849
--debug-generator=*) NJS_DEBUG_GENERATOR="$value" ;;
4950

51+
--no-quickjs) NJS_QUICKJS=NO ;;
5052
--no-openssl) NJS_OPENSSL=NO ;;
5153
--no-libxml2) NJS_LIBXML2=NO ;;
5254
--no-zlib) NJS_ZLIB=NO ;;

auto/quickjs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
# Copyright (C) Dmitry Volyntsev
3+
# Copyright (C) NGINX, Inc.
4+
5+
6+
NJS_QUICKJS_LIB=
7+
NJS_HAVE_QUICKJS=NO
8+
9+
if [ $NJS_QUICKJS = YES ]; then
10+
njs_found=no
11+
12+
njs_feature="QuickJS library"
13+
njs_feature_name=NJS_HAVE_QUICKJS
14+
njs_feature_run=yes
15+
njs_feature_incs=
16+
njs_feature_libs=""
17+
njs_feature_test="#if defined(__GNUC__) && (__GNUC__ >= 8)
18+
#pragma GCC diagnostic push
19+
#pragma GCC diagnostic ignored \"-Wcast-function-type\"
20+
#endif
21+
22+
#include <quickjs.h>
23+
24+
int main() {
25+
JSRuntime *rt;
26+
27+
rt = JS_NewRuntime();
28+
JS_FreeRuntime(rt);
29+
return 0;
30+
}"
31+
. auto/feature
32+
33+
if [ $njs_found = no ]; then
34+
njs_feature="QuickJS library -lquickjs.lto"
35+
njs_feature_incs="/usr/include/quickjs/"
36+
njs_feature_libs="-L/usr/lib/quickjs/ -lquickjs.lto -lm -ldl -lpthread"
37+
38+
. auto/feature
39+
fi
40+
41+
if [ $njs_found = no ]; then
42+
njs_feature="QuickJS library -lquickjs"
43+
njs_feature_libs="-L/usr/lib/quickjs/ -lquickjs -lm -ldl -lpthread"
44+
45+
. auto/feature
46+
fi
47+
48+
if [ $njs_found = yes ]; then
49+
NJS_HAVE_QUICKJS=YES
50+
NJS_QUICKJS_LIB="$njs_feature_libs"
51+
NJS_LIB_INCS="$NJS_LIB_INCS $njs_feature_incs"
52+
NJS_LIB_AUX_LIBS="$NJS_LIB_AUX_LIBS $njs_feature_libs"
53+
fi
54+
55+
fi

auto/summary

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ if [ $NJS_HAVE_READLINE = YES ]; then
1818
echo " + using readline library: $NJS_READLINE_LIB"
1919
fi
2020

21+
if [ $NJS_HAVE_QUICKJS = YES ]; then
22+
echo " + using QuickJS library: $NJS_QUICKJS_LIB"
23+
fi
24+
2125
if [ $NJS_HAVE_OPENSSL = YES ]; then
2226
echo " + using OpenSSL library: $NJS_OPENSSL_LIB"
2327
fi

configure

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ NJS_LIB_AUX_LIBS=
5050
. auto/explicit_bzero
5151
. auto/pcre
5252
. auto/readline
53+
. auto/quickjs
5354
. auto/openssl
5455
. auto/libxml2
5556
. auto/zlib

0 commit comments

Comments
 (0)