From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web11.35480.1675060001774817159 for ; Sun, 29 Jan 2023 22:26:42 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=VwXzDyOR; spf=pass (domain: intel.com, ip: 192.55.52.93, mailfrom: yuwei.chen@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675060002; x=1706596002; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=lUfWYe8cfgYA7/FrNdFcvDGnKWMSTzMtgP+y9C0pB9k=; b=VwXzDyORtXuvexY780QYAoQSo496hyEDpeBw6rQZ5uNqvfWCD0ntvY7J rT9QpBKLB9JDEH+JSkzbdqG9lVV8h1uwo2ae8Qs4o2sqwSbqcz13V35g2 bPrepZ4mapgX/JEZjN76SwEcxOi9Z73DanjaVXODYm59pUFqY09UkHkgO MF2uRMI0pdFlTVIUZQ0rXBigRtmBT0OCXa9bxyiP9mv9hZWlM8PIqk7xe skkI6iCQEKPXaf7Y699lb4p6D9xI5QTgA82NrKrQXz3vZSnbZjpyDBX9P E/uM7+CWHw6ZIKx0mfn14ijbip+YI3E68SjGS1l6Odmkn6xev5+sFpN9S Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10605"; a="325182167" X-IronPort-AV: E=Sophos;i="5.97,257,1669104000"; d="scan'208";a="325182167" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jan 2023 22:26:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10605"; a="665967493" X-IronPort-AV: E=Sophos;i="5.97,257,1669104000"; d="scan'208";a="665967493" Received: from yuweipc.ccr.corp.intel.com ([10.239.158.38]) by fmsmga007.fm.intel.com with ESMTP; 29 Jan 2023 22:26:34 -0800 From: "Yuwei Chen" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao Subject: [Patch V2 2/3] [edk2-staging]BaseTools: Add new build option for PyVfrCompiler yaml generation Date: Mon, 30 Jan 2023 14:26:31 +0800 Message-Id: <20230130062631.667-1-yuwei.chen@intel.com> X-Mailer: git-send-email 2.27.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Add new build option "--vfr-yaml-enable" for Python VfrCompiler extended output yaml file generation. Cc: Bob Feng Cc: Liming Gao Signed-off-by: Yuwei Chen --- BaseTools/Source/Python/AutoGen/DataPipe.py | 2 ++ BaseTools/Source/Python/AutoGen/ModuleAutoGen.py | 8 ++++++++ BaseTools/Source/Python/Common/GlobalData.py | 4 ++++ BaseTools/Source/Python/build/build.py | 33 ++++++++++++++++++++= +++++++++++++ BaseTools/Source/Python/build/buildoptions.py | 1 + 5 files changed, 48 insertions(+) diff --git a/BaseTools/Source/Python/AutoGen/DataPipe.py b/BaseTools/Source= /Python/AutoGen/DataPipe.py index 848c7a8296..c700baf7b7 100755 --- a/BaseTools/Source/Python/AutoGen/DataPipe.py +++ b/BaseTools/Source/Python/AutoGen/DataPipe.py @@ -171,3 +171,5 @@ class MemoryDataPipe(DataPipe): self.DataContainer =3D {"EnableGenfdsMultiThread":GlobalData.gEnab= leGenfdsMultiThread}=0D =0D self.DataContainer =3D {"gPlatformFinalPcds":GlobalData.gPlatformF= inalPcds}=0D +=0D + self.DataContainer =3D {"VfrYamlEnable": GlobalData.gVfrYamlEnable= }=0D diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py b/BaseTools/S= ource/Python/AutoGen/ModuleAutoGen.py index d05410b329..eb81c3f3af 100755 --- a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py +++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py @@ -434,6 +434,14 @@ class ModuleAutoGen(AutoGen): def DebugDir(self):=0D return _MakeDir((self.BuildDir, "DEBUG"))=0D =0D + @cached_property=0D + def VarIFiles(self):=0D + rt =3D []=0D + for SrcFile in self.SourceFileList:=0D + if SrcFile.Ext.lower() =3D=3D '.vfr':=0D + rt.append(os.path.join(self.OutputDir, "{}.i".format(SrcFi= le.BaseName)))=0D + return rt=0D +=0D ## Return the path of custom file=0D @cached_property=0D def CustomMakefile(self):=0D diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Sourc= e/Python/Common/GlobalData.py index 197bd83666..039a9648aa 100755 --- a/BaseTools/Source/Python/Common/GlobalData.py +++ b/BaseTools/Source/Python/Common/GlobalData.py @@ -123,3 +123,7 @@ gSikpAutoGenCache =3D set() # Common lock for the file access in multiple process AutoGens=0D file_lock =3D None=0D =0D +#=0D +# Build flag for generate Yaml file from Vfr file=0D +#=0D +gVfrYamlEnable =3D False=0D diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Pyth= on/build/build.py index 51fb1f433e..7e2f25686d 100755 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -748,6 +748,7 @@ class Build(): GlobalData.gBinCacheSource =3D BuildOptions.BinCacheSource=0D GlobalData.gEnableGenfdsMultiThread =3D not BuildOptions.NoGenfdsM= ultiThread=0D GlobalData.gDisableIncludePathCheck =3D BuildOptions.DisableInclud= ePathCheck=0D + GlobalData.gVfrYamlEnable =3D BuildOptions.VfrYamlEnable=0D =0D if GlobalData.gBinCacheDest and not GlobalData.gUseHashCache:=0D EdkLogger.error("build", OPTION_NOT_SUPPORTED, ExtraData=3D"--= binary-destination must be used together with --hash.")=0D @@ -1460,6 +1461,17 @@ class Build(): =0D # genfds=0D if Target =3D=3D 'fds':=0D + if GlobalData.gVfrYamlEnable:=0D + from VfrCompiler.main import VfrParse=0D + variable_i_filelist =3D os.path.join(AutoGenObject.BuildDi= r,"variable_i_filelist.txt")=0D + if os.path.exists(variable_i_filelist):=0D + with open(variable_i_filelist) as file:=0D + i_filelist =3D file.readlines()=0D + for i_file in i_filelist:=0D + inputfile =3D i_file.replace("\n", "")=0D + yamloutputfile =3D inputfile.split(".")[0] + '= .yaml'=0D + jsonoutputfile =3D inputfile.split(".")[0] + '= .json'=0D + VfrParse(inputfile, yamloutputfile, jsonoutput= file)=0D if GenFdsApi(AutoGenObject.GenFdsCommandDict, self.Db):=0D EdkLogger.error("build", COMMAND_FAILURE)=0D Threshold =3D self.GetFreeSizeThreshold()=0D @@ -2246,6 +2258,15 @@ class Build(): fw.write("Arch=3D%s\n" % "|".join((Wa.ArchList)))=0D fw.write("BuildDir=3D%s\n" % Wa.BuildDir)=0D fw.write("PlatformGuid=3D%s\n" % str(Wa.AutoGenObjectList[0].G= uid))=0D + variable_i_filelist =3D os.path.join(Wa.BuildDir,"variable_i_filel= ist.txt")=0D + vfr_var_i =3D []=0D + if GlobalData.gVfrYamlEnable:=0D + for ma in self.AllModules:=0D + vfr_var_i.extend(ma.VarIFiles)=0D + SaveFileOnChange(variable_i_filelist, "\n".join(vfr_var_i), Fa= lse)=0D + else:=0D + if os.path.exists(variable_i_filelist):=0D + os.remove(variable_i_filelist)=0D =0D if GlobalData.gBinCacheSource:=0D BuildModules.extend(self.MakeCacheMiss)=0D @@ -2358,6 +2379,18 @@ class Build(): #=0D # Generate FD image if there's a FDF file found=0D #=0D + if GlobalData.gVfrYamlEnable:=0D + from VfrCompiler.main import VfrParse=0D + variable_i_filelist =3D os.path.join(Wa.BuildD= ir,"variable_i_filelist.txt")=0D + if os.path.exists(variable_i_filelist):=0D + with open(variable_i_filelist) as file:=0D + i_filelist =3D file.readlines()=0D + for i_file in i_filelist:=0D + inputfile =3D i_file.replace("\n",= "")=0D + yamloutputfile =3D inputfile.split= (".")[0] + '.yaml'=0D + jsonoutputfile =3D inputfile.split= (".")[0] + '.json'=0D + print('inputfile ', inputfile)=0D + VfrParse(inputfile, yamloutputfile= , jsonoutputfile)=0D GenFdsStart =3D time.time()=0D if GenFdsApi(Wa.GenFdsCommandDict, self.Db):=0D EdkLogger.error("build", COMMAND_FAILURE)=0D diff --git a/BaseTools/Source/Python/build/buildoptions.py b/BaseTools/Sour= ce/Python/build/buildoptions.py index 8334604b46..c0304c2f98 100644 --- a/BaseTools/Source/Python/build/buildoptions.py +++ b/BaseTools/Source/Python/build/buildoptions.py @@ -103,4 +103,5 @@ class MyOptionParser(): Parser.add_option("--genfds-multi-thread", action=3D"store_true", = dest=3D"GenfdsMultiThread", default=3DTrue, help=3D"Enable GenFds multi thr= ead to generate ffs file.")=0D Parser.add_option("--no-genfds-multi-thread", action=3D"store_true= ", dest=3D"NoGenfdsMultiThread", default=3DFalse, help=3D"Disable GenFds mu= lti thread to generate ffs file.")=0D Parser.add_option("--disable-include-path-check", action=3D"store_= true", dest=3D"DisableIncludePathCheck", default=3DFalse, help=3D"Disable t= he include path check for outside of package.")=0D + Parser.add_option("--vfr-yaml-enable", action=3D"store_true", dest= =3D"VfrYamlEnable", default=3DFalse, help=3D"Enable the Vfr to yaml functio= n.")=0D self.BuildOption, self.BuildTarget =3D Parser.parse_args()=0D --=20 2.27.0.windows.1