diff options
author | rillig <rillig@pkgsrc.org> | 2006-08-30 05:41:19 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2006-08-30 05:41:19 +0000 |
commit | 4ee2cb47d0372846c000210246a7eb5412d4aada (patch) | |
tree | b729cf7500035272825d59578f1c7acca4e0aa8b /pkgtools | |
parent | f3398823b2b19eb6f3443410974054edff7b2309 (diff) | |
download | pkgsrc-4ee2cb47d0372846c000210246a7eb5412d4aada.tar.gz |
The *.mk files need two passes to make the BUILD_DEFS check work
reasonably well. In the first pass, all variables that are added to
BUILD_DEFS are collected, and in the second pass it is checked whether
any remaining user-defined variables are used but have not been added to
BUILD_DEFS. This way, it does not matter in which order the variables
appear in the files.
Diffstat (limited to 'pkgtools')
-rw-r--r-- | pkgtools/pkglint/files/pkglint.pl | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/pkgtools/pkglint/files/pkglint.pl b/pkgtools/pkglint/files/pkglint.pl index e5fd2eec106..d06c7fcee0e 100644 --- a/pkgtools/pkglint/files/pkglint.pl +++ b/pkgtools/pkglint/files/pkglint.pl @@ -1,5 +1,5 @@ #! @PERL@ -# $NetBSD: pkglint.pl,v 1.670 2006/08/28 12:41:49 rillig Exp $ +# $NetBSD: pkglint.pl,v 1.671 2006/08/30 05:41:19 rillig Exp $ # # pkglint - static analyzer and checker for pkgsrc packages @@ -5429,14 +5429,6 @@ sub checkline_mk_varassign($$$$$) { "It is this meaning that should be described."); } - if ($varname eq "BUILD_DEFS") { - assert(defined($mkctx_build_defs), "The build_defs variable must be defined here."); - foreach my $bdvar (split(qr"\s+", $value)) { - $mkctx_build_defs->{$bdvar} = true; - $opt_debug_misc and $line->log_debug("${bdvar} is added to BUILD_DEFS."); - } - } - if ($value =~ qr"\$\{(PKGNAME|PKGVERSION)[:\}]") { my ($pkgvarname) = ($1); if ($varname =~ qr"^PKG_.*_REASON$") { @@ -5673,6 +5665,24 @@ sub checklines_mk($) { } } + # + # In the first pass, all additions to BUILD_DEFS are collected, + # to make the order of the definitions irrelevant. + # + + foreach my $line (@{$lines}) { + if ($line->has("is_varassign") && $line->get("varname") eq "BUILD_DEFS") { + foreach my $varname (split(qr"\s+", $line->get("value"))) { + $mkctx_build_defs->{$varname} = true; + $opt_debug_misc and $line->log_debug("${varname} is added to BUILD_DEFS."); + } + } + } + + # + # In the second pass, all "normal" checks are done. + # + if (0 <= $#{$lines}) { checkline_rcsid_regex($lines->[0], qr"^#\s+", "# "); } |