mirror of
https://github.com/mirror/make.git
synced 2025-02-06 01:30:23 +08:00
Obey order of multiple print/no-print directory options
Previously if --no-print-directory was seen anywhere even once (environment, command line, etc.) it would always take precedence over any --print-directory option. Change this so that the last seen option (which will be the command line, if present there) takes precedence. * NEWS: Mark this change in behavior. * src/makeint.h (print_directory): A new variable to control printing. * src/output.c (output_dump): Use the new variable. (output_start): Ditto. * src/main.c: Add a new variable print_directory. Use -1 for print_directory_flag so we know of the option was seen or not. Add a new default_print_directory_flag set to -1 to keep options from being added. (switches): Use flag_off for --no-print-directory, rather than a separate inhibit_print_directory_flag. (main): If print_directory_flag was set by the user, use that for print_directory. If not, compute the print_directory value based on -s, -C, and sub-makes as before. * tests/scripts/variables/GNUMAKEFLAGS: -w is not added automatically * tests/scripts/options/print-directory: Add tests for overriding print-directory options.
This commit is contained in:
parent
660a2eafe5
commit
8e024a2532
6
NEWS
6
NEWS
@ -15,6 +15,12 @@ A complete list of bugs fixed in this version is available here:
|
||||
|
||||
https://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=109&set=custom
|
||||
|
||||
* WARNING: Backward-incompatibility!
|
||||
Previously if --no-print-directory was seen anywhere in the environment or
|
||||
command line it would take precedence over --print-directory. Now, the
|
||||
last setting of directory printing options seen will be used, so a command
|
||||
line such as "--no-print-directory -w" _will_ show directory entry/exits.
|
||||
|
||||
* GNU Make can now be built for MS-Windows using the Tiny C tcc compiler.
|
||||
|
||||
|
||||
|
31
src/main.c
31
src/main.c
@ -227,12 +227,9 @@ int check_symlink_flag = 0;
|
||||
|
||||
/* Nonzero means print directory before starting and when done (-w). */
|
||||
|
||||
int print_directory_flag = 0;
|
||||
|
||||
/* Nonzero means ignore print_directory_flag and never print the directory.
|
||||
This is necessary because print_directory_flag is set implicitly. */
|
||||
|
||||
int inhibit_print_directory_flag = 0;
|
||||
int print_directory;
|
||||
static int print_directory_flag = -1;
|
||||
static const int default_print_directory_flag = -1;
|
||||
|
||||
/* Nonzero means print version information. */
|
||||
|
||||
@ -438,7 +435,8 @@ static const struct command_switch switches[] =
|
||||
"no-keep-going" },
|
||||
{ 't', flag, &touch_flag, 1, 1, 1, 0, 0, "touch" },
|
||||
{ 'v', flag, &print_version_flag, 1, 1, 0, 0, 0, "version" },
|
||||
{ 'w', flag, &print_directory_flag, 1, 1, 0, 0, 0, "print-directory" },
|
||||
{ 'w', flag, &print_directory_flag, 1, 1, 0, 0,
|
||||
&default_print_directory_flag, "print-directory" },
|
||||
|
||||
/* These options take arguments. */
|
||||
{ 'C', filename, &directories, 0, 0, 0, 0, 0, "directory" },
|
||||
@ -457,12 +455,13 @@ static const struct command_switch switches[] =
|
||||
{ CHAR_MAX+1, strlist, &db_flags, 1, 1, 0, "basic", 0, "debug" },
|
||||
{ CHAR_MAX+2, string, &jobserver_auth, 1, 1, 0, 0, 0, "jobserver-auth" },
|
||||
{ CHAR_MAX+3, flag, &trace_flag, 1, 1, 0, 0, 0, "trace" },
|
||||
{ CHAR_MAX+4, flag, &inhibit_print_directory_flag, 1, 1, 0, 0, 0,
|
||||
"no-print-directory" },
|
||||
{ CHAR_MAX+4, flag_off, &print_directory_flag, 1, 1, 0, 0,
|
||||
&default_print_directory_flag, "no-print-directory" },
|
||||
{ CHAR_MAX+5, flag, &warn_undefined_variables_flag, 1, 1, 0, 0, 0,
|
||||
"warn-undefined-variables" },
|
||||
{ CHAR_MAX+7, string, &sync_mutex, 1, 1, 0, 0, 0, "sync-mutex" },
|
||||
{ CHAR_MAX+8, flag_off, &silent_flag, 1, 1, 0, 0, &default_silent_flag, "no-silent" },
|
||||
{ CHAR_MAX+8, flag_off, &silent_flag, 1, 1, 0, 0, &default_silent_flag,
|
||||
"no-silent" },
|
||||
{ CHAR_MAX+9, string, &jobserver_auth, 1, 0, 0, 0, 0, "jobserver-fds" },
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
@ -1722,13 +1721,13 @@ main (int argc, char **argv, char **envp)
|
||||
no_default_sh_exe = !find_and_set_default_shell (NULL);
|
||||
#endif /* WINDOWS32 */
|
||||
|
||||
/* Except under -s, always do -w in sub-makes and under -C. */
|
||||
if (!silent_flag && (directories != 0 || makelevel > 0))
|
||||
print_directory_flag = 1;
|
||||
/* If the user didn't specify any print-directory options, compute the
|
||||
default setting: disable under -s / print in sub-makes and under -C. */
|
||||
|
||||
/* Let the user disable that with --no-print-directory. */
|
||||
if (inhibit_print_directory_flag)
|
||||
print_directory_flag = 0;
|
||||
if (print_directory_flag == -1)
|
||||
print_directory = !silent_flag && (directories != 0 || makelevel > 0);
|
||||
else
|
||||
print_directory = print_directory_flag;
|
||||
|
||||
/* If -R was given, set -r too (doesn't make sense otherwise!) */
|
||||
if (no_builtin_variables_flag)
|
||||
|
@ -670,7 +670,7 @@ extern unsigned short stopchar_map[];
|
||||
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;
|
||||
extern int print_version_flag, print_directory, check_symlink_flag;
|
||||
extern int warn_undefined_variables_flag, trace_flag, posix_pedantic;
|
||||
extern int not_parallel, second_expansion, clock_skew_detected;
|
||||
extern int rebuilding_makefiles, one_shell, output_sync, verify_flag;
|
||||
|
@ -367,7 +367,7 @@ output_dump (struct output *out)
|
||||
void *sem = acquire_semaphore ();
|
||||
|
||||
/* Log the working directory for this dump. */
|
||||
if (print_directory_flag && output_sync != OUTPUT_SYNC_RECURSE)
|
||||
if (print_directory && output_sync != OUTPUT_SYNC_RECURSE)
|
||||
traced = log_working_directory (1);
|
||||
|
||||
if (outfd_not_empty)
|
||||
@ -517,7 +517,7 @@ output_start (void)
|
||||
/* If we're not syncing this output per-line or per-target, make sure we emit
|
||||
the "Entering..." message where appropriate. */
|
||||
if (output_sync == OUTPUT_SYNC_NONE || output_sync == OUTPUT_SYNC_RECURSE)
|
||||
if (! stdio_traced && print_directory_flag)
|
||||
if (! stdio_traced && print_directory)
|
||||
stdio_traced = log_working_directory (1);
|
||||
}
|
||||
|
||||
|
@ -2,15 +2,25 @@
|
||||
|
||||
$description = "Test the -w option to GNU make.";
|
||||
|
||||
my $enter = "#MAKE#: Entering directory '#PWD#'";
|
||||
my $leave = "#MAKE#: Leaving directory '#PWD#'";
|
||||
|
||||
# Simple test without -w
|
||||
run_make_test(q!
|
||||
all: ; @echo hi
|
||||
!,
|
||||
"", "hi\n");
|
||||
|
||||
my $ans = "$enter\nhi\n$leave\n";
|
||||
|
||||
# Simple test with -w
|
||||
run_make_test(undef, "-w",
|
||||
"#MAKE#: Entering directory '#PWD#'\nhi\n#MAKE#: Leaving directory '#PWD#'\n");
|
||||
run_make_test(undef, "-w", $ans);
|
||||
|
||||
# Simple test with overriding -w
|
||||
run_make_test(undef, "-w --no-print-directory", "hi\n");
|
||||
|
||||
# Simple test with overriding --no-print-directory
|
||||
run_make_test(undef, "--no-print-directory --print-directory", $ans);
|
||||
|
||||
# Test makefile rebuild to ensure no enter/leave
|
||||
run_make_test(q!
|
||||
@ -21,13 +31,40 @@ foo: ; touch foo
|
||||
"", "touch foo\n");
|
||||
unlink('foo');
|
||||
|
||||
$ans = "$enter\ntouch foo\n$leave\n";
|
||||
|
||||
# Test makefile rebuild with -w
|
||||
run_make_test(q!
|
||||
include foo
|
||||
all: ;@:
|
||||
foo: ; touch foo
|
||||
!,
|
||||
"-w", "#MAKE#: Entering directory '#PWD#'\ntouch foo\n#MAKE#: Leaving directory '#PWD#'\n");
|
||||
run_make_test(undef, "-w", $ans);
|
||||
unlink('foo');
|
||||
|
||||
# Test makefile rebuild with -w overridden
|
||||
run_make_test(undef, "-w --no-print-directory", "touch foo\n");
|
||||
unlink('foo');
|
||||
|
||||
# Test makefile rebuild with --no-print-directory overridden
|
||||
run_make_test(undef, "--no-print-directory --print-directory", $ans);
|
||||
unlink('foo');
|
||||
|
||||
my $enter1 = "#MAKE#[1]: Entering directory '#PWD#'";
|
||||
my $leave1 = "#MAKE#[1]: Leaving directory '#PWD#'";
|
||||
|
||||
$ans = "$enter1\nhi\n$leave1\n";
|
||||
|
||||
# Test makefile recursion with default enter/leave
|
||||
run_make_test(q!
|
||||
all: ;@$(MAKE) -f #MAKEFILE# recurse
|
||||
recurse: ; @echo hi
|
||||
!,
|
||||
"", $ans);
|
||||
|
||||
# Disable enter/leave
|
||||
run_make_test(undef, "--no-print-directory", "hi\n");
|
||||
|
||||
# Re-enable enter/leave
|
||||
$ans = "$enter\n$ans$leave\n";
|
||||
run_make_test(undef, "--no-print-directory -w", $ans);
|
||||
|
||||
# Override enter/leave
|
||||
run_make_test(undef, "-w --no-print-directory", "hi\n");
|
||||
|
||||
1;
|
||||
|
@ -35,7 +35,7 @@ all: ; @echo $@; echo MAKEFLAGS = $$MAKEFLAGS; echo GNUMAKEFLAGS = $$GNUMAKEFLAG
|
||||
-include x.mk
|
||||
x.mk: ; @echo $@; echo MAKEFLAGS = $$MAKEFLAGS; echo GNUMAKEFLAGS = $$GNUMAKEFLAGS; echo > $@
|
||||
!,
|
||||
"", "x.mk\nMAKEFLAGS = -Itst/bad\nGNUMAKEFLAGS =\nrecurse\nMAKEFLAGS = -Itst/bad\nGNUMAKEFLAGS =\n#MAKE#[1]: Entering directory '#PWD#'\nall\nMAKEFLAGS = w -Itst/bad\nGNUMAKEFLAGS =\n#MAKE#[1]: Leaving directory '#PWD#'\n");
|
||||
"", "x.mk\nMAKEFLAGS = -Itst/bad\nGNUMAKEFLAGS =\nrecurse\nMAKEFLAGS = -Itst/bad\nGNUMAKEFLAGS =\n#MAKE#[1]: Entering directory '#PWD#'\nall\nMAKEFLAGS = -Itst/bad\nGNUMAKEFLAGS =\n#MAKE#[1]: Leaving directory '#PWD#'\n");
|
||||
|
||||
unlink('x.mk');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user