From nobody Fri Apr 26 08:23:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+80641+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+80641+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1631604451; cv=none; d=zohomail.com; s=zohoarc; b=dopHvUJvuJbPJfjJ3CboMtcmWvmX6xGnS7BX7gTGGM/6DJPRkSi100iDc9FjNt0m5AGea0wCW2XglPEke65ITjiUfIbMoqqiAlLxMpGohesbI5URWs3wdmIsUB3qvI9hPqwHC/0SjOwx8s3mfCY56yJZFT+7VKKgEMyudm0h7D0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631604451; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=VfpIRuHhZvutBLTRMoQaX88fmTMeQuX802UIRuyxIl8=; b=G8oMOLFNX+tinGfBVVYJ247KTBOkbVchs4G+wUVIXZM+WImAUO5a4qDSr65N9n9uwuNTPs8tTzChdvA69gCJvMAFQULsNITS3GNqhd3eB0EwcNZjFQxp131mBZhsDPocyDyBjykZL7W6cPvGn5RRDxo5GoqmI/qvIplaCaaguEo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+80641+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1631604451806366.47956672838484; Tue, 14 Sep 2021 00:27:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id SsyYYY1788612x7PX9ygJ94j; Tue, 14 Sep 2021 00:27:31 -0700 X-Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web12.6780.1631604450190241902 for ; Tue, 14 Sep 2021 00:27:30 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10106"; a="221579629" X-IronPort-AV: E=Sophos;i="5.85,292,1624345200"; d="scan'208";a="221579629" X-Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2021 00:27:28 -0700 X-IronPort-AV: E=Sophos;i="5.85,292,1624345200"; d="scan'208";a="552288493" X-Received: from duntan-mobl.ccr.corp.intel.com ([10.255.29.20]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2021 00:27:26 -0700 From: "duntan" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Maurice Ma , Benjamin You , Zhiguang Liu , Bob Feng Subject: [edk2-devel] [Patch V2] UefiPayloadPkg: Add script to build UniversalPayload in UefiPayloadPkg Date: Tue, 14 Sep 2021 15:26:07 +0800 Message-Id: <20210914072607.366-1-dun.tan@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,dun.tan@intel.com X-Gm-Message-State: 4FdtKKYjbe3x11G90U40w59ax1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1631604451; bh=EO1L7E7NwhTnk8FcErccMPMVvBsBmkMSsxbZeJpjSfs=; h=Cc:Date:From:Reply-To:Subject:To; b=KzyMGOWg7DzGBzbYi6A2t2Ah6MFIIopeeksW3cocxJrCbc5etQuuyNuExvNAKFnUohs /GtQWyUxCfDENvRetgrNtGkXL6X+Ctow9RDMRobdVP2NT2zH3KXDDgazVOq3JTgYxmyui N5OuvVqswcSLiARFNgTj9su9I1gJj0SHw5w= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1631604452717100002 Content-Type: text/plain; charset="utf-8" V1: Add script to build UniversalPayload, which can be used after edksetup = rebuild The final UPL.elf will be located at root folder of edk2 V2: Revise the ouput directory of generated files and coding style in the s= cript Cc: Guo Dong Cc: Ray Ni Cc: Maurice Ma Cc: Benjamin You Cc: Zhiguang Liu Cc: Bob Feng Signed-off-by: Dun Tan Reviewed-by: Ray Ni --- UefiPayloadPkg/UniversalPayloadBuild.py | 98 +++++++++++++++++++++++++++++= +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/UefiPayloadPkg/UniversalPayloadBuild.py b/UefiPayloadPkg/Unive= rsalPayloadBuild.py new file mode 100644 index 0000000000..ab7e2be042 --- /dev/null +++ b/UefiPayloadPkg/UniversalPayloadBuild.py @@ -0,0 +1,98 @@ +## @file +# This file contains the script to build UniversalPayload +# +# Copyright (c) 2021, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +import argparse +import subprocess +import os +import shutil +import sys + +def RunCommand(cmd): + print(cmd) + p =3D subprocess.Popen(cmd, shell=3DTrue, stdout=3Dsubprocess.PIPE, st= derr=3Dsubprocess.STDOUT,cwd=3Dos.environ['WORKSPACE']) + while True: + line =3D p.stdout.readline() + if not line: + break + print(line.strip().decode(errors=3D'ignore')) + + p.communicate() + if p.returncode !=3D 0: + print("- Failed - error happened when run command: %s"%cmd) + raise Exception("ERROR: when run command: %s"%cmd) + +def BuildUniversalPayload(Args, MacroList): + BuildTarget =3D Args.Target + ToolChain =3D Args.ToolChain + ElfToolChain =3D 'CLANGDWARF' + + EntryModuleInf =3D os.path.normpath("UefiPayloadPkg/UefiPayloadEntry/U= niversalPayloadEntry.inf") + DscPath =3D os.path.normpath("UefiPayloadPkg/UefiPayloadPkg.dsc") + BuildDir =3D os.path.join(os.environ['WORKSPACE'], os.path.normpath("B= uild/UefiPayloadPkgX64")) + FvOutputDir =3D os.path.join(BuildDir, f"{BuildTarget}_{ToolChain}", o= s.path.normpath("FV/DXEFV.Fv")) + EntryOutputDir =3D os.path.join(BuildDir, f"{BuildTarget}_{ElfToolChai= n}", os.path.normpath("X64/UefiPayloadPkg/UefiPayloadEntry/UniversalPayload= Entry/DEBUG/UniversalPayloadEntry.dll")) + PayloadReportPath =3D os.path.join(BuildDir, "UefiUniversalPayload.txt= ") + ModuleReportPath =3D os.path.join(BuildDir, "UefiUniversalPayloadEntry= .txt") + =20 + if "CLANG_BIN" in os.environ: + LlvmObjcopyPath =3D os.path.join(os.environ["CLANG_BIN"], "llvm-ob= jcopy") + else: + LlvmObjcopyPath =3D "llvm-objcopy" + try: + RunCommand('"%s" --version'%LlvmObjcopyPath) + except: + print("- Failed - Please check if LLVM is installed or if CLANG_BI= N is set correctly") + sys.exit(1) + + Defines =3D "" + for key in MacroList: + Defines +=3D" -D {0}=3D{1}".format(key, MacroList[key]) + + # + # Building DXE core and DXE drivers as DXEFV. + # + BuildPayload =3D f"build -p {DscPath} -b {BuildTarget} -a X64 -t {Tool= Chain} -y {PayloadReportPath}" + BuildPayload +=3D Defines + RunCommand(BuildPayload) + # + # Building Universal Payload entry. + # + BuildModule =3D f"build -p {DscPath} -b {BuildTarget} -a X64 -m {Entry= ModuleInf} -t {ElfToolChain} -y {ModuleReportPath}" + BuildModule +=3D Defines + RunCommand(BuildModule) + + # + # Copy the DXEFV as a section in elf format Universal Payload entry. + # + remove_section =3D '"%s" -I elf64-x86-64 -O elf64-x86-64 --remove-sect= ion .upld.uefi_fv %s'%(LlvmObjcopyPath, EntryOutputDir) + add_section =3D '"%s" -I elf64-x86-64 -O elf64-x86-64 --add-section .u= pld.uefi_fv=3D%s %s'%(LlvmObjcopyPath, FvOutputDir, EntryOutputDir) + set_section =3D '"%s" -I elf64-x86-64 -O elf64-x86-64 --set-section-al= ignment .upld.uefi_fv=3D16 %s'%(LlvmObjcopyPath, EntryOutputDir) + RunCommand(remove_section) + RunCommand(add_section) + RunCommand(set_section) + + shutil.copy (EntryOutputDir, os.path.join(BuildDir, 'UniversalPayload.= elf')) + +def main(): + parser =3D argparse.ArgumentParser(description=3D'For building Univers= al Payload') + parser.add_argument('-t', '--ToolChain') + parser.add_argument('-b', '--Target', default=3D'DEBUG') + parser.add_argument("-D", "--Macro", action=3D"append", default=3D["UN= IVERSAL_PAYLOAD=3DTRUE"]) + MacroList =3D {} + args =3D parser.parse_args() + if args.Macro is not None: + for Argument in args.Macro: + if Argument.count('=3D') !=3D 1: + print("Unknown variable passed in: %s"%Argument) + raise Exception("ERROR: Unknown variable passed in: %s"%Ar= gument) + tokens =3D Argument.strip().split('=3D') + MacroList[tokens[0].upper()] =3D tokens[1] + BuildUniversalPayload(args, MacroList) + print ("Successfully build Universal Payload") + +if __name__ =3D=3D '__main__': + main() --=20 2.31.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#80641): https://edk2.groups.io/g/devel/message/80641 Mute This Topic: https://groups.io/mt/85596689/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-