pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files Added the command line argument...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/eb7bdeee2485
branches:  trunk
changeset: 513911:eb7bdeee2485
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Mon Jun 05 22:34:40 2006 +0000

description:
Added the command line argument -D{foo,bar,...} that enables or disables
certain categories of debugging output.

diffstat:

 pkgtools/pkglint/files/pkglint.0  |   28 +++++++
 pkgtools/pkglint/files/pkglint.1  |   30 +++++++-
 pkgtools/pkglint/files/pkglint.pl |  145 ++++++++++++++++++++-----------------
 3 files changed, 136 insertions(+), 67 deletions(-)

diffs (truncated from 445 to 300 lines):

diff -r 6c32927b75c1 -r eb7bdeee2485 pkgtools/pkglint/files/pkglint.0
--- a/pkgtools/pkglint/files/pkglint.0  Mon Jun 05 22:24:12 2006 +0000
+++ b/pkgtools/pkglint/files/pkglint.0  Mon Jun 05 22:34:40 2006 +0000
@@ -14,6 +14,9 @@
      --CC{{[[nnoo--]]cchheecckk,,......}}  Enable or disable specific checks.  For a list of
                          checks, see below.
 
+     --DD{{[[nnoo--]]ddeebbuugg,,......}}  Enable or disable debugging categories.  For a list
+                         of categories, see below.
+
      --FF|----aauuttooffiixx        Repair trivial things automatically.
 
      --II                  Show the _M_a_k_e_f_i_l_e that is constructed by including
@@ -89,6 +92,31 @@
 
      [[nnoo--]]ppaattcchheess        Check the pkgsrc specific patch files.
 
+   DDeebbuuggggiinngg OOppttiioonnss
+     aallll                 Enable all debugging options.
+
+     nnoonnee                Disable all debugging options.
+
+     [[nnoo--]]iinncclluuddee        Show the pathnames of the included Makefiles.
+
+     [[nnoo--]]mmiisscc           Some debugging stuff that hasn't made it into its own
+                         category.
+
+     [[nnoo--]]ppaattcchheess        Print the states of the patch file parser.
+
+     [[nnoo--]]qquuoottiinngg        Additional information about why variables should be
+                         quoted or not.
+
+     [[nnoo--]]sshheellll          Parser information from the shell word and the shell
+                         command parsers.
+
+     [[nnoo--]]ttoooollss          Additional information about the tools from the tools
+                         framework.
+
+     [[nnoo--]]vvaarrttyyppeess       Additional information about the variable types.
+
+     [[nnoo--]]vvaarruussee         Information about used and unused variables.
+
    WWaarrnniinnggss
      aallll                 Enable all warnings.
 
diff -r 6c32927b75c1 -r eb7bdeee2485 pkgtools/pkglint/files/pkglint.1
--- a/pkgtools/pkglint/files/pkglint.1  Mon Jun 05 22:24:12 2006 +0000
+++ b/pkgtools/pkglint/files/pkglint.1  Mon Jun 05 22:34:40 2006 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: pkglint.1,v 1.39 2006/05/22 06:05:46 rillig Exp $
+.\"    $NetBSD: pkglint.1,v 1.40 2006/06/05 22:34:40 rillig Exp $
 .\"    From FreeBSD: portlint.1,v 1.8 1997/11/25 14:53:14 itojun Exp
 .\"
 .\" Copyright (c) 1997 by Jun-ichiro Itoh <itojun%itojun.org@localhost>.
@@ -27,6 +27,9 @@
 .It Fl C{[no-]check,...}
 Enable or disable specific checks.
 For a list of checks, see below.
+.It Fl D{[no-]debug,...}
+Enable or disable debugging categories.
+For a list of categories, see below.
 .It Fl F Ns | Ns Fl -autofix
 Repair trivial things automatically.
 .It Fl I
@@ -113,6 +116,31 @@
 .El
 .Pp
 .\" =======================================================================
+.Ss Debugging Options
+.Bl -tag -width 18n
+.It Cm all
+Enable all debugging options.
+.It Cm none
+Disable all debugging options.
+.It Cm [no-]include
+Show the pathnames of the included Makefiles.
+.It Cm [no-]misc
+Some debugging stuff that hasn't made it into its own category.
+.It Cm [no-]patches
+Print the states of the patch file parser.
+.It Cm [no-]quoting
+Additional information about why variables should be quoted or not.
+.It Cm [no-]shell
+Parser information from the shell word and the shell command parsers.
+.It Cm [no-]tools
+Additional information about the tools from the tools framework.
+.It Cm [no-]vartypes
+Additional information about the variable types.
+.It Cm [no-]varuse
+Information about used and unused variables.
+.El
+.Pp
+.\" =======================================================================
 .Ss Warnings
 .Bl -tag -width 18n
 .It Cm all
diff -r 6c32927b75c1 -r eb7bdeee2485 pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Mon Jun 05 22:24:12 2006 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Mon Jun 05 22:34:40 2006 +0000
@@ -1,5 +1,5 @@
 #! @PERL@
