From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web08.3523.1668502286851191491 for ; Tue, 15 Nov 2022 00:51:27 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=MClxQShg; spf=pass (domain: intel.com, ip: 134.134.136.31, 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=1668502286; x=1700038286; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=SFvtJzN0V8b3zNEg4G74Bwg+flpOZSGrefdX7C5gvaU=; b=MClxQShgXhJdpOdog3wrcp2jSrnI7DCiCmtfErZDCOPOHYFGgT+vr9mD DYABmRMgGvW1WWQclxdrjF6I4kbzP0xuI0DeV5DA2JpBAv92HcIRluVKc mnrAkR8hSqFO3zjq6SpF19Z+3I9T23uZYKmNrgBhbpaxjHujUo8Xc2kRl uyfKJvyMbC+ygsXnTYcNsVbLn8ab+I/QTNSN8vZ3JZ/4kvtT4bSfSTgOD LJm1F/HJsS65Cq0nJbRi0L4IP4ZquRO/5Lv3ZLidJEnlW3MIrIPLdZ/If CmCtkEX5GOfNixqMh1vdM/sPYmL0RJUOJJilr7riDEw6kQYTCUycjqkTA g==; X-IronPort-AV: E=McAfee;i="6500,9779,10531"; a="374335051" X-IronPort-AV: E=Sophos;i="5.96,165,1665471600"; d="scan'208";a="374335051" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Nov 2022 00:51:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10531"; a="967917263" X-IronPort-AV: E=Sophos;i="5.96,165,1665471600"; d="scan'208";a="967917263" Received: from yuweipc.ccr.corp.intel.com ([10.239.158.38]) by fmsmga005.fm.intel.com with ESMTP; 15 Nov 2022 00:51:22 -0800 From: "Yuwei Chen" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao Subject: [Patch V1 2/3] BaseTools: Add new build option for PyVfrCompiler yaml generation Date: Tue, 15 Nov 2022 16:51:20 +0800 Message-Id: <20221115085120.1191-1-yuwei.chen@intel.com> X-Mailer: git-send-email 2.27.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- edk2basetools/AutoGen/DataPipe.py | 2 ++ edk2basetools/AutoGen/ModuleAutoGen.py | 8 ++++++++ edk2basetools/Common/GlobalData.py | 4 ++++ edk2basetools/build/build.py | 32 ++++++++++++++++++++++++++++++++ edk2basetools/build/buildoptions.py | 1 + 5 files changed, 47 insertions(+) diff --git a/edk2basetools/AutoGen/DataPipe.py b/edk2basetools/AutoGen/DataPipe.py index f562deb..01a90dd 100755 --- a/edk2basetools/AutoGen/DataPipe.py +++ b/edk2basetools/AutoGen/DataPipe.py @@ -171,3 +171,5 @@ def FillData(self,PlatformInfo): self.DataContainer = {"EnableGenfdsMultiThread":GlobalData.gEnableGenfdsMultiThread} self.DataContainer = {"gPlatformFinalPcds":GlobalData.gPlatformFinalPcds} + + self.DataContainer = {"VfrYamlEnable": GlobalData.gVfrYamlEnable} diff --git a/edk2basetools/AutoGen/ModuleAutoGen.py b/edk2basetools/AutoGen/ModuleAutoGen.py index a7ca949..679a989 100755 --- a/edk2basetools/AutoGen/ModuleAutoGen.py +++ b/edk2basetools/AutoGen/ModuleAutoGen.py @@ -434,6 +434,14 @@ def FfsOutputDir(self): def DebugDir(self): return _MakeDir((self.BuildDir, "DEBUG")) + @cached_property + def VarIFiles(self): + rt = [] + for SrcFile in self.SourceFileList: + if SrcFile.Ext.lower() == '.vfr': + rt.append(os.path.join(self.OutputDir, "{}.i".format(SrcFile.BaseName))) + return rt + ## Return the path of custom file @cached_property def CustomMakefile(self): diff --git a/edk2basetools/Common/GlobalData.py b/edk2basetools/Common/GlobalData.py index fcde26b..475193e 100755 --- a/edk2basetools/Common/GlobalData.py +++ b/edk2basetools/Common/GlobalData.py @@ -123,3 +123,7 @@ # Common lock for the file access in multiple process AutoGens file_lock = None +# +# Build flag for generate Yaml file from Vfr file +# +gVfrYamlEnable = False diff --git a/edk2basetools/build/build.py b/edk2basetools/build/build.py index 1ccb4be..f737172 100755 --- a/edk2basetools/build/build.py +++ b/edk2basetools/build/build.py @@ -750,6 +750,7 @@ def __init__(self, Target, WorkspaceDir, BuildOptions,log_q): GlobalData.gBinCacheSource = BuildOptions.BinCacheSource GlobalData.gEnableGenfdsMultiThread = not BuildOptions.NoGenfdsMultiThread GlobalData.gDisableIncludePathCheck = BuildOptions.DisableIncludePathCheck + GlobalData.gVfrYamlEnable = BuildOptions.VfrYamlEnable if GlobalData.gBinCacheDest and not GlobalData.gUseHashCache: EdkLogger.error("build", OPTION_NOT_SUPPORTED, ExtraData="--binary-destination must be used together with --hash.") @@ -1462,6 +1463,17 @@ def _Build(self, Target, AutoGenObject, CreateDepsCodeFile=True, CreateDepsMakeF # genfds if Target == 'fds': + if GlobalData.gVfrYamlEnable: + from VfrCompiler.main import VfrParse + variable_i_filelist = os.path.join(AutoGenObject.BuildDir,"variable_i_filelist.txt") + if os.path.exists(variable_i_filelist): + with open(variable_i_filelist) as file: + i_filelist = file.readlines() + for i_file in i_filelist: + inputfile = i_file.replace("\n", "") + yamloutputfile = inputfile.split(".")[0] + '.yaml' + jsonoutputfile = inputfile.split(".")[0] + '.json' + VfrParse(inputfile, yamloutputfile, jsonoutputfile) if GenFdsApi(AutoGenObject.GenFdsCommandDict, self.Db): EdkLogger.error("build", COMMAND_FAILURE) Threshold = self.GetFreeSizeThreshold() @@ -2248,6 +2260,15 @@ def PerformAutoGen(self,BuildTarget,ToolChain): fw.write("Arch=%s\n" % "|".join((Wa.ArchList))) fw.write("BuildDir=%s\n" % Wa.BuildDir) fw.write("PlatformGuid=%s\n" % str(Wa.AutoGenObjectList[0].Guid)) + variable_i_filelist = os.path.join(Wa.BuildDir,"variable_i_filelist.txt") + vfr_var_i = [] + if GlobalData.gVfrYamlEnable: + for ma in self.AllModules: + vfr_var_i.extend(ma.VarIFiles) + SaveFileOnChange(variable_i_filelist, "\n".join(vfr_var_i), False) + else: + if os.path.exists(variable_i_filelist): + os.remove(variable_i_filelist) if GlobalData.gBinCacheSource: BuildModules.extend(self.MakeCacheMiss) @@ -2360,6 +2381,17 @@ def _MultiThreadBuildPlatform(self): # # Generate FD image if there's a FDF file found # + if GlobalData.gVfrYamlEnable: + from VfrCompiler.main import VfrParse + variable_i_filelist = os.path.join(Wa.BuildDir,"variable_i_filelist.txt") + if os.path.exists(variable_i_filelist): + with open(variable_i_filelist) as file: + i_filelist = file.readlines() + for i_file in i_filelist: + inputfile = i_file.replace("\n", "") + yamloutputfile = inputfile.split(".")[0] + '.yaml' + jsonoutputfile = inputfile.split(".")[0] + '.json' + VfrParse(inputfile, yamloutputfile, jsonoutputfile) GenFdsStart = time.time() if GenFdsApi(Wa.GenFdsCommandDict, self.Db): EdkLogger.error("build", COMMAND_FAILURE) diff --git a/edk2basetools/build/buildoptions.py b/edk2basetools/build/buildoptions.py index 2afeb3a..ebefa77 100644 --- a/edk2basetools/build/buildoptions.py +++ b/edk2basetools/build/buildoptions.py @@ -102,4 +102,5 @@ def GetOption(self): Parser.add_option("--genfds-multi-thread", action="store_true", dest="GenfdsMultiThread", default=True, help="Enable GenFds multi thread to generate ffs file.") Parser.add_option("--no-genfds-multi-thread", action="store_true", dest="NoGenfdsMultiThread", default=False, help="Disable GenFds multi thread to generate ffs file.") Parser.add_option("--disable-include-path-check", action="store_true", dest="DisableIncludePathCheck", default=False, help="Disable the include path check for outside of package.") + Parser.add_option("--vfr-yaml-enable", action="store_true", dest="VfrYamlEnable", default=False, help="Enable the Vfr to yaml function.") self.BuildOption, self.BuildTarget = Parser.parse_args() -- 2.27.0.windows.1