diff options
author | Richard Levitte <levitte@openssl.org> | 2021-04-26 09:17:05 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2021-04-28 21:35:26 +0200 |
commit | 2e535eb50aa9c6b73c796f668e1aef8bc17f14c4 (patch) | |
tree | 0142e28aa342ecc6cdb3fbdf01446544222f9609 /util/add-depends.pl | |
parent | 0bd138b8c36c7e8e504beb2c12a2771929c24cfb (diff) |
Configuration: rework how dependency making is handled
Previously, we had dependency making pretty much hard coded in the
build file templates, with a bit of an exception for Unix family
platforms, where we had different cases depending on what dependency
making program was found.
With the Embarcadero C++ builder, a separate scheme appeared, with a
different logic.
This change merges the two, and introduces two config target
attributes:
makedepcmd The program to use, where this is relevant.
This replaces the earlier configuration
attribute 'makedepprog'.
makedep_scheme This is a keyword that can be used by build
files templates to produce different sorts of
commands, but most importantly, to pass as
argument to util/add-depend.pl, which uses
this keyword as a "producer" for the
dependency lines.
If the config target doesn't define the 'makedep_scheme' attribute,
Configure tries to figure it out by looking for GCC compatible
compilers or for the 'makedepend' command.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/15006)
Diffstat (limited to 'util/add-depends.pl')
-rw-r--r-- | util/add-depends.pl | 64 |
1 files changed, 51 insertions, 13 deletions
diff --git a/util/add-depends.pl b/util/add-depends.pl index 4a0f1d5a76..f1454323c5 100644 --- a/util/add-depends.pl +++ b/util/add-depends.pl @@ -154,21 +154,58 @@ my %procedures = ( } return ($objfile, $depconv_cache{$line}) if defined $depconv_cache{$line}; - print STDERR "DEBUG[VMS C]: ignoring $objfile <- $line\n" + print STDERR "DEBUG[$producer]: ignoring $objfile <- $line\n" if $debug; return undef; }, 'VC' => sub { - # On Windows, with Microsoft Visual C the flags /Zs /showIncludes - # give us the necessary output to be able to create dependencies - # that nmake (or any 'make' implementation) should be able to read, - # with a bit of help. The output we're interested in looks like - # this (it always starts the same) + # With Microsoft Visual C the flags /Zs /showIncludes give us the + # necessary output to be able to create dependencies that nmake + # (or any 'make' implementation) should be able to read, with a + # bit of help. The output we're interested in looks something + # like this (it always starts the same) # # Note: including file: {whatever header file} # + # Since there's no object file name at all in that information, + # we must construct it ourselves. + + (my $objfile = shift) =~ s|\.d$|.obj|i; + my $line = shift; + + # There are also other lines mixed in, for example compiler + # warnings, so we simply discard anything that doesn't start with + # the Note: + + if (/^Note: including file: */) { + (my $tail = $') =~ s/\s*\R$//; + + # 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); + + 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[$producer]: ignoring $objfile <- $tail\n" + if $debug; + } + + return undef; + }, + 'embarcadero' => + sub { # With Embarcadero C++Builder's preprocessor (cpp32.exe) the -Hp # flag gives us the preprocessed output annotated with the following # note whenever a #include file is read: @@ -176,7 +213,7 @@ my %procedures = ( # Including ->->{whatever header file} # # where each "->" indicates the nesting level of the #include. The - # logic here is otherwise the same as the 'VC' case. + # logic here is otherwise the same as the 'VC' scheme. # # Since there's no object file name at all in that information, # we must construct it ourselves. @@ -188,13 +225,13 @@ my %procedures = ( # warnings, so we simply discard anything that doesn't start with # the Note: - if (/^Note: including file: */ or /^Including (->)*/) { + if (/^Including (->)*/) { (my $tail = $') =~ s/\s*\R$//; - # 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. C++Builder gives - # us relative paths when possible, so convert to absolute paths. + # C++Builder gives us relative paths when possible, so to + # remove system header dependencies, we convert them to + # absolute paths and check that they don't match $abs_srcdir + # or $abs_blddir, just as the 'VC' scheme. $tail = rel2abs($tail); unless (defined $depconv_cache{$tail}) { @@ -208,7 +245,7 @@ my %procedures = ( } return ($objfile, '"'.$depconv_cache{$tail}.'"') if defined $depconv_cache{$tail}; - print STDERR "DEBUG[VC]: ignoring $objfile <- $tail\n" + print STDERR "DEBUG[$producer]: ignoring $objfile <- $tail\n" if $debug; } @@ -220,6 +257,7 @@ my %continuations = ( 'makedepend' => "\\", 'VMS C' => "-", 'VC' => "\\", + 'embarcadero' => "\\", ); die "Producer unrecognised: $producer\n" |