summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorFrank Heckenbach <f.heckenbach@fh-soft.de>2013-04-14 15:38:07 -0400
committerPaul Smith <psmith@gnu.org>2013-04-14 15:38:07 -0400
commitcb64352c75f0da8979c9addd37b2b78bb97d5301 (patch)
treecfc17e9359b14ed657e46d6092f55b921a1047f2 /main.c
parent6a52395ed14e0bda22be3fc0819e4507a71278e1 (diff)
downloadgunmake-cb64352c75f0da8979c9addd37b2b78bb97d5301.tar.gz
Initial patch for output synchronization. See Savannah bug #33138.
Based on work by David Boyce <David.S.Boyce@gmail.com>.
Diffstat (limited to 'main.c')
-rw-r--r--main.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/main.c b/main.c
index 0a2774c..0447888 100644
--- a/main.c
+++ b/main.c
@@ -228,6 +228,15 @@ static unsigned int master_job_slots = 0;
static unsigned int inf_jobs = 0;
+#ifdef PARALLEL_SYNC
+
+/* Default value for parallel sync without an argument. */
+
+static unsigned int no_parallel_sync = 0;
+static unsigned int default_parallel_sync = PARALLEL_SYNC_FINE;
+
+#endif
+
/* File descriptors for the jobs pipe. */
static struct stringlist *jobserver_fds = 0;
@@ -344,6 +353,10 @@ static const char *const usage[] =
Consider FILE to be very old and don't remake it.\n"),
N_("\
-p, --print-data-base Print make's internal database.\n"),
+#ifdef PARALLEL_SYNC
+ N_("\
+ -P [2], --parallel-sync[=2] Synchronize output of parallel jobs [coarse].\n"),
+#endif
N_("\
-q, --question Run no recipe; exit status says if up to date.\n"),
N_("\
@@ -408,6 +421,11 @@ 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" },
{ 'p', flag, &print_data_base_flag, 1, 1, 0, 0, 0, "print-data-base" },
+#ifdef PARALLEL_SYNC
+ // { 'P', flag, &parallel_sync, 1, 1, 0, 0, 0, "parallel-sync" }, // two-state
+ { 'P', positive_int, &parallel_sync, 1, 1, 0, &default_parallel_sync,
+ &no_parallel_sync, "parallel-sync" },
+#endif
{ 'q', flag, &question_flag, 1, 1, 1, 0, 0, "question" },
{ 'r', flag, &no_builtin_rules_flag, 1, 1, 0, 0, 0, "no-builtin-rules" },
{ 'R', flag, &no_builtin_variables_flag, 1, 1, 0, 0, 0,
@@ -503,6 +521,14 @@ int second_expansion;
int one_shell;
+/* Either PARALLEL_SYNC_FINE or PARALLEL_SYNC_COARSE
+ if the "--parallel-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. */
+
+int parallel_sync;
+
/* Nonzero if we have seen the '.NOTPARALLEL' target.
This turns off parallel builds for this invocation of make. */
@@ -2095,7 +2121,7 @@ main (int argc, char **argv, char **envp)
if (print_data_base_flag)
print_data_base ();
- log_working_directory (0);
+ log_working_directory (0, 0);
clean_jobserver (0);
@@ -3280,7 +3306,7 @@ die (int status)
_x = chdir (directory_before_chdir);
}
- log_working_directory (0);
+ log_working_directory (0, 0);
}
exit (status);
@@ -3290,17 +3316,18 @@ die (int status)
left (according to ENTERING) the current directory. */
void
-log_working_directory (int entering)
+log_working_directory (int entering, int force)
{
static int entered = 0;
/* Print nothing without the flag. Don't print the entering message
again if we already have. Don't print the leaving message if we
haven't printed the entering message. */
- if (! print_directory_flag || entering == entered)
+ if (! print_directory_flag || (!force && entering == entered))
return;
- entered = entering;
+ if (!force)
+ entered = entering;
if (print_data_base_flag)
fputs ("# ", stdout);