+2013-05-13 Paul Smith <psmith@gnu.org>
+
+ * makeint.h (TRACE_NONE, TRACE_RULE, TRACE_DIRECTORY): Define
+ constants for the trace mode.
+ * main.c: Add new --trace mode parsing.
+ (decode_trace_flags): New function.
+ (decode_switches): Call it.
+ (define_makeflags): Fix a bug with long-name options.
+ * misc.c (fatal): Remove special output-sync handling.
+ * make.1: Document new --trace mode flags.
+ * doc/make.texi (Options Summary): Ditto.
+
2013-05-11 Eli Zaretskii <eliz@gnu.org>
* job.c (child_out): Output the newline following the message
of each target is grouped together. With the type @samp{line}, output
from each line in the recipe is grouped together. With the type
@samp{recurse}, the output from an entire recursive make is grouped
-together. @xref{Parallel Output, ,Output During Parallel Execution}.
+together. With the type @samp{none}, no output synchronization is
+performed. @xref{Parallel Output, ,Output During Parallel Execution}.
@item -q
@cindex @code{-q}
recipes were done, in order to fool future invocations of
@code{make}. @xref{Instead of Execution, ,Instead of Executing Recipes}.
-@item --trace
+@item --trace[=@var{mode}]
@cindex @code{--trace}
-@c Extra blank line here makes the table look better.
-
-Print the entire recipe to be executed, even for recipes that are
-normally silent (due to @code{.SILENT} or @samp{@@}). Also print the
-makefile name and line number where the recipe was defined.
+Show tracing information for @code{make} execution. With no mode or
+the type @samp{rule}, print the entire recipe to be executed, even for
+recipes that are normally silent (due to @code{.SILENT} or @samp{@@}).
+Also print the makefile name and line number where the recipe was
+defined, and information on why the target is being rebuilt. With the
+type @samp{dir}, directory enter/leave lines are shown around each
+synchronized output segment. These modes are cumulative and can be
+set with multiple instances of the @code{--trace} flag. With the type
+@samp{none}, all tracing is disabled.
@item -v
@cindex @code{-v}
unsynchronized; still better than silently discarding it. */
void *sem = acquire_semaphore ();
- /* We've entered the "critical section" during which a lock is held.
- We want to keep it as short as possible. */
- log_working_directory (1, 1);
+ /* We've entered the "critical section" during which a lock is held. We
+ want to keep it as short as possible. */
+
+ /* Log the working directory. Force it if we're doing dir tracing. */
+ log_working_directory (1, (trace_flag & TRACE_DIRECTORY));
+
if (outfd_not_empty)
- pump_from_tmp (c->outfd, stdout);
+ pump_from_tmp (c->outfd, stdout);
if (errfd_not_empty && c->errfd != c->outfd)
pump_from_tmp (c->errfd, stderr);
- log_working_directory (0, 1);
+
+ /* If we're doing dir tracing, force the leave message. */
+ if (trace_flag & TRACE_DIRECTORY)
+ log_working_directory (0, 1);
/* Exit the critical section. */
if (sem)
return;
}
- print_cmd = (just_print_flag || trace_flag
+ print_cmd = (just_print_flag || (trace_flag & TRACE_RULE)
|| (!(flags & COMMANDS_SILENT) && !silent_flag));
#ifdef OUTPUT_SYNC
/* Trace the build.
Use message here so that changes to working directories are logged. */
- if (trace_flag)
+ if (trace_flag & TRACE_RULE)
{
char *newer = allocated_variable_expand_for_file ("$?", c->file);
const char *nm;
/* Tracing (--trace). */
-int trace_flag = 0;
+static struct stringlist *trace_option = 0;
#ifdef WINDOWS32
/* Suspend make in main for a short time to allow debugger to attach */
N_("\
-t, --touch Touch targets instead of remaking them.\n"),
N_("\
- --trace Print tracing information.\n"),
+ --trace[=MODE] Print tracing information.\n"),
N_("\
-v, --version Print the version number of make and exit.\n"),
N_("\
{ 'S', flag_off, &keep_going_flag, 1, 1, 0, 0, &default_keep_going_flag,
"no-keep-going" },
{ 't', flag, &touch_flag, 1, 1, 1, 0, 0, "touch" },
- { CHAR_MAX+3, flag, &trace_flag, 1, 1, 0, 0, 0, "trace" },
+ { CHAR_MAX+3, string, &trace_option, 1, 1, 0, "rule", 0, "trace" },
{ 'v', flag, &print_version_flag, 1, 1, 0, 0, 0, "version" },
{ 'w', flag, &print_directory_flag, 1, 1, 0, 0, 0, "print-directory" },
{ CHAR_MAX+4, flag, &inhibit_print_directory_flag, 1, 1, 0, 0, 0,
attempts to synchronize the output of parallel jobs such that the results
of each job stay together. */
-int output_sync;
+int output_sync = OUTPUT_SYNC_NONE;
+
+/* One of TRACE_* if the "--trace" option was given. Enables various types of
+ tracing. */
+
+int trace_flag = TRACE_NONE;
/* Nonzero if we have seen the '.NOTPARALLEL' target.
This turns off parallel builds for this invocation of make. */
}
}
+static void
+decode_trace_flags (void)
+{
+ const char **pp;
+
+ if (!trace_option)
+ return;
+
+ for (pp=trace_option->list; *pp; ++pp)
+ {
+ const char *p = *pp;
+
+ if (streq (p, "none"))
+ trace_flag = TRACE_NONE;
+ else if (streq (p, "rule"))
+ trace_flag |= TRACE_RULE;
+ else if (streq (p, "dir"))
+ trace_flag |= TRACE_DIRECTORY;
+ else
+ fatal (NILF, _("unknown trace mode '%s'"), p);
+ }
+}
+
static void
decode_output_sync_flags (void)
{
/* If there are any options that need to be decoded do it now. */
decode_debug_flags ();
decode_output_sync_flags ();
+ decode_trace_flags ();
}
/* Decode switches from environment variable ENVAR (which is LEN chars long).
*p++ = flags->cs->c;
else
{
- if (*p != '-')
+ /* If we don't have a dash, start a double-dash. */
+ if (p[-1] != '-')
{
*p++ = ' ';
*p++ = '-';
.I type
is
.B line
-the output from each line within a recipe is grouped together.
+the output from each command line within a recipe is grouped together.
If
.I type
is
future invocations of
.BR make .
.TP 0.5i
-.B \-\-trace
+.B \-\-trace\fR[=\fImode\fR]
Print information about the commands invoked by
-.BR make.
+.BR make .
+If
+.I mode
+is not specified or is
+.B rule
+information about the disposition of each target is printed. If
+.I mode
+is
+.B dir
+then directory enter/leave trace statements are shown for each synchronized
+output segment (see
+.BR \-O ).
+If
+.I mode
+is
+.B none
+then no tracing is performed.
.TP 0.5i
\fB\-v\fR, \fB\-\-version\fR
Print the version of the
#define OUTPUT_SYNC_TARGET 2
#define OUTPUT_SYNC_RECURSE 3
+#define TRACE_NONE 0x0
+#define TRACE_RULE 0x1
+#define TRACE_DIRECTORY 0x2
+
extern const gmk_floc *reading_file;
extern const gmk_floc **expanding_var;
{
va_list args;
- if (output_sync)
- log_working_directory (1, 1);
- else
- log_working_directory (1, 0);
+ log_working_directory (1, 0);
if (flocp && flocp->filenm)
fprintf (stderr, "%s:%lu: *** ", flocp->filenm, flocp->lineno);
fputs (_(". Stop.\n"), stderr);
- if (output_sync)
- log_working_directory (0, 1);
+ log_working_directory (0, 1);
die (2);
}
+2013-05-13 Paul Smith <psmith@gnu.org>
+
+ * scripts/features/output-sync (output_sync_set): Update for new
+ --trace behavior.
+
2013-05-05 Paul Smith <psmith@gnu.org>
* scripts/features/output-sync (output_sync_set): Remove
#MAKE#[1]: Entering directory '#PWD#/bar'
bar: start
bar: end
-#MAKE#[1]: Leaving directory '#PWD#/bar'
-#MAKE#[1]: Entering directory '#PWD#/bar'
baz: start
baz: end
#MAKE#[1]: Leaving directory '#PWD#/bar'\n", 0, 6);
#MAKE#[1]: Entering directory '#PWD#/bar'
bar: start
bar: end
-#MAKE#[1]: Leaving directory '#PWD#/bar'
#MAKE#[1]: Entering directory '#PWD#/foo'
foo: start
foo: end
#MAKE#[1]: Leaving directory '#PWD#/foo'
-#MAKE#[1]: Entering directory '#PWD#/bar'
baz: start
baz: end
#MAKE#[1]: Leaving directory '#PWD#/bar'\n", 0, 6);
$sleep_command 1 ; #MAKEPATH# -C bar bar-job
#MAKE#[1]: Entering directory '#PWD#/foo'
foo: start
-#MAKE#[1]: Leaving directory '#PWD#/foo'
#MAKE#[1]: Entering directory '#PWD#/bar'
bar: start
-#MAKE#[1]: Leaving directory '#PWD#/bar'
-#MAKE#[1]: Entering directory '#PWD#/bar'
bar: end
#MAKE#[1]: Leaving directory '#PWD#/bar'
-#MAKE#[1]: Entering directory '#PWD#/foo'
foo: end
#MAKE#[1]: Leaving directory '#PWD#/foo'\n", 0, 6);