Re: [PATCH 6/6] kbuild: optimize headers_* targets

From: Sam Ravnborg
Date: Sun Jun 08 2008 - 17:14:51 EST


On Sun, Jun 08, 2008 at 10:37:41PM +0200, Vegard Nossum wrote:
> Hi Sam,
>
> Just one more comment from me :-)
>
> On Sun, Jun 8, 2008 at 10:07 PM, Sam Ravnborg <sam@xxxxxxxxxxxx> wrote:
> > diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
> > new file mode 100644
> > index 0000000..283c055
> > --- /dev/null
> > +++ b/scripts/headers_install.pl
> > @@ -0,0 +1,43 @@
> > +#!/usr/bin/perl
> > +#
> > +# headers_install prepare the listed header files for use in
> > +# user space and copy the files to their destination.
> > +#
> > +# Usage: headers_install.pl odir installdir [files...]
> > +# odir: dir to open files
> > +# install: dir to install the files
> > +# files: list of files to check
> > +#
> > +# Step in preparation for users space:
> > +# 1) Drop all use of compiler.h definitions
> > +# 2) Drop include of compiler.h
> > +# 3) Drop all sections defined out by __KERNEL__ (using unifdef)
> > +
> > +use strict;
> > +use warnings;
> > +
> > +my ($odir, $installdir, @files) = @ARGV;
> > +
> > +my $ret = 0;
> > +my $unifdef = "scripts/unifdef -U__KERNEL__";
> > +
> > +foreach my $file (@files) {
> > + my $tmpfile = "$installdir/$file.tmp";
> > + open(my $infile, '<', "$odir/$file") or die "$odir/$file: $!\n";
> > + open(my $outfile, '>', "$tmpfile") or die "$tmpfile: $!\n";
> > + while (my $line = <$infile>) {
> > + $line =~ s/([\s(])__user\s/$1/g;
> > + $line =~ s/([\s(])__force\s/$1/g;
> > + $line =~ s/([\s(])__iomem\s/$1/g;
> > + $line =~ s/\s__attribute_const__\s/ /g;
> > + $line =~ s/\s__attribute_const__$//g;
> > + $line =~ s/^#include <linux\/compiler.h>//;
> > + printf $outfile "%s", $line;
> > + }
> > + close $outfile;
> > + close $infile;
> > + $ret = system $unifdef . " $tmpfile > $installdir/$file";
>
> This seems flawed as we'll always exit with the $ret of the last file.
> Do you intend to abort on the first error, or go as far as possible?
>
> Maybe you can use something like this:
>
> system ... or warn "$file: $!\n"
> $ret = $? unless $ret;
>
> (This should preserve the $ret from the first process that fails with
> a non-zero exit code.)
>
> > + unlink $tmpfile;
> > +}
> > +
> > +exit $ret;
>
> What do you think?
[Not much - late here....]

Thanks - I will try to fix it somehow.
But I hope that someone with more perl fu than me will redo
the unifdef stuff so I do not have to worry...

Sam
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/