summaryrefslogtreecommitdiff
path: root/mcon/pl
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 /mcon/pl
parente17476b806aad1f8da32470141419a79a9fe1a78 (diff)
Enhanced metalint to better validate ?MAKE: lines.
In particular, validate the special "pick" command further to avoid nasty surprises when running metaconfig.
Diffstat (limited to 'mcon/pl')
-rw-r--r--mcon/pl/lint.pl44
1 files changed, 43 insertions, 1 deletions
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"