summaryrefslogtreecommitdiffstats
path: root/util/add-depends.pl
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2018-03-15 20:38:23 +0100
committerRichard Levitte <levitte@openssl.org>2018-03-16 09:33:54 +0100
commit433e857214731b45565668931d83b11c894b7a29 (patch)
tree0bb9c07706662e0c6722ca6cbe8e89cd577e7d39 /util/add-depends.pl
parent17928cf9f91af72cd5a83480d43cd278aff1f93a (diff)
Visual C: reduce the dependency paths to be relative
Reviewed-by: Andy Polyakov <appro@openssl.org> (Merged from https://github.com/openssl/openssl/pull/5631)
Diffstat (limited to 'util/add-depends.pl')
-rw-r--r--util/add-depends.pl41
1 files changed, 33 insertions, 8 deletions
diff --git a/util/add-depends.pl b/util/add-depends.pl
index 67b69b0ac7..1ffebc9fd7 100644
--- a/util/add-depends.pl
+++ b/util/add-depends.pl
@@ -12,7 +12,7 @@ use warnings;
use lib '.';
use configdata;
-use File::Spec::Functions qw(canonpath rel2abs);
+use File::Spec::Functions qw(:DEFAULT rel2abs);
use File::Compare qw(compare_text);
# When using stat() on Windows, we can get it to perform better by avoid some
@@ -42,11 +42,26 @@ exit 0 unless $rebuild;
# Ok, primary checks are done, time to do some real work
+my $producer = shift @ARGV;
+die "Producer not given\n" unless $producer;
+
my $abs_srcdir = rel2abs($config{sourcedir});
my $abs_blddir = rel2abs($config{builddir});
-my $producer = shift @ARGV;
-die "Producer not given\n" unless $producer;
+# Convenient cache of absolute to relative map. We start with filling it
+# with mappings for the known generated header files. They are relative to
+# the current working directory, so that's an easy task.
+# NOTE: there's more than C header files that are generated. They will also
+# generate entries in this map. We could of course deal with C header files
+# only, but in case we decide to handle more than just C files in the future,
+# we already have the mechanism in place here.
+# NOTE2: we lower case the index to make it searchable without regard for
+# character case. That could seem dangerous, but as long as we don't have
+# files we depend on in the same directory that only differ by character case,
+# we're fine.
+my %depconv_cache =
+ map { lc catfile($abs_blddir, $_) => $_ }
+ keys %{$unified_info{generate}};
my %procedures = (
'gcc' => undef, # gcc style dependency files needs no mods
@@ -138,12 +153,22 @@ my %procedures = (
# 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 ($objfile, "\"$tail\"");
+ # they don't match $abs_srcdir or $abs_blddir.
+ $tail = lc canonpath($tail);
+
+ unless (defined $depconv_cache{$tail}) {
+ my $dep = $tail;
+ # Since we have already pre-populated the cache with
+ # mappings for generated headers, we only need to deal
+ # with the source tree.
+ if ($dep =~ s|^\Q$abs_srcdir\E\\|\$(SRCDIR)\\|i) {
+ $depconv_cache{$tail} = $dep;
+ }
}
+ return ($objfile, '"'.$depconv_cache{$tail}.'"')
+ if defined $depconv_cache{$tail};
+ print STDERR "DEBUG[VC]: ignoring $objfile <- $tail\n"
+ if $debug;
}
return undef;