1
1
# ! /usr/bin/env perl
2
2
# -*- mode: perl; -*-
3
- # Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
3
+ # Copyright 2016-2022 The OpenSSL Project Authors. All Rights Reserved.
4
4
#
5
5
# Licensed under the Apache License 2.0 (the "License"). You may not use
6
6
# this file except in compliance with the License. You can obtain a copy
@@ -17,6 +17,7 @@ use lib "$FindBin::Bin/util/perl";
17
17
use File::Basename;
18
18
use File::Spec::Functions qw/ :DEFAULT abs2rel rel2abs splitdir/ ;
19
19
use File::Path qw/ mkpath/ ;
20
+ use File::Compare qw( compare_text) ;
20
21
use OpenSSL::fallback " $FindBin::Bin /external/perl/MODULES.txt" ;
21
22
use OpenSSL::Glob;
22
23
use OpenSSL::Template;
@@ -2214,9 +2215,10 @@ if ($builder eq "unified") {
2214
2215
\$ attributes{depends}, $ +{ATTRIBS},
2215
2216
tokenize($expand_variables ->($ +{VALUE})))
2216
2217
if !@skip || $skip [$ #skip] > 0; },
2217
- qr/^\s * GENERATE ${index_re} \s * = \s * ${value_re} \s * $ /x
2218
+ qr/^\s * GENERATE ${index_re} ${attribs_re} \s * = \s * ${value_re} \s * $ /x
2218
2219
=> sub { $push_to ->(\% generate, $expand_variables ->($ +{INDEX}),
2219
- undef, undef, $expand_variables ->($ +{VALUE}))
2220
+ \$ attributes{generate}, $ +{ATTRIBS},
2221
+ $expand_variables ->($ +{VALUE}))
2220
2222
if !@skip || $skip [$ #skip] > 0; },
2221
2223
qr/^\s * (?:\# .*)? $ /x => sub { },
2222
2224
"OTHERWISE" => sub { die "Something wrong with this line:\n $_ \n at $sourced /$f " },
@@ -2384,6 +2386,10 @@ EOF
2384
2386
$check_generate {$ddest }-> {$generator [0]}++;
2385
2387
2386
2388
$unified_info {generate }-> {$ddest } = [ @generator ];
2389
+ # Fix up associated attributes
2390
+ $unified_info {attributes }-> {generate }-> {$ddest } =
2391
+ $attributes {generate }-> {$dest }-> {$gen }
2392
+ if defined $attributes {generate }-> {$dest }-> {$gen };
2387
2393
}
2388
2394
2389
2395
foreach (keys %depends ) {
@@ -2774,7 +2780,7 @@ EOF
2774
2780
keys %{$unified_info {htmldocs } // {}}),
2775
2781
(map { @{$unified_info {mandocs }-> {$_ } // []} }
2776
2782
keys %{$unified_info {mandocs } // {}}) ] );
2777
- foreach my $type (keys %loopinfo ) {
2783
+ foreach my $type (sort keys %loopinfo ) {
2778
2784
foreach my $product (@{$loopinfo {$type }}) {
2779
2785
my %dirs = ();
2780
2786
my $pd = dirname($product );
@@ -2795,7 +2801,7 @@ EOF
2795
2801
push @{$unified_info {dirinfo }-> {$d }-> {deps }}, $_
2796
2802
if $d ne $pd ;
2797
2803
}
2798
- foreach (keys %dirs ) {
2804
+ foreach (sort keys %dirs ) {
2799
2805
push @{$unified_info {dirinfo }-> {$_ }-> {products }-> {$type }},
2800
2806
$product ;
2801
2807
}
@@ -2830,7 +2836,6 @@ my %template_vars = (
2830
2836
user_crossable => \@user_crossable ,
2831
2837
);
2832
2838
my $configdata_outname = ' configdata.pm' ;
2833
- print " Creating $configdata_outname \n " ;
2834
2839
open CONFIGDATA, " >$configdata_outname .new"
2835
2840
or die " Trying to create $configdata_outname .new: $! " ;
2836
2841
my $configdata_tmplname = cleanfile($srcdir , " configdata.pm.in" , $blddir );
@@ -2846,19 +2851,60 @@ $configdata_tmpl->fill_in(
2846
2851
] }
2847
2852
) or die $Text::Template::ERROR ;
2848
2853
close CONFIGDATA;
2849
- rename " $configdata_outname .new" , $configdata_outname ;
2850
- if ($builder_platform eq ' unix' ) {
2851
- my $mode = (0755 & ~umask );
2852
- chmod $mode , ' configdata.pm'
2853
- or warn sprintf (" WARNING: Couldn't change mode for 'configdata.pm' to 0%03o: %s \n " ,$mode ,$! );
2854
- }
2855
-
2856
- print " Running $configdata_outname \n " ;
2857
- my $perlcmd = (quotify(" maybeshell" , $config {PERL }))[0];
2858
- my $cmd = " $perlcmd $configdata_outname " ;
2859
- # print STDERR "DEBUG[run_dofile]: \$cmd = $cmd\n";
2860
- system ($cmd );
2861
- exit 1 if $? != 0;
2854
+
2855
+ # When using stat() on Windows, we can get it to perform better by avoid some
2856
+ # data. This doesn't affect the mtime field, so we're not losing anything...
2857
+ ${^WIN32_SLOPPY_STAT} = 1;
2858
+
2859
+ my $update_configdata = 0;
2860
+ my $run_configdata = 0;
2861
+ if (-f $configdata_outname ) {
2862
+ my $Configure_mtime = (stat ($0 ))[9];
2863
+ my $configdata_mtime = (stat ($configdata_outname ))[9];
2864
+
2865
+ # If this script was updated after the last configdata.pm, or if
2866
+ # configdata.pm.new differs from configdata.pm, we update configdata.pm
2867
+ if ($configdata_mtime < $Configure_mtime
2868
+ || compare_text(" $configdata_outname .new" , $configdata_outname ) != 0) {
2869
+ $update_configdata = 1;
2870
+ } else {
2871
+ # If nothing has changed, let's just drop the new one and pretend
2872
+ # like nothing happened
2873
+ unlink " $configdata_outname .new" ;
2874
+
2875
+ # We still run configdata.pm if one of the build file (Makefile) or
2876
+ # the configuration header file are missing
2877
+ $run_configdata =
2878
+ !( -f $target {build_file } )
2879
+ || !( -f catfile(' include' , ' openssl' , ' configuration.h' ) );
2880
+ }
2881
+ } else {
2882
+ $update_configdata = 1;
2883
+ }
2884
+
2885
+ if ($update_configdata ) {
2886
+ # If something did change, or there was no previous configdata.pm, we
2887
+ # rename the new one, set permissions as needed, and run it.
2888
+ rename " $configdata_outname .new" , $configdata_outname ;
2889
+ if ($builder_platform eq ' unix' ) {
2890
+ my $mode = (0755 & ~umask );
2891
+ chmod $mode , ' configdata.pm'
2892
+ or warn sprintf (" WARNING: Couldn't change mode for 'configdata.pm' to 0%03o: %s \n " ,$mode ,$! );
2893
+ }
2894
+ $run_configdata = 1;
2895
+ print " Created $configdata_outname \n " ;
2896
+ }
2897
+
2898
+ if ($run_configdata ) {
2899
+ print " Running $configdata_outname \n " ;
2900
+ my $perlcmd = (quotify(" maybeshell" , $config {PERL }))[0];
2901
+ my $cmd = " $perlcmd $configdata_outname " ;
2902
+ # print STDERR "DEBUG[run_dofile]: \$cmd = $cmd\n";
2903
+ system ($cmd );
2904
+ exit 1 if $? != 0;
2905
+ } else {
2906
+ print " No changes in $configdata_outname , no need to run it\n " ;
2907
+ }
2862
2908
2863
2909
$SIG {__DIE__ } = $orig_death_handler ;
2864
2910
0 commit comments