[edk2-devel] [PATCH] UefiPayloadPkg: Add the capability to override pcd when build the payload.

Yuanhao Xie posted 1 patch 2 weeks, 4 days ago
Failed in applying to current master (apply log)
UefiPayloadPkg/UniversalPayloadBuild.py | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)

[edk2-devel] [PATCH] UefiPayloadPkg: Add the capability to override pcd when build the payload.

Posted by Yuanhao Xie 2 weeks, 4 days ago
Add the capability to override pcd when building the payload, one can use
'--pcd a=b' to pass the argument.

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
---
 UefiPayloadPkg/UniversalPayloadBuild.py | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/UefiPayloadPkg/UniversalPayloadBuild.py b/UefiPayloadPkg/UniversalPayloadBuild.py
index e624ec5874..c7f31f5089 100644
--- a/UefiPayloadPkg/UniversalPayloadBuild.py
+++ b/UefiPayloadPkg/UniversalPayloadBuild.py
@@ -50,7 +50,7 @@ def RunCommand(cmd):
         print("- Failed - error happened when run command: %s"%cmd)
         raise Exception("ERROR: when run command: %s"%cmd)
 
-def BuildUniversalPayload(Args, MacroList):
+def BuildUniversalPayload(Args, MacroList, PcdList):
     BuildTarget = Args.Target
     ToolChain = Args.ToolChain
     ElfToolChain = 'CLANGDWARF'
@@ -77,18 +77,23 @@ def BuildUniversalPayload(Args, MacroList):
     Defines = ""
     for key in MacroList:
         Defines +=" -D {0}={1}".format(key, MacroList[key])
+    Pcd = ""
+    for key in PcdList:
+        Pcd +=" --pcd {0}={1}".format(key, PcdList[key])
 
     #
     # Building DXE core and DXE drivers as DXEFV.
     #
     BuildPayload = f"build -p {DscPath} -b {BuildTarget} -a X64 -t {ToolChain} -y {PayloadReportPath}"
     BuildPayload += Defines
+    BuildPayload += Pcd
     RunCommand(BuildPayload)
     #
     # Building Universal Payload entry.
     #
     BuildModule = f"build -p {DscPath} -b {BuildTarget} -a X64 -m {EntryModuleInf} -t {ElfToolChain} -y {ModuleReportPath}"
     BuildModule += Defines
+    BuildModule += Pcd
     RunCommand(BuildModule)
 
     #
@@ -118,6 +123,7 @@ def main():
     parser.add_argument('-b', '--Target', default='DEBUG')
     parser.add_argument("-D", "--Macro", action="append", default=["UNIVERSAL_PAYLOAD=TRUE"])
     parser.add_argument('-i', '--ImageId', type=str, help='Specify payload ID (16 bytes maximal).', default ='UEFI')
+    parser.add_argument("--pcd", action="append", default=[])
     MacroList = {}
     args = parser.parse_args()
     if args.Macro is not None:
@@ -127,7 +133,15 @@ def main():
                 raise Exception("ERROR: Unknown variable passed in: %s"%Argument)
             tokens = Argument.strip().split('=')
             MacroList[tokens[0].upper()] = tokens[1]
-    BuildUniversalPayload(args, MacroList)
+    PcdList = {}
+    if args.pcd is not None:
+        for Argument in args.pcd:
+            if Argument.count('=') != 1:
+                print("Unknown variable passed in: %s"%Argument)
+                raise Exception("ERROR: Unknown variable passed in: %s"%Argument)
+            tokens = Argument.strip().split('=')
+            PcdList[tokens[0]] = tokens[1]
+    BuildUniversalPayload(args, MacroList, PcdList)
     print ("Successfully build Universal Payload")
 
 if __name__ == '__main__':
-- 
2.26.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#83811): https://edk2.groups.io/g/devel/message/83811
Mute This Topic: https://groups.io/mt/87122162/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-