-# $NetBSD: pkglint.pl,v 1.601 2006/06/03 07:27:25 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.602 2006/06/05 22:34:40 rillig Exp $
 #
 
 # pkglint - static analyzer and checker for pkgsrc packages
@@ -269,9 +269,7 @@
 }
 sub log_debug($$$) {
        my ($fname, $lineno, $msg) = @_;
-       if ($verbosity >= 2) {
-               log_message(LL_DEBUG, $fname, $lineno, $msg);
-       }
+       log_message(LL_DEBUG, $fname, $lineno, $msg);
 }
 
 sub explain($$@) {
@@ -572,9 +570,7 @@
 }
 sub log_debug($$) {
        my ($self, $text) = @_;
-       if (PkgLint::Logging::get_verbosity() >= 2) {
-               $self->show_source(*STDOUT);
-       }
+       $self->show_source(*STDOUT);
        PkgLint::Logging::log_debug($self->fname, $self->[LINES], $text);
 }
 sub explain_error($@) {
@@ -1401,6 +1397,25 @@
        "PLIST"         => [\$opt_check_PLIST, "check PLIST files"],
 );
 
+my $opt_debug_include  = false;
+my $opt_debug_misc     = false;
+my $opt_debug_patches  = false;
+my $opt_debug_quoting  = false;
+my $opt_debug_shell    = false;
+my $opt_debug_tools    = false;
+my $opt_debug_vartypes = false;
+my $opt_debug_varuse   = false;
+my (%debug) = (
+       "include"       => [\$opt_debug_include, "included files"],
+       "misc"          => [\$opt_debug_misc, "all things that didn't fit elsewhere"],
+       "patches"       => [\$opt_debug_patches, "the states of the patch parser"],
+       "quoting"       => [\$opt_debug_quoting, "additional information about quoting"],
+       "shell"         => [\$opt_debug_shell, "the parsers for shell words and shell commands"],
+       "tools"         => [\$opt_debug_tools, "the tools framework"],
+       "vartypes"      => [\$opt_debug_vartypes, "additional type information"],
+       "varuse"        => [\$opt_debug_varuse, "used and unused variables"],
+);
+
 my $opt_warn_absname   = true;
 my $opt_warn_directcmd = true;
 my $opt_warn_extra     = false;
@@ -1444,6 +1459,12 @@
                my ($opt, $val) = @_;
                parse_multioption($val, \%checks);
          } ],
+       [ "-D{debug,...}", "Enable or disable debugging categories",
+         "debugging|D=s",
+         sub ($$) {
+               my ($opt, $val) = @_;
+               parse_multioption($val, \%debug);
+         } ],
        [ "-F|--autofix", "Try to automatically fix some errors (experimental)",
          "autofix|F", \$opt_autofix ],
        [ "-I|--dumpmakefile", "Dump the Makefile after parsing",
@@ -1601,31 +1622,29 @@
                exit($exitval);
        }
 
-       my (@checks_table) = (
-               ["  ", "all", "", "enable all checks"],
-               ["  ", "none", "", "disable all checks"],
-       );
-       foreach my $check (sort keys %checks) {
-               push(@checks_table, [ "  ", $check,
-                       (${$checks{$check}->[0]} ? "(enabled)" : "(disabled)"),
-                       $checks{$check}->[1]]);
-       }
-       print $out ("checks: (use \"check\" to enable, \"no-check\" to disable)\n");
-       PkgLint::Util::print_table($out, \@checks_table);
-       print $out ("\n");
-
-       my (@warnings_table) = (
-               ["  ", "all", "", "enable all warnings"],
-               ["  ", "none", "", "disable all warnings"],
-       );
-       foreach my $warning (sort keys %warnings) {
-               push(@warnings_table, [ "  ", $warning,
-                       (${$warnings{$warning}->[0]} ? "(enabled)" : "(disabled)"),
-                       $warnings{$warning}->[1]]);
-       }
-       print $out ("warnings: (use \"warn\" to enable, \"no-warn\" to disable)\n");
-       PkgLint::Util::print_table($out, \@warnings_table);
-       print $out ("\n");
+       my $categories = [
+               # options, leading text, 
+               [ \%checks, "checks", "check" ],
+               [ \%debug, "debugging options", "debug" ],
+               [ \%warnings, "warnings", "warning" ],
+       ];
+       foreach my $category (@{$categories}) {
+               my ($options, $leading, $name) = (@{$category});
+               my $table = [
+                       ["  ", "all", "", "enable all ".$category->[1]],
+                       ["  ", "none", "", "disable all ".$category->[1]],
+               ];
+
+               foreach my $opt (sort keys %{$options}) {
+                       push(@{$table}, [ "  ", $opt,
+                               (${$options->{$opt}->[0]} ? "(enabled)" : "(disabled)"),
+                               $options->{$opt}->[1]]);
+               }
+
+               print $out ("${leading}: (use \"${name}\" to enable, \"no-${name}\" to disable)\n");
+               PkgLint::Util::print_table($out, $table);
+               print $out ("\n");
+       }
 
        exit($exitval);
 }
