Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions auto/quickjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ NJS_QUICKJS_LIB=
NJS_HAVE_QUICKJS=NO
NJS_QUICKJS_DEFAULT_INCS="src $NJS_BUILD_DIR"

# Alternative pkg-config binary can be supplied by setting the PKG_CONFIG
# environment variable.
: "${PKG_CONFIG:=pkg-config}"

if [ $NJS_TRY_QUICKJS = YES ]; then
njs_found=no

Expand Down Expand Up @@ -57,6 +61,20 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
. auto/feature
fi

if [ $njs_found = no ]; then
njs_feature="QuickJS-NG library via pkg-config"

flags="$("${PKG_CONFIG}" --cflags-only-I quickjs-ng)"
# Trim the -I prefix from includes.
pkg_config_includes="$(printf "%s\n" "$flags" | sed 's|-I||g')"
pkg_config_libs="$("${PKG_CONFIG}" --libs quickjs-ng)"

njs_feature_incs="$NJS_QUICKJS_DEFAULT_INCS ${pkg_config_includes}"
njs_feature_libs="-lm -ldl -lpthread ${pkg_config_libs}"

. auto/feature
fi


if [ $njs_found = yes ]; then

Expand Down
19 changes: 19 additions & 0 deletions nginx/config
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ NJS_QUICKJS_INC=
NJS_QUICKJS_DEFAULT_INCS="$ngx_addon_dir/../src $ngx_addon_dir/../build"
NJS_HAVE_QUICKJS=

# Alternative pkg-config binary can be supplied by setting the PKG_CONFIG
# environment variable.
: "${PKG_CONFIG:=pkg-config}"

if [ $NJS_QUICKJS != NO ]; then

ngx_feature="QuickJS library -lquickjs.lto"
Expand Down Expand Up @@ -71,6 +75,21 @@ if [ $NJS_QUICKJS != NO ]; then
. auto/feature
fi

if [ $ngx_found = no ]; then
ngx_feature="QuickJS-NG library via pkg-config"

flags="$("${PKG_CONFIG}" --cflags-only-I quickjs-ng)"
# Trim the -I prefix from includes.
pkg_config_includes="$(printf "%s\n" "$flags" | sed 's|-I||g')"
pkg_config_libs="$("${PKG_CONFIG}" --libs quickjs-ng)"

ngx_feature_path="$NJS_QUICKJS_DEFAULT_INCS ${pkg_config_includes}"
ngx_feature_libs="-lm -ldl -lpthread ${pkg_config_libs}"

. auto/feature
fi


if [ $ngx_found = yes ]; then

ngx_feature="QuickJS JS_GetClassID()"
Expand Down
4 changes: 4 additions & 0 deletions src/quickjs_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@
#ifndef JS_BOOL
#define JS_BOOL bool
#endif

#ifdef QUICKJS_NG
#define JS_IsError(cx, val) JS_IsError(val)
#endif