* [PATCH 1/1] IntelFsp2Pkg/Tools/GenCfgOpt.py: Fix a bug about parse macro
@ 2020-06-28 6:53 Tan, Ming
2020-06-29 0:49 ` Chiu, Chasel
0 siblings, 1 reply; 2+ messages in thread
From: Tan, Ming @ 2020-06-28 6:53 UTC (permalink / raw)
To: devel; +Cc: Chasel Chiu, Nate DeSimone, Star Zeng
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2827
Fix a bug about parse the macro value which use another macro.
Use the following example to verify:
[Define]
DEFINE M1 = V1
DEFINE M2 = $(M1)/V2
!include $(M2)/pcd.dsc
The old code will failed parse M2 and cause following error:
Traceback (most recent call last):
File "Edk2\IntelFsp2Pkg\Tools\GenCfgOpt.py", line 1550, in <module>
sys.exit(Main())
File "Edk2\IntelFsp2Pkg\Tools\GenCfgOpt.py", line 1513, in Main
if GenCfgOpt.ParseDscFile(DscFile, FvDir) != 0:
File "Edk2\IntelFsp2Pkg\Tools\GenCfgOpt.py", line 533, in ParseDscFile
NewDscLines = IncludeDsc.readlines()
ValueError: I/O operation on closed file.
The tool should support the value use another macro, and expand it.
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Signed-off-by: Ming Tan <ming.tan@intel.com>
---
IntelFsp2Pkg/Tools/GenCfgOpt.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/IntelFsp2Pkg/Tools/GenCfgOpt.py b/IntelFsp2Pkg/Tools/GenCfgOpt.py
index e6c15108f5c5..e9de128e5055 100644
--- a/IntelFsp2Pkg/Tools/GenCfgOpt.py
+++ b/IntelFsp2Pkg/Tools/GenCfgOpt.py
@@ -546,11 +546,11 @@ EndList
#DEFINE FSP_T_UPD_TOOL_GUID = 34686CA3-34F9-4901-B82A-BA630F0714C6
#DEFINE FSP_M_UPD_TOOL_GUID = 39A250DB-E465-4DD1-A2AC-E2BD3C0E2385
#DEFINE FSP_S_UPD_TOOL_GUID = CAE3605B-5B34-4C85-B3D7-27D54273C40F
- Match = re.match("^\s*(?:DEFINE\s+)*(\w+)\s*=\s*([-.\w]+)", DscLine)
+ Match = re.match("^\s*(?:DEFINE\s+)*(\w+)\s*=\s*([/$()-.\w]+)", DscLine)
if Match:
- self._MacroDict[Match.group(1)] = Match.group(2)
+ self._MacroDict[Match.group(1)] = self.ExpandMacros(Match.group(2))
if self.Debug:
- print ("INFO : DEFINE %s = [ %s ]" % (Match.group(1), Match.group(2)))
+ print ("INFO : DEFINE %s = [ %s ]" % (Match.group(1), self.ExpandMacros(Match.group(2))))
elif IsPcdSect:
#gSiPkgTokenSpaceGuid.PcdTxtEnable|FALSE
#gSiPkgTokenSpaceGuid.PcdOverclockEnable|TRUE
--
2.24.0.windows.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] IntelFsp2Pkg/Tools/GenCfgOpt.py: Fix a bug about parse macro
2020-06-28 6:53 [PATCH 1/1] IntelFsp2Pkg/Tools/GenCfgOpt.py: Fix a bug about parse macro Tan, Ming
@ 2020-06-29 0:49 ` Chiu, Chasel
0 siblings, 0 replies; 2+ messages in thread
From: Chiu, Chasel @ 2020-06-29 0:49 UTC (permalink / raw)
To: Tan, Ming, devel@edk2.groups.io; +Cc: Desimone, Nathaniel L, Zeng, Star
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
> -----Original Message-----
> From: Tan, Ming <ming.tan@intel.com>
> Sent: Sunday, June 28, 2020 2:54 PM
> To: devel@edk2.groups.io
> Cc: Chiu, Chasel <chasel.chiu@intel.com>; Desimone, Nathaniel L
> <nathaniel.l.desimone@intel.com>; Zeng, Star <star.zeng@intel.com>
> Subject: [PATCH 1/1] IntelFsp2Pkg/Tools/GenCfgOpt.py: Fix a bug about parse
> macro
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2827
>
> Fix a bug about parse the macro value which use another macro.
>
> Use the following example to verify:
> [Define]
> DEFINE M1 = V1
> DEFINE M2 = $(M1)/V2
>
> !include $(M2)/pcd.dsc
>
> The old code will failed parse M2 and cause following error:
> Traceback (most recent call last):
> File "Edk2\IntelFsp2Pkg\Tools\GenCfgOpt.py", line 1550, in <module>
> sys.exit(Main())
> File "Edk2\IntelFsp2Pkg\Tools\GenCfgOpt.py", line 1513, in Main
> if GenCfgOpt.ParseDscFile(DscFile, FvDir) != 0:
> File "Edk2\IntelFsp2Pkg\Tools\GenCfgOpt.py", line 533, in ParseDscFile
> NewDscLines = IncludeDsc.readlines()
> ValueError: I/O operation on closed file.
>
> The tool should support the value use another macro, and expand it.
>
> Cc: Chasel Chiu <chasel.chiu@intel.com>
> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Signed-off-by: Ming Tan <ming.tan@intel.com>
> ---
> IntelFsp2Pkg/Tools/GenCfgOpt.py | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/IntelFsp2Pkg/Tools/GenCfgOpt.py
> b/IntelFsp2Pkg/Tools/GenCfgOpt.py index e6c15108f5c5..e9de128e5055
> 100644
> --- a/IntelFsp2Pkg/Tools/GenCfgOpt.py
> +++ b/IntelFsp2Pkg/Tools/GenCfgOpt.py
> @@ -546,11 +546,11 @@ EndList
> #DEFINE FSP_T_UPD_TOOL_GUID =
> 34686CA3-34F9-4901-B82A-BA630F0714C6
> #DEFINE FSP_M_UPD_TOOL_GUID =
> 39A250DB-E465-4DD1-A2AC-E2BD3C0E2385
> #DEFINE FSP_S_UPD_TOOL_GUID =
> CAE3605B-5B34-4C85-B3D7-27D54273C40F
> - Match =
> re.match("^\s*(?:DEFINE\s+)*(\w+)\s*=\s*([-.\w]+)", DscLine)
> + Match =
> + re.match("^\s*(?:DEFINE\s+)*(\w+)\s*=\s*([/$()-.\w]+)", DscLine)
> if Match:
> - self._MacroDict[Match.group(1)] = Match.group(2)
> + self._MacroDict[Match.group(1)] =
> + self.ExpandMacros(Match.group(2))
> if self.Debug:
> - print ("INFO : DEFINE %s = [ %s ]" %
> (Match.group(1), Match.group(2)))
> + print ("INFO : DEFINE %s = [ %s ]" %
> + (Match.group(1), self.ExpandMacros(Match.group(2))))
> elif IsPcdSect:
> #gSiPkgTokenSpaceGuid.PcdTxtEnable|FALSE
> #gSiPkgTokenSpaceGuid.PcdOverclockEnable|TRUE
> --
> 2.24.0.windows.2
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-29 0:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-28 6:53 [PATCH 1/1] IntelFsp2Pkg/Tools/GenCfgOpt.py: Fix a bug about parse macro Tan, Ming
2020-06-29 0:49 ` Chiu, Chasel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox