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 | |
parent | Modify ENGINE_pkey_asn1_find_str() to use a read lock instead of a write (diff) | |
download | openssl-b684ee2ce4bbf2c877d2cdc39e095d52ea3fe2a3.tar.xz openssl-b684ee2ce4bbf2c877d2cdc39e095d52ea3fe2a3.zip |
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')
-rw-r--r-- | Configurations/descrip.mms.tmpl | 46 | ||||
-rw-r--r-- | Configurations/unix-Makefile.tmpl | 44 | ||||
-rw-r--r-- | Configurations/windows-makefile.tmpl | 44 |
3 files changed, 115 insertions, 19 deletions
diff --git a/Configurations/descrip.mms.tmpl b/Configurations/descrip.mms.tmpl index ce74b3703f..b6e6eb4d60 100644 --- a/Configurations/descrip.mms.tmpl +++ b/Configurations/descrip.mms.tmpl @@ -1056,16 +1056,48 @@ 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; + 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; + } + my @decc_include_data = make_decc_include_files(dirname($args{src}), dirname($gen0)); my $decc_include_scripture = pop @decc_include_data; - $deps = join(' ', $deps, @decc_include_data, - compute_platform_depends(@perlmodules)); - @perlmodules = map { '"-M'.basename($_, '.pm').'"' } @perlmodules; - my $perlmodules = join(' ', '', sort keys %perlmoduleincs, @perlmodules); + # Because of the special treatment of dependencies, we need to + # recompute $deps completely + my $deps + = join(" ", @decc_include_data, + compute_platform_depends(@{$args{generator_deps}}, + sort keys %perlmoduledeps)); + my $perlmodules = join(' ', '', ( sort keys %perlmoduleincs ), @perlmodules); + return <<"EOF"; $args{src} : $gen0 $deps 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 > \$@ diff --git a/Configurations/windows-makefile.tmpl b/Configurations/windows-makefile.tmpl index 9250b989ca..c05d03f369 100644 --- a/Configurations/windows-makefile.tmpl +++ b/Configurations/windows-makefile.tmpl @@ -790,12 +790,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 > \$@ |