Package: dpkg-dev Version: 1.16.1.2 Severity: wishlist Tags: patch It would be nice to have some action of dpkg-buildflags to output the actual compiler flags so maintainers can call this and log analysers can find that information in the log. (dpkg-buildflags --dump would hard to identify without false positives and suggesting to add something like dpkg-buildflags | sed -e 's/^/dpkg-buildflags: /' would surely lead to unneeded variance).
If that would also output the feature flags and some information why the values get this way (so that one can help new developers by just looking at some build log instead of requesting each piece of information manually). Attached is a patch relative to current dpkg git master to output environment variables, vendor, feature flags and compiler flags in a nice way as new action '--status'. Bernhard R. Link
>From 2075bebb2fad5bd2d7ff134ce8b9bc18196a14da Mon Sep 17 00:00:00 2001 From: "Bernhard R. Link" <brl...@debian.org> Date: Thu, 15 Mar 2012 11:25:39 +0100 Subject: [PATCH] dpkg-buildflags: add --status action to describe what is happening It's hard to see from a build log file what values should have been used and why. The new --status action added by this tries to output all meaningful information in way useful for human consumption and for automatic log parsers. Signed-off-by: Bernhard R. Link <brl...@debian.org> --- man/dpkg-buildflags.1 | 11 +++++++++ scripts/Dpkg/BuildFlags.pm | 12 ++++++++++ scripts/dpkg-buildflags.pl | 52 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 0 deletions(-) diff --git a/man/dpkg-buildflags.1 b/man/dpkg-buildflags.1 index 4244b82..0c9829c 100644 --- a/man/dpkg-buildflags.1 +++ b/man/dpkg-buildflags.1 @@ -72,6 +72,17 @@ Print the list of flags supported by the current vendor (one per line). See the \fBSUPPORTED FLAGS\fP section for more information about them. .TP +.BI \-\-status +Print all information to standard output: +Environment variables that might have had some influence, +the current vendor, +the state of all feature flags, and finally +all compiler flags together with their origin and values. + +This is intended to be run from debian/rules, so that the log +contains all the information or to debug why the flags are that +they end up to be. +.TP .BI \-\-export= format Print to standard output shell (if \fIformat\fP is \fBsh\fP) or make (if \fIformat\fP is \fBmake\fP) commands that can be used to export diff --git a/scripts/Dpkg/BuildFlags.pm b/scripts/Dpkg/BuildFlags.pm index b114335..b18c860 100644 --- a/scripts/Dpkg/BuildFlags.pm +++ b/scripts/Dpkg/BuildFlags.pm @@ -320,6 +320,18 @@ sub get { return $self->{'flags'}{$key}; } +=item $bf->get_feature_areas() + +Return the feature areas +(i.e. the area values has_features will return true for). + +=cut + +sub get_feature_areas { + my ($self) = @_; + return keys $self->{'features'}; +} + =item $bf->get_features($area) Return, for the given area, a hash with keys as feature names, and values diff --git a/scripts/dpkg-buildflags.pl b/scripts/dpkg-buildflags.pl index d0f9fa8..890076b 100755 --- a/scripts/dpkg-buildflags.pl +++ b/scripts/dpkg-buildflags.pl @@ -24,6 +24,7 @@ use Dpkg; use Dpkg::Gettext; use Dpkg::ErrorHandling; use Dpkg::BuildFlags; +use Dpkg::Vendor qw(get_current_vendor); textdomain("dpkg-dev"); @@ -52,6 +53,7 @@ Actions: compilation flags in a shell script, in make, or on a ./configure command line. --dump output all compilation flags with their values + --status informational message about current status --help show this help message. --version show the version. "), $progname; @@ -80,6 +82,10 @@ while (@ARGV) { usageerr(_g("two commands specified: --%s and --%s"), "list", $action) if defined($action); $action = "list"; + } elsif (m/^--status$/) { + usageerr(_g("two commands specified: --%s and --%s"), "status", $action) + if defined($action); + $action = "status"; } elsif (m/^-(h|-help)$/) { usage(); exit 0; @@ -147,6 +153,52 @@ if ($action eq "get") { print "$flag=$value\n"; } exit(0); +} elsif ($action eq "status") { + # prefix everything with "dpkg-buildflags: " to allow easy extraction + # from a buildd log. + # First print all environment variables that might have changed the + # results: (would be nice to only print those having an effect for + # the current vendor, but getting that information here would be + # quite tough): + my @envvars = ('DEB_VENDOR', 'DEB_BUILD_OPTIONS', + 'DEB_BUILD_MAINT_OPTIONS', 'DEB_BUILD_HARDENING'); + foreach my $flag ($build_flags->list()) { + push @envvars, "DEB_" . $flag . "_SET", + "DEB_" . $flag . "_STRIP", + "DEB_" . $flag . "_APPEND", + "DEB_" . $flag . "_PREPEND", + "DEB_" . $flag . "_MAINT_SET", + "DEB_" . $flag . "_MAINT_STRIP", + "DEB_" . $flag . "_MAINT_APPEND", + "DEB_" . $flag . "_MAINT_PREPEND"; + } + for my $envvar (@envvars) { + if (exists $ENV{$envvar}) { + printf "dpkg-buildflags: environment variable %s=%s\n", + $envvar, $ENV{$envvar}; + } + } + my $vendor = Dpkg::Vendor::get_current_vendor(); + $vendor = "undefined" unless defined($vendor); + print "dpkg-buildflags: vendor is $vendor\n"; + # Then the resulting features: + foreach my $area (sort $build_flags->get_feature_areas()) { + print "dpkg-buildflags: $area features:"; + my %features = $build_flags->get_features($area); + foreach my $feature (sort keys %features) { + printf " %s=%s", $feature, $features{$feature} ? "yes" : "no"; + } + print "\n"; + } + # Then the resulting values (with their origin): + foreach my $flag ($build_flags->list()) { + my $value = $build_flags->get($flag); + my $origin = $build_flags->get_origin($flag); + # note that DEB_*_MAINT_* currently is not reflected + # by $origin... + print "dpkg-buildflags: $flag [$origin]: $value\n"; + } + exit(0); } exit(1); -- 1.7.9.1