summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2013-04-15 13:22:51 -0400
committerPaul Smith <psmith@gnu.org>2013-04-15 13:22:51 -0400
commit2bd957a89d7a5995d5cda145d39a8ec1e315bc0d (patch)
treeab90ba692b2180ef9dd408a0d3a259102f75d0c8
parent7f7e6f80c5c8c1e67eb022a2bde9918512b98c65 (diff)
downloadgunmake-2bd957a89d7a5995d5cda145d39a8ec1e315bc0d.tar.gz
Change the arg option for -O from numeric to string.
-rw-r--r--ChangeLog12
-rw-r--r--doc/make.texi32
-rw-r--r--job.c4
-rw-r--r--main.c74
-rw-r--r--make.113
-rw-r--r--makeint.h4
-rw-r--r--tests/ChangeLog4
-rw-r--r--tests/scripts/features/output-sync4
8 files changed, 100 insertions, 47 deletions
diff --git a/ChangeLog b/ChangeLog
index 744eb07..deca62a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2013-04-15 Paul Smith <psmith@gnu.org>
+
+ * makeint.h (OUTPUT_SYNC_TARGET, OUTPUT_SYNC_MAKE): Rename.
+ * job.c (start_job_command): Use new constants.
+ * main.c: New -O argument format.
+
+ * doc/make.texi (Options Summary): Document the argument to -O.
+ * make.1: Ditto.
+
+ * main.c (define_makeflags): Don't add space between a single-char
+ option and its argument.
+
2013-04-06 Paul Smith <psmith@gnu.org>
* doc/make.texi (Implicit Variables): Clarify LDFLAGS vs. LDLIBS.
diff --git a/doc/make.texi b/doc/make.texi
index e004984..ce8e07b 100644
--- a/doc/make.texi
+++ b/doc/make.texi
@@ -8616,26 +8616,28 @@ The data base output contains file name and line number information for
recipe and variable definitions, so it can be a useful debugging tool
in complex environments.
-@item -O
+@item -O[@var{type}]
@cindex @code{-O}
-@itemx --output-sync
+@itemx --output-sync[=@var{type}]
@cindex @code{--output-sync}
-@cindex output of parallel execution
-@cindex parallel execution, output of
+@cindex output during parallel execution
+@cindex parallel execution, output during
Ensure that the complete output from each recipe is printed in one
uninterrupted sequence. This option is only useful when using the
@code{--jobs} option to run multiple recipes simultaneously
-(@pxref{Parallel, ,Parallel Execution}). Without this option output
-will be displayed as it is generated by the recipes.
-
-With no argument or the argument @samp{1}, messages from each job in
-recursive makes are grouped together. With the argument @samp{2}, the
-complete output from any recursive make is grouped together. The latter
-achieves better grouping of output from related jobs, but causes longer
-delay, since messages do not appear until the recursive make has
-completed. Therefore @samp{-O} is more useful when watching the output
-while make runs, and @samp{-O2} is better suited when running a complex
-parallel build in the background and checking its output afterwards.
+(@pxref{Parallel, ,Parallel Execution}) Without this option output
+will be displayed as it is generated by the recipes.@refill
+
+With no type or the type @samp{target}, output from each individual
+target is grouped together. With the type @samp{make}, the output
+from an entire recursive make is grouped together. The latter
+achieves better grouping of output from related jobs, but causes
+longer delay since messages do not appear until the entire recursive
+make has completed (this does not increase the total build time,
+though). In general @samp{target} mode is useful when watching the
+output while make runs, and @samp{make} mode is useful when running a
+complex parallel build in the background and checking its output
+afterwards.
@item -q
@cindex @code{-q}
diff --git a/job.c b/job.c
index 360729b..84bc39b 100644
--- a/job.c
+++ b/job.c
@@ -1635,8 +1635,8 @@ start_job_command (struct child *child)
/* If it still looks like we can synchronize, create a temp
file to hold stdout (and one for stderr if separate). */
- if (output_sync >= OUTPUT_SYNC_COARSE
- || (output_sync == OUTPUT_SYNC_FINE && !(flags & COMMANDS_RECURSE)))
+ if (output_sync == OUTPUT_SYNC_MAKE
+ || (output_sync == OUTPUT_SYNC_TARGET && !(flags & COMMANDS_RECURSE)))
{
if (!assign_child_tempfiles (child, combined_output))
output_sync = 0;
diff --git a/main.c b/main.c
index d9c2dcd..985c765 100644
--- a/main.c
+++ b/main.c
@@ -151,6 +151,14 @@ static int debug_flag = 0;
int db_level = 0;
+#ifdef OUTPUT_SYNC
+
+/* Synchronize output (--output-sync). */
+
+static struct stringlist *output_sync_option;
+
+#endif
+
/* Tracing (--trace). */
int trace_flag = 0;
@@ -228,15 +236,6 @@ static unsigned int master_job_slots = 0;
static unsigned int inf_jobs = 0;
-#ifdef OUTPUT_SYNC
-
-/* Default value for output-sync without an argument. */
-
-static unsigned int no_output_sync = 0;
-static unsigned int default_output_sync = OUTPUT_SYNC_FINE;
-
-#endif
-
/* File descriptors for the jobs pipe. */
static struct stringlist *jobserver_fds = 0;
@@ -353,7 +352,8 @@ static const char *const usage[] =
Consider FILE to be very old and don't remake it.\n"),
#ifdef OUTPUT_SYNC
N_("\
- -O [2], --output-sync[=2] Synchronize output of parallel jobs [coarse].\n"),
+ -O[TYPE], --output-sync[=TYPE]\n\
+ Synchronize output of parallel jobs by TYPE.\n"),
#endif
N_("\
-p, --print-data-base Print make's internal database.\n"),
@@ -421,9 +421,7 @@ static const struct command_switch switches[] =
{ 'n', flag, &just_print_flag, 1, 1, 1, 0, 0, "just-print" },
{ 'o', filename, &old_files, 0, 0, 0, 0, 0, "old-file" },
#ifdef OUTPUT_SYNC
- // { 'O', flag, &output_sync, 1, 1, 0, 0, 0, "output-sync" }, // two-state
- { 'O', positive_int, &output_sync, 1, 1, 0, &default_output_sync,
- &no_output_sync, "output-sync" },
+ { 'O', string, &output_sync_option, 1, 1, 0, "target", 0, "output-sync" },
#endif
{ 'p', flag, &print_data_base_flag, 1, 1, 0, 0, 0, "print-data-base" },
{ 'q', flag, &question_flag, 1, 1, 1, 0, 0, "question" },
@@ -521,11 +519,9 @@ int second_expansion;
int one_shell;
-/* Either OUTPUT_SYNC_FINE or OUTPUT_SYNC_COARSE
- if the "--output-sync" option was given.
- This attempts to synchronize the output of parallel
- jobs such that the results of each job stay together.
- It works best in combination with .ONESHELL. */
+/* Either OUTPUT_SYNC_TARGET or OUTPUT_SYNC_MAKE if the "--output-sync" option
+ was given. This attempts to synchronize the output of parallel jobs such
+ that the results of each job stay together. */
int output_sync;
@@ -689,6 +685,27 @@ decode_debug_flags (void)
}
}
+static void
+decode_output_sync_flags (void)
+{
+ const char **pp;
+
+ if (!output_sync_option)
+ return;
+
+ for (pp=output_sync_option->list; *pp; ++pp)
+ {
+ const char *p = *pp;
+
+ if (streq (p, "target"))
+ output_sync = OUTPUT_SYNC_TARGET;
+ else if (streq (p, "make"))
+ output_sync = OUTPUT_SYNC_MAKE;
+ else
+ fatal (NILF, _("unknown output-sync type '%s'"), p);
+ }
+}
+
#ifdef WINDOWS32
/*
* HANDLE runtime exceptions by avoiding a requestor on the GUI. Capture
@@ -1314,8 +1331,6 @@ main (int argc, char **argv, char **envp)
}
#endif
- decode_debug_flags ();
-
/* Set always_make_flag if -B was given and we've not restarted already. */
always_make_flag = always_make_set && (restarts == 0);
@@ -2465,14 +2480,17 @@ init_switches (void)
long_options[i].name = 0;
}
+
+/* Non-option argument. It might be a variable definition. */
static void
handle_non_switch_argument (char *arg, int env)
{
- /* Non-option argument. It might be a variable definition. */
struct variable *v;
+
if (arg[0] == '-' && arg[1] == '\0')
/* Ignore plain '-' for compatibility. */
return;
+
v = try_variable_definition (0, arg, o_command, 0);
if (v != 0)
{
@@ -2738,12 +2756,15 @@ decode_switches (int argc, char **argv, int env)
while (optind < argc)
handle_non_switch_argument (argv[optind++], env);
-
if (!env && (bad || print_usage_flag))
{
print_usage (bad);
die (bad ? 2 : 0);
}
+
+ /* If there are any options that need to be decoded do it now. */
+ decode_debug_flags ();
+ decode_output_sync_flags ();
}
/* Decode switches from environment variable ENVAR (which is LEN chars long).
@@ -2876,8 +2897,8 @@ define_makeflags (int all, int makefile)
if (new->arg == 0) \
++flagslen; /* Just a single flag letter. */ \
else \
- /* " -x foo", plus space to expand "foo". */ \
- flagslen += 1 + 1 + 1 + 1 + (3 * (LEN)); \
+ /* " -xfoo", plus space to expand "foo". */ \
+ flagslen += 1 + 1 + 1 + (3 * (LEN)); \
if (!short_option (cs->c)) \
/* This switch has no single-letter version, so we use the long. */ \
flagslen += 2 + strlen (cs->long_name); \
@@ -2997,8 +3018,9 @@ define_makeflags (int all, int makefile)
is considered the arg for the first. */
if (flags->arg[0] != '\0')
{
- /* Add its argument too. */
- *p++ = !short_option (flags->cs->c) ? '=' : ' ';
+ /* Add its argument too. Long options require '='. */
+ if (!short_option (flags->cs->c))
+ *p++ = '=';
p = quote_for_env (p, flags->arg);
}
++words;
diff --git a/make.1 b/make.1
index e25ee8c..6eeaaf8 100644
--- a/make.1
+++ b/make.1
@@ -220,6 +220,19 @@ on account of changes in
.IR file .
Essentially the file is treated as very old and its rules are ignored.
.TP 0.5i
+\fB\-O\fR[\fItype\fR], \fB\-\-output\-sync\fR[=\fItype\fR]
+When running multiple jobs in parallel with \fB-j\fR, ensure the output of
+each job is collected together rather than interspersed with output from
+other jobs. If
+.I type
+is not specified or is
+.B target
+output is grouped together on a per-target basis. If
+.I type
+is
+.B make
+output from an entire recursive make is grouped together.
+.TP 0.5i
\fB\-p\fR, \fB\-\-print\-data\-base\fR
Print the data base (rules and variable values) that results from
reading the makefiles; then execute as usual or as otherwise
diff --git a/makeint.h b/makeint.h
index 1310d8f..fe43260 100644
--- a/makeint.h
+++ b/makeint.h
@@ -525,8 +525,8 @@ int strncasecmp (const char *s1, const char *s2, int n);
# endif
#endif
-#define OUTPUT_SYNC_FINE 1
-#define OUTPUT_SYNC_COARSE 2
+#define OUTPUT_SYNC_TARGET 1
+#define OUTPUT_SYNC_MAKE 2
extern const gmk_floc *reading_file;
extern const gmk_floc **expanding_var;
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 31f1dee..0502aba 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,7 @@
+2013-04-15 Paul Smith <psmith@gnu.org>
+
+ * scripts/features/output-sync (output_sync_set): New arg syntax.
+
2013-04-14 Paul Smith <psmith@gnu.org>
* scripts/features/output-sync: Rewrite to be more reliable.
diff --git a/tests/scripts/features/output-sync b/tests/scripts/features/output-sync
index 100646c..dce2ac4 100644
--- a/tests/scripts/features/output-sync
+++ b/tests/scripts/features/output-sync
@@ -82,7 +82,7 @@ all: make-foo make-bar
make-foo: ; \$(MAKE) -C foo
make-bar: ; \$(MAKE) -C bar!,
- '-j -O2',
+ '-j -Omake',
"#MAKEPATH# -C foo
#MAKEPATH# -C bar
#MAKE#[1]: Entering directory '#PWD#/foo'
@@ -114,7 +114,7 @@ all: make-foo make-bar
make-foo: ; \$(MAKE) -C foo
make-bar: ; $sleep_command 1 ; \$(MAKE) -C bar!,
- '-j --output-sync',
+ '-j --output-sync=target',
"#MAKEPATH# -C foo
$sleep_command 1 ; #MAKEPATH# -C bar
#MAKE#[1]: Entering directory '#PWD#/foo'