mirror of
https://github.com/mirror/make.git
synced 2025-03-03 14:20:54 +08:00
[SV 54740] Ensure .SILENT settings do not leak into sub-makes
Create a new variable run_silent to hold the current instance's global silence setting, allowing silent_flag to represent only whether the -s option was provided on the command line. * src/makeint.h: Change silent_flag variable to run_silent. * src/job.c: Ditto. * src/remake.c: Ditto. * src/file.c: Ditto. * src/main.c: Add a new global variable run_silent. (decode_switches): After switches are decoded, initialize run_silent. * tests/scripts/targets/SILENT: Add a test for recursive behavior.
This commit is contained in:
parent
389dcb608f
commit
b5de783f77
@ -410,7 +410,7 @@ remove_intermediates (int sig)
|
||||
{
|
||||
if (! doneany)
|
||||
DB (DB_BASIC, (_("Removing intermediate files...\n")));
|
||||
if (!silent_flag)
|
||||
if (!run_silent)
|
||||
{
|
||||
if (! doneany)
|
||||
{
|
||||
@ -768,7 +768,7 @@ snap_deps (void)
|
||||
if (f != 0 && f->is_target)
|
||||
{
|
||||
if (f->deps == 0)
|
||||
silent_flag = 1;
|
||||
run_silent = 1;
|
||||
else
|
||||
for (d = f->deps; d != 0; d = d->next)
|
||||
for (f2 = d->file; f2 != 0; f2 = f2->prev)
|
||||
|
@ -541,7 +541,7 @@ child_error (struct child *child,
|
||||
const char *nm;
|
||||
size_t l;
|
||||
|
||||
if (ignored && silent_flag)
|
||||
if (ignored && run_silent)
|
||||
return;
|
||||
|
||||
if (exit_sig && coredump)
|
||||
@ -1312,7 +1312,7 @@ start_job_command (struct child *child)
|
||||
|
||||
/* Print the command if appropriate. */
|
||||
if (just_print_flag || trace_flag
|
||||
|| (!(flags & COMMANDS_SILENT) && !silent_flag))
|
||||
|| (!(flags & COMMANDS_SILENT) && !run_silent))
|
||||
OS (message, 0, "%s", p);
|
||||
|
||||
/* Tell update_goal_chain that a command has been started on behalf of
|
||||
|
@ -164,9 +164,13 @@ int verify_flag;
|
||||
|
||||
/* Nonzero means do not print commands to be executed (-s). */
|
||||
|
||||
int silent_flag;
|
||||
static int silent_flag;
|
||||
static const int default_silent_flag = 0;
|
||||
|
||||
/* Nonzero means either -s was given, or .SILENT-with-no-deps was seen. */
|
||||
|
||||
int run_silent = 0;
|
||||
|
||||
/* Nonzero means just touch the files
|
||||
that would appear to need remaking (-t) */
|
||||
|
||||
@ -3012,6 +3016,9 @@ decode_switches (int argc, const char **argv, int env)
|
||||
/* If there are any options that need to be decoded do it now. */
|
||||
decode_debug_flags ();
|
||||
decode_output_sync_flags ();
|
||||
|
||||
/* Perform any special switch handling. */
|
||||
run_silent = silent_flag;
|
||||
}
|
||||
|
||||
/* Decode switches from environment variable ENVAR (which is LEN chars long).
|
||||
|
@ -654,7 +654,7 @@ extern const floc **expanding_var;
|
||||
|
||||
extern unsigned short stopchar_map[];
|
||||
|
||||
extern int just_print_flag, silent_flag, ignore_errors_flag, keep_going_flag;
|
||||
extern int just_print_flag, run_silent, ignore_errors_flag, keep_going_flag;
|
||||
extern int print_data_base_flag, question_flag, touch_flag, always_make_flag;
|
||||
extern int env_overrides, no_builtin_rules_flag, no_builtin_variables_flag;
|
||||
extern int print_version_flag, print_directory_flag, check_symlink_flag;
|
||||
|
@ -221,7 +221,7 @@ update_goal_chain (struct goaldep *goaldeps)
|
||||
any commands were actually started for this goal. */
|
||||
&& file->update_status == us_success && !g->changed
|
||||
/* Never give a message under -s or -q. */
|
||||
&& !silent_flag && !question_flag)
|
||||
&& !run_silent && !question_flag)
|
||||
OS (message, 1, ((file->phony || file->cmds == 0)
|
||||
? _("Nothing to be done for '%s'.")
|
||||
: _("'%s' is up to date.")),
|
||||
@ -1144,7 +1144,7 @@ check_dep (struct file *file, unsigned int depth,
|
||||
static enum update_status
|
||||
touch_file (struct file *file)
|
||||
{
|
||||
if (!silent_flag)
|
||||
if (!run_silent)
|
||||
OS (message, 0, "touch %s", file->name);
|
||||
|
||||
/* Print-only (-n) takes precedence over touch (-t). */
|
||||
|
@ -1,31 +1,33 @@
|
||||
# -*-perl-*-
|
||||
|
||||
$description = "The following tests the special target .SILENT. By simply\n"
|
||||
."mentioning this as a target, it tells make not to print\n"
|
||||
."commands before executing them.";
|
||||
$description = "Test the special target .SILENT.";
|
||||
|
||||
$details = "This test is the same as the clean test except that it should\n"
|
||||
."not echo its command before deleting the specified file.\n";
|
||||
run_make_test(q!
|
||||
.PHONY: M a b
|
||||
M: a b
|
||||
.SILENT : b
|
||||
a b: ; echo $@
|
||||
!,
|
||||
'', "echo a\na\nb");
|
||||
|
||||
$example = "EXAMPLE_FILE";
|
||||
run_make_test(q!
|
||||
.PHONY: M a b
|
||||
M: a b
|
||||
.SILENT:
|
||||
a b: ; echo $@
|
||||
!,
|
||||
'', "a\nb");
|
||||
|
||||
open(MAKEFILE,"> $makefile");
|
||||
print MAKEFILE qq!
|
||||
.SILENT : clean
|
||||
clean: ; $CMD_rmfile $example
|
||||
!;
|
||||
close(MAKEFILE);
|
||||
# SV 54740 : don't inherit .SILENT settings in sub-makes
|
||||
run_make_test(q!
|
||||
.PHONY: M r a b
|
||||
r: a b ; @$(MAKE) -f #MAKEFILE# M V=x
|
||||
a b: ; echo $@
|
||||
|
||||
touch($example);
|
||||
|
||||
$answer = '';
|
||||
run_make_with_options($makefile,"clean",&get_logfile,0);
|
||||
if (-f $example) {
|
||||
$test_passed = 0;
|
||||
}
|
||||
compare_output($answer,&get_logfile(1));
|
||||
|
||||
# Just in case
|
||||
unlink($example);
|
||||
V =
|
||||
$V.SILENT:
|
||||
M: a b
|
||||
!,
|
||||
'--no-print-directory', "a\nb\necho a\na\necho b\nb");
|
||||
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user