mirror of
https://github.com/mirror/make.git
synced 2025-02-05 09:10:12 +08:00
* Fix PR/1379: -n/-q behaves correctly when all commands are recursive.
This commit is contained in:
parent
829f4fd04b
commit
281951154b
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
1999-10-12 Paul D. Smith <psmith@gnu.org>
|
||||||
|
|
||||||
|
* remake.c (notice_finished_file): If we get here and -n is set,
|
||||||
|
look for any commands that aren't recursive. If we find at least
|
||||||
|
one, we assume that command updates the target and set mtime of
|
||||||
|
the target to "very new". If there are none, then we ran every
|
||||||
|
command there is, so check the mtime on this file just like we
|
||||||
|
would normally, rather than assuming it's "very new".
|
||||||
|
|
||||||
|
* job.c (start_job_command): Update lines_flags in the file's cmds
|
||||||
|
structure with any per-line tokens we found (`@', `-', `+').
|
||||||
|
|
||||||
1999-10-08 Paul D. Smith <psmith@gnu.org>
|
1999-10-08 Paul D. Smith <psmith@gnu.org>
|
||||||
|
|
||||||
* variable.c (initialize_file_variables): Always recurse to
|
* variable.c (initialize_file_variables): Always recurse to
|
||||||
|
164
commands.c
164
commands.c
@ -233,93 +233,97 @@ void
|
|||||||
chop_commands (cmds)
|
chop_commands (cmds)
|
||||||
register struct commands *cmds;
|
register struct commands *cmds;
|
||||||
{
|
{
|
||||||
if (cmds != 0 && cmds->command_lines == 0)
|
register char *p;
|
||||||
{
|
unsigned int nlines, idx;
|
||||||
/* Chop CMDS->commands up into lines in CMDS->command_lines.
|
char **lines;
|
||||||
|
|
||||||
|
/* If we don't have any commands,
|
||||||
|
or we already parsed them, never mind. */
|
||||||
|
|
||||||
|
if (!cmds || cmds->command_lines != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Chop CMDS->commands up into lines in CMDS->command_lines.
|
||||||
Also set the corresponding CMDS->lines_flags elements,
|
Also set the corresponding CMDS->lines_flags elements,
|
||||||
and the CMDS->any_recurse flag. */
|
and the CMDS->any_recurse flag. */
|
||||||
register char *p;
|
|
||||||
unsigned int nlines, idx;
|
|
||||||
char **lines;
|
|
||||||
|
|
||||||
nlines = 5;
|
nlines = 5;
|
||||||
lines = (char **) xmalloc (5 * sizeof (char *));
|
lines = (char **) xmalloc (5 * sizeof (char *));
|
||||||
idx = 0;
|
idx = 0;
|
||||||
p = cmds->commands;
|
p = cmds->commands;
|
||||||
while (*p != '\0')
|
while (*p != '\0')
|
||||||
{
|
{
|
||||||
char *end = p;
|
char *end = p;
|
||||||
find_end:;
|
find_end:;
|
||||||
end = index (end, '\n');
|
end = index (end, '\n');
|
||||||
if (end == 0)
|
if (end == 0)
|
||||||
end = p + strlen (p);
|
end = p + strlen (p);
|
||||||
else if (end > p && end[-1] == '\\')
|
else if (end > p && end[-1] == '\\')
|
||||||
{
|
{
|
||||||
int backslash = 1;
|
int backslash = 1;
|
||||||
register char *b;
|
register char *b;
|
||||||
for (b = end - 2; b >= p && *b == '\\'; --b)
|
for (b = end - 2; b >= p && *b == '\\'; --b)
|
||||||
backslash = !backslash;
|
backslash = !backslash;
|
||||||
if (backslash)
|
if (backslash)
|
||||||
{
|
{
|
||||||
++end;
|
++end;
|
||||||
goto find_end;
|
goto find_end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (idx == nlines)
|
if (idx == nlines)
|
||||||
{
|
{
|
||||||
nlines += 2;
|
nlines += 2;
|
||||||
lines = (char **) xrealloc ((char *) lines,
|
lines = (char **) xrealloc ((char *) lines,
|
||||||
nlines * sizeof (char *));
|
nlines * sizeof (char *));
|
||||||
}
|
}
|
||||||
lines[idx++] = savestring (p, end - p);
|
lines[idx++] = savestring (p, end - p);
|
||||||
p = end;
|
p = end;
|
||||||
if (*p != '\0')
|
if (*p != '\0')
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (idx != nlines)
|
if (idx != nlines)
|
||||||
{
|
{
|
||||||
nlines = idx;
|
nlines = idx;
|
||||||
lines = (char **) xrealloc ((char *) lines,
|
lines = (char **) xrealloc ((char *) lines,
|
||||||
nlines * sizeof (char *));
|
nlines * sizeof (char *));
|
||||||
}
|
}
|
||||||
|
|
||||||
cmds->ncommand_lines = nlines;
|
cmds->ncommand_lines = nlines;
|
||||||
cmds->command_lines = lines;
|
cmds->command_lines = lines;
|
||||||
|
|
||||||
cmds->any_recurse = 0;
|
cmds->any_recurse = 0;
|
||||||
cmds->lines_flags = (char *) xmalloc (nlines);
|
cmds->lines_flags = (char *) xmalloc (nlines);
|
||||||
for (idx = 0; idx < nlines; ++idx)
|
for (idx = 0; idx < nlines; ++idx)
|
||||||
{
|
{
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
for (p = lines[idx];
|
for (p = lines[idx];
|
||||||
isblank (*p) || *p == '-' || *p == '@' || *p == '+';
|
isblank (*p) || *p == '-' || *p == '@' || *p == '+';
|
||||||
++p)
|
++p)
|
||||||
switch (*p)
|
switch (*p)
|
||||||
{
|
{
|
||||||
case '+':
|
case '+':
|
||||||
flags |= COMMANDS_RECURSE;
|
flags |= COMMANDS_RECURSE;
|
||||||
break;
|
break;
|
||||||
case '@':
|
case '@':
|
||||||
flags |= COMMANDS_SILENT;
|
flags |= COMMANDS_SILENT;
|
||||||
break;
|
break;
|
||||||
case '-':
|
case '-':
|
||||||
flags |= COMMANDS_NOERROR;
|
flags |= COMMANDS_NOERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!(flags & COMMANDS_RECURSE))
|
if (!(flags & COMMANDS_RECURSE))
|
||||||
{
|
{
|
||||||
unsigned int len = strlen (p);
|
unsigned int len = strlen (p);
|
||||||
if (sindex (p, len, "$(MAKE)", 7) != 0
|
if (sindex (p, len, "$(MAKE)", 7) != 0
|
||||||
|| sindex (p, len, "${MAKE}", 7) != 0)
|
|| sindex (p, len, "${MAKE}", 7) != 0)
|
||||||
flags |= COMMANDS_RECURSE;
|
flags |= COMMANDS_RECURSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmds->lines_flags[idx] = flags;
|
cmds->lines_flags[idx] = flags;
|
||||||
cmds->any_recurse |= flags & COMMANDS_RECURSE;
|
cmds->any_recurse |= flags & COMMANDS_RECURSE;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,9 +345,7 @@ execute_file_commands (file)
|
|||||||
break;
|
break;
|
||||||
if (*p == '\0')
|
if (*p == '\0')
|
||||||
{
|
{
|
||||||
/* We are all out of commands.
|
/* If there are no commands, assume everything worked. */
|
||||||
If we have gotten this far, all the previous commands
|
|
||||||
have run successfully, so we have winning update status. */
|
|
||||||
set_command_state (file, cs_running);
|
set_command_state (file, cs_running);
|
||||||
file->update_status = 0;
|
file->update_status = 0;
|
||||||
notice_finished_file (file);
|
notice_finished_file (file);
|
||||||
|
3
job.c
3
job.c
@ -794,6 +794,9 @@ start_job_command (child)
|
|||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update the file's command flags with any new ones we found. */
|
||||||
|
child->file->cmds->lines_flags[child->command_line - 1] |= flags;
|
||||||
|
|
||||||
/* If -q was given, just say that updating `failed'. The exit status of
|
/* If -q was given, just say that updating `failed'. The exit status of
|
||||||
1 tells the user that -q is saying `something to do'; the exit status
|
1 tells the user that -q is saying `something to do'; the exit status
|
||||||
for a random error is 2. */
|
for a random error is 2. */
|
||||||
|
39
remake.c
39
remake.c
@ -93,15 +93,6 @@ update_goal_chain (goals, makefiles)
|
|||||||
g->changed = 0;
|
g->changed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Only run one job at a time when building makefiles.
|
|
||||||
No one seems to know why this was done, and no one can think of a good
|
|
||||||
reason to do it. Hopefully an obvious one won't appear as soon as we
|
|
||||||
release the next version :-/. */
|
|
||||||
if (makefiles)
|
|
||||||
job_slots = 1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* All files start with the considered bit 0, so the global value is 1. */
|
/* All files start with the considered bit 0, so the global value is 1. */
|
||||||
considered = 1;
|
considered = 1;
|
||||||
|
|
||||||
@ -746,12 +737,23 @@ notice_finished_file (file)
|
|||||||
if (ran && !file->phony)
|
if (ran && !file->phony)
|
||||||
{
|
{
|
||||||
struct file *f;
|
struct file *f;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
if (just_print_flag || question_flag
|
/* If -n or -q and all the commands are recursive, we ran them so
|
||||||
|| (file->is_target && file->cmds == 0))
|
really check the target's mtime again. Otherwise, assume the target
|
||||||
file->last_mtime = NEW_MTIME;
|
would have been updated. */
|
||||||
else
|
|
||||||
file->last_mtime = 0;
|
if (question_flag || just_print_flag)
|
||||||
|
for (i = file->cmds->ncommand_lines; i > 0; --i)
|
||||||
|
if (! (file->cmds->lines_flags[i-1] & COMMANDS_RECURSE))
|
||||||
|
break;
|
||||||
|
|
||||||
|
/* If there were no commands at all, it's always new. */
|
||||||
|
|
||||||
|
else if (file->is_target && file->cmds == 0)
|
||||||
|
i = 1;
|
||||||
|
|
||||||
|
file->last_mtime = i == 0 ? 0 : NEW_MTIME;
|
||||||
|
|
||||||
/* Propagate the change of modification time to all the double-colon
|
/* Propagate the change of modification time to all the double-colon
|
||||||
entries for this file. */
|
entries for this file. */
|
||||||
@ -970,20 +972,21 @@ remake_file (file)
|
|||||||
Pretend it was successfully remade. */
|
Pretend it was successfully remade. */
|
||||||
file->update_status = 0;
|
file->update_status = 0;
|
||||||
else
|
else
|
||||||
no_rule_error(file);
|
no_rule_error (file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
chop_commands (file->cmds);
|
chop_commands (file->cmds);
|
||||||
|
|
||||||
|
/* The normal case: start some commands. */
|
||||||
if (!touch_flag || file->cmds->any_recurse)
|
if (!touch_flag || file->cmds->any_recurse)
|
||||||
{
|
{
|
||||||
execute_file_commands (file);
|
execute_file_commands (file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
/* This tells notice_finished_file it is ok to touch the file. */
|
/* This tells notice_finished_file it is ok to touch the file. */
|
||||||
file->update_status = 0;
|
file->update_status = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This does the touching under -t. */
|
/* This does the touching under -t. */
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
1999-10-13 Paul D. Smith <psmith@gnu.org>
|
||||||
|
|
||||||
|
* scripts/options/dash-n: Add a test for PR/1379: "-n doesn't
|
||||||
|
behave properly when used with recursive targets".
|
||||||
|
|
||||||
1999-10-08 Paul D. Smith <psmith@gnu.org>
|
1999-10-08 Paul D. Smith <psmith@gnu.org>
|
||||||
|
|
||||||
* scripts/features/targetvars: Add a check for PR/1378:
|
* scripts/features/targetvars: Add a check for PR/1378:
|
||||||
|
@ -28,4 +28,34 @@ $answer = "echo >> intermediate\necho >> final\n";
|
|||||||
|
|
||||||
unlink('orig', 'intermediate', 'final');
|
unlink('orig', 'intermediate', 'final');
|
||||||
|
|
||||||
|
# TEST2
|
||||||
|
# We consider the actual updated timestamp of targets with all
|
||||||
|
# recursive commands, even with -n.
|
||||||
|
|
||||||
|
$makefile2 = &get_tmpfile;
|
||||||
|
|
||||||
|
open(MAKEFILE, "> $makefile2");
|
||||||
|
|
||||||
|
print MAKEFILE <<'EOF';
|
||||||
|
.SUFFIXES:
|
||||||
|
BAR = # nothing
|
||||||
|
FOO = +$(BAR)
|
||||||
|
a: b; echo > $@
|
||||||
|
b: c; $(FOO)
|
||||||
|
EOF
|
||||||
|
|
||||||
|
close(MAKEFILE);
|
||||||
|
|
||||||
|
&touch('a', 'b');
|
||||||
|
sleep(1);
|
||||||
|
&touch('c');
|
||||||
|
|
||||||
|
&run_make_with_options($makefile2, "", &get_logfile);
|
||||||
|
$answer = "$make_name: `a' is up to date.\n";
|
||||||
|
&compare_output($answer, &get_logfile(1));
|
||||||
|
|
||||||
|
&run_make_with_options($makefile2, "-n", &get_logfile);
|
||||||
|
$answer = "$make_name: `a' is up to date.\n";
|
||||||
|
&compare_output($answer, &get_logfile(1));
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user