From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.3529.1668502000544735359 for ; Tue, 15 Nov 2022 00:46:40 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=YLcKLkFp; spf=pass (domain: intel.com, ip: 192.55.52.136, 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=1668502000; x=1700038000; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=lUfWYe8cfgYA7/FrNdFcvDGnKWMSTzMtgP+y9C0pB9k=; b=YLcKLkFpU/Cvy9SowiXbV0U2HjQeXEsxePp/x05GRQ06ovPT+GHJkDgO Unp9gMAhk6ZPp6y05GCmjt8MlowNGHIJaOYPeucUeG/jodVvbpNePUa+n hypQT4sDdUzskO5qXQXbxqub8+YBaDnhuvnrHZGyxNhxMf+0MwKY1LV4s aGIXDClcjywyUPHmYkRwxjlb2I18cjvGO0e8g7G6UZwEAijUebtUmlfEY UDwmqGwlvH6PbfXcw0zfzc8slVzF4mbizE2VE9GnVpRh/WJqfxKD54Czg dABwvCWEog8peI69r4Fz8vqick+jy29tfgRbalXvjyV7bM9pQr1WgXCic w==; X-IronPort-AV: E=McAfee;i="6500,9779,10531"; a="291911258" X-IronPort-AV: E=Sophos;i="5.96,165,1665471600"; d="scan'208";a="291911258" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2022 00:46:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10531"; a="813607352" X-IronPort-AV: E=Sophos;i="5.96,165,1665471600"; d="scan'208";a="813607352" Received: from yuweipc.ccr.corp.intel.com ([10.239.158.38]) by orsmga005.jf.intel.com with ESMTP; 15 Nov 2022 00:46:17 -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: Tue, 15 Nov 2022 16:46:13 +0800 Message-Id: <20221115084613.2036-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