@@ -2103,7 +2122,7 @@
                                my ($varname, undef, $value, undef) = ($1, $2, $3, $4);
 
                                if ($varname eq "USE_TOOLS") {
-                                       $line->log_debug("[cond_depth=${cond_depth}] $value");
+                                       $opt_debug_tools and $line->log_debug("[cond_depth=${cond_depth}] $value");
                                        if ($cond_depth == 0) {
                                                foreach my $tool (split(qr"\s+", $value)) {
                                                        if ($tool !~ regex_unresolved && exists($vartools->{$tool})) {
@@ -2125,10 +2144,10 @@
                }
        }
 
-       log_debug(NO_FILE, NO_LINE_NUMBER, "Known tools: ".join(" ", sort(keys(%{$tools}))));
-       log_debug(NO_FILE, NO_LINE_NUMBER, "Known vartools: ".join(" ", sort(keys(%{$vartools}))));
-       log_debug(NO_FILE, NO_LINE_NUMBER, "Predefined vartools: " . join(" ", sort(keys(%{$predefined_vartools}))));
-       log_debug(NO_FILE, NO_LINE_NUMBER, "Known varnames: " . join(" ", sort(keys(%{$varname_to_toolname}))));
+       $opt_debug_tools and log_debug(NO_FILE, NO_LINE_NUMBER, "Known tools: ".join(" ", sort(keys(%{$tools}))));
+       $opt_debug_tools and log_debug(NO_FILE, NO_LINE_NUMBER, "Known vartools: ".join(" ", sort(keys(%{$vartools}))));
+       $opt_debug_tools and log_debug(NO_FILE, NO_LINE_NUMBER, "Predefined vartools: " . join(" ", sort(keys(%{$predefined_vartools}))));
+       $opt_debug_tools and log_debug(NO_FILE, NO_LINE_NUMBER, "Known varnames: " . join(" ", sort(keys(%{$varname_to_toolname}))));
 
        $load_tool_names_tools = $tools;
        $load_tool_names_vartools = $vartools;
@@ -2441,7 +2460,7 @@
                        my ($varname) = ($1);
                        $varuse->{$varname} = $line;
                        $varuse->{varname_canon($varname)} = $line;
-                       $line->log_debug("Variable ${varname} is used.");
+                       $opt_debug_varuse and $line->log_debug("Variable ${varname} is used.");
                }
        }
 }
@@ -2634,14 +2653,8 @@
                return doesnt_matter;
        }
 
-       $opt_debug and $line->log_debug("[variable_needs_quoting] varname $varname context " . $context->to_string() . " type " . $type->to_string());
-       $opt_debug and $line->log_debug(sprintf("[%s] want_list=%d have_list=%d", "variable_needs_quoting", $want_list, $have_list));
-       backtrace();
-
-       # Assigning lists to lists does not need additional quoting.
-       if ($want_list && $have_list && ($context->extent == VUC_EXTENT_WORD || $context->extent == VUC_EXTENT_FULL)) {
-               return false;
-       }
+       $opt_debug_quoting and $line->log_debug("[variable_needs_quoting] varname $varname context " . $context->to_string() . " type " . $type->to_string());
+       $opt_debug_quoting and $line->log_debug(sprintf("[%s] want_list=%d have_list=%d", "variable_needs_quoting", $want_list, $have_list));
 
        # Appending elements to a list requires quoting, as well as
        # assigning a list value to a non-list variable.
@@ -2715,7 +2728,7 @@
                                && (!defined($1) || $1 ne "../mk")
                                && $2 ne "buildlink3.mk"
                                && $2 ne "options.mk")) {
-                               $line->log_debug("including ${includefile} sets seen_Makefile_common.");
+                               $opt_debug_include and $line->log_debug("including ${includefile} sets seen_Makefile_common.");
                                $seen_Makefile_common = true;
                        }
                        if ($includefile =~ qr"/mk/") {
@@ -2740,7 +2753,7 @@
                        my ($varname, $op, $value, $comment) = ($1, $2, $3, $4);
 
                        if ($op ne "?=" || !exists($makevar->{$varname})) {
-                               $opt_debug and $line->log_debug("varassign(${varname}, ${op}, ${value})");
+                               $opt_debug_misc and $line->log_debug("varassign(${varname}, ${op}, ${value})");
                                $makevar->{$varname} = $line;
                        }
                        $contents .= $text . "\n";
@@ -2960,7 +2973,7 @@
                my ($macro) = ($1);
 
                if (exists(good_macros->{$macro})) {
-                       $line->log_debug("Found good macro \"${macro}\".");
+                       $opt_debug_misc and $line->log_debug("Found good macro \"${macro}\".");
                } elsif (exists(bad_macros->{$macro})) {
                        $line->log_warning("The macro \"${macro}\" is not portable enough. Please use \"".bad_macros->{$macro}."\" instead.");
                        $line->explain_warning("See the pkgsrc guide, section \"CPP defines\" for details.");
@@ -3126,7 +3139,7 @@



Home | Main Index | Thread Index | Old Index