details: https://hg.nginx.org/njs/rev/144e430d0ed5 branches: changeset: 1752:144e430d0ed5 user: Dmitry Volyntsev <xei...@nginx.com> date: Mon Nov 29 14:41:09 2021 +0000 description: Allowing to build njs util without interactive shell support.
diffstat: auto/make | 21 ++------------------- auto/readline | 6 ++---- auto/summary | 5 +---- src/njs_shell.c | 24 +++++++++++++++++++----- 4 files changed, 24 insertions(+), 32 deletions(-) diffs (156 lines): diff -r 94e5a03702f9 -r 144e430d0ed5 auto/make --- a/auto/make Mon Nov 29 14:05:33 2021 +0000 +++ b/auto/make Mon Nov 29 14:41:09 2021 +0000 @@ -26,7 +26,7 @@ NJS_TYPES_VER = \$(NJS_VER) NPM = npm -default: $NJS_DEFAULT_TARGET +default: njs NJS_LIB_INCS = -Isrc -I$NJS_BUILD_DIR @@ -69,8 +69,6 @@ done # njs cli. -if [ $NJS_HAVE_READLINE = YES ]; then - cat << END >> $NJS_MAKEFILE $NJS_BUILD_DIR/njs: \\ @@ -84,21 +82,6 @@ cat << END >> $NJS_MAKEFILE 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 @@ -209,7 +192,7 @@ 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 \\ diff -r 94e5a03702f9 -r 144e430d0ed5 auto/readline --- a/auto/readline Mon Nov 29 14:05:33 2021 +0000 +++ b/auto/readline Mon Nov 29 14:41:09 2021 +0000 @@ -68,14 +68,12 @@ if [ $njs_found = no ]; then . 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 diff -r 94e5a03702f9 -r 144e430d0ed5 auto/summary --- a/auto/summary Mon Nov 29 14:05:33 2021 +0000 +++ b/auto/summary Mon Nov 29 14:41:09 2021 +0000 @@ -21,9 +21,6 @@ fi echo echo " njs build dir: $NJS_BUILD_DIR" - -if [ $NJS_HAVE_READLINE = YES ]; then - echo " njs CLI: $NJS_BUILD_DIR/njs" -fi +echo " njs CLI: $NJS_BUILD_DIR/njs" echo diff -r 94e5a03702f9 -r 144e430d0ed5 src/njs_shell.c --- a/src/njs_shell.c Mon Nov 29 14:05:33 2021 +0000 +++ b/src/njs_shell.c Mon Nov 29 14:41:09 2021 +0000 @@ -7,7 +7,7 @@ #include <njs_main.h> -#ifndef NJS_FUZZER_TARGET +#if (!defined NJS_FUZZER_TARGET && defined NJS_HAVE_READLINE) #include <locale.h> #if (NJS_HAVE_EDITLINE) @@ -101,10 +101,13 @@ static njs_int_t njs_process_script(njs_ 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 @@ -282,10 +285,16 @@ main(int argc, char **argv) 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; @@ -314,9 +323,14 @@ njs_options_parse(njs_opts_t *opts, int 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" @@ -914,7 +928,7 @@ njs_process_script(njs_opts_t *opts, njs } -#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) _______________________________________________ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel