* [Patch V2 2/3] [edk2-staging]BaseTools: Add new build option for PyVfrCompiler yaml generation
@ 2023-01-30 6:26 Yuwei Chen
2023-01-30 6:45 ` Bob Feng
0 siblings, 1 reply; 4+ messages in thread
From: Yuwei Chen @ 2023-01-30 6:26 UTC (permalink / raw)
To: devel; +Cc: Bob Feng, Liming Gao
Add new build option "--vfr-yaml-enable" for Python VfrCompiler
extended output yaml file generation.
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
---
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 = {"EnableGenfdsMultiThread":GlobalData.gEnableGenfdsMultiThread}
self.DataContainer = {"gPlatformFinalPcds":GlobalData.gPlatformFinalPcds}
+
+ self.DataContainer = {"VfrYamlEnable": GlobalData.gVfrYamlEnable}
diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py b/BaseTools/Source/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):
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/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Source/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 = set()
# 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/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/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 = 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.")
@@ -1460,6 +1461,17 @@ class Build():
# 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()
@@ -2246,6 +2258,15 @@ class Build():
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)
@@ -2358,6 +2379,18 @@ class Build():
#
# 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'
+ print('inputfile ', inputfile)
+ VfrParse(inputfile, yamloutputfile, jsonoutputfile)
GenFdsStart = time.time()
if GenFdsApi(Wa.GenFdsCommandDict, self.Db):
EdkLogger.error("build", COMMAND_FAILURE)
diff --git a/BaseTools/Source/Python/build/buildoptions.py b/BaseTools/Source/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="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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Patch V2 2/3] [edk2-staging]BaseTools: Add new build option for PyVfrCompiler yaml generation
2023-01-30 6:26 [Patch V2 2/3] [edk2-staging]BaseTools: Add new build option for PyVfrCompiler yaml generation Yuwei Chen
@ 2023-01-30 6:45 ` Bob Feng
0 siblings, 0 replies; 4+ messages in thread
From: Bob Feng @ 2023-01-30 6:45 UTC (permalink / raw)
To: Chen, Christine, devel@edk2.groups.io; +Cc: Gao, Liming
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
-----Original Message-----
From: Chen, Christine <yuwei.chen@intel.com>
Sent: Monday, January 30, 2023 2:27 PM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>
Subject: [Patch V2 2/3] [edk2-staging]BaseTools: Add new build option for PyVfrCompiler yaml generation
Add new build option "--vfr-yaml-enable" for Python VfrCompiler extended output yaml file generation.
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
---
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 = {"EnableGenfdsMultiThread":GlobalData.gEnableGenfdsMultiThread} self.DataContainer = {"gPlatformFinalPcds":GlobalData.gPlatformFinalPcds}++ self.DataContainer = {"VfrYamlEnable": GlobalData.gVfrYamlEnable}diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py b/BaseTools/Source/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): 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/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Source/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 = set() # Common lock for the file access in multiple process AutoGens file_lock = None +#+# Build flag for generate Yaml file from Vfr file+#+gVfrYamlEnable = Falsediff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/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 = 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.")@@ -1460,6 +1461,17 @@ class Build():
# 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()@@ -2246,6 +2258,15 @@ class Build():
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)@@ -2358,6 +2379,18 @@ class Build():
# # 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'+ print('inputfile ', inputfile)+ VfrParse(inputfile, yamloutputfile, jsonoutputfile) GenFdsStart = time.time() if GenFdsApi(Wa.GenFdsCommandDict, self.Db): EdkLogger.error("build", COMMAND_FAILURE)diff --git a/BaseTools/Source/Python/build/buildoptions.py b/BaseTools/Source/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="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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Patch V2 2/3] [edk2-staging]BaseTools: Add new build option for PyVfrCompiler yaml generation
@ 2022-11-15 8:46 Yuwei Chen
2022-12-06 0:51 ` Bob Feng
0 siblings, 1 reply; 4+ messages in thread
From: Yuwei Chen @ 2022-11-15 8:46 UTC (permalink / raw)
To: devel; +Cc: Bob Feng, Liming Gao
Add new build option "--vfr-yaml-enable" for Python VfrCompiler
extended output yaml file generation.
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
---
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 = {"EnableGenfdsMultiThread":GlobalData.gEnableGenfdsMultiThread}
self.DataContainer = {"gPlatformFinalPcds":GlobalData.gPlatformFinalPcds}
+
+ self.DataContainer = {"VfrYamlEnable": GlobalData.gVfrYamlEnable}
diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py b/BaseTools/Source/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):
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/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Source/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 = set()
# 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/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/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 = 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.")
@@ -1460,6 +1461,17 @@ class Build():
# 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()
@@ -2246,6 +2258,15 @@ class Build():
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)
@@ -2358,6 +2379,18 @@ class Build():
#
# 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'
+ print('inputfile ', inputfile)
+ VfrParse(inputfile, yamloutputfile, jsonoutputfile)
GenFdsStart = time.time()
if GenFdsApi(Wa.GenFdsCommandDict, self.Db):
EdkLogger.error("build", COMMAND_FAILURE)
diff --git a/BaseTools/Source/Python/build/buildoptions.py b/BaseTools/Source/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="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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Patch V2 2/3] [edk2-staging]BaseTools: Add new build option for PyVfrCompiler yaml generation
2022-11-15 8:46 Yuwei Chen
@ 2022-12-06 0:51 ` Bob Feng
0 siblings, 0 replies; 4+ messages in thread
From: Bob Feng @ 2022-12-06 0:51 UTC (permalink / raw)
To: Chen, Christine, devel@edk2.groups.io; +Cc: Gao, Liming
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
-----Original Message-----
From: Chen, Christine <yuwei.chen@intel.com>
Sent: Tuesday, November 15, 2022 4:46 PM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>
Subject: [Patch V2 2/3] [edk2-staging]BaseTools: Add new build option for PyVfrCompiler yaml generation
Add new build option "--vfr-yaml-enable" for Python VfrCompiler extended output yaml file generation.
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
---
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 = {"EnableGenfdsMultiThread":GlobalData.gEnableGenfdsMultiThread} self.DataContainer = {"gPlatformFinalPcds":GlobalData.gPlatformFinalPcds}++ self.DataContainer = {"VfrYamlEnable": GlobalData.gVfrYamlEnable}diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py b/BaseTools/Source/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): 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/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Source/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 = set() # Common lock for the file access in multiple process AutoGens file_lock = None +#+# Build flag for generate Yaml file from Vfr file+#+gVfrYamlEnable = Falsediff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/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 = 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.")@@ -1460,6 +1461,17 @@ class Build():
# 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()@@ -2246,6 +2258,15 @@ class Build():
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)@@ -2358,6 +2379,18 @@ class Build():
# # 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'+ print('inputfile ', inputfile)+ VfrParse(inputfile, yamloutputfile, jsonoutputfile) GenFdsStart = time.time() if GenFdsApi(Wa.GenFdsCommandDict, self.Db): EdkLogger.error("build", COMMAND_FAILURE)diff --git a/BaseTools/Source/Python/build/buildoptions.py b/BaseTools/Source/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="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
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-01-30 6:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-30 6:26 [Patch V2 2/3] [edk2-staging]BaseTools: Add new build option for PyVfrCompiler yaml generation Yuwei Chen
2023-01-30 6:45 ` Bob Feng
-- strict thread matches above, loose matches on Subject: below --
2022-11-15 8:46 Yuwei Chen
2022-12-06 0:51 ` Bob Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox