mirror of
https://github.com/mirror/make.git
synced 2026-09-04 05:32:57 +08:00
Add support for .WARNINGS special variable
Create a new special variable, .WARNINGS, to allow per-makefile control over warnings. The command line settings will override this. Move the handling of warning flags to a new file: src/warning.c. Allow the decode to work with generic strings, and call it from decode_switches(). * Makefile.am: Add new file src/warning.c. * build_w32.bat: Ditto. * builddos.bat: Ditto. * po/POTFILES.in: Ditto. * src/makeint.h: #define for the .WARNINGS variable name. * src/warning.h: Add declarations for methods moved from main.c. Rename the enum warning_state to warning_action. * src/warning.c: New file. Move all warning encode/decode here from main.c. * src/main.c: Move methods into warning.c and call those methods instead. (main): Set .WARNINGS as a special variable. * src/job.c (construct_command_argv): Rename to warning_action. * src/read.c (tilde_expand): Ditto. * src/variable.c (set_special_var): Update warnings when the .WARNINGS special variable is set. * tests/scripts/options/warn: Check invalid warning options. * tests/scripts/variables/WARNINGS: Add tests for the .WARNINGS special variable.
This commit is contained in:
@@ -53,7 +53,7 @@ all:;
|
||||
X := $(averyveryveryloooooooooooooooooooooooooooongvariablename)
|
||||
!,
|
||||
'--warn=undefined-var',
|
||||
"#MAKEFILE#:3: reference to undefined variable 'averyveryveryloooooooooooooooooooooooooooongvariablename'
|
||||
"#MAKEFILE#:3: warning: reference to undefined variable 'averyveryveryloooooooooooooooooooooooooooongvariablename'
|
||||
#MAKE#: 'all' is up to date.\n"
|
||||
);
|
||||
|
||||
@@ -75,8 +75,8 @@ run_make_test(undef, '--warn=undefined-var:ignore', 'ref');
|
||||
|
||||
# Check warnings
|
||||
run_make_test(undef, '--warn=undefined-var',
|
||||
"#MAKEFILE#:7: reference to undefined variable 'UNDEFINED'
|
||||
#MAKEFILE#:9: reference to undefined variable 'UNDEFINED'
|
||||
"#MAKEFILE#:7: warning: reference to undefined variable 'UNDEFINED'
|
||||
#MAKEFILE#:9: warning: reference to undefined variable 'UNDEFINED'
|
||||
ref");
|
||||
|
||||
# Check and errors
|
||||
@@ -96,9 +96,9 @@ define nl
|
||||
endef
|
||||
|
||||
all: ; @echo ref $(also$(nl)bad) $(IREF) $(SIREF)',
|
||||
'', "#MAKEFILE#:2: invalid variable reference 'bad variable'
|
||||
#MAKEFILE#:10: invalid variable reference 'also\nbad'
|
||||
#MAKEFILE#:2: invalid variable reference 'bad variable'
|
||||
'', "#MAKEFILE#:2: warning: invalid variable reference 'bad variable'
|
||||
#MAKEFILE#:10: warning: invalid variable reference 'also\nbad'
|
||||
#MAKEFILE#:2: warning: invalid variable reference 'bad variable'
|
||||
ref");
|
||||
|
||||
run_make_test(undef, '--warn=ignore', 'ref');
|
||||
@@ -133,18 +133,26 @@ foo
|
||||
endef
|
||||
|
||||
all: ; @echo ref',
|
||||
'', "#MAKEFILE#:4: invalid variable name 'BAD VAR'
|
||||
#MAKEFILE#:11: invalid variable name 'NL\nVAR'
|
||||
#MAKEFILE#:13: invalid variable name 'BAD DEF'
|
||||
#MAKEFILE#:17: invalid variable name 'NL\nDEF'
|
||||
'', "#MAKEFILE#:4: warning: invalid variable name 'BAD VAR'
|
||||
#MAKEFILE#:11: warning: invalid variable name 'NL\nVAR'
|
||||
#MAKEFILE#:13: warning: invalid variable name 'BAD DEF'
|
||||
#MAKEFILE#:17: warning: invalid variable name 'NL\nDEF'
|
||||
ref");
|
||||
|
||||
run_make_test(undef, '--warn=ignore', 'ref');
|
||||
|
||||
run_make_test(undef, '--warn=invalid-var:ignore', 'ref');
|
||||
|
||||
# Check and errors
|
||||
# Check errors
|
||||
run_make_test(undef, '--warn=invalid-var:error',
|
||||
"#MAKEFILE#:4: *** invalid variable name 'BAD VAR'. Stop.", 512);
|
||||
|
||||
# Make sure unknown warnings and actions fail when given on the command line.
|
||||
|
||||
run_make_test(undef, '--warn=no-such-warn',
|
||||
"#MAKE#: *** unknown warning 'no-such-warn'. Stop.", 512);
|
||||
|
||||
run_make_test(undef, '--warn=invalid-var:no-such-action',
|
||||
"#MAKE#: *** unknown warning action 'no-such-action'. Stop.", 512);
|
||||
|
||||
1;
|
||||
|
||||
Reference in New Issue
Block a user