|
From: <js...@us...> - 2011-11-21 08:41:10
|
Revision: 2421
http://edk2-buildtools.svn.sourceforge.net/edk2-buildtools/?rev=2421&view=rev
Author: jsu1
Date: 2011-11-21 08:40:57 +0000 (Mon, 21 Nov 2011)
Log Message:
-----------
Update UPT to not break on EDKI style comment for EDKI INFs
Reviewed-by: yingke
Reviewed-by: djboyer
Signed-off-by: jsu1
Modified Paths:
--------------
trunk/BaseTools/Source/Python/UPT/Library/Misc.py
trunk/BaseTools/Source/Python/UPT/Logger/StringTable.py
trunk/BaseTools/Source/Python/UPT/Parser/InfParser.py
Modified: trunk/BaseTools/Source/Python/UPT/Library/Misc.py
===================================================================
--- trunk/BaseTools/Source/Python/UPT/Library/Misc.py 2011-11-21 07:00:55 UTC (rev 2420)
+++ trunk/BaseTools/Source/Python/UPT/Library/Misc.py 2011-11-21 08:40:57 UTC (rev 2421)
@@ -834,6 +834,59 @@
return NewList
+## ProcessEdkComment
+#
+# Process EDK style comment in LineList: c style /* */ comment or cpp style // comment
+#
+#
+# @param LineList The LineList need to be processed.
+#
+# @return LineList The LineList been processed.
+# @return FirstPos Where Edk comment is first found, -1 if not found
+#
+def ProcessEdkComment(LineList):
+ FindEdkBlockComment = False
+ Count = 0
+ StartPos = -1
+ EndPos = -1
+ FirstPos = -1
+
+ while(Count < len(LineList)):
+ Line = LineList[Count].strip()
+ if Line.startswith("/*"):
+ #
+ # handling c style comment
+ #
+ StartPos = Count
+ while Count < len(LineList):
+ Line = LineList[Count].strip()
+ if Line.endswith("*/"):
+ if (Count == StartPos) and Line.strip() == '/*/':
+ Count = Count + 1
+ continue
+ EndPos = Count
+ FindEdkBlockComment = True
+ break
+ Count = Count + 1
+
+ if FindEdkBlockComment:
+ if FirstPos == -1:
+ FirstPos = StartPos
+ for Index in xrange(StartPos, EndPos+1):
+ LineList[Index] = ''
+ FindEdkBlockComment = False
+ elif Line.find("//") != -1:
+ #
+ # handling cpp style comment
+ #
+ LineList[Count] = Line.replace("//", '#')
+ if FirstPos == -1:
+ FirstPos = Count
+
+ Count = Count + 1
+
+ return LineList, FirstPos
+
## GetLibInstanceInfo
#
# Get the information from Library Instance INF file.
Modified: trunk/BaseTools/Source/Python/UPT/Logger/StringTable.py
===================================================================
--- trunk/BaseTools/Source/Python/UPT/Logger/StringTable.py 2011-11-21 07:00:55 UTC (rev 2420)
+++ trunk/BaseTools/Source/Python/UPT/Logger/StringTable.py 2011-11-21 08:40:57 UTC (rev 2421)
@@ -196,6 +196,7 @@
_("The INF file %s defines both VERSION_NUMBER and VERSION_STRING, "
"using VERSION_STRING")
ERR_INF_PARSER_NOT_SUPPORT_EDKI_INF = _("EDKI INF is not supported")
+ERR_INF_PARSER_EDKI_COMMENT_IN_EDKII = _("The EDKI style comment is not supported in EDKII modules")
ERR_INF_PARSER_FEATUREPCD_USAGE_INVALID = _("The usage for FeaturePcd can only"
" be type of \"CONSUMES\".")
Modified: trunk/BaseTools/Source/Python/UPT/Parser/InfParser.py
===================================================================
--- trunk/BaseTools/Source/Python/UPT/Parser/InfParser.py 2011-11-21 07:00:55 UTC (rev 2420)
+++ trunk/BaseTools/Source/Python/UPT/Parser/InfParser.py 2011-11-21 08:40:57 UTC (rev 2421)
@@ -26,6 +26,7 @@
from Library.String import GetSplitValueList
from Library.String import ConvertSpecialChar
from Library.Misc import ProcessLineExtender
+from Library.Misc import ProcessEdkComment
from Library.Parsing import NormPath
from Library.ParserValidate import IsValidInfMoudleTypeList
from Library.ParserValidate import IsValidArch
@@ -165,6 +166,12 @@
FileLinesList = ProcessLineExtender(FileLinesList)
#
+ # Process EdkI INF style comment if found
+ #
+ OrigLines = [Line for Line in FileLinesList]
+ FileLinesList, EdkCommentStartPos = ProcessEdkComment(FileLinesList)
+
+ #
# Judge whether the INF file is Binary INF or not
#
if IsBinaryInf(FileLinesList):
@@ -339,6 +346,17 @@
File=self.FullPath)
#
+ # EDKII INF should not have EDKI style comment
+ #
+ if EdkCommentStartPos != -1:
+ Logger.Error("InfParser",
+ FORMAT_INVALID,
+ ST.ERR_INF_PARSER_EDKI_COMMENT_IN_EDKII,
+ File=self.FullPath,
+ Line=EdkCommentStartPos + 1,
+ ExtraData=OrigLines[EdkCommentStartPos])
+
+ #
# extract [Event] [Hob] [BootMode] sections
#
self._ExtractEventHobBootMod(FileLinesList)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|