From d351c1fef2ec30b69f92163e0572d7d7d7b33db4 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Wed, 28 Dec 2016 00:41:38 -0500 Subject: [PATCH] * main.c (switches): Add -E as an alias for --eval. * make.1: Document the -E and --eval options. * doc/make.texi: Document the -E option. * tests/scripts/options/eval: Test the -E option and MAKEFILES. * NEWS: Add information about the new option. --- NEWS | 2 ++ doc/make.texi | 2 ++ main.c | 4 ++-- make.1 | 8 ++++++-- tests/scripts/options/eval | 19 +++++++++++++++++-- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 9e10a9f2..e60644a1 100644 --- a/NEWS +++ b/NEWS @@ -36,6 +36,8 @@ http://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=108&set * A new option --no-silent has been added, that cancels the effect of the -s/--silent/--quiet flag. +* A new option -E has been added as a short alias for --eval. + Version 4.2.1 (10 Jun 2016) diff --git a/doc/make.texi b/doc/make.texi index a1aa5d32..e629f49e 100644 --- a/doc/make.texi +++ b/doc/make.texi @@ -8657,6 +8657,8 @@ Give variables taken from the environment precedence over variables from makefiles. @xref{Environment, ,Variables from the Environment}. +@item -E @var{string} +@cindex @code{-E} @item --eval=@var{string} @cindex @code{--eval} @c Extra blank line here makes the table look better. diff --git a/main.c b/main.c index a17b70e8..5b0a8544 100644 --- a/main.c +++ b/main.c @@ -350,7 +350,7 @@ static const char *const usage[] = -e, --environment-overrides\n\ Environment variables override makefiles.\n"), N_("\ - --eval=STRING Evaluate STRING as a makefile statement.\n"), + -E STRING, --eval=STRING Evaluate STRING as a makefile statement.\n"), N_("\ -f FILE, --file=FILE, --makefile=FILE\n\ Read FILE as a makefile.\n"), @@ -425,6 +425,7 @@ static const struct command_switch switches[] = { 'D', flag, &suspend_flag, 1, 1, 0, 0, 0, "suspend-for-debug" }, #endif { 'e', flag, &env_overrides, 1, 1, 0, 0, 0, "environment-overrides", }, + { 'E', strlist, &eval_strings, 1, 0, 0, 0, 0, "eval" }, { 'h', flag, &print_usage_flag, 0, 0, 0, 0, 0, "help" }, { 'i', flag, &ignore_errors_flag, 1, 1, 0, 0, 0, "ignore-errors" }, { 'k', flag, &keep_going_flag, 1, 1, 0, 0, &default_keep_going_flag, @@ -465,7 +466,6 @@ static const struct command_switch switches[] = "no-print-directory" }, { CHAR_MAX+5, flag, &warn_undefined_variables_flag, 1, 1, 0, 0, 0, "warn-undefined-variables" }, - { CHAR_MAX+6, strlist, &eval_strings, 1, 0, 0, 0, 0, "eval" }, { CHAR_MAX+7, string, &sync_mutex, 1, 1, 0, 0, 0, "sync-mutex" }, { CHAR_MAX+8, flag_off, &silent_flag, 1, 1, 0, 0, &default_silent_flag, "no-silent" }, { CHAR_MAX+9, string, &jobserver_auth, 1, 0, 0, 0, 0, "jobserver-fds" }, diff --git a/make.1 b/make.1 index 5396650a..e0faeaed 100644 --- a/make.1 +++ b/make.1 @@ -148,8 +148,12 @@ for debugging while remaking makefiles. Use to disable all previous debugging flags. .TP 0.5i \fB\-e\fR, \fB\-\-environment\-overrides\fR -Give variables taken from the environment precedence -over variables from makefiles. +Give variables taken from the environment precedence over variables +from makefiles. +.TP 0.5i +\fB\-E\fR \fIstring\fR, \fB\-\-eval\fR \fIstring\fR +Interpret \fIstring\fR using the \fBeval\fR function, before parsing any +makefiles. .TP 0.5i \fB\-f\fR \fIfile\fR, \fB\-\-file\fR=\fIfile\fR, \fB\-\-makefile\fR=\fIFILE\fR Use diff --git a/tests/scripts/options/eval b/tests/scripts/options/eval index 0f824090..b02b9255 100644 --- a/tests/scripts/options/eval +++ b/tests/scripts/options/eval @@ -7,14 +7,22 @@ and are passed to sub-makes."; # Verify that --eval is evaluated first run_make_test(q! +$(info infile) BAR = bar all: ; @echo all recurse: ; @$(MAKE) -f #MAKEFILE# && echo recurse!, - '--eval=\$\(info\ eval\) FOO=\$\(BAR\)', "eval\nall"); + '--eval=\$\(info\ eval\) FOO=\$\(BAR\)', "eval\ninfile\nall"); # Make sure that --eval is handled correctly during recursion run_make_test(undef, '--no-print-directory --eval=\$\(info\ eval\) recurse', - "eval\neval\nall\nrecurse"); + "eval\ninfile\neval\ninfile\nall\nrecurse"); + +# Make sure that --eval is not passed in MAKEFLAGS +run_make_test(q! +all: ; @echo "MAKEFLAGS=$$MAKEFLAGS" +!, + '--eval=\$\(info\ eval\)', + "eval\n".'MAKEFLAGS= --eval=$$(info\ eval)'); # Make sure that --eval is handled correctly during restarting run_make_test(q! @@ -26,4 +34,11 @@ gen.mk: ; @echo > $@ unlink('gen.mk'); +# Check -E +run_make_test(q! +BAR = bar +all: ; @echo all +recurse: ; @$(MAKE) -f #MAKEFILE# && echo recurse!, + '-E \$\(info\ eval\) FOO=\$\(BAR\)', "eval\nall"); + 1; -- 2.47.3