From 75d47db49d41176d1f9a363f80e5a45e834563b8 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Sat, 3 Nov 2018 18:38:04 +0100 Subject: [PATCH] Simplify the processing of skipped source directories We kept a number of arrays of directory names to keep track of exactly which directories to look for build.info. Some of these had the extra function to hold the directories to actually build. With the added SUBDIRS keyword, these arrays are no longer needed. The logic for skipping certain directories needs to be kept, though. That is now very much simplified, and is made opportunistic. Reviewed-by: Tim Hudson (Merged from https://github.com/openssl/openssl/pull/7558) --- Configure | 63 ++++++++++++++++++++--------------------------- build.info | 2 ++ crypto/build.info | 2 ++ 3 files changed, 31 insertions(+), 36 deletions(-) diff --git a/Configure b/Configure index f596b1892f..94e48b4113 100755 --- a/Configure +++ b/Configure @@ -298,21 +298,6 @@ $config{libdir}=""; my $auto_threads=1; # enable threads automatically? true by default my $default_ranlib; -# Top level directories to build -$config{dirs} = [ "crypto", "ssl", "engines", "apps", "test", "util", "tools", "fuzz" ]; -# crypto/ subdirectories to build -$config{sdirs} = [ - "objects", - "md2", "md4", "md5", "sha", "mdc2", "hmac", "ripemd", "whrlpool", "poly1305", "blake2", "siphash", "sm3", - "des", "aes", "rc2", "rc4", "rc5", "idea", "aria", "bf", "cast", "camellia", "seed", "sm4", "chacha", "modes", - "bn", "ec", "rsa", "dsa", "dh", "sm2", "dso", "engine", - "buffer", "bio", "stack", "lhash", "rand", "err", - "evp", "asn1", "pem", "x509", "x509v3", "conf", "txt_db", "pkcs7", "pkcs12", "comp", "ocsp", "ui", - "cms", "ts", "srp", "gmac", "cmac", "ct", "async", "kdf", "store" - ]; -# test/ subdirectories to build -$config{tdirs} = [ "ossl_shim" ]; - # Known TLS and DTLS protocols my @tls = qw(ssl3 tls1 tls1_1 tls1_2 tls1_3); my @dtls = qw(dtls1 dtls1_2); @@ -1171,6 +1156,19 @@ foreach (keys %user) { # Allow overriding the build file name $config{build_file} = env('BUILDFILE') || $target{build_file} || "Makefile"; +###################################################################### +# Build up information for skipping certain directories depending on disabled +# features, as well as setting up macros for disabled features. + +# This is a tentative database of directories to skip. Some entries may not +# correspond to anything real, but that's ok, they will simply be ignored. +# The actual processing of these entries is done in the build.info lookup +# loop further down. +# +# The key is a Unix formated path in the source tree, the value is an index +# into %disabled_info, so any existing path gets added to a corresponding +# 'skipped' entry in there with the list of skipped directories. +my %skipdir = (); my %disabled_info = (); # For configdata.pm foreach my $what (sort keys %disabled) { $config{options} .= " no-$what"; @@ -1179,32 +1177,18 @@ foreach my $what (sort keys %disabled) { 'dynamic-engine', 'makedepend', 'zlib-dynamic', 'zlib', 'sse2' )) { (my $WHAT = uc $what) =~ s|-|_|g; - - # Fix up C macro end names - $WHAT = "RMD160" if $what eq "ripemd"; + my $skipdir = $what; # fix-up crypto/directory name(s) - $what = "ripemd" if $what eq "rmd160"; - $what = "whrlpool" if $what eq "whirlpool"; + $skipdir = "ripemd" if $what eq "rmd160"; + $skipdir = "whrlpool" if $what eq "whirlpool"; my $macro = $disabled_info{$what}->{macro} = "OPENSSL_NO_$WHAT"; + push @{$config{openssl_feature_defines}}, $macro; - if ((grep { $what eq $_ } @{$config{sdirs}}) - && $what ne 'async' && $what ne 'err') { - @{$config{sdirs}} = grep { $what ne $_} @{$config{sdirs}}; - $disabled_info{$what}->{skipped} = [ catdir('crypto', $what) ]; - - if ($what ne 'engine') { - push @{$config{openssl_feature_defines}}, $macro; - } else { - @{$config{dirs}} = grep !/^engines$/, @{$config{dirs}}; - push @{$disabled_info{engine}->{skipped}}, catdir('engines'); - push @{$config{openssl_feature_defines}}, $macro; - } - } else { - push @{$config{openssl_feature_defines}}, $macro; - } - + $skipdir{engines} = $what if $what eq 'engine'; + $skipdir{"crypto/$skipdir"} = $what + unless $what eq 'async' || $what eq 'err'; } } @@ -1685,6 +1669,13 @@ if ($builder eq "unified") { my $sourced = catdir($srcdir, @curd); my $buildd = catdir($blddir, @curd); + my $unixdir = join('/', @curd); + if (exists $skipdir{$unixdir}) { + my $what = $skipdir{$unixdir}; + push @{$disabled_info{$what}->{skipped}}, catdir(@curd); + next; + } + mkpath($buildd); my $f = 'build.info'; diff --git a/build.info b/build.info index 9dffdd5b35..53629c40eb 100644 --- a/build.info +++ b/build.info @@ -1,3 +1,5 @@ +# Note that some of these directories are filtered in Configure. Look for +# %skipdir there for further explanations. SUBDIRS=crypto ssl apps test util tools fuzz engines {- diff --git a/crypto/build.info b/crypto/build.info index 71e1110f9d..a8b24977da 100644 --- a/crypto/build.info +++ b/crypto/build.info @@ -1,3 +1,5 @@ +# Note that these directories are filtered in Configure. Look for %skipdir +# there for further explanations. SUBDIRS=objects buffer bio stack lhash rand evp asn1 pem x509 x509v3 conf \ txt_db pkcs7 pkcs12 ui kdf store \ md2 md4 md5 sha mdc2 hmac ripemd whrlpool poly1305 blake2 \ -- 2.34.1