Add newguid.bat/sh to update jiteeversionguid.h (#88022)
authorEgor Bogatov <egorbo@gmail.com>
Mon, 26 Jun 2023 22:42:28 +0000 (00:42 +0200)
committerGitHub <noreply@github.com>
Mon, 26 Jun 2023 22:42:28 +0000 (00:42 +0200)
src/coreclr/tools/Common/JitInterface/ThunkGenerator/Program.cs
src/coreclr/tools/Common/JitInterface/ThunkGenerator/gen.bat
src/coreclr/tools/Common/JitInterface/ThunkGenerator/gen.sh

index b28a018..1f0362e 100644 (file)
@@ -8,6 +8,7 @@ using System.Diagnostics;
 using System.IO;
 using System.Linq;
 using System.Text;
+using System.Text.RegularExpressions;
 using System.Threading.Tasks;
 
 namespace Thunkerator
@@ -633,6 +634,28 @@ public:
                                 wrappedObjectName: "original_ICorJitInfo");
         }
 
+        private static void GenerateNewJitEEVersion(string file)
+        {
+            if (!File.Exists(file))
+                throw new FileNotFoundException(file);
+
+            Guid newGuid = Guid.NewGuid();
+            string[] hex = newGuid.ToString("X").Replace("{", "").Replace("}", "").Split(',');
+
+            string newGuidStr = $$"""
+constexpr GUID JITEEVersionIdentifier = { /* {{newGuid:D}} */
+    {{hex[0]}},
+    {{hex[1]}},
+    {{hex[2]}},
+    {{{hex[3]}}, {{hex[4]}}, {{hex[5]}}, {{hex[6]}}, {{hex[7]}}, {{hex[8]}}, {{hex[9]}}, {{hex[10]}}}
+  };
+""";
+            string pattern = @"constexpr GUID JITEEVersionIdentifier = .*\n.*\n.*\n.*\n.*\n.*;";
+            string output = Regex.Replace(File.ReadAllText(file), pattern, newGuidStr);
+            File.WriteAllText(file, output);
+            Console.WriteLine($"Updated to {newGuid}");
+        }
+
         private static void Main(string[] args)
         {
             if (args.Length == 0)
@@ -640,11 +663,22 @@ public:
                 Console.WriteLine("ThunkGenerator - Generate thunks for the jit interface and for defining the set of instruction sets supported by the runtime, JIT, and crossgen2. Call by using the gen scripts which are aware of the right set of files generated and command line args.");
                 return;
             }
-            if (args[0] == "InstructionSetGenerator")
+
+            if (args[0] == "NewJITEEVersion")
+            {
+                if (args.Length != 2)
+                {
+                    Console.WriteLine("Incorrect number of arguments specified for NewJITEEVersion");
+                    return;
+                }
+                GenerateNewJitEEVersion(args[1]);
+            }
+            else if (args[0] == "InstructionSetGenerator")
             {
                 if (args.Length != 7)
                 {
                     Console.WriteLine("Incorrect number of files specified for generation");
+                    return;
                 }
                 InstructionSetGenerator generator = new InstructionSetGenerator();
                 if (!generator.ParseInput(new StreamReader(args[1])))
@@ -685,6 +719,7 @@ public:
                 if (args.Length != 8)
                 {
                     Console.WriteLine("Incorrect number of files specified for generation");
+                    return;
                 }
 
                 IEnumerable<FunctionDecl> functions = ParseInput(new StreamReader(args[0]));
index cd59f14..a77ea5c 100644 (file)
@@ -1,4 +1,5 @@
 pushd %~dp0
 call ..\..\..\..\..\..\dotnet.cmd run -- ThunkInput.txt ..\CorInfoImpl_generated.cs ..\..\..\aot\jitinterface\jitinterface_generated.h ..\..\..\..\jit\ICorJitInfo_names_generated.h ..\..\..\..\jit\ICorJitInfo_wrapper_generated.hpp ..\..\..\..\inc\icorjitinfoimpl_generated.h ..\..\..\..\tools\superpmi\superpmi-shim-counter\icorjitinfo_generated.cpp ..\..\..\..\tools\superpmi\superpmi-shim-simple\icorjitinfo_generated.cpp
 call ..\..\..\..\..\..\dotnet.cmd run -- InstructionSetGenerator InstructionSetDesc.txt ..\..\Internal\Runtime\ReadyToRunInstructionSet.cs ..\..\Internal\Runtime\ReadyToRunInstructionSetHelper.cs ..\CorInfoInstructionSet.cs ..\..\..\..\inc\corinfoinstructionset.h ..\..\..\..\inc\readytoruninstructionset.h
+call ..\..\..\..\..\..\dotnet.cmd run -- NewJITEEVersion ..\..\..\..\inc\jiteeversionguid.h
 popd
index a582087..ddc4032 100755 (executable)
@@ -2,3 +2,4 @@
 cd "$(dirname ${BASH_SOURCE[0]})"
 ../../../../../../dotnet.sh run -- ThunkInput.txt ../CorInfoImpl_generated.cs ../../../aot/jitinterface/jitinterface_generated.h ../../../../jit/ICorJitInfo_names_generated.h ../../../../jit/ICorJitInfo_wrapper_generated.hpp ../../../../inc/icorjitinfoimpl_generated.h ../../../../tools/superpmi/superpmi-shim-counter/icorjitinfo_generated.cpp ../../../../tools/superpmi/superpmi-shim-simple/icorjitinfo_generated.cpp
 ../../../../../../dotnet.sh run -- InstructionSetGenerator InstructionSetDesc.txt ../../Internal/Runtime/ReadyToRunInstructionSet.cs ../../Internal/Runtime/ReadyToRunInstructionSetHelper.cs ../CorInfoInstructionSet.cs ../../../../inc/corinfoinstructionset.h ../../../../inc/readytoruninstructionset.h
+../../../../../../dotnet.sh run -- NewJITEEVersion ../../../../inc/jiteeversionguid.h