Hi, Here is a small patch that adds a new option to make that causes make to abort after N failures. An extra argument --stop-at-err-count[=N] is provided which forces GNU Make to return immediately when the number of errors is reached. The current problem with this patch is that when GNU make exits, the children processes left are not killed by GNU make when it exits. I want all children to be killed before GNU Make returns. I am not well versed with GNU Make code, so any advice or feedback would be appreciated!
diff -u /home/foo/make_git/make/job.c make/make-4.2.1/job.c--- /home/foo/make_git/make/job.c 2018-10-04 16:30:01.108348000 -0400+++ make/make-4.2.1/job.c 2018-10-04 16:28:12.119052000 -0400@@ -478,9 +478,19 @@ const char *nm; size_t l; + if (max_stop_at_err_count <= stop_at_err_count)+ {+ error (NILF, 0, _("*** [%p] Error (aborted after %d failures) %d"),+ child, stop_at_err_count, exit_code);+ die (2);+ }+ if (ignored && silent_flag) return; +/* Only increase STOP_AT_ERR_COUNT if the job _really_ failed. */+ stop_at_err_count++;+ if (exit_sig && coredump) dump = _(" (core dumped)"); @@ -595,8 +605,14 @@ /* We might block for a while, so let the user know why. Only print this message once no matter how many jobs are left. */ fflush (stdout);- if (!printed)- O (error, NILF, _("*** Waiting for unfinished jobs...."));+ if (!printed) {+ O (error, NILF, _("*** Waiting for unfinished jobs...."));+ if (max_stop_at_err_count <= stop_at_err_count)+ {+ error (NILF,0, _("*** Aborting after %d failures"),stop_at_err_count);+ die (2);+ }+ } printed = 1; } diff -u /home/foo/make_git/make/main.c make/make-4.2.1/main.c--- /home/foo/make_git/make/main.c 2018-10-04 16:30:01.120391000 -0400+++ make/make-4.2.1/main.c 2018-10-04 16:29:19.185057000 -0400@@ -216,9 +216,13 @@ /* Nonzero means keep going even if remaking some file fails (-k). */ -int keep_going_flag;+int keep_going_flag = 0; int default_keep_going_flag = 0; +int stop_at_err_count = 0;+unsigned int max_stop_at_err_count = -1;+static unsigned int inf_stop_at_err_count = 0;+ /* Nonzero means check symlink mtimes. */ int check_symlink_flag = 0;@@ -394,6 +398,8 @@ -S, --no-keep-going, --stop\n\ Turns off -k.\n"), N_("\+ --stop-at-err-count[=N] Stop when N errors are reached. Default 0 (infinite).\n"),+ N_("\ -t, --touch Touch targets instead of remaking them.\n"), N_("\ --trace Print tracing information.\n"),@@ -471,6 +477,9 @@ "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, positive_int, (char *) &max_stop_at_err_count, 1, 1, 0,+ (char *) &inf_stop_at_err_count,+ (char *) &max_stop_at_err_count, "stop-at-err-count" }, { 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; diff -u /home/foo/make_git/make/makeint.h make/make-4.2.1/makeint.h--- /home/foo/make_git/make/makeint.h 2018-10-04 16:30:01.169374000 -0400+++ make/make-4.2.1/makeint.h 2018-10-04 14:15:07.587723000 -0400@@ -639,6 +639,9 @@ extern const floc *reading_file; extern const floc **expanding_var; +extern int stop_at_err_count;+extern unsigned int max_stop_at_err_count;+ extern unsigned short stopchar_map[]; extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag; Regards Richa Bindra _______________________________________________ Help-make mailing list Help-make@gnu.org https://lists.gnu.org/mailman/listinfo/help-make