NPM = npm
-default: $NJS_DEFAULT_TARGET
+default: njs
NJS_LIB_INCS = -Isrc -I$NJS_BUILD_DIR
# njs cli.
-if [ $NJS_HAVE_READLINE = YES ]; then
-
cat << END >> $NJS_MAKEFILE
$NJS_BUILD_DIR/njs: \\
END
-else
-
-cat << END >> $NJS_MAKEFILE
-
-$NJS_BUILD_DIR/njs:
- @echo
- @echo " error: to make njs CLI \"readline\" library is required."
- @echo
- @exit 1
-
-END
-
-fi
-
-
# njs fuzzer.
cat << END >> $NJS_MAKEFILE
@exit 1
all: $NJS_BUILD_DIR/njs_auto_config.h \\
- $NJS_DEFAULT_TARGET ts test lib_test benchmark
+ njs ts test lib_test benchmark
njs: $NJS_BUILD_DIR/njs_auto_config.h $NJS_BUILD_DIR/njs
njs_fuzzer: $NJS_BUILD_DIR/njs_auto_config.h \\
. auto/feature
fi
-NJS_DEFAULT_TARGET=libnjs
-
if [ $njs_found = yes ]; then
NJS_HAVE_READLINE=YES
+ njs_define=NJS_HAVE_READLINE . auto/define
NJS_READLINE_LIB=$njs_feature_libs
- NJS_DEFAULT_TARGET="$NJS_DEFAULT_TARGET njs"
else
NJS_HAVE_READLINE=NO
- echo " - building interactive shell is not possible"
+ echo " - njs CLI is built without interactive shell support"
fi
#include <njs_main.h>
-#ifndef NJS_FUZZER_TARGET
+#if (!defined NJS_FUZZER_TARGET && defined NJS_HAVE_READLINE)
#include <locale.h>
#if (NJS_HAVE_EDITLINE)
static njs_int_t njs_options_parse(njs_opts_t *opts, int argc, char **argv);
static void njs_options_free(njs_opts_t *opts);
static njs_int_t njs_process_file(njs_opts_t *opts, njs_vm_opt_t *vm_options);
+
+#ifdef NJS_HAVE_READLINE
static njs_int_t njs_interactive_shell(njs_opts_t *opts,
njs_vm_opt_t *vm_options);
static njs_int_t njs_editline_init(void);
static char *njs_completion_generator(const char *text, int state);
+#endif
#endif
vm_options.ast = opts.ast;
vm_options.unhandled_rejection = opts.unhandled_rejection;
+#ifdef NJS_HAVE_READLINE
+
if (opts.interactive) {
ret = njs_interactive_shell(&opts, &vm_options);
- } else if (opts.command) {
+ } else
+
+#endif
+
+ if (opts.command) {
vm = njs_create_vm(&opts, &vm_options);
if (vm != NULL) {
command.start = (u_char *) opts.command;
njs_uint_t n;
static const char help[] =
- "Interactive njs shell.\n"
+ "njs [options] [-c string | script.js | -] [script args]\n"
"\n"
- "njs [options] [-c string | script.js | -] [script args]"
+ "Interactive shell: "
+#ifdef NJS_HAVE_READLINE
+ "enabled\n"
+#else
+ "disabled\n"
+#endif
"\n"
"Options:\n"
" -a print AST.\n"
}
-#ifndef NJS_FUZZER_TARGET
+#if (!defined NJS_FUZZER_TARGET && defined NJS_HAVE_READLINE)
static njs_int_t
njs_interactive_shell(njs_opts_t *opts, njs_vm_opt_t *vm_options)