public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] UefiPayloadPkg:Add YAML support version configuration
@ 2023-05-05  6:27 kasimx.liu
  0 siblings, 0 replies; only message in thread
From: kasimx.liu @ 2023-05-05  6:27 UTC (permalink / raw)
  To: devel; +Cc: KasimX Liu, Guo Dong, Ray Ni, James Lu, Gua Guo

From: KasimX Liu <kasimx.liu@intel.com>

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4445

To record the default value of SpecRevision and Revision.

add '-st' command of input YAML setting file

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: James Lu <james.lu@intel.com>
Cc: Gua Guo <gua.guo@intel.com>
Signed-off-by: KasimX Liu <kasimx.liu@intel.com>
---
 UefiPayloadPkg/Settings/UplSettings.yaml | 11 ++++++++++
 UefiPayloadPkg/UniversalPayloadBuild.py  | 28 ++++++++++++++++++++++--
 2 files changed, 37 insertions(+), 2 deletions(-)
 create mode 100644 UefiPayloadPkg/Settings/UplSettings.yaml

diff --git a/UefiPayloadPkg/Settings/UplSettings.yaml b/UefiPayloadPkg/Settings/UplSettings.yaml
new file mode 100644
index 0000000000..959170ae76
--- /dev/null
+++ b/UefiPayloadPkg/Settings/UplSettings.yaml
@@ -0,0 +1,11 @@
+## @file
+# Set shell variable EDK_TOOL_PATH to this folder
+#
+# Copyright (c) Microsoft Corporation.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+{
+  'SpecRevision': '0x0070',
+  'Revision': '0x0000010105'
+}
diff --git a/UefiPayloadPkg/UniversalPayloadBuild.py b/UefiPayloadPkg/UniversalPayloadBuild.py
index 416946a431..a32c76a2da 100644
--- a/UefiPayloadPkg/UniversalPayloadBuild.py
+++ b/UefiPayloadPkg/UniversalPayloadBuild.py
@@ -13,6 +13,7 @@ import sys
 from   ctypes import *
 from Tools.ElfFv import ReplaceFv
 sys.dont_write_bytecode = True
+import re
 
 class UPLD_INFO_HEADER(LittleEndianStructure):
     _pack_ = 1
@@ -153,6 +154,18 @@ def main():
 
         return int('0x{0:02x}{1:02x}'.format(Major, Minor), 0)
 
+    def GetUplVerFile(Argument):
+      FilePath = open(os.path.abspath(Argument), 'r')
+      FileControl = FilePath.read()
+      SpecRevision = ""
+      Revision = ""
+      Rule1 = r"\{\n*.+: *'(?P<SpecRevision>.+)', *.+: '(?P<Revision>.+)'\n\}"
+      ModuleObjs = re.finditer(Rule1, FileControl, re.I|re.S)
+      for ModeObj in ModuleObjs:
+        SpecRevision = ModeObj.group("SpecRevision")
+        Revision = ModeObj.group("Revision")
+      return SpecRevision, Revision
+
     def Validate32BitInteger (Argument):
         try:
             Value = int (Argument, 0)
@@ -184,14 +197,25 @@ def main():
     parser.add_argument('-i', '--ImageId', type=str, help='Specify payload ID (16 bytes maximal).', default ='UEFI')
     parser.add_argument('-q', '--Quiet', action='store_true', help='Disable all build messages except FATAL ERRORS.')
     parser.add_argument("-p", "--pcd", action="append")
-    parser.add_argument("-s", "--SpecRevision", type=ValidateSpecRevision, default ='0.7', help='Indicates compliance with a revision of this specification in the BCD format.')
-    parser.add_argument("-r", "--Revision", type=Validate32BitInteger, default ='0x0000010105', help='Revision of the Payload binary. Major.Minor.Revision.Build')
+    group1 = parser.add_mutually_exclusive_group()
+    arg_a = group1.add_argument('-st',"--Settings",type=GetUplVerFile, default="UefiPayloadPkg\\Settings\\UplSettings.yaml", help='Get the UplSettings.yaml')
+    group1.add_argument('-s', "--SpecRevision", type=ValidateSpecRevision, default ='0.7', help='Indicates compliance with a revision of this specification in the BCD format.')
+    group2 = parser.add_mutually_exclusive_group()
+    group2.add_argument('-r', "--Revision", type=Validate32BitInteger, default ='0x0000010105', help='Revision of the Payload binary. Major.Minor.Revision.Build')
+    group2._group_actions.append(arg_a)
+
     parser.add_argument("-o", "--ProducerId", default ='INTEL', help='A null-terminated OEM-supplied string that identifies the payload producer (16 bytes maximal).')
     parser.add_argument("-e", "--BuildEntryOnly", action='store_true', help='Build UniversalPayload Entry file')
     parser.add_argument("-pb", "--PreBuildUplBinary", default=None, help='Specify the UniversalPayload file')
     parser.add_argument("-sk", "--SkipBuild", action='store_true', help='Skip UniversalPayload build')
     parser.add_argument("-af", "--AddFv", type=ValidateAddFv, action='append', help='Add or replace specific FV into payload, Ex: uefi_fv=XXX.fv')
     args = parser.parse_args()
+    SpecRevision, Revision= args.Settings
+    if SpecRevision != args.SpecRevision:
+        args.SpecRevision = SpecRevision
+    if Revision != args.Revision:
+        args.Revision = Revision
+    print(args)
 
     MultiFvList = []
     UniversalPayloadBinary = args.PreBuildUplBinary
-- 
2.39.1.windows.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-05-05  6:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-05  6:27 [PATCH] UefiPayloadPkg:Add YAML support version configuration kasimx.liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox