]>
Commit | Line | Data |
---|---|---|
4234283c | 1 | ## @file\r |
f7496d71 LG |
2 | # This file is used to define class objects of INF file [Depex] section.\r |
3 | # It will consumed by InfParser.\r | |
4234283c | 4 | #\r |
f7496d71 | 5 | # Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r |
4234283c | 6 | #\r |
2e351cbe | 7 | # SPDX-License-Identifier: BSD-2-Clause-Patent\r |
4234283c LG |
8 | \r |
9 | '''\r | |
10 | InfDepexObject\r | |
11 | '''\r | |
12 | \r | |
13 | from Library import DataType as DT\r | |
14 | from Library import GlobalData\r | |
15 | import Logger.Log as Logger\r | |
16 | from Logger import ToolError\r | |
17 | from Logger import StringTable as ST\r | |
18 | \r | |
19 | from Object.Parser.InfCommonObject import InfSectionCommonDef\r | |
20 | from Library.ParserValidate import IsValidArch\r | |
21 | \r | |
22 | class InfDepexContentItem():\r | |
23 | def __init__(self):\r | |
24 | self.SectionType = ''\r | |
25 | self.SectionString = ''\r | |
26 | \r | |
27 | def SetSectionType(self, SectionType):\r | |
28 | self.SectionType = SectionType\r | |
29 | def GetSectionType(self):\r | |
30 | return self.SectionType\r | |
31 | \r | |
32 | def SetSectionString(self, SectionString):\r | |
33 | self.SectionString = SectionString\r | |
34 | def GetSectionString(self):\r | |
35 | return self.SectionString\r | |
36 | \r | |
37 | \r | |
38 | class InfDepexItem():\r | |
39 | def __init__(self):\r | |
40 | self.DepexContent = ''\r | |
41 | self.ModuleType = ''\r | |
42 | self.SupArch = ''\r | |
43 | self.HelpString = ''\r | |
44 | self.FeatureFlagExp = ''\r | |
45 | self.InfDepexContentItemList = []\r | |
46 | \r | |
47 | def SetFeatureFlagExp(self, FeatureFlagExp):\r | |
48 | self.FeatureFlagExp = FeatureFlagExp\r | |
49 | def GetFeatureFlagExp(self):\r | |
50 | return self.FeatureFlagExp\r | |
51 | \r | |
52 | def SetSupArch(self, Arch):\r | |
53 | self.SupArch = Arch\r | |
54 | def GetSupArch(self):\r | |
55 | return self.SupArch\r | |
56 | \r | |
57 | def SetHelpString(self, HelpString):\r | |
58 | self.HelpString = HelpString\r | |
59 | def GetHelpString(self):\r | |
60 | return self.HelpString\r | |
61 | \r | |
62 | def SetModuleType(self, Type):\r | |
63 | self.ModuleType = Type\r | |
64 | def GetModuleType(self):\r | |
65 | return self.ModuleType\r | |
66 | \r | |
67 | def SetDepexConent(self, Content):\r | |
68 | self.DepexContent = Content\r | |
69 | def GetDepexContent(self):\r | |
70 | return self.DepexContent\r | |
71 | \r | |
72 | def SetInfDepexContentItemList(self, InfDepexContentItemList):\r | |
73 | self.InfDepexContentItemList = InfDepexContentItemList\r | |
74 | def GetInfDepexContentItemList(self):\r | |
75 | return self.InfDepexContentItemList\r | |
76 | \r | |
77 | ## InfDepexObject\r | |
78 | #\r | |
79 | #\r | |
80 | #\r | |
81 | class InfDepexObject(InfSectionCommonDef):\r | |
82 | def __init__(self):\r | |
83 | self.Depex = []\r | |
84 | self.AllContent = ''\r | |
85 | self.SectionContent = ''\r | |
86 | InfSectionCommonDef.__init__(self)\r | |
87 | \r | |
88 | def SetDepex(self, DepexContent, KeyList=None, CommentList=None):\r | |
89 | for KeyItem in KeyList:\r | |
90 | Arch = KeyItem[0]\r | |
91 | ModuleType = KeyItem[1]\r | |
92 | InfDepexItemIns = InfDepexItem()\r | |
93 | \r | |
94 | #\r | |
95 | # Validate Arch\r | |
f7496d71 | 96 | #\r |
4234283c LG |
97 | if IsValidArch(Arch.strip().upper()):\r |
98 | InfDepexItemIns.SetSupArch(Arch)\r | |
99 | else:\r | |
100 | Logger.Error("InfParser",\r | |
101 | ToolError.FORMAT_INVALID,\r | |
102 | ST.ERR_INF_PARSER_DEFINE_NAME_INVALID % (Arch),\r | |
103 | File=GlobalData.gINF_MODULE_NAME,\r | |
104 | Line=KeyItem[2])\r | |
105 | \r | |
106 | #\r | |
107 | # Validate Module Type\r | |
108 | #\r | |
109 | if ModuleType and ModuleType != 'COMMON':\r | |
110 | if ModuleType in DT.VALID_DEPEX_MODULE_TYPE_LIST:\r | |
111 | InfDepexItemIns.SetModuleType(ModuleType)\r | |
112 | else:\r | |
113 | Logger.Error("InfParser",\r | |
114 | ToolError.FORMAT_INVALID,\r | |
115 | ST.ERR_INF_PARSER_DEPEX_SECTION_MODULE_TYPE_ERROR % (ModuleType),\r | |
116 | File=GlobalData.gINF_MODULE_NAME,\r | |
117 | Line=KeyItem[2])\r | |
118 | \r | |
119 | #\r | |
120 | # Parser content in [Depex] section.\r | |
121 | #\r | |
122 | DepexString = ''\r | |
123 | HelpString = ''\r | |
124 | #\r | |
125 | # Get Depex Expression\r | |
126 | #\r | |
127 | for Line in DepexContent:\r | |
128 | LineContent = Line[0].strip()\r | |
129 | if LineContent.find(DT.TAB_COMMENT_SPLIT) > -1:\r | |
130 | LineContent = LineContent[:LineContent.find(DT.TAB_COMMENT_SPLIT)]\r | |
131 | if LineContent:\r | |
132 | DepexString = DepexString + LineContent + DT.END_OF_LINE\r | |
133 | continue\r | |
134 | \r | |
135 | if DepexString.endswith(DT.END_OF_LINE):\r | |
136 | DepexString = DepexString[:-1]\r | |
137 | \r | |
138 | if not DepexString.strip():\r | |
139 | continue\r | |
140 | \r | |
141 | #\r | |
142 | # Get Help Text\r | |
143 | #\r | |
144 | for HelpLine in CommentList:\r | |
145 | HelpString = HelpString + HelpLine + DT.END_OF_LINE\r | |
146 | if HelpString.endswith(DT.END_OF_LINE):\r | |
147 | HelpString = HelpString[:-1]\r | |
148 | \r | |
149 | InfDepexItemIns.SetDepexConent(DepexString)\r | |
150 | InfDepexItemIns.SetHelpString(HelpString)\r | |
151 | \r | |
152 | self.Depex.append(InfDepexItemIns)\r | |
153 | \r | |
154 | return True\r | |
155 | \r | |
156 | def GetDepex(self):\r | |
157 | return self.Depex\r | |
158 | \r | |
159 | def GetAllContent(self):\r | |
160 | return self.AllContent\r |