Commit 75d47db4 authored by Richard Levitte's avatar Richard Levitte
Browse files

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: default avatarTim Hudson <tjh@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7558)
parent e0bf7c01
Loading
Loading
Loading
Loading
+27 −36
Original line number Original line Diff line number Diff line
@@ -298,21 +298,6 @@ $config{libdir}="";
my $auto_threads=1;    # enable threads automatically? true by default
my $auto_threads=1;    # enable threads automatically? true by default
my $default_ranlib;
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
# Known TLS and DTLS protocols
my @tls = qw(ssl3 tls1 tls1_1 tls1_2 tls1_3);
my @tls = qw(ssl3 tls1 tls1_1 tls1_2 tls1_3);
my @dtls = qw(dtls1 dtls1_2);
my @dtls = qw(dtls1 dtls1_2);
@@ -1171,6 +1156,19 @@ foreach (keys %user) {
# Allow overriding the build file name
# Allow overriding the build file name
$config{build_file} = env('BUILDFILE') || $target{build_file} || "Makefile";
$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
my %disabled_info = ();         # For configdata.pm
foreach my $what (sort keys %disabled) {
foreach my $what (sort keys %disabled) {
    $config{options} .= " no-$what";
    $config{options} .= " no-$what";
@@ -1179,32 +1177,18 @@ foreach my $what (sort keys %disabled) {
                                'dynamic-engine', 'makedepend',
                                'dynamic-engine', 'makedepend',
                                'zlib-dynamic', 'zlib', 'sse2' )) {
                                'zlib-dynamic', 'zlib', 'sse2' )) {
        (my $WHAT = uc $what) =~ s|-|_|g;
        (my $WHAT = uc $what) =~ s|-|_|g;

        my $skipdir = $what;
        # Fix up C macro end names
        $WHAT = "RMD160" if $what eq "ripemd";


        # fix-up crypto/directory name(s)
        # fix-up crypto/directory name(s)
        $what = "ripemd" if $what eq "rmd160";
        $skipdir = "ripemd" if $what eq "rmd160";
        $what = "whrlpool" if $what eq "whirlpool";
        $skipdir = "whrlpool" if $what eq "whirlpool";


        my $macro = $disabled_info{$what}->{macro} = "OPENSSL_NO_$WHAT";
        my $macro = $disabled_info{$what}->{macro} = "OPENSSL_NO_$WHAT";

        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;
        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 $sourced = catdir($srcdir, @curd);
        my $buildd = catdir($blddir, @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);
        mkpath($buildd);


        my $f = 'build.info';
        my $f = 'build.info';
+2 −0
Original line number Original line Diff line number Diff line
# 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
SUBDIRS=crypto ssl apps test util tools fuzz engines


{-
{-
+2 −0
Original line number Original line Diff line number Diff line
# 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 \
SUBDIRS=objects buffer bio stack lhash rand evp asn1 pem x509 x509v3 conf \
        txt_db pkcs7 pkcs12 ui kdf store \
        txt_db pkcs7 pkcs12 ui kdf store \
        md2 md4 md5 sha mdc2 hmac ripemd whrlpool poly1305 blake2 \
        md2 md4 md5 sha mdc2 hmac ripemd whrlpool poly1305 blake2 \