summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphael Manfredi <Raphael_Manfredi@pobox.com>2017-05-13 14:59:32 +0200
committerRaphael Manfredi <Raphael_Manfredi@pobox.com>2017-05-13 14:59:32 +0200
commit400b5416d705dfa1c25eaefa9f2dcccf142a77c6 (patch)
treec18b2eab7147b656942130545564098c80bb1b57
parente17476b806aad1f8da32470141419a79a9fe1a78 (diff)
Enhanced metalint to better validate ?MAKE: lines.
In particular, validate the special "pick" command further to avoid nasty surprises when running metaconfig.
-rwxr-xr-xmcon/man/mlint.SH19
-rw-r--r--mcon/pl/lint.pl44
2 files changed, 62 insertions, 1 deletions
diff --git a/mcon/man/mlint.SH b/mcon/man/mlint.SH
index ea20938..597fb3c 100755
--- a/mcon/man/mlint.SH
+++ b/mcon/man/mlint.SH
@@ -113,6 +113,12 @@ Print version number and exit.
.SH DIAGNOSTICS
The following diagnostics may be emitted by \fImetalint\fR:
.TP 5
+"(?MAKE) command line must start with a leading TAB character."
+Self explainatory.
+.TP
+"(?MAKE) fourth pick argument is missing."
+Self explainatory.
+.TP
"(?MAKE) ignoring duplicate dependency listing line."
More than one ?MAKE: line bearing dependencies was found in the unit. There
may be only one such line, although multiple ?MAKE action lines may occur.
@@ -136,6 +142,19 @@ Symbol is listed as a normal dependency and as a conditional one.
will consider this as being a full dependency, but that may not be what you
initially wanted...
.TP
+"(?MAKE) pick needs a command argument."
+There is no command name after the special "pick" directive, which is invalid.
+.TP
+"(?MAKE) third pick argument must be $@.
+The third argument to the special "pick" directive must be $@, litterally.
+.TP
+"(?MAKE) unknown pick command 'xxx'.
+The command argument listed for the special "pick" directive is unknown.
+.TP
+"(?MAKE) weird fourth argument 'xxx' to pick.
+The fourth argument for pick, the target file, should be a unit name, a file
+path introduced by "./" or the special "%<" token.
+.TP
"(?Y) unknown layout directive 'xxx'."
Layout directives may only be one of \fItop\fR, \fIdefault\fR or \fIbottom\fR,
but case does not matter. An unknown directive is just ignored and
diff --git a/mcon/pl/lint.pl b/mcon/pl/lint.pl
index 64bb466..3762e3d 100644
--- a/mcon/pl/lint.pl
+++ b/mcon/pl/lint.pl
@@ -125,6 +125,48 @@ sub init_extraction {
sub end_extraction {
}
+# Process the command line of ?MAKE: lines
+sub p_make_command {
+ local ($_) = @_;
+ my $where = "\"$file\", line $. (?MAKE:)";
+ unless (s/^\t+//) {
+ warn "$where: command line must start with a leading TAB character.\n";
+ s/^\s+//; # Remove spaces and continue
+ }
+ return unless s/^-?pick\b//;
+ # Validate the special "pick" make command, processed internally
+ # by metaconfig.
+ my %valid = map { $_ => 1 } qw(
+ add add.Config_sh add.Null
+ c_h_weed cm_h_weed close.Config_sh
+ prepend weed wipe
+
+ );
+ my $cmd;
+ $cmd = $1 if s/^\s+(\S+)//;
+ unless (defined $cmd) {
+ warn "$where: pick needs a command argument.\n";
+ return;
+ }
+ $wiped_unit++ if $cmd eq 'wipe';
+ warn "$where: unknown pick command '$cmd'.\n" unless $valid{$cmd};
+ s/^\s+//;
+ unless (s/^\$\@//) {
+ warn "$where: third pick argument must be \$\@\n";
+ return;
+ }
+ s/^\s+//;
+ my $target;
+ $target = $1 if s/^(\S+)//;
+ unless (defined $target) {
+ warn "$where: fourth pick argument is missing\n";
+ return;
+ }
+ return if $target =~ m|^\./|;
+ warn "$where: weird fourth argument '$target' to pick.\n"
+ unless $target =~ /^\w+$/;
+}
+
# Process the ?MAKE: line
sub p_make {
local($_) = @_;
@@ -132,7 +174,7 @@ sub p_make {
local(@dep); # Dependencies
local($where) = "\"$file\", line $. (?MAKE:)";
unless (/^[\w+ ]*:/) {
- $wiped_unit++ if /^\t+-pick\s+wipe\b/;
+ &p_make_command;
return; # We only want the main dependency rule
}
warn "$where: ignoring duplicate dependency listing line.\n"