]>
Commit | Line | Data |
---|---|---|
4234283c LG |
1 | ## @file\r |
2 | # This file is used to define class objects of INF file [Binaries] section. \r | |
3 | # It will consumed by InfParser. \r | |
4 | #\r | |
421ccda3 | 5 | # Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r |
4234283c LG |
6 | #\r |
7 | # This program and the accompanying materials are licensed and made available \r | |
8 | # under the terms and conditions of the BSD License which accompanies this \r | |
9 | # distribution. The full text of the license may be found at \r | |
10 | # http://opensource.org/licenses/bsd-license.php\r | |
11 | #\r | |
12 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | '''\r | |
16 | InfBinaryObject\r | |
17 | '''\r | |
18 | \r | |
19 | import os\r | |
20 | \r | |
21 | from copy import deepcopy\r | |
22 | from Library import DataType as DT\r | |
23 | from Library import GlobalData\r | |
24 | import Logger.Log as Logger\r | |
25 | from Logger import ToolError\r | |
26 | from Logger import StringTable as ST\r | |
27 | from Library.Misc import Sdict\r | |
28 | \r | |
29 | from Object.Parser.InfCommonObject import InfSectionCommonDef\r | |
30 | from Object.Parser.InfCommonObject import CurrentLine\r | |
31 | from Library.Misc import ConvPathFromAbsToRel\r | |
32 | from Library.ExpressionValidate import IsValidFeatureFlagExp\r | |
33 | from Library.Misc import ValidFile\r | |
34 | from Library.ParserValidate import IsValidPath\r | |
35 | \r | |
36 | \r | |
37 | class InfBianryItem():\r | |
38 | def __init__(self):\r | |
39 | self.FileName = ''\r | |
40 | self.Target = ''\r | |
41 | self.FeatureFlagExp = ''\r | |
42 | self.HelpString = ''\r | |
43 | self.Type = ''\r | |
44 | self.SupArchList = []\r | |
45 | \r | |
46 | def SetFileName(self, FileName):\r | |
47 | self.FileName = FileName\r | |
48 | def GetFileName(self):\r | |
49 | return self.FileName\r | |
50 | \r | |
51 | def SetTarget(self, Target):\r | |
52 | self.Target = Target\r | |
53 | def GetTarget(self):\r | |
54 | return self.Target\r | |
55 | \r | |
56 | def SetFeatureFlagExp(self, FeatureFlagExp):\r | |
57 | self.FeatureFlagExp = FeatureFlagExp\r | |
58 | def GetFeatureFlagExp(self):\r | |
59 | return self.FeatureFlagExp\r | |
60 | \r | |
61 | def SetHelpString(self, HelpString):\r | |
62 | self.HelpString = HelpString\r | |
63 | def GetHelpString(self):\r | |
64 | return self.HelpString\r | |
65 | \r | |
66 | def SetType(self, Type):\r | |
67 | self.Type = Type\r | |
68 | def GetType(self):\r | |
69 | return self.Type\r | |
70 | def SetSupArchList(self, SupArchList):\r | |
71 | self.SupArchList = SupArchList\r | |
72 | def GetSupArchList(self):\r | |
73 | return self.SupArchList\r | |
74 | \r | |
75 | class InfBianryVerItem(InfBianryItem, CurrentLine):\r | |
76 | def __init__(self):\r | |
77 | InfBianryItem.__init__(self)\r | |
78 | CurrentLine.__init__(self)\r | |
79 | self.VerTypeName = ''\r | |
80 | \r | |
81 | def SetVerTypeName(self, VerTypeName):\r | |
82 | self.VerTypeName = VerTypeName\r | |
83 | def GetVerTypeName(self):\r | |
84 | return self.VerTypeName\r | |
85 | \r | |
86 | class InfBianryUiItem(InfBianryItem, CurrentLine):\r | |
87 | def __init__(self):\r | |
88 | InfBianryItem.__init__(self)\r | |
89 | CurrentLine.__init__(self)\r | |
90 | self.UiTypeName = ''\r | |
91 | \r | |
92 | def SetUiTypeName(self, UiTypeName):\r | |
93 | self.UiTypeName = UiTypeName\r | |
94 | def GetVerTypeName(self):\r | |
95 | return self.UiTypeName\r | |
96 | \r | |
97 | class InfBianryCommonItem(InfBianryItem, CurrentLine):\r | |
98 | def __init__(self):\r | |
99 | self.CommonType = ''\r | |
100 | self.TagName = ''\r | |
101 | self.Family = ''\r | |
421ccda3 | 102 | self.GuidValue = ''\r |
4234283c LG |
103 | InfBianryItem.__init__(self)\r |
104 | CurrentLine.__init__(self)\r | |
105 | \r | |
106 | def SetCommonType(self, CommonType):\r | |
107 | self.CommonType = CommonType\r | |
108 | def GetCommonType(self):\r | |
109 | return self.CommonType\r | |
110 | \r | |
111 | def SetTagName(self, TagName):\r | |
112 | self.TagName = TagName\r | |
113 | def GetTagName(self):\r | |
114 | return self.TagName\r | |
115 | \r | |
116 | def SetFamily(self, Family):\r | |
117 | self.Family = Family\r | |
118 | def GetFamily(self):\r | |
119 | return self.Family\r | |
421ccda3 HC |
120 | \r |
121 | def SetGuidValue(self, GuidValue):\r | |
122 | self.GuidValue = GuidValue\r | |
123 | def GetGuidValue(self):\r | |
124 | return self.GuidValue\r | |
4234283c LG |
125 | \r |
126 | ##\r | |
127 | #\r | |
128 | #\r | |
129 | #\r | |
130 | class InfBinariesObject(InfSectionCommonDef):\r | |
131 | def __init__(self):\r | |
132 | self.Binaries = Sdict()\r | |
133 | #\r | |
134 | # Macro defined in this section should be only used in this section.\r | |
135 | #\r | |
136 | self.Macros = {}\r | |
137 | InfSectionCommonDef.__init__(self)\r | |
138 | \r | |
139 | ## CheckVer\r | |
140 | #\r | |
141 | #\r | |
142 | def CheckVer(self, Ver, __SupArchList):\r | |
143 | #\r | |
144 | # Check Ver\r | |
145 | #\r | |
146 | for VerItem in Ver:\r | |
147 | IsValidFileFlag = False\r | |
148 | VerContent = VerItem[0]\r | |
149 | VerComment = VerItem[1]\r | |
150 | VerCurrentLine = VerItem[2]\r | |
151 | GlobalData.gINF_CURRENT_LINE = VerCurrentLine\r | |
152 | InfBianryVerItemObj = None\r | |
153 | #\r | |
154 | # Should not less than 2 elements\r | |
155 | #\r | |
156 | if len(VerContent) < 2:\r | |
157 | Logger.Error("InfParser",\r | |
158 | ToolError.FORMAT_INVALID,\r | |
421ccda3 | 159 | ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (VerContent[0], 2),\r |
4234283c LG |
160 | File=VerCurrentLine.GetFileName(),\r |
161 | Line=VerCurrentLine.GetLineNo(),\r | |
162 | ExtraData=VerCurrentLine.GetLineString())\r | |
163 | return False\r | |
164 | if len(VerContent) > 4:\r | |
165 | Logger.Error("InfParser",\r | |
166 | ToolError.FORMAT_INVALID,\r | |
167 | ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID_MAX % (VerContent[0], 4),\r | |
168 | File=VerCurrentLine.GetFileName(),\r | |
169 | Line=VerCurrentLine.GetLineNo(),\r | |
170 | ExtraData=VerCurrentLine.GetLineString())\r | |
171 | return False\r | |
172 | if len(VerContent) >= 2:\r | |
173 | #\r | |
174 | # Create a Ver Object.\r | |
175 | #\r | |
176 | InfBianryVerItemObj = InfBianryVerItem()\r | |
177 | \r | |
178 | if VerContent[0] != DT.BINARY_FILE_TYPE_VER:\r | |
179 | Logger.Error("InfParser",\r | |
180 | ToolError.FORMAT_INVALID,\r | |
181 | ST.ERR_INF_PARSER_BINARY_VER_TYPE % DT.BINARY_FILE_TYPE_VER,\r | |
182 | File=VerCurrentLine.GetFileName(),\r | |
183 | Line=VerCurrentLine.GetLineNo(),\r | |
184 | ExtraData=VerCurrentLine.GetLineString())\r | |
185 | \r | |
186 | InfBianryVerItemObj.SetVerTypeName(VerContent[0])\r | |
187 | InfBianryVerItemObj.SetType(VerContent[0])\r | |
188 | #\r | |
189 | # Verify File exist or not\r | |
190 | #\r | |
191 | FullFileName = os.path.normpath(os.path.realpath(os.path.join(GlobalData.gINF_MODULE_DIR,\r | |
192 | VerContent[1])))\r | |
193 | if not (ValidFile(FullFileName) or ValidFile(VerContent[1])):\r | |
194 | Logger.Error("InfParser",\r | |
195 | ToolError.FORMAT_INVALID,\r | |
196 | ST.ERR_INF_PARSER_BINARY_ITEM_FILE_NOT_EXIST % (VerContent[1]),\r | |
197 | File=VerCurrentLine.GetFileName(),\r | |
198 | Line=VerCurrentLine.GetLineNo(),\r | |
199 | ExtraData=VerCurrentLine.GetLineString())\r | |
200 | #\r | |
201 | # Validate file exist/format.\r | |
202 | #\r | |
203 | if IsValidPath(VerContent[1], GlobalData.gINF_MODULE_DIR):\r | |
204 | IsValidFileFlag = True\r | |
205 | else:\r | |
206 | Logger.Error("InfParser",\r | |
207 | ToolError.FORMAT_INVALID,\r | |
208 | ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID % (VerContent[1]),\r | |
209 | File=VerCurrentLine.GetFileName(),\r | |
210 | Line=VerCurrentLine.GetLineNo(),\r | |
211 | ExtraData=VerCurrentLine.GetLineString())\r | |
212 | return False\r | |
213 | if IsValidFileFlag:\r | |
214 | VerContent[0] = ConvPathFromAbsToRel(VerContent[0],\r | |
215 | GlobalData.gINF_MODULE_DIR)\r | |
216 | InfBianryVerItemObj.SetFileName(VerContent[1])\r | |
217 | if len(VerContent) >= 3:\r | |
218 | #\r | |
219 | # Add Target information\r | |
220 | #\r | |
221 | InfBianryVerItemObj.SetTarget(VerContent[2])\r | |
222 | if len(VerContent) == 4:\r | |
223 | if VerContent[3].strip() == '':\r | |
224 | Logger.Error("InfParser",\r | |
225 | ToolError.FORMAT_INVALID,\r | |
226 | ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,\r | |
227 | File=VerCurrentLine.GetFileName(),\r | |
228 | Line=VerCurrentLine.GetLineNo(),\r | |
229 | ExtraData=VerCurrentLine.GetLineString())\r | |
230 | #\r | |
231 | # Validate Feature Flag Express \r | |
232 | #\r | |
233 | FeatureFlagRtv = IsValidFeatureFlagExp(VerContent[3].\\r | |
234 | strip())\r | |
235 | if not FeatureFlagRtv[0]:\r | |
236 | Logger.Error("InfParser",\r | |
237 | ToolError.FORMAT_INVALID,\r | |
238 | ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),\r | |
239 | File=VerCurrentLine.GetFileName(),\r | |
240 | Line=VerCurrentLine.GetLineNo(),\r | |
241 | ExtraData=VerCurrentLine.GetLineString())\r | |
242 | InfBianryVerItemObj.SetFeatureFlagExp(VerContent[3])\r | |
243 | \r | |
244 | InfBianryVerItemObj.SetSupArchList(__SupArchList)\r | |
245 | \r | |
246 | #\r | |
247 | # Determine binary file name duplicate. Follow below rule:\r | |
248 | #\r | |
249 | # A binary filename must not be duplicated within \r | |
250 | # a [Binaries] section. A binary filename may appear in \r | |
251 | # multiple architectural [Binaries] sections. A binary \r | |
252 | # filename listed in an architectural [Binaries] section \r | |
253 | # must not be listed in the common architectural \r | |
254 | # [Binaries] section.\r | |
255 | # \r | |
256 | # NOTE: This check will not report error now.\r | |
257 | # \r | |
258 | for Item in self.Binaries:\r | |
259 | if Item.GetFileName() == InfBianryVerItemObj.GetFileName():\r | |
260 | ItemSupArchList = Item.GetSupArchList()\r | |
261 | for ItemArch in ItemSupArchList:\r | |
262 | for VerItemObjArch in __SupArchList:\r | |
263 | if ItemArch == VerItemObjArch:\r | |
264 | #\r | |
265 | # ST.ERR_INF_PARSER_ITEM_DUPLICATE\r | |
266 | #\r | |
267 | pass\r | |
268 | if ItemArch.upper() == 'COMMON' or VerItemObjArch.upper() == 'COMMON':\r | |
269 | #\r | |
270 | # ERR_INF_PARSER_ITEM_DUPLICATE_COMMON\r | |
271 | #\r | |
272 | pass\r | |
273 | \r | |
4231a819 | 274 | if InfBianryVerItemObj is not None:\r |
4234283c LG |
275 | if self.Binaries.has_key((InfBianryVerItemObj)):\r |
276 | BinariesList = self.Binaries[InfBianryVerItemObj]\r | |
277 | BinariesList.append((InfBianryVerItemObj, VerComment))\r | |
278 | self.Binaries[InfBianryVerItemObj] = BinariesList\r | |
279 | else:\r | |
280 | BinariesList = []\r | |
281 | BinariesList.append((InfBianryVerItemObj, VerComment))\r | |
282 | self.Binaries[InfBianryVerItemObj] = BinariesList\r | |
283 | \r | |
284 | ## ParseCommonBinary\r | |
285 | #\r | |
286 | # ParseCommonBinary\r | |
287 | #\r | |
288 | def ParseCommonBinary(self, CommonBinary, __SupArchList):\r | |
289 | #\r | |
290 | # Check common binary definitions\r | |
291 | # Type | FileName | Target | Family | TagName | FeatureFlagExp\r | |
292 | #\r | |
293 | for Item in CommonBinary:\r | |
294 | IsValidFileFlag = False\r | |
295 | ItemContent = Item[0]\r | |
296 | ItemComment = Item[1]\r | |
297 | CurrentLineOfItem = Item[2]\r | |
298 | GlobalData.gINF_CURRENT_LINE = CurrentLineOfItem\r | |
299 | InfBianryCommonItemObj = None\r | |
421ccda3 HC |
300 | if ItemContent[0] == 'SUBTYPE_GUID':\r |
301 | if len(ItemContent) < 3:\r | |
302 | Logger.Error("InfParser",\r | |
303 | ToolError.FORMAT_INVALID,\r | |
304 | ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (ItemContent[0], 3),\r | |
305 | File=CurrentLineOfItem.GetFileName(),\r | |
306 | Line=CurrentLineOfItem.GetLineNo(),\r | |
307 | ExtraData=CurrentLineOfItem.GetLineString())\r | |
308 | return False\r | |
309 | else:\r | |
310 | if len(ItemContent) < 2:\r | |
311 | Logger.Error("InfParser",\r | |
312 | ToolError.FORMAT_INVALID,\r | |
313 | ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (ItemContent[0], 2),\r | |
314 | File=CurrentLineOfItem.GetFileName(),\r | |
315 | Line=CurrentLineOfItem.GetLineNo(),\r | |
316 | ExtraData=CurrentLineOfItem.GetLineString())\r | |
317 | return False\r | |
318 | \r | |
319 | if len(ItemContent) > 7:\r | |
4234283c LG |
320 | Logger.Error("InfParser",\r |
321 | ToolError.FORMAT_INVALID,\r | |
421ccda3 | 322 | ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID_MAX % (ItemContent[0], 7),\r |
4234283c LG |
323 | File=CurrentLineOfItem.GetFileName(),\r |
324 | Line=CurrentLineOfItem.GetLineNo(),\r | |
325 | ExtraData=CurrentLineOfItem.GetLineString())\r | |
326 | return False\r | |
327 | if len(ItemContent) >= 2:\r | |
328 | #\r | |
329 | # Create a Common Object.\r | |
330 | #\r | |
331 | InfBianryCommonItemObj = InfBianryCommonItem()\r | |
332 | #\r | |
333 | # Convert Binary type.\r | |
334 | #\r | |
335 | BinaryFileType = ItemContent[0].strip()\r | |
336 | if BinaryFileType == 'RAW' or BinaryFileType == 'ACPI' or BinaryFileType == 'ASL':\r | |
337 | BinaryFileType = 'BIN'\r | |
421ccda3 | 338 | \r |
4234283c LG |
339 | if BinaryFileType not in DT.BINARY_FILE_TYPE_LIST:\r |
340 | Logger.Error("InfParser",\r | |
341 | ToolError.FORMAT_INVALID,\r | |
342 | ST.ERR_INF_PARSER_BINARY_ITEM_INVALID_FILETYPE % \\r | |
343 | (DT.BINARY_FILE_TYPE_LIST.__str__()),\r | |
344 | File=CurrentLineOfItem.GetFileName(),\r | |
345 | Line=CurrentLineOfItem.GetLineNo(),\r | |
346 | ExtraData=CurrentLineOfItem.GetLineString())\r | |
347 | \r | |
348 | if BinaryFileType == 'SUBTYPE_GUID':\r | |
349 | BinaryFileType = 'FREEFORM'\r | |
350 | \r | |
351 | if BinaryFileType == 'LIB' or BinaryFileType == 'UEFI_APP':\r | |
352 | Logger.Error("InfParser",\r | |
353 | ToolError.FORMAT_INVALID,\r | |
354 | ST.ERR_INF_PARSER_BINARY_ITEM_INVALID_FILETYPE % \\r | |
355 | (DT.BINARY_FILE_TYPE_LIST.__str__()),\r | |
356 | File=CurrentLineOfItem.GetFileName(),\r | |
357 | Line=CurrentLineOfItem.GetLineNo(),\r | |
358 | ExtraData=CurrentLineOfItem.GetLineString())\r | |
359 | \r | |
360 | InfBianryCommonItemObj.SetType(BinaryFileType)\r | |
361 | InfBianryCommonItemObj.SetCommonType(ItemContent[0])\r | |
421ccda3 HC |
362 | FileName = ''\r |
363 | if BinaryFileType == 'FREEFORM':\r | |
364 | InfBianryCommonItemObj.SetGuidValue(ItemContent[1])\r | |
365 | if len(ItemContent) >= 3:\r | |
366 | FileName = ItemContent[2]\r | |
367 | else:\r | |
368 | Logger.Error("InfParser",\r | |
369 | ToolError.FORMAT_INVALID,\r | |
370 | ST.ERR_INF_PARSER_BINARY_ITEM_FILENAME_NOT_EXIST,\r | |
371 | File=CurrentLineOfItem.GetFileName(),\r | |
372 | Line=CurrentLineOfItem.GetLineNo(),\r | |
373 | ExtraData=CurrentLineOfItem.GetLineString())\r | |
374 | else:\r | |
375 | FileName = ItemContent[1]\r | |
4234283c LG |
376 | #\r |
377 | # Verify File exist or not\r | |
378 | #\r | |
379 | FullFileName = os.path.normpath(os.path.realpath(os.path.join(GlobalData.gINF_MODULE_DIR,\r | |
421ccda3 HC |
380 | FileName)))\r |
381 | if not (ValidFile(FullFileName) or ValidFile(FileName)):\r | |
4234283c LG |
382 | Logger.Error("InfParser",\r |
383 | ToolError.FORMAT_INVALID,\r | |
421ccda3 | 384 | ST.ERR_INF_PARSER_BINARY_ITEM_FILE_NOT_EXIST % (FileName),\r |
4234283c LG |
385 | File=CurrentLineOfItem.GetFileName(),\r |
386 | Line=CurrentLineOfItem.GetLineNo(),\r | |
387 | ExtraData=CurrentLineOfItem.GetLineString())\r | |
388 | #\r | |
389 | # Validate file exist/format.\r | |
390 | #\r | |
421ccda3 | 391 | if IsValidPath(FileName, GlobalData.gINF_MODULE_DIR):\r |
4234283c LG |
392 | IsValidFileFlag = True\r |
393 | else:\r | |
394 | Logger.Error("InfParser",\r | |
395 | ToolError.FORMAT_INVALID,\r | |
421ccda3 | 396 | ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID % (FileName),\r |
4234283c LG |
397 | File=CurrentLineOfItem.GetFileName(),\r |
398 | Line=CurrentLineOfItem.GetLineNo(),\r | |
399 | ExtraData=CurrentLineOfItem.GetLineString())\r | |
400 | return False\r | |
401 | if IsValidFileFlag:\r | |
402 | ItemContent[0] = ConvPathFromAbsToRel(ItemContent[0], GlobalData.gINF_MODULE_DIR)\r | |
421ccda3 | 403 | InfBianryCommonItemObj.SetFileName(FileName)\r |
4234283c LG |
404 | if len(ItemContent) >= 3:\r |
405 | #\r | |
406 | # Add Target information\r | |
407 | #\r | |
421ccda3 HC |
408 | if BinaryFileType != 'FREEFORM':\r |
409 | InfBianryCommonItemObj.SetTarget(ItemContent[2])\r | |
410 | \r | |
4234283c LG |
411 | if len(ItemContent) >= 4:\r |
412 | #\r | |
413 | # Add Family information\r | |
414 | #\r | |
421ccda3 HC |
415 | if BinaryFileType != 'FREEFORM':\r |
416 | InfBianryCommonItemObj.SetFamily(ItemContent[3])\r | |
417 | else:\r | |
418 | InfBianryCommonItemObj.SetTarget(ItemContent[3])\r | |
419 | \r | |
4234283c LG |
420 | if len(ItemContent) >= 5:\r |
421 | #\r | |
422 | # TagName entries are build system specific. If there \r | |
423 | # is content in the entry, the tool must exit \r | |
424 | # gracefully with an error message that indicates build\r | |
425 | # system specific content cannot be distributed using \r | |
426 | # the UDP\r | |
427 | #\r | |
421ccda3 HC |
428 | if BinaryFileType != 'FREEFORM':\r |
429 | if ItemContent[4].strip() != '':\r | |
430 | Logger.Error("InfParser",\r | |
431 | ToolError.FORMAT_INVALID,\r | |
432 | ST.ERR_INF_PARSER_TAGNAME_NOT_PERMITTED % (ItemContent[4]),\r | |
433 | File=CurrentLineOfItem.GetFileName(),\r | |
434 | Line=CurrentLineOfItem.GetLineNo(),\r | |
435 | ExtraData=CurrentLineOfItem.GetLineString())\r | |
436 | else:\r | |
437 | InfBianryCommonItemObj.SetFamily(ItemContent[4])\r | |
438 | \r | |
439 | if len(ItemContent) >= 6:\r | |
4234283c LG |
440 | #\r |
441 | # Add FeatureFlagExp\r | |
442 | #\r | |
421ccda3 HC |
443 | if BinaryFileType != 'FREEFORM':\r |
444 | if ItemContent[5].strip() == '':\r | |
445 | Logger.Error("InfParser",\r | |
446 | ToolError.FORMAT_INVALID,\r | |
447 | ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,\r | |
448 | File=CurrentLineOfItem.GetFileName(),\r | |
449 | Line=CurrentLineOfItem.GetLineNo(),\r | |
450 | ExtraData=CurrentLineOfItem.GetLineString())\r | |
451 | #\r | |
452 | # Validate Feature Flag Express \r | |
453 | #\r | |
454 | FeatureFlagRtv = IsValidFeatureFlagExp(ItemContent[5].strip())\r | |
455 | if not FeatureFlagRtv[0]:\r | |
456 | Logger.Error("InfParser",\r | |
457 | ToolError.FORMAT_INVALID,\r | |
458 | ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),\r | |
459 | File=CurrentLineOfItem.GetFileName(),\r | |
460 | Line=CurrentLineOfItem.GetLineNo(),\r | |
461 | ExtraData=CurrentLineOfItem.GetLineString())\r | |
462 | InfBianryCommonItemObj.SetFeatureFlagExp(ItemContent[5])\r | |
463 | else:\r | |
464 | if ItemContent[5].strip() != '':\r | |
465 | Logger.Error("InfParser",\r | |
466 | ToolError.FORMAT_INVALID,\r | |
467 | ST.ERR_INF_PARSER_TAGNAME_NOT_PERMITTED % (ItemContent[5]),\r | |
468 | File=CurrentLineOfItem.GetFileName(),\r | |
469 | Line=CurrentLineOfItem.GetLineNo(),\r | |
470 | ExtraData=CurrentLineOfItem.GetLineString())\r | |
471 | \r | |
472 | if len(ItemContent) == 7:\r | |
473 | if ItemContent[6].strip() == '':\r | |
4234283c | 474 | Logger.Error("InfParser",\r |
421ccda3 HC |
475 | ToolError.FORMAT_INVALID,\r |
476 | ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,\r | |
477 | File=CurrentLineOfItem.GetFileName(),\r | |
478 | Line=CurrentLineOfItem.GetLineNo(),\r | |
479 | ExtraData=CurrentLineOfItem.GetLineString())\r | |
4234283c LG |
480 | #\r |
481 | # Validate Feature Flag Express \r | |
482 | #\r | |
421ccda3 | 483 | FeatureFlagRtv = IsValidFeatureFlagExp(ItemContent[6].strip())\r |
4234283c LG |
484 | if not FeatureFlagRtv[0]:\r |
485 | Logger.Error("InfParser",\r | |
486 | ToolError.FORMAT_INVALID,\r | |
487 | ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),\r | |
488 | File=CurrentLineOfItem.GetFileName(),\r | |
489 | Line=CurrentLineOfItem.GetLineNo(),\r | |
490 | ExtraData=CurrentLineOfItem.GetLineString())\r | |
421ccda3 | 491 | InfBianryCommonItemObj.SetFeatureFlagExp(ItemContent[6])\r |
4234283c LG |
492 | \r |
493 | InfBianryCommonItemObj.SetSupArchList(__SupArchList)\r | |
494 | \r | |
495 | #\r | |
496 | # Determine binary file name duplicate. Follow below rule:\r | |
497 | #\r | |
498 | # A binary filename must not be duplicated within \r | |
499 | # a [Binaries] section. A binary filename may appear in \r | |
500 | # multiple architectural [Binaries] sections. A binary \r | |
501 | # filename listed in an architectural [Binaries] section \r | |
502 | # must not be listed in the common architectural \r | |
503 | # [Binaries] section.\r | |
504 | # \r | |
505 | # NOTE: This check will not report error now.\r | |
506 | # \r | |
507 | # for Item in self.Binaries:\r | |
508 | # if Item.GetFileName() == InfBianryCommonItemObj.GetFileName():\r | |
509 | # ItemSupArchList = Item.GetSupArchList()\r | |
510 | # for ItemArch in ItemSupArchList:\r | |
511 | # for ComItemObjArch in __SupArchList:\r | |
512 | # if ItemArch == ComItemObjArch:\r | |
513 | # #\r | |
514 | # # ST.ERR_INF_PARSER_ITEM_DUPLICATE\r | |
515 | # #\r | |
516 | # pass\r | |
517 | #\r | |
518 | # if ItemArch.upper() == 'COMMON' or ComItemObjArch.upper() == 'COMMON':\r | |
519 | # #\r | |
520 | # # ERR_INF_PARSER_ITEM_DUPLICATE_COMMON\r | |
521 | # #\r | |
522 | # pass\r | |
523 | \r | |
4231a819 | 524 | if InfBianryCommonItemObj is not None:\r |
4234283c LG |
525 | if self.Binaries.has_key((InfBianryCommonItemObj)):\r |
526 | BinariesList = self.Binaries[InfBianryCommonItemObj]\r | |
527 | BinariesList.append((InfBianryCommonItemObj, ItemComment))\r | |
528 | self.Binaries[InfBianryCommonItemObj] = BinariesList\r | |
529 | else:\r | |
530 | BinariesList = []\r | |
531 | BinariesList.append((InfBianryCommonItemObj, ItemComment))\r | |
532 | self.Binaries[InfBianryCommonItemObj] = BinariesList\r | |
533 | \r | |
534 | def SetBinary(self, UiInf=None, Ver=None, CommonBinary=None, ArchList=None):\r | |
535 | \r | |
536 | __SupArchList = []\r | |
537 | for ArchItem in ArchList:\r | |
538 | #\r | |
539 | # Validate Arch\r | |
540 | # \r | |
4231a819 | 541 | if (ArchItem == '' or ArchItem is None):\r |
4234283c LG |
542 | ArchItem = 'COMMON'\r |
543 | __SupArchList.append(ArchItem)\r | |
544 | \r | |
4231a819 | 545 | if UiInf is not None:\r |
4234283c LG |
546 | if len(UiInf) > 0:\r |
547 | #\r | |
548 | # Check UI\r | |
549 | # \r | |
550 | for UiItem in UiInf:\r | |
551 | IsValidFileFlag = False\r | |
552 | InfBianryUiItemObj = None\r | |
553 | UiContent = UiItem[0]\r | |
554 | UiComment = UiItem[1]\r | |
555 | UiCurrentLine = UiItem[2]\r | |
556 | GlobalData.gINF_CURRENT_LINE = deepcopy(UiItem[2])\r | |
557 | #\r | |
558 | # Should not less than 2 elements\r | |
559 | #\r | |
560 | if len(UiContent) < 2:\r | |
561 | Logger.Error("InfParser",\r | |
562 | ToolError.FORMAT_INVALID,\r | |
421ccda3 | 563 | ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID % (UiContent[0], 2),\r |
4234283c LG |
564 | File=UiCurrentLine.GetFileName(),\r |
565 | Line=UiCurrentLine.GetLineNo(),\r | |
566 | ExtraData=UiCurrentLine.GetLineString())\r | |
567 | return False\r | |
568 | \r | |
569 | if len(UiContent) > 4:\r | |
570 | Logger.Error("InfParser",\r | |
571 | ToolError.FORMAT_INVALID,\r | |
572 | ST.ERR_INF_PARSER_BINARY_ITEM_FORMAT_INVALID_MAX % (UiContent[0], 4),\r | |
573 | File=UiCurrentLine.GetFileName(),\r | |
574 | Line=UiCurrentLine.GetLineNo(),\r | |
575 | ExtraData=UiCurrentLine.GetLineString())\r | |
576 | return False\r | |
577 | if len(UiContent) >= 2:\r | |
578 | #\r | |
579 | # Create an Ui Object.\r | |
580 | #\r | |
581 | InfBianryUiItemObj = InfBianryUiItem()\r | |
582 | if UiContent[0] != 'UI':\r | |
583 | Logger.Error("InfParser",\r | |
584 | ToolError.FORMAT_INVALID,\r | |
585 | ST.ERR_INF_PARSER_BINARY_VER_TYPE % ('UI'),\r | |
586 | File=UiCurrentLine.GetFileName(),\r | |
587 | Line=UiCurrentLine.GetLineNo(),\r | |
588 | ExtraData=UiCurrentLine.GetLineString())\r | |
589 | InfBianryUiItemObj.SetUiTypeName(UiContent[0])\r | |
590 | InfBianryUiItemObj.SetType(UiContent[0])\r | |
591 | #\r | |
592 | # Verify File exist or not\r | |
593 | #\r | |
594 | FullFileName = os.path.normpath(os.path.realpath(os.path.join(GlobalData.gINF_MODULE_DIR,\r | |
595 | UiContent[1])))\r | |
596 | if not (ValidFile(FullFileName) or ValidFile(UiContent[1])):\r | |
597 | Logger.Error("InfParser",\r | |
598 | ToolError.FORMAT_INVALID,\r | |
599 | ST.ERR_INF_PARSER_BINARY_ITEM_FILE_NOT_EXIST % (UiContent[1]),\r | |
600 | File=UiCurrentLine.GetFileName(),\r | |
601 | Line=UiCurrentLine.GetLineNo(),\r | |
602 | ExtraData=UiCurrentLine.GetLineString())\r | |
603 | #\r | |
604 | # Validate file exist/format.\r | |
605 | #\r | |
606 | if IsValidPath(UiContent[1], GlobalData.gINF_MODULE_DIR):\r | |
607 | IsValidFileFlag = True\r | |
608 | else:\r | |
609 | Logger.Error("InfParser",\r | |
610 | ToolError.FORMAT_INVALID,\r | |
611 | ST.ERR_INF_PARSER_FILE_NOT_EXIST_OR_NAME_INVALID % (UiContent[1]),\r | |
612 | File=UiCurrentLine.GetFileName(),\r | |
613 | Line=UiCurrentLine.GetLineNo(),\r | |
614 | ExtraData=UiCurrentLine.GetLineString())\r | |
615 | return False\r | |
616 | if IsValidFileFlag:\r | |
617 | UiContent[0] = ConvPathFromAbsToRel(UiContent[0], GlobalData.gINF_MODULE_DIR)\r | |
618 | InfBianryUiItemObj.SetFileName(UiContent[1])\r | |
619 | if len(UiContent) >= 3:\r | |
620 | #\r | |
621 | # Add Target information\r | |
622 | #\r | |
623 | InfBianryUiItemObj.SetTarget(UiContent[2])\r | |
624 | if len(UiContent) == 4:\r | |
625 | if UiContent[3].strip() == '':\r | |
626 | Logger.Error("InfParser",\r | |
627 | ToolError.FORMAT_INVALID,\r | |
628 | ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_MISSING,\r | |
629 | File=UiCurrentLine.GetFileName(),\r | |
630 | Line=UiCurrentLine.GetLineNo(),\r | |
631 | ExtraData=UiCurrentLine.GetLineString())\r | |
632 | #\r | |
633 | # Validate Feature Flag Express \r | |
634 | #\r | |
635 | FeatureFlagRtv = IsValidFeatureFlagExp(UiContent[3].strip())\r | |
636 | if not FeatureFlagRtv[0]:\r | |
637 | Logger.Error("InfParser",\r | |
638 | ToolError.FORMAT_INVALID,\r | |
639 | ST.ERR_INF_PARSER_FEATURE_FLAG_EXP_SYNTAX_INVLID % (FeatureFlagRtv[1]),\r | |
640 | File=UiCurrentLine.GetFileName(),\r | |
641 | Line=UiCurrentLine.GetLineNo(),\r | |
642 | ExtraData=UiCurrentLine.GetLineString())\r | |
643 | InfBianryUiItemObj.SetFeatureFlagExp(UiContent[3])\r | |
644 | \r | |
645 | InfBianryUiItemObj.SetSupArchList(__SupArchList)\r | |
646 | \r | |
647 | #\r | |
648 | # Determine binary file name duplicate. Follow below rule:\r | |
649 | #\r | |
650 | # A binary filename must not be duplicated within \r | |
651 | # a [Binaries] section. A binary filename may appear in \r | |
652 | # multiple architectural [Binaries] sections. A binary \r | |
653 | # filename listed in an architectural [Binaries] section \r | |
654 | # must not be listed in the common architectural \r | |
655 | # [Binaries] section.\r | |
656 | # \r | |
657 | # NOTE: This check will not report error now.\r | |
658 | # \r | |
659 | # for Item in self.Binaries:\r | |
660 | # if Item.GetFileName() == InfBianryUiItemObj.GetFileName():\r | |
661 | # ItemSupArchList = Item.GetSupArchList()\r | |
662 | # for ItemArch in ItemSupArchList:\r | |
663 | # for UiItemObjArch in __SupArchList:\r | |
664 | # if ItemArch == UiItemObjArch:\r | |
665 | # #\r | |
666 | # # ST.ERR_INF_PARSER_ITEM_DUPLICATE\r | |
667 | # #\r | |
668 | # pass\r | |
669 | # if ItemArch.upper() == 'COMMON' or UiItemObjArch.upper() == 'COMMON':\r | |
670 | # #\r | |
671 | # # ERR_INF_PARSER_ITEM_DUPLICATE_COMMON\r | |
672 | # #\r | |
673 | # pass\r | |
674 | \r | |
4231a819 | 675 | if InfBianryUiItemObj is not None:\r |
4234283c LG |
676 | if self.Binaries.has_key((InfBianryUiItemObj)):\r |
677 | BinariesList = self.Binaries[InfBianryUiItemObj]\r | |
678 | BinariesList.append((InfBianryUiItemObj, UiComment))\r | |
679 | self.Binaries[InfBianryUiItemObj] = BinariesList\r | |
680 | else:\r | |
681 | BinariesList = []\r | |
682 | BinariesList.append((InfBianryUiItemObj, UiComment))\r | |
683 | self.Binaries[InfBianryUiItemObj] = BinariesList\r | |
4231a819 | 684 | if Ver is not None and len(Ver) > 0:\r |
4234283c LG |
685 | self.CheckVer(Ver, __SupArchList)\r |
686 | if CommonBinary and len(CommonBinary) > 0:\r | |
687 | self.ParseCommonBinary(CommonBinary, __SupArchList)\r | |
688 | \r | |
689 | return True\r | |
690 | \r | |
691 | def GetBinary(self):\r | |
692 | return self.Binaries\r |