CryptoPkg/Library/OpensslLib: Update process_files.pl INF generation

Update process_files.pl to generate all OpensslLib INF files.
* OpensslLib.inf
* OpensslLibAccel.inf
* OpensslLibCrypto.inf
* OpensslLibFull.inf
* OpensslLibFullAccel.inf

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyu1.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Christopher Zurcher <christopher.zurcher@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Yi Li <yi1.li@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
Yi Li 2022-10-18 13:10:55 +08:00 committed by mergify[bot]
parent 3b46a1e243
commit d79295b5c5
1 changed files with 87 additions and 6 deletions

View File

@ -15,6 +15,15 @@
# ./process_files.pl
# ./process_files.pl X64
# ./process_files.pl [Arch]
#
# Follow the command below to update the INF file:
# 1. OpensslLib.inf ,OpensslLibCrypto.inf and OpensslLibFull.inf
# ./process_files.pl
# 2. OpensslLibAccel.inf and OpensslLibFullAccel.inf
# ./process_files.pl X64
# ./process_files.pl X64Gcc
# ./process_files.pl IA32
# ./process_files.pl IA32Gcc
use strict;
use Cwd;
@ -79,6 +88,7 @@ my $inf_file;
my $OPENSSL_PATH;
my $uefi_config;
my $extension;
my $compile;
my $arch;
my @inf;
@ -90,31 +100,32 @@ BEGIN {
if (defined $arch) {
if (uc ($arch) eq "X64") {
$arch = "X64";
$inf_file = "OpensslLibX64.inf";
$uefi_config = "UEFI-x86_64";
$extension = "nasm";
$compile = "MSFT";
$comment_character = ";";
} elsif (uc ($arch) eq "X64GCC") {
$arch = "X64Gcc";
$inf_file = "OpensslLibX64Gcc.inf";
$uefi_config = "UEFI-x86_64-GCC";
$extension = "S";
$compile = "GCC";
$comment_character = "#";
} elsif (uc ($arch) eq "IA32") {
$arch = "IA32";
$inf_file = "OpensslLibIa32.inf";
$uefi_config = "UEFI-x86";
$extension = "nasm";
$compile = "MSFT";
$comment_character = ";";
} elsif (uc ($arch) eq "IA32GCC") {
$arch = "IA32Gcc";
$inf_file = "OpensslLibIa32Gcc.inf";
$uefi_config = "UEFI-x86-GCC";
$extension = "S";
$compile = "GCC";
$comment_character = "#";
} else {
die "Unsupported architecture \"" . $arch . "\"!";
}
$inf_file = "OpensslLibAccel.inf";
if ($extension eq "nasm") {
if (`nasm -v 2>&1`) {
#Presence of nasm executable will trigger inclusion of AVX instructions
@ -256,6 +267,7 @@ foreach my $f (@{$config{lib_defines}}) {
my @cryptofilelist = ();
my @sslfilelist = ();
my @ecfilelist = ();
my @asmfilelist = ();
my @asmbuild = ();
foreach my $product ((@{$unified_info{libraries}},
@ -286,10 +298,14 @@ foreach my $product ((@{$unified_info{libraries}},
$buildstring .= " ./$arch/$path$s.$extension";
make_path ("./$arch/$path");
push @asmbuild, "$buildstring\n";
push @asmfilelist, " $arch/$path$s.$extension\r\n";
push @asmfilelist, " $arch/$path$s.$extension |$compile\r\n";
}
next;
}
if ($s =~ "/ec/" || $s =~ "/sm2/") {
push @ecfilelist, ' $(OPENSSL_PATH)/' . $s . "\r\n";
next;
}
if ($product =~ "libssl") {
push @sslfilelist, ' $(OPENSSL_PATH)/' . $s . "\r\n";
next;
@ -323,6 +339,10 @@ foreach (@headers){
push @sslfilelist, ' $(OPENSSL_PATH)/' . $_ . "\r\n";
next;
}
if ($_ =~ "/ec/" || $_ =~ "/sm2/") {
push @ecfilelist, ' $(OPENSSL_PATH)/' . $_ . "\r\n";
next;
}
push @cryptofilelist, ' $(OPENSSL_PATH)/' . $_ . "\r\n";
}
@ -351,10 +371,18 @@ foreach (@inf) {
next;
}
if ( $_ =~ "# Autogenerated files list starts here" ) {
push @new_inf, $_, @asmfilelist, @cryptofilelist, @sslfilelist;
push @new_inf, $_, @cryptofilelist, @sslfilelist;
$subbing = 1;
next;
}
if (defined $arch) {
my $arch_asmfile_flag = "# Autogenerated " . $arch . " files list starts here";
if ($_ =~ $arch_asmfile_flag) {
push @new_inf, $_, @asmfilelist;
$subbing = 1;
next;
}
}
if ( $_ =~ "# Autogenerated files list ends here" ) {
push @new_inf, $_;
$subbing = 0;
@ -421,6 +449,59 @@ if (!defined $arch) {
print "Done!";
}
#
# Update OpensslLibFull.inf with autogenerated file list
#
if (!defined $arch) {
$inf_file = "OpensslLibFull.inf";
} else {
$inf_file = "OpensslLibFullAccel.inf";
}
# Read the contents of the inf file
@inf = ();
@new_inf = ();
open( FD, "<" . $inf_file ) ||
die "Cannot open \"" . $inf_file . "\"!";
@inf = (<FD>);
close(FD) ||
die "Cannot close \"" . $inf_file . "\"!";
$subbing = 0;
print "\n--> Updating $inf_file ... ";
foreach (@inf) {
if ( $_ =~ "# Autogenerated files list starts here" ) {
push @new_inf, $_, @cryptofilelist, @sslfilelist, @ecfilelist;
$subbing = 1;
next;
}
if (defined $arch) {
my $arch_asmfile_flag = "# Autogenerated " . $arch . " files list starts here";
if ($_ =~ $arch_asmfile_flag) {
push @new_inf, $_, @asmfilelist;
$subbing = 1;
next;
}
}
if ( $_ =~ "# Autogenerated files list ends here" ) {
push @new_inf, $_;
$subbing = 0;
next;
}
push @new_inf, $_
unless ($subbing);
}
$new_inf_file = $inf_file . ".new";
open( FD, ">" . $new_inf_file ) ||
die $new_inf_file;
print( FD @new_inf ) ||
die $new_inf_file;
close(FD) ||
die $new_inf_file;
rename( $new_inf_file, $inf_file ) ||
die "rename $inf_file";
print "Done!";
#
# Copy opensslconf.h and dso_conf.h generated from OpenSSL Configuration
#