summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2013-09-19 01:15:22 -0400
committerPaul Smith <psmith@gnu.org>2013-09-21 14:24:44 -0400
commit4120f91846f781ead7350f86c9614a19824450f5 (patch)
tree22d2d901aeaf39b23272204c583e59cc67b60b86
parent30a5ee0d8551ea1879b0c7638f455d956456cee1 (diff)
downloadgunmake-4120f91846f781ead7350f86c9614a19824450f5.tar.gz
Don't write "Entering" every time we re-exec for remake makefiles.
-rw-r--r--ChangeLog7
-rw-r--r--main.c20
-rw-r--r--output.c7
-rw-r--r--output.h4
-rw-r--r--tests/ChangeLog4
-rw-r--r--tests/scripts/options/dash-w33
6 files changed, 65 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 8fb2037..861d841 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-09-19 Paul Smith <psmith@gnu.org>
+
+ * main.c (main): Set MAKE_RESTARTS to negative before re-exec if
+ we've already generated an "Entering" message. If we are started
+ and notice that MAKE_RESTARTS is negative, assume we already wrote
+ "Entering" and don't write it again.
+
2013-09-18 Paul Smith <psmith@gnu.org>
* main.c (main): Set starting_directory before we write any
diff --git a/main.c b/main.c
index 059f5b5..1a6c193 100644
--- a/main.c
+++ b/main.c
@@ -1332,11 +1332,17 @@ main (int argc, char **argv, char **envp)
shell_var.value = xstrdup (ep + 1);
}
- /* If MAKE_RESTARTS is set, remember it but don't export it. */
- if (streq (v->name, "MAKE_RESTARTS"))
+ /* If MAKE_RESTARTS is set, remember it but don't export it.
+ If it's negative, it means the "enter" message was printed. */
+ else if (streq (v->name, "MAKE_RESTARTS"))
{
v->export = v_noexport;
- restarts = (unsigned int) atoi (ep + 1);
+ if (*(++ep) == '-')
+ {
+ OUTPUT_TRACED ();
+ ++ep;
+ }
+ restarts = (unsigned int) atoi (ep);
}
}
}
@@ -2309,7 +2315,8 @@ main (int argc, char **argv, char **envp)
else if (strneq (*p, "MAKE_RESTARTS=", CSTRLEN ("MAKE_RESTARTS=")))
{
*p = alloca (40);
- sprintf (*p, "MAKE_RESTARTS=%u", restarts);
+ sprintf (*p, "MAKE_RESTARTS=%s%u",
+ OUTPUT_IS_TRACED () ? "-" : "", restarts);
restarts = 0;
}
}
@@ -2321,7 +2328,7 @@ main (int argc, char **argv, char **envp)
sprintf (buffer, "%u", makelevel);
SetVar (MAKELEVEL_NAME, buffer, -1, GVF_GLOBAL_ONLY);
- sprintf (buffer, "%u", restarts);
+ sprintf (buffer, "%s%u", OUTPUT_IS_TRACED () ? "-" : "", restarts);
SetVar ("MAKE_RESTARTS", buffer, -1, GVF_GLOBAL_ONLY);
restarts = 0;
}
@@ -2331,7 +2338,8 @@ main (int argc, char **argv, char **envp)
if (restarts)
{
char *b = alloca (40);
- sprintf (b, "MAKE_RESTARTS=%u", restarts);
+ sprintf (b, "MAKE_RESTARTS=%s%u",
+ OUTPUT_IS_TRACED () ? "-" : "", restarts);
putenv (b);
}
diff --git a/output.c b/output.c
index c445e63..32334eb 100644
--- a/output.c
+++ b/output.c
@@ -36,7 +36,7 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#endif /* WINDOWS32 */
struct output *output_context = NULL;
-static unsigned int stdio_traced = 0;
+unsigned int stdio_traced = 0;
#define OUTPUT_NONE (-1)
@@ -374,15 +374,14 @@ output_dump (struct output *out)
int traced = 0;
/* Try to acquire the semaphore. If it fails, dump the output
- unsynchronized; still better than silently discarding it. */
+ unsynchronized; still better than silently discarding it.
+ We want to keep this lock for as little time as possible. */
void *sem = acquire_semaphore ();
/* Log the working directory for this dump. */
if (print_directory_flag && output_sync != OUTPUT_SYNC_RECURSE)
traced = log_working_directory (output_context, 1);
- /* We've entered the "critical section" during which a lock is held. We
- want to keep it as short as possible. */
if (outfd_not_empty)
pump_from_tmp (out->out, stdout);
if (errfd_not_empty && out->err != out->out)
diff --git a/output.h b/output.h
index 2bb1c39..1f0e2d7 100644
--- a/output.h
+++ b/output.h
@@ -22,10 +22,14 @@ struct output
};
extern struct output *output_context;
+extern unsigned int stdio_traced;
#define OUTPUT_SET(_new) do{ if ((_new)->syncout) output_context = (_new); }while(0)
#define OUTPUT_UNSET() do{ output_context = NULL; }while(0)
+#define OUTPUT_TRACED() do{ stdio_traced = 1; }while(0)
+#define OUTPUT_IS_TRACED() (!!stdio_traced)
+
FILE *output_tmpfile (char **, const char *);
/* Initialize and close a child output structure: if NULL do this program's
diff --git a/tests/ChangeLog b/tests/ChangeLog
index c6cebbf..4ee7265 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2013-09-21 Paul Smith <psmith@gnu.org>
+
+ * scripts/options/dash-w: Add a test for -w flag.
+
2013-09-15 Paul Smith <psmith@gnu.org>
* scripts/misc/fopen-fail: Check for failure on infinite recursion.
diff --git a/tests/scripts/options/dash-w b/tests/scripts/options/dash-w
new file mode 100644
index 0000000..a05bbee
--- /dev/null
+++ b/tests/scripts/options/dash-w
@@ -0,0 +1,33 @@
+# -*-perl-*-
+
+$description = "Test the -w option to GNU make.";
+
+# Simple test without -w
+run_make_test(q!
+all: ; @echo hi
+!,
+ "", "hi\n");
+
+# Simple test with -w
+run_make_test(undef, "-w",
+ "#MAKE#: Entering directory '#PWD#'\nhi\n#MAKE#: Leaving directory '#PWD#'\n");
+
+# Test makefile rebuild to ensure no enter/leave
+run_make_test(q!
+include foo
+all: ;@:
+foo: ; touch foo
+!,
+ "", "#MAKEFILE#:2: foo: No such file or directory\ntouch foo\n");
+unlink('foo');
+
+# Test makefile rebuild with -w
+run_make_test(q!
+include foo
+all: ;@:
+foo: ; touch foo
+!,
+ "-w", "#MAKE#: Entering directory '#PWD#'\n#MAKEFILE#:2: foo: No such file or directory\ntouch foo\n#MAKE#: Leaving directory '#PWD#'\n");
+unlink('foo');
+
+1;