public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] UefiPayloadPkg: Add the capability to override pcd when build the payload.
@ 2021-11-17  5:59 yuanhao.xie
  0 siblings, 0 replies; only message in thread
From: yuanhao.xie @ 2021-11-17  5:59 UTC (permalink / raw)
  To: devel; +Cc: Guo Dong, Ray Ni, Maurice Ma, Benjamin You

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


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

only message in thread, other threads:[~2021-11-17  5:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-17  5:59 [PATCH] UefiPayloadPkg: Add the capability to override pcd when build the payload yuanhao.xie

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