util/postprocess-makedepend.pl: For VC, don't include system headers
authorRichard Levitte <levitte@openssl.org>
Wed, 14 Mar 2018 09:37:26 +0000 (10:37 +0100)
committerRichard Levitte <levitte@openssl.org>
Thu, 15 Mar 2018 14:21:52 +0000 (15:21 +0100)
All dependencies that VC gives us are absolute paths, so we need to
check if some of them are within our source or build tree.  We do that
by comparing the start of each dependency with the absolute versions
of our source and build directories.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5591)

util/postprocess-makedepend.pl

index 790738015f85043ae076365814182be8a08f5e5d..5d0cf3d02aeb0b3df898b59aaddef3ce95fc8906 100644 (file)
@@ -9,8 +9,15 @@
 use strict;
 use warnings;
 
-my $producer = shift @ARGV;
+use lib '.';
+use configdata;
+
+use File::Spec::Functions qw(canonpath rel2abs);
+
+my $abs_srcdir = rel2abs($config{sourcedir});
+my $abs_blddir = rel2abs($config{builddir});
 
+my $producer = shift @ARGV;
 die "Producer not given\n" unless $producer;
 
 my $procedure = {
@@ -98,7 +105,15 @@ my $procedure = {
 
             if (/^Note: including file: */) {
                 (my $tail = $') =~ s/\s*\R$//;
-                return "${object}: \"$tail\"\n";
+
+                # VC gives us absolute paths for all include files, so to
+                # remove system header dependencies, we need to check that
+                # they don't match $abs_srcdir or $abs_blddir
+                $tail = canonpath($tail);
+                if ($tail =~ m|^\Q$abs_srcdir\E|i
+                        || $tail =~ m|^\Q$abs_blddir\E|i) {
+                    return "${object}: \"$tail\"\n";
+                }
             }
 
             return undef;