]> git.proxmox.com Git - mirror_edk2.git/blobdiff - CryptoPkg/Library/OpensslLib/process_files.pl
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / CryptoPkg / Library / OpensslLib / process_files.pl
index 42bff05fa629bd93340d467cde3b1e3809ad12c7..fba97e7c39a780cd775d45c23f7f9bd29502db4c 100755 (executable)
 #   ./process_files.pl\r
 #   ./process_files.pl X64\r
 #   ./process_files.pl [Arch]\r
+#\r
+# Follow the command below to update the INF file:\r
+# 1. OpensslLib.inf ,OpensslLibCrypto.inf and OpensslLibFull.inf\r
+# ./process_files.pl\r
+# 2. OpensslLibAccel.inf and OpensslLibFullAccel.inf\r
+# ./process_files.pl X64\r
+# ./process_files.pl X64Gcc\r
+# ./process_files.pl IA32\r
+# ./process_files.pl IA32Gcc\r
 \r
 use strict;\r
 use Cwd;\r
@@ -79,6 +88,7 @@ my $inf_file;
 my $OPENSSL_PATH;\r
 my $uefi_config;\r
 my $extension;\r
+my $compile;\r
 my $arch;\r
 my @inf;\r
 \r
@@ -90,19 +100,32 @@ BEGIN {
     if (defined $arch) {\r
         if (uc ($arch) eq "X64") {\r
             $arch = "X64";\r
-            $inf_file = "OpensslLibX64.inf";\r
             $uefi_config = "UEFI-x86_64";\r
             $extension = "nasm";\r
+            $compile = "MSFT";\r
             $comment_character = ";";\r
         } elsif (uc ($arch) eq "X64GCC") {\r
             $arch = "X64Gcc";\r
-            $inf_file = "OpensslLibX64Gcc.inf";\r
             $uefi_config = "UEFI-x86_64-GCC";\r
             $extension = "S";\r
+            $compile = "GCC";\r
+            $comment_character = "#";\r
+        } elsif (uc ($arch) eq "IA32") {\r
+            $arch = "IA32";\r
+            $uefi_config = "UEFI-x86";\r
+            $extension = "nasm";\r
+            $compile = "MSFT";\r
+            $comment_character = ";";\r
+        } elsif (uc ($arch) eq "IA32GCC") {\r
+            $arch = "IA32Gcc";\r
+            $uefi_config = "UEFI-x86-GCC";\r
+            $extension = "S";\r
+            $compile = "GCC";\r
             $comment_character = "#";\r
         } else {\r
             die "Unsupported architecture \"" . $arch . "\"!";\r
         }\r
+        $inf_file = "OpensslLibAccel.inf";\r
         if ($extension eq "nasm") {\r
             if (`nasm -v 2>&1`) {\r
                 #Presence of nasm executable will trigger inclusion of AVX instructions\r
@@ -169,7 +192,6 @@ BEGIN {
                 "no-dgram",\r
                 "no-dsa",\r
                 "no-dynamic-engine",\r
-                "no-ec",\r
                 "no-ec2m",\r
                 "no-engine",\r
                 "no-err",\r
@@ -245,6 +267,7 @@ foreach my $f (@{$config{lib_defines}}) {
 \r
 my @cryptofilelist = ();\r
 my @sslfilelist = ();\r
+my @ecfilelist = ();\r
 my @asmfilelist = ();\r
 my @asmbuild = ();\r
 foreach my $product ((@{$unified_info{libraries}},\r
@@ -275,10 +298,14 @@ foreach my $product ((@{$unified_info{libraries}},
                     $buildstring .= " ./$arch/$path$s.$extension";\r
                     make_path ("./$arch/$path");\r
                     push @asmbuild, "$buildstring\n";\r
-                    push @asmfilelist, "  $arch/$path$s.$extension\r\n";\r
+                    push @asmfilelist, "  $arch/$path$s.$extension  |$compile\r\n";\r
                 }\r
                 next;\r
             }\r
+            if ($s =~ "/ec/" || $s =~ "/sm2/") {\r
+                push @ecfilelist, '  $(OPENSSL_PATH)/' . $s . "\r\n";\r
+                next;\r
+            }\r
             if ($product =~ "libssl") {\r
                 push @sslfilelist, '  $(OPENSSL_PATH)/' . $s . "\r\n";\r
                 next;\r
@@ -312,6 +339,10 @@ foreach (@headers){
     push @sslfilelist, '  $(OPENSSL_PATH)/' . $_ . "\r\n";\r
     next;\r
   }\r
+  if ($_ =~ "/ec/" || $_ =~ "/sm2/") {\r
+    push @ecfilelist, '  $(OPENSSL_PATH)/' . $_ . "\r\n";\r
+    next;\r
+  }\r
   push @cryptofilelist, '  $(OPENSSL_PATH)/' . $_ . "\r\n";\r
 }\r
 \r
@@ -340,10 +371,18 @@ foreach (@inf) {
         next;\r
     }\r
     if ( $_ =~ "# Autogenerated files list starts here" ) {\r
-        push @new_inf, $_, @asmfilelist, @cryptofilelist, @sslfilelist;\r
+        push @new_inf, $_, @cryptofilelist, @sslfilelist;\r
         $subbing = 1;\r
         next;\r
     }\r
+    if (defined $arch) {\r
+        my $arch_asmfile_flag = "# Autogenerated " . $arch . " files list starts here";\r
+        if ($_ =~ $arch_asmfile_flag) {\r
+            push @new_inf, $_, @asmfilelist;\r
+            $subbing = 1;\r
+            next;\r
+        }\r
+    }\r
     if ( $_ =~ "# Autogenerated files list ends here" ) {\r
         push @new_inf, $_;\r
         $subbing = 0;\r
@@ -410,6 +449,59 @@ if (!defined $arch) {
     print "Done!";\r
 }\r
 \r
+#\r
+# Update OpensslLibFull.inf with autogenerated file list\r
+#\r
+if (!defined $arch) {\r
+    $inf_file = "OpensslLibFull.inf";\r
+} else {\r
+    $inf_file = "OpensslLibFullAccel.inf";\r
+}\r
+# Read the contents of the inf file\r
+@inf = ();\r
+@new_inf = ();\r
+open( FD, "<" . $inf_file ) ||\r
+    die "Cannot open \"" . $inf_file . "\"!";\r
+@inf = (<FD>);\r
+close(FD) ||\r
+    die "Cannot close \"" . $inf_file . "\"!";\r
+$subbing = 0;\r
+print "\n--> Updating $inf_file ... ";\r
+foreach (@inf) {\r
+    if ( $_ =~ "# Autogenerated files list starts here" ) {\r
+        push @new_inf, $_, @cryptofilelist, @sslfilelist, @ecfilelist;\r
+        $subbing = 1;\r
+        next;\r
+    }\r
+    if (defined $arch) {\r
+        my $arch_asmfile_flag = "# Autogenerated " . $arch . " files list starts here";\r
+        if ($_ =~ $arch_asmfile_flag) {\r
+            push @new_inf, $_, @asmfilelist;\r
+            $subbing = 1;\r
+            next;\r
+        }\r
+    }\r
+    if ( $_ =~ "# Autogenerated files list ends here" ) {\r
+        push @new_inf, $_;\r
+        $subbing = 0;\r
+        next;\r
+    }\r
+\r
+    push @new_inf, $_\r
+        unless ($subbing);\r
+}\r
+\r
+$new_inf_file = $inf_file . ".new";\r
+open( FD, ">" . $new_inf_file ) ||\r
+    die $new_inf_file;\r
+print( FD @new_inf ) ||\r
+    die $new_inf_file;\r
+close(FD) ||\r
+    die $new_inf_file;\r
+rename( $new_inf_file, $inf_file ) ||\r
+    die "rename $inf_file";\r
+print "Done!";\r
+\r
 #\r
 # Copy opensslconf.h and dso_conf.h generated from OpenSSL Configuration\r
 #\r