pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files - In -Wextra mode, emit warning...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/88b2a432297a
branches:  trunk
changeset: 506442:88b2a432297a
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Mon Jan 16 01:37:39 2006 +0000

description:
- In -Wextra mode, emit warnings if a "?=" operator occurs before
  ../../bsd.prefs.mk is included. (It is only shown in -Wextra mode
  because it is still quite unreliable.)

diffstat:

 pkgtools/pkglint/files/pkglint.pl |  18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diffs (61 lines):

diff -r af7b0dc33f5c -r 88b2a432297a pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Mon Jan 16 00:45:52 2006 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Mon Jan 16 01:37:39 2006 +0000
@@ -1,5 +1,5 @@
 #! @PERL@
-# $NetBSD: pkglint.pl,v 1.475 2006/01/15 01:35:55 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.476 2006/01/16 01:37:39 rillig Exp $
 #
 
 # pkglint - static analyzer and checker for pkgsrc packages
@@ -1142,6 +1142,7 @@
 my $distinfo_file;             # DISTINFO_FILE from the package Makefile
 my $pkgname;                   # PKGNAME from the package Makefile
 my $hack_php_patches;          # Ignore non-existing patches in distinfo
+my $seen_bsd_prefs_mk;         # Has bsd.prefs.mk already been included?
 
 my $makevar;                   # Table of variables and values
 my $seen_Makefile_common;      # Does the package have any .includes?
@@ -2885,6 +2886,15 @@
        my ($line, $varname, $op, $value, $comment) = @_;
        my $varbase = ($varname =~ qr"(.+?)\..*") ? $1 : $varname;
 
+       if ($op eq "?=" && defined($seen_bsd_prefs_mk) && !$seen_bsd_prefs_mk) {
+               if ($varbase eq "BUILDLINK_PKGSRCDIR"
+                   || $varbase eq "BUILDLINK_RECOMMENDED") {
+                       # FIXME: What about these ones? They occur quite often.
+               } else {
+                       $opt_warn_extra and $line->log_warning("Please include \"../../mk/bsd.prefs.mk\" before using \"?=\".");
+               }
+       }
+
        checkline_mk_vartype($line, $varname, $op, $value, $comment);
 
        if (!$is_internal && $varname =~ qr"^_") {
@@ -3152,6 +3162,10 @@
                                        "Makefile.common.");
                        }
 
+                       if ($includefile eq "../../mk/bsd.prefs.mk") {
+                               $seen_bsd_prefs_mk = true;
+                       }
+
                } elsif ($text =~ qr"^\.\s*(if|ifdef|ifndef|else|elif|endif|for|endfor|undef)(?:\s+([^\s#][^#]*?))?\s*(?:#.*)?$") {
                        my ($directive, $args) = ($1, $2);
 
@@ -4052,6 +4066,7 @@
 
        # Initialize global variables
        $makevar = {};
+       $seen_bsd_prefs_mk = false;
 
        # we need to handle the Makefile first to get some variables
        if (!load_package_Makefile("${current_dir}/Makefile", \$whole, \$lines)) {
@@ -4125,6 +4140,7 @@
        $seen_Makefile_common   = undef;
        $pkgname                = undef;
        $hack_php_patches       = false;
+       $seen_bsd_prefs_mk      = undef;
 
        $current_dir = $is_dir ? $item : dirname($item);
        my $abs_current_dir = Cwd::abs_path($current_dir);



Home | Main Index | Thread Index | Old Index