public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Michael D Kinney" <michael.d.kinney@intel.com>
To: devel@edk2.groups.io
Cc: Yi Li <yi1.li@intel.com>, Jiewen Yao <jiewen.yao@intel.com>,
	Jian J Wang <jian.j.wang@intel.com>,
	Xiaoyu Lu <xiaoyu1.lu@intel.com>,
	Guomin Jiang <guomin.jiang@intel.com>,
	Christopher Zurcher <christopher.zurcher@microsoft.com>
Subject: [Patch v2 14/16] CryptoPkg/Library/OpensslLib: Update process_files.pl INF generation
Date: Thu, 20 Oct 2022 11:35:08 -0700	[thread overview]
Message-ID: <20221020183510.1799-15-michael.d.kinney@intel.com> (raw)
In-Reply-To: <20221020183510.1799-1-michael.d.kinney@intel.com>

From: Yi Li <yi1.li@intel.com>

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>
---
 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 = (<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
 #
-- 
2.37.1.windows.1


  parent reply	other threads:[~2022-10-20 18:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20 18:34 [Patch v2 00/16] CryptoPkg: Remove EC PCD and merge perf opt OpensslLibs Michael D Kinney
2022-10-20 18:34 ` [Patch v2 01/16] CryptoPkg: Document and disable deprecated crypto services Michael D Kinney
2022-10-20 18:34 ` [Patch v2 02/16] CryptoPkg/Library/BaseCryptLib: Add missing UNI file and fix format Michael D Kinney
2022-10-20 18:34 ` [Patch v2 03/16] CryptoPkg/Library/BaseCryptLib: Update internal functions/variables Michael D Kinney
2022-10-20 18:34 ` [Patch v2 04/16] CryptoPkg/Test/UnitTest/Library/BaseCryptLib: Unit test fixes Michael D Kinney
2022-10-20 18:34 ` [Patch v2 05/16] CryptoPkg/Library: Cleanup BaseCryptLib and TlsLib Michael D Kinney
2022-10-20 18:35 ` [Patch v2 06/16] CryptoPkg/Library/OpensslLib: Combine all performance optimized INFs Michael D Kinney
2022-10-20 18:35 ` [Patch v2 07/16] CryptoPkg/Library/OpensslLib: Produce consistent set of APIs Michael D Kinney
2022-10-20 18:35 ` [Patch v2 08/16] CryptoPkg/Library/OpensslLib: Remove PrintLib from INF files Michael D Kinney
2022-10-20 18:35 ` [Patch v2 09/16] CryptoPkg: Remove PcdOpensslEcEnabled from CryptoPkg.dec Michael D Kinney
2022-10-20 18:35 ` [Patch v2 10/16] CryptoPkg: Update DSC to improve CI test coverage Michael D Kinney
2022-10-20 18:35 ` [Patch v2 11/16] CryptoPkg: Fixed host-based unit tests Michael D Kinney
2022-10-20 18:35 ` [Patch v2 12/16] CryptoPkg: Add Readme.md Michael D Kinney
2022-10-20 18:35 ` [Patch v2 13/16] Revert "CryptoPkg: Update process_files.pl to auto add PCD config option" Michael D Kinney
2022-10-20 18:35 ` Michael D Kinney [this message]
2022-10-20 18:35 ` [Patch v2 15/16] CryptoPkg/Library/OpensslLib: Add generated flag to Accel INF Michael D Kinney
2022-10-20 18:35 ` [Patch v2 16/16] CryptoPkg/Library/OpensslLib: update auto-generated files Michael D Kinney
2022-10-24  3:52 ` [Patch v2 00/16] CryptoPkg: Remove EC PCD and merge perf opt OpensslLibs Yao, Jiewen
     [not found] ` <1720E4F0EDFC384F.808@groups.io>
2022-10-24  3:54   ` [edk2-devel] " Yao, Jiewen
2022-10-24  5:43     ` Michael D Kinney
2022-10-24  6:24       ` Yao, Jiewen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221020183510.1799-15-michael.d.kinney@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox