mirror of
https://github.com/mirror/make.git
synced 2025-03-26 12:04:42 +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
|
||||||
|
20
commands.c
20
commands.c
@ -233,15 +233,20 @@ void
|
|||||||
chop_commands (cmds)
|
chop_commands (cmds)
|
||||||
register struct commands *cmds;
|
register struct commands *cmds;
|
||||||
{
|
{
|
||||||
if (cmds != 0 && cmds->command_lines == 0)
|
|
||||||
{
|
|
||||||
/* Chop CMDS->commands up into lines in CMDS->command_lines.
|
|
||||||
Also set the corresponding CMDS->lines_flags elements,
|
|
||||||
and the CMDS->any_recurse flag. */
|
|
||||||
register char *p;
|
register char *p;
|
||||||
unsigned int nlines, idx;
|
unsigned int nlines, idx;
|
||||||
char **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,
|
||||||
|
and the CMDS->any_recurse flag. */
|
||||||
|
|
||||||
nlines = 5;
|
nlines = 5;
|
||||||
lines = (char **) xmalloc (5 * sizeof (char *));
|
lines = (char **) xmalloc (5 * sizeof (char *));
|
||||||
idx = 0;
|
idx = 0;
|
||||||
@ -321,7 +326,6 @@ chop_commands (cmds)
|
|||||||
cmds->any_recurse |= flags & COMMANDS_RECURSE;
|
cmds->any_recurse |= flags & COMMANDS_RECURSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Execute the commands to remake FILE. If they are currently executing,
|
/* Execute the commands to remake FILE. If they are currently executing,
|
||||||
return or have already finished executing, just return. Otherwise,
|
return or have already finished executing, just return. Otherwise,
|
||||||
@ -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. */
|
||||||
|
33
remake.c
33
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. */
|
||||||
@ -976,12 +978,13 @@ remake_file (file)
|
|||||||
{
|
{
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -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