From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web11.1060.1666290939355166472 for ; Thu, 20 Oct 2022 11:35:40 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Rli7J9ZU; spf=pass (domain: intel.com, ip: 134.134.136.65, mailfrom: michael.d.kinney@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666290939; x=1697826939; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5UsfQi6jBQ0yWb6b1NFep2baIcOOtuAne00ZbtJYq7w=; b=Rli7J9ZUMe8Y5xwYtiaZtcGThyqdOHNTBEBCJhfdpc92WLC5sNXsNi3r PKnkRdYgo1Zfk1y4a9PF9NRfj2TQQ70x1AYosubDxV8nnLBD4LQj0C9bb 2shSUFglbOHwSZNzRxei8kv66GyBpOuW1IAv3THBaD2XiULQG927af0qh voYi7pqMRkk3UCGHjF7zVnix1gkczdNJszICoI8MUlktavuy3r6bZcuTq /mmXzz1snPN6XlqquM9UEAlw0GYC5KbEEmcrZ5bKcef5OH9NJqDRRW+de Vj1uzGuYbvO6dVTQilpcnlZ4pvvqXTXbmuNkyIQAEiEU42oYvgd6BHF2B A==; X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="308485579" X-IronPort-AV: E=Sophos;i="5.95,199,1661842800"; d="scan'208";a="308485579" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2022 11:35:37 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10506"; a="632427863" X-IronPort-AV: E=Sophos;i="5.95,199,1661842800"; d="scan'208";a="632427863" Received: from mdkinney-mobl2.amr.corp.intel.com ([10.212.188.143]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2022 11:35:37 -0700 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Yi Li , Jiewen Yao , Jian J Wang , Xiaoyu Lu , Guomin Jiang , Christopher Zurcher Subject: [Patch v2 14/16] CryptoPkg/Library/OpensslLib: Update process_files.pl INF generation Date: Thu, 20 Oct 2022 11:35:08 -0700 Message-Id: <20221020183510.1799-15-michael.d.kinney@intel.com> X-Mailer: git-send-email 2.37.1.windows.1 In-Reply-To: <20221020183510.1799-1-michael.d.kinney@intel.com> References: <20221020183510.1799-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Yi Li Update process_files.pl to generate all OpensslLib INF files. * OpensslLib.inf * OpensslLibAccel.inf * OpensslLibCrypto.inf * OpensslLibFull.inf * OpensslLibFullAccel.inf Cc: Jiewen Yao Cc: Jian J Wang Cc: Xiaoyu Lu Cc: Guomin Jiang Cc: Christopher Zurcher Cc: Michael D Kinney Signed-off-by: Yi Li --- CryptoPkg/Library/OpensslLib/process_files.pl | 93 +++++++++++++++++-- 1 file changed, 87 insertions(+), 6 deletions(-) diff --git a/CryptoPkg/Library/OpensslLib/process_files.pl b/CryptoPkg/Library/OpensslLib/process_files.pl index 7e18c9f52d35..fba97e7c39a7 100755 --- a/CryptoPkg/Library/OpensslLib/process_files.pl +++ b/CryptoPkg/Library/OpensslLib/process_files.pl @@ -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 = (); +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 # -- 2.37.1.windows.1