Module Name: src
Committed By: sjg
Date: Wed Aug 10 23:49:12 UTC 2016
Modified Files:
src/usr.bin/make: main.c make.1
Log Message:
Set .ERROR_CMD if we can
To generate a diff of this commit:
cvs rdiff -u -r1.248 -r1.249 src/usr.bin/make/main.c
cvs rdiff -u -r1.259 -r1.260 src/usr.bin/make/make.1
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.248 src/usr.bin/make/main.c:1.249
--- src/usr.bin/make/main.c:1.248 Tue Jun 7 03:04:45 2016
+++ src/usr.bin/make/main.c Wed Aug 10 23:49:12 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.248 2016/06/07 03:04:45 christos Exp $ */
+/* $NetBSD: main.c,v 1.249 2016/08/10 23:49:12 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.248 2016/06/07 03:04:45 christos Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.249 2016/08/10 23:49:12 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.248 2016/06/07 03:04:45 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.249 2016/08/10 23:49:12 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -1889,6 +1889,12 @@ PrintAddr(void *a, void *b)
}
+static int
+addErrorCMD(void *cmdp, void *gnp)
+{
+ Var_Append(".ERROR_CMD", cmdp, VAR_GLOBAL);
+ return 0;
+}
void
PrintOnError(GNode *gn, const char *s)
@@ -1909,6 +1915,8 @@ PrintOnError(GNode *gn, const char *s)
* We can print this even if there is no .ERROR target.
*/
Var_Set(".ERROR_TARGET", gn->name, VAR_GLOBAL, 0);
+ Var_Delete(".ERROR_CMD", VAR_GLOBAL);
+ Lst_ForEach(gn->commands, addErrorCMD, gn);
}
strncpy(tmp, "${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'\n@}",
sizeof(tmp) - 1);
Index: src/usr.bin/make/make.1
diff -u src/usr.bin/make/make.1:1.259 src/usr.bin/make/make.1:1.260
--- src/usr.bin/make/make.1:1.259 Fri Jun 3 07:07:37 2016
+++ src/usr.bin/make/make.1 Wed Aug 10 23:49:12 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.259 2016/06/03 07:07:37 wiz Exp $
+.\" $NetBSD: make.1,v 1.260 2016/08/10 23:49:12 sjg Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
.\"
-.Dd June 2, 2016
+.Dd August 10, 2016
.Dt MAKE 1
.Os
.Sh NAME
@@ -973,7 +973,19 @@ per normal evaluation rules.
.It Va MAKE_PRINT_VAR_ON_ERROR
When
.Nm
-stops due to an error, it prints its name and the value of
+stops due to an error, it sets
+.Ql Va .ERROR_TARGET
+to the name of the target that failed,
+.Ql Va .ERROR_CMD
+to the commands of the failed target,
+and in "meta" mode, it also sets
+.Ql Va .ERROR_CWD
+to the
+.Xr getcwd 3 ,
+and
+.Ql Va .ERROR_META_FILE
+to the path of the meta file (if any) describing the failed target.
+It then prints its name and the value of
.Ql Va .CURDIR
as well as the value of any variables named in
.Ql Va MAKE_PRINT_VAR_ON_ERROR .