diff options
author | Ron Yorston <rmy@pobox.com> | 2023-12-22 07:48:54 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2023-12-22 08:50:04 +0000 |
commit | 628e1ab2b3af4e9a0d4f8331e20c970db5eba150 (patch) | |
tree | 34fb564165a5051fa199057c0d0854f557332afe | |
parent | 8d85a4a5be88931978fad594b94e762313d37afc (diff) | |
download | busybox-w32-628e1ab2b3af4e9a0d4f8331e20c970db5eba150.tar.gz busybox-w32-628e1ab2b3af4e9a0d4f8331e20c970db5eba150.tar.bz2 busybox-w32-628e1ab2b3af4e9a0d4f8331e20c970db5eba150.zip |
make: proper handling of build failure with '-k'
When a build command fails and the '-k' option (continue on error)
is in effect, no further commands should be executed for the
current target.
Also, the resulting diagnostic should be reported to stderr. As
should the final 'not built due to errors' diagnostic.
Adds 80 bytes.
(pdpmake GitHub issue 35)
-rw-r--r-- | miscutils/make.c | 11 | ||||
-rwxr-xr-x | testsuite/make.tests | 14 |
2 files changed, 22 insertions, 3 deletions
diff --git a/miscutils/make.c b/miscutils/make.c index 785e25f7d..841daa93e 100644 --- a/miscutils/make.c +++ b/miscutils/make.c | |||
@@ -2221,9 +2221,14 @@ docmds(struct name *np, struct cmd *cp) | |||
2221 | } else if (status != 0 && !signore) { | 2221 | } else if (status != 0 && !signore) { |
2222 | if (!posix && WIFSIGNALED(status)) | 2222 | if (!posix && WIFSIGNALED(status)) |
2223 | remove_target(); | 2223 | remove_target(); |
2224 | if (errcont || doinclude) { | 2224 | if (errcont) { |
2225 | warning("failed to build '%s'", np->n_name); | 2225 | diagnostic("failed to build '%s'", np->n_name); |
2226 | estat |= MAKE_FAILURE; | 2226 | estat |= MAKE_FAILURE; |
2227 | free(command); | ||
2228 | free(cmd); | ||
2229 | break; | ||
2230 | } else if (doinclude) { | ||
2231 | warning("failed to build '%s'", np->n_name); | ||
2227 | } else { | 2232 | } else { |
2228 | const char *err_type = NULL; | 2233 | const char *err_type = NULL; |
2229 | int err_value; | 2234 | int err_value; |
@@ -2488,7 +2493,7 @@ make(struct name *np, int level) | |||
2488 | else if (!doinclude && level == 0 && !(estat & MAKE_DIDSOMETHING)) | 2493 | else if (!doinclude && level == 0 && !(estat & MAKE_DIDSOMETHING)) |
2489 | warning("nothing to be done for %s", np->n_name); | 2494 | warning("nothing to be done for %s", np->n_name); |
2490 | } else if (!doinclude) { | 2495 | } else if (!doinclude) { |
2491 | warning("'%s' not built due to errors", np->n_name); | 2496 | diagnostic("'%s' not built due to errors", np->n_name); |
2492 | } | 2497 | } |
2493 | free(oodate); | 2498 | free(oodate); |
2494 | } | 2499 | } |
diff --git a/testsuite/make.tests b/testsuite/make.tests index 3c2aa5cf5..745a840f3 100755 --- a/testsuite/make.tests +++ b/testsuite/make.tests | |||
@@ -102,6 +102,20 @@ a = a | |||
102 | target:;@echo a = $(a) | 102 | target:;@echo a = $(a) |
103 | ' | 103 | ' |
104 | 104 | ||
105 | # When a build command fails and the '-k' option has been provided | ||
106 | # (continue execution on error) no further commands should be executed | ||
107 | # for the current target. | ||
108 | testing "make failure of build command with -k" \ | ||
109 | "make -k -f - 2>/dev/null" "OK\n" "" ' | ||
110 | all: bar baz | ||
111 | bar: | ||
112 | @echo OK | ||
113 | @false | ||
114 | @echo Not reached | ||
115 | baz: | ||
116 | @: | ||
117 | ' | ||
118 | |||
105 | # A macro created using ::= remembers it's of type immediate-expansion. | 119 | # A macro created using ::= remembers it's of type immediate-expansion. |
106 | # Immediate expansion also occurs when += is used to append to such a macro. | 120 | # Immediate expansion also occurs when += is used to append to such a macro. |
107 | testing "make appending to immediate-expansion macro" \ | 121 | testing "make appending to immediate-expansion macro" \ |