diff options
author | Richard Levitte <levitte@openssl.org> | 2023-06-02 14:32:07 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2023-06-08 07:53:10 +0200 |
commit | b684ee2ce4bbf2c877d2cdc39e095d52ea3fe2a3 (patch) | |
tree | ffac760438fbbe091d921e0637029b43b78d8715 /Configurations/unix-Makefile.tmpl | |
parent | b8fa5be5506e43b405c9a3ecc3d65c77044777be (diff) |
build.info: Introduce special syntax for dependencies on script modules
The DEPEND statement, when applied on files generated with GENERATE, may
be used to specify script modules that the template to be generated from
depends on. In short, this sort of depend:
DEPEND[generated]=util/perl/OpenSSL/something.pm
... would generate a perl run that has the inclusion directory
'util/perl/OpenSSL' and 'something' as the module to be loaded. However,
the package name for this module is 'OpenSSL::something', so to load it the
way it's expected, the inclusion directory should be 'util/perl', and the
module to be loaded should be specified as 'OpenSSL/something' (to be
massaged into a proper module name by the build file template).
To allow this, we introduce a file syntax, where a single '|' is used as a
directory separator, to delineate what part should be used as the inclustion
directory, and which part the module name to be loaded should be derived
from:
DEPEND[generated]=util/perl|OpenSSL/something.pm
Fixes #21112
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21117)
Diffstat (limited to 'Configurations/unix-Makefile.tmpl')
-rw-r--r-- | Configurations/unix-Makefile.tmpl | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/Configurations/unix-Makefile.tmpl b/Configurations/unix-Makefile.tmpl index 89f9b81e72..f852acf513 100644 --- a/Configurations/unix-Makefile.tmpl +++ b/Configurations/unix-Makefile.tmpl @@ -1641,12 +1641,44 @@ EOF my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, "util", "dofile.pl")), rel2abs($config{builddir})); - my @perlmodules = ( 'configdata.pm', - grep { $_ =~ m|\.pm$| } @{$args{deps}} ); - my %perlmoduleincs = map { '"-I'.dirname($_).'"' => 1 } @perlmodules; - $deps = join(' ', $deps, compute_platform_depends(@perlmodules)); - @perlmodules = map { "-M".basename($_, '.pm') } @perlmodules; - my $perlmodules = join(' ', '', sort keys %perlmoduleincs, @perlmodules); + my @perlmodules = (); + my %perlmoduleincs = (); + my %perlmoduledeps = (); + foreach my $x (('configdata.pm', @{$args{deps}})) { + # Compute (i)nclusion directory, (m)odule name and (d)ependency + my $i, $m, $d; + if ($x =~ /\|/) { + $i = $`; + $d = $'; + + # Massage the module part to become a real perl module spec + $m = $d; + $m =~ s|\.pm$||; + # Directory specs are :: in perl package names + $m =~ s|/|::|g; + + # Full file name of the dependency + $d = catfile($i, $d) if $i; + } elsif ($x =~ /\.pm$/) { + $i = dirname($x); + $m = basename($x, '.pm'); + $d = $x; + } else { + # All other dependencies are simply collected + $d = $x; + } + push @perlmodules, '"-M'.$m.'"' if $m; + $perlmoduledeps{$d} = 1; + $perlmoduleincs{'"-I'.$i.'"'} = 1 if $i; + } + + # Because of the special treatment of dependencies, we need to + # recompute $deps completely + my $deps + = join(" ", compute_platform_depends(@{$args{generator_deps}}, + sort keys %perlmoduledeps)); + my $perlmodules = join(' ', '', ( sort keys %perlmoduleincs ), @perlmodules); + return <<"EOF"; $args{src}: $gen0 $deps \$(PERL)$perlmodules "$dofile" "-o$target{build_file}" $gen0$gen_args > \$@ |