summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/UPT/Parser/InfDepexSectionParser.py
diff options
context:
space:
mode:
authorkx <kx@radix.pro>2024-06-04 06:43:08 +0300
committerkx <kx@radix.pro>2024-06-04 06:43:08 +0300
commit7e2ccccace24636f29ddc210b94606abd4c7e42b (patch)
tree545d43ea12671048956cafeb12303e84d601e571 /BaseTools/Source/Python/UPT/Parser/InfDepexSectionParser.py
parent27b044605cd5f6b33a3d231576003850b3fe305b (diff)
downloadedk2-trunk.tar.xz
Renormalized end-of-lines from master@27b044605cd5f6b33a3d231576003850b3fe305btrunk
Diffstat (limited to 'BaseTools/Source/Python/UPT/Parser/InfDepexSectionParser.py')
-rw-r--r--BaseTools/Source/Python/UPT/Parser/InfDepexSectionParser.py196
1 files changed, 98 insertions, 98 deletions
diff --git a/BaseTools/Source/Python/UPT/Parser/InfDepexSectionParser.py b/BaseTools/Source/Python/UPT/Parser/InfDepexSectionParser.py
index a2e836e482..86634b3281 100644
--- a/BaseTools/Source/Python/UPT/Parser/InfDepexSectionParser.py
+++ b/BaseTools/Source/Python/UPT/Parser/InfDepexSectionParser.py
@@ -1,98 +1,98 @@
-## @file
-# This file contained the parser for [Depex] sections in INF file
-#
-# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-'''
-InfDepexSectionParser
-'''
-##
-# Import Modules
-#
-import re
-import Logger.Log as Logger
-from Logger import StringTable as ST
-from Logger.ToolError import FORMAT_INVALID
-from Parser.InfParserMisc import InfExpandMacro
-from Library import DataType as DT
-from Library.Misc import GetSplitValueList
-from Parser.InfParserMisc import InfParserSectionRoot
-
-class InfDepexSectionParser(InfParserSectionRoot):
- ## InfDepexParser
- #
- # For now, only separate Depex String and comments.
- # Have two types of section header.
- # 1. [Depex.Arch.ModuleType, ...]
- # 2. [Depex.Arch|FFE, ...]
- #
- def InfDepexParser(self, SectionString, InfSectionObject, FileName):
- DepexContent = []
- DepexComment = []
- ValueList = []
- #
- # Parse section content
- #
- for Line in SectionString:
- LineContent = Line[0]
- LineNo = Line[1]
-
- #
- # Found comment
- #
- if LineContent.strip().startswith(DT.TAB_COMMENT_SPLIT):
- DepexComment.append((LineContent, LineNo))
- continue
- #
- # Replace with [Defines] section Macro
- #
- LineContent = InfExpandMacro(LineContent,
- (FileName, LineContent, Line[1]),
- self.FileLocalMacros,
- None, True)
-
- CommentCount = LineContent.find(DT.TAB_COMMENT_SPLIT)
-
- if CommentCount > -1:
- DepexComment.append((LineContent[CommentCount:], LineNo))
- LineContent = LineContent[:CommentCount-1]
-
-
- CommentCount = -1
- DepexContent.append((LineContent, LineNo))
-
- TokenList = GetSplitValueList(LineContent, DT.TAB_COMMENT_SPLIT)
- ValueList[0:len(TokenList)] = TokenList
-
- #
- # Current section archs
- #
- KeyList = []
- LastItem = ''
- for Item in self.LastSectionHeaderContent:
- LastItem = Item
- if (Item[1], Item[2], Item[3]) not in KeyList:
- KeyList.append((Item[1], Item[2], Item[3]))
-
- NewCommentList = []
- FormatCommentLn = -1
- ReFormatComment = re.compile(r"""#(?:\s*)\[(.*?)\](?:.*)""", re.DOTALL)
- for CommentItem in DepexComment:
- CommentContent = CommentItem[0]
- if ReFormatComment.match(CommentContent) is not None:
- FormatCommentLn = CommentItem[1] + 1
- continue
-
- if CommentItem[1] != FormatCommentLn:
- NewCommentList.append(CommentContent)
- else:
- FormatCommentLn = CommentItem[1] + 1
-
- if not InfSectionObject.SetDepex(DepexContent, KeyList = KeyList, CommentList = NewCommentList):
- Logger.Error('InfParser',
- FORMAT_INVALID,
- ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR%("[Depex]"),
- File=FileName,
- Line=LastItem[3])
+## @file
+# This file contained the parser for [Depex] sections in INF file
+#
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+'''
+InfDepexSectionParser
+'''
+##
+# Import Modules
+#
+import re
+import Logger.Log as Logger
+from Logger import StringTable as ST
+from Logger.ToolError import FORMAT_INVALID
+from Parser.InfParserMisc import InfExpandMacro
+from Library import DataType as DT
+from Library.Misc import GetSplitValueList
+from Parser.InfParserMisc import InfParserSectionRoot
+
+class InfDepexSectionParser(InfParserSectionRoot):
+ ## InfDepexParser
+ #
+ # For now, only separate Depex String and comments.
+ # Have two types of section header.
+ # 1. [Depex.Arch.ModuleType, ...]
+ # 2. [Depex.Arch|FFE, ...]
+ #
+ def InfDepexParser(self, SectionString, InfSectionObject, FileName):
+ DepexContent = []
+ DepexComment = []
+ ValueList = []
+ #
+ # Parse section content
+ #
+ for Line in SectionString:
+ LineContent = Line[0]
+ LineNo = Line[1]
+
+ #
+ # Found comment
+ #
+ if LineContent.strip().startswith(DT.TAB_COMMENT_SPLIT):
+ DepexComment.append((LineContent, LineNo))
+ continue
+ #
+ # Replace with [Defines] section Macro
+ #
+ LineContent = InfExpandMacro(LineContent,
+ (FileName, LineContent, Line[1]),
+ self.FileLocalMacros,
+ None, True)
+
+ CommentCount = LineContent.find(DT.TAB_COMMENT_SPLIT)
+
+ if CommentCount > -1:
+ DepexComment.append((LineContent[CommentCount:], LineNo))
+ LineContent = LineContent[:CommentCount-1]
+
+
+ CommentCount = -1
+ DepexContent.append((LineContent, LineNo))
+
+ TokenList = GetSplitValueList(LineContent, DT.TAB_COMMENT_SPLIT)
+ ValueList[0:len(TokenList)] = TokenList
+
+ #
+ # Current section archs
+ #
+ KeyList = []
+ LastItem = ''
+ for Item in self.LastSectionHeaderContent:
+ LastItem = Item
+ if (Item[1], Item[2], Item[3]) not in KeyList:
+ KeyList.append((Item[1], Item[2], Item[3]))
+
+ NewCommentList = []
+ FormatCommentLn = -1
+ ReFormatComment = re.compile(r"""#(?:\s*)\[(.*?)\](?:.*)""", re.DOTALL)
+ for CommentItem in DepexComment:
+ CommentContent = CommentItem[0]
+ if ReFormatComment.match(CommentContent) is not None:
+ FormatCommentLn = CommentItem[1] + 1
+ continue
+
+ if CommentItem[1] != FormatCommentLn:
+ NewCommentList.append(CommentContent)
+ else:
+ FormatCommentLn = CommentItem[1] + 1
+
+ if not InfSectionObject.SetDepex(DepexContent, KeyList = KeyList, CommentList = NewCommentList):
+ Logger.Error('InfParser',
+ FORMAT_INVALID,
+ ST.ERR_INF_PARSER_MODULE_SECTION_TYPE_ERROR%("[Depex]"),
+ File=FileName,
+ Line=LastItem[3])