]>
Commit | Line | Data |
---|---|---|
ae7b6df8 LG |
1 | ## @file\r |
2 | # This file is used to create a database used by build tool\r | |
3 | #\r | |
e0db09cd | 4 | # Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r |
ae7b6df8 LG |
5 | # (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r |
6 | # This program and the accompanying materials\r | |
7 | # are licensed and made available under the terms and conditions of the BSD License\r | |
8 | # which accompanies this distribution. The full text of the license may be found at\r | |
9 | # http://opensource.org/licenses/bsd-license.php\r | |
10 | #\r | |
11 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | #\r | |
5a57246e | 14 | from Common.StringUtils import *\r |
ae7b6df8 LG |
15 | from Common.DataType import *\r |
16 | from Common.Misc import *\r | |
17 | from types import *\r | |
79820e32 | 18 | from collections import OrderedDict\r |
ae7b6df8 LG |
19 | \r |
20 | from Workspace.BuildClassObject import PackageBuildClassObject, StructurePcd, PcdClassObject\r | |
21 | \r | |
22 | ## Platform build information from DEC file\r | |
23 | #\r | |
24 | # This class is used to retrieve information stored in database and convert them\r | |
25 | # into PackageBuildClassObject form for easier use for AutoGen.\r | |
26 | #\r | |
27 | class DecBuildData(PackageBuildClassObject):\r | |
28 | # dict used to convert PCD type in database to string used by build tool\r | |
29 | _PCD_TYPE_STRING_ = {\r | |
be409b67 CJ |
30 | MODEL_PCD_FIXED_AT_BUILD : TAB_PCDS_FIXED_AT_BUILD,\r |
31 | MODEL_PCD_PATCHABLE_IN_MODULE : TAB_PCDS_PATCHABLE_IN_MODULE,\r | |
32 | MODEL_PCD_FEATURE_FLAG : TAB_PCDS_FEATURE_FLAG,\r | |
33 | MODEL_PCD_DYNAMIC : TAB_PCDS_DYNAMIC,\r | |
34 | MODEL_PCD_DYNAMIC_DEFAULT : TAB_PCDS_DYNAMIC,\r | |
35 | MODEL_PCD_DYNAMIC_HII : TAB_PCDS_DYNAMIC_HII,\r | |
36 | MODEL_PCD_DYNAMIC_VPD : TAB_PCDS_DYNAMIC_VPD,\r | |
37 | MODEL_PCD_DYNAMIC_EX : TAB_PCDS_DYNAMIC_EX,\r | |
38 | MODEL_PCD_DYNAMIC_EX_DEFAULT : TAB_PCDS_DYNAMIC_EX,\r | |
39 | MODEL_PCD_DYNAMIC_EX_HII : TAB_PCDS_DYNAMIC_EX_HII,\r | |
40 | MODEL_PCD_DYNAMIC_EX_VPD : TAB_PCDS_DYNAMIC_EX_VPD,\r | |
ae7b6df8 LG |
41 | }\r |
42 | \r | |
43 | # dict used to convert part of [Defines] to members of DecBuildData directly\r | |
44 | _PROPERTY_ = {\r | |
45 | #\r | |
46 | # Required Fields\r | |
47 | #\r | |
48 | TAB_DEC_DEFINES_PACKAGE_NAME : "_PackageName",\r | |
49 | TAB_DEC_DEFINES_PACKAGE_GUID : "_Guid",\r | |
50 | TAB_DEC_DEFINES_PACKAGE_VERSION : "_Version",\r | |
51 | TAB_DEC_DEFINES_PKG_UNI_FILE : "_PkgUniFile",\r | |
52 | }\r | |
53 | \r | |
54 | \r | |
55 | ## Constructor of DecBuildData\r | |
56 | #\r | |
57 | # Initialize object of DecBuildData\r | |
58 | #\r | |
59 | # @param FilePath The path of package description file\r | |
60 | # @param RawData The raw data of DEC file\r | |
61 | # @param BuildDataBase Database used to retrieve module information\r | |
62 | # @param Arch The target architecture\r | |
63 | # @param Platform (not used for DecBuildData)\r | |
64 | # @param Macros Macros used for replacement in DSC file\r | |
65 | #\r | |
55c84777 | 66 | def __init__(self, File, RawData, BuildDataBase, Arch=TAB_ARCH_COMMON, Target=None, Toolchain=None):\r |
ae7b6df8 LG |
67 | self.MetaFile = File\r |
68 | self._PackageDir = File.Dir\r | |
69 | self._RawData = RawData\r | |
70 | self._Bdb = BuildDataBase\r | |
71 | self._Arch = Arch\r | |
72 | self._Target = Target\r | |
73 | self._Toolchain = Toolchain\r | |
74 | self._Clear()\r | |
75 | \r | |
76 | ## XXX[key] = value\r | |
77 | def __setitem__(self, key, value):\r | |
78 | self.__dict__[self._PROPERTY_[key]] = value\r | |
79 | \r | |
80 | ## value = XXX[key]\r | |
81 | def __getitem__(self, key):\r | |
82 | return self.__dict__[self._PROPERTY_[key]]\r | |
83 | \r | |
84 | ## "in" test support\r | |
85 | def __contains__(self, key):\r | |
86 | return key in self._PROPERTY_\r | |
87 | \r | |
88 | ## Set all internal used members of DecBuildData to None\r | |
89 | def _Clear(self):\r | |
90 | self._Header = None\r | |
91 | self._PackageName = None\r | |
92 | self._Guid = None\r | |
93 | self._Version = None\r | |
94 | self._PkgUniFile = None\r | |
95 | self._Protocols = None\r | |
96 | self._Ppis = None\r | |
97 | self._Guids = None\r | |
98 | self._Includes = None\r | |
0a57a978 | 99 | self._CommonIncludes = None\r |
ae7b6df8 LG |
100 | self._LibraryClasses = None\r |
101 | self._Pcds = None\r | |
71cac3f7 | 102 | self._MacroDict = None\r |
ae7b6df8 LG |
103 | self._PrivateProtocols = None\r |
104 | self._PrivatePpis = None\r | |
105 | self._PrivateGuids = None\r | |
106 | self._PrivateIncludes = None\r | |
107 | \r | |
108 | ## Get current effective macros\r | |
71cac3f7 CJ |
109 | @property\r |
110 | def _Macros(self):\r | |
111 | if self._MacroDict is None:\r | |
112 | self._MacroDict = dict(GlobalData.gGlobalDefines)\r | |
113 | return self._MacroDict\r | |
ae7b6df8 LG |
114 | \r |
115 | ## Get architecture\r | |
71cac3f7 CJ |
116 | @property\r |
117 | def Arch(self):\r | |
ae7b6df8 LG |
118 | return self._Arch\r |
119 | \r | |
ae7b6df8 LG |
120 | ## Retrieve all information in [Defines] section\r |
121 | #\r | |
122 | # (Retriving all [Defines] information in one-shot is just to save time.)\r | |
123 | #\r | |
124 | def _GetHeaderInfo(self):\r | |
125 | RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch]\r | |
126 | for Record in RecordList:\r | |
127 | Name = Record[1]\r | |
128 | if Name in self:\r | |
129 | self[Name] = Record[2]\r | |
130 | self._Header = 'DUMMY'\r | |
131 | \r | |
132 | ## Retrieve package name\r | |
71cac3f7 CJ |
133 | @property\r |
134 | def PackageName(self):\r | |
4231a819 CJ |
135 | if self._PackageName is None:\r |
136 | if self._Header is None:\r | |
ae7b6df8 | 137 | self._GetHeaderInfo()\r |
4231a819 | 138 | if self._PackageName is None:\r |
ae7b6df8 LG |
139 | EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "No PACKAGE_NAME", File=self.MetaFile)\r |
140 | return self._PackageName\r | |
141 | \r | |
142 | ## Retrieve file guid\r | |
71cac3f7 CJ |
143 | @property\r |
144 | def PackageName(self):\r | |
4231a819 CJ |
145 | if self._Guid is None:\r |
146 | if self._Header is None:\r | |
ae7b6df8 | 147 | self._GetHeaderInfo()\r |
4231a819 | 148 | if self._Guid is None:\r |
ae7b6df8 LG |
149 | EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "No PACKAGE_GUID", File=self.MetaFile)\r |
150 | return self._Guid\r | |
151 | \r | |
152 | ## Retrieve package version\r | |
71cac3f7 CJ |
153 | @property\r |
154 | def Version(self):\r | |
4231a819 CJ |
155 | if self._Version is None:\r |
156 | if self._Header is None:\r | |
ae7b6df8 | 157 | self._GetHeaderInfo()\r |
4231a819 | 158 | if self._Version is None:\r |
ae7b6df8 LG |
159 | self._Version = ''\r |
160 | return self._Version\r | |
161 | \r | |
162 | ## Retrieve protocol definitions (name/value pairs)\r | |
71cac3f7 CJ |
163 | @property\r |
164 | def Protocols(self):\r | |
4231a819 | 165 | if self._Protocols is None:\r |
ae7b6df8 LG |
166 | #\r |
167 | # tdict is a special kind of dict, used for selecting correct\r | |
168 | # protocol defition for given ARCH\r | |
169 | #\r | |
170 | ProtocolDict = tdict(True)\r | |
171 | PrivateProtocolDict = tdict(True)\r | |
172 | NameList = []\r | |
173 | PrivateNameList = []\r | |
174 | PublicNameList = []\r | |
175 | # find out all protocol definitions for specific and 'common' arch\r | |
176 | RecordList = self._RawData[MODEL_EFI_PROTOCOL, self._Arch]\r | |
177 | for Name, Guid, Dummy, Arch, PrivateFlag, ID, LineNo in RecordList:\r | |
178 | if PrivateFlag == 'PRIVATE':\r | |
179 | if Name not in PrivateNameList:\r | |
180 | PrivateNameList.append(Name)\r | |
181 | PrivateProtocolDict[Arch, Name] = Guid\r | |
182 | if Name in PublicNameList:\r | |
183 | EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % Name, File=self.MetaFile, Line=LineNo)\r | |
184 | else:\r | |
185 | if Name not in PublicNameList:\r | |
186 | PublicNameList.append(Name)\r | |
187 | if Name in PrivateNameList:\r | |
188 | EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % Name, File=self.MetaFile, Line=LineNo)\r | |
189 | if Name not in NameList:\r | |
190 | NameList.append(Name)\r | |
191 | ProtocolDict[Arch, Name] = Guid\r | |
6e6d767e CJ |
192 | # use OrderedDict to keep the order\r |
193 | self._Protocols = OrderedDict()\r | |
194 | self._PrivateProtocols = OrderedDict()\r | |
ae7b6df8 LG |
195 | for Name in NameList:\r |
196 | #\r | |
197 | # limit the ARCH to self._Arch, if no self._Arch found, tdict\r | |
198 | # will automatically turn to 'common' ARCH for trying\r | |
199 | #\r | |
200 | self._Protocols[Name] = ProtocolDict[self._Arch, Name]\r | |
201 | for Name in PrivateNameList:\r | |
202 | self._PrivateProtocols[Name] = PrivateProtocolDict[self._Arch, Name]\r | |
203 | return self._Protocols\r | |
204 | \r | |
205 | ## Retrieve PPI definitions (name/value pairs)\r | |
71cac3f7 CJ |
206 | @property\r |
207 | def Ppis(self):\r | |
4231a819 | 208 | if self._Ppis is None:\r |
ae7b6df8 LG |
209 | #\r |
210 | # tdict is a special kind of dict, used for selecting correct\r | |
211 | # PPI defition for given ARCH\r | |
212 | #\r | |
213 | PpiDict = tdict(True)\r | |
214 | PrivatePpiDict = tdict(True)\r | |
215 | NameList = []\r | |
216 | PrivateNameList = []\r | |
217 | PublicNameList = []\r | |
218 | # find out all PPI definitions for specific arch and 'common' arch\r | |
219 | RecordList = self._RawData[MODEL_EFI_PPI, self._Arch]\r | |
220 | for Name, Guid, Dummy, Arch, PrivateFlag, ID, LineNo in RecordList:\r | |
221 | if PrivateFlag == 'PRIVATE':\r | |
222 | if Name not in PrivateNameList:\r | |
223 | PrivateNameList.append(Name)\r | |
224 | PrivatePpiDict[Arch, Name] = Guid\r | |
225 | if Name in PublicNameList:\r | |
226 | EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % Name, File=self.MetaFile, Line=LineNo)\r | |
227 | else:\r | |
228 | if Name not in PublicNameList:\r | |
229 | PublicNameList.append(Name)\r | |
230 | if Name in PrivateNameList:\r | |
231 | EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % Name, File=self.MetaFile, Line=LineNo)\r | |
232 | if Name not in NameList:\r | |
233 | NameList.append(Name)\r | |
234 | PpiDict[Arch, Name] = Guid\r | |
6e6d767e CJ |
235 | # use OrderedDict to keep the order\r |
236 | self._Ppis = OrderedDict()\r | |
237 | self._PrivatePpis = OrderedDict()\r | |
ae7b6df8 LG |
238 | for Name in NameList:\r |
239 | #\r | |
240 | # limit the ARCH to self._Arch, if no self._Arch found, tdict\r | |
241 | # will automatically turn to 'common' ARCH for trying\r | |
242 | #\r | |
243 | self._Ppis[Name] = PpiDict[self._Arch, Name]\r | |
244 | for Name in PrivateNameList:\r | |
245 | self._PrivatePpis[Name] = PrivatePpiDict[self._Arch, Name]\r | |
246 | return self._Ppis\r | |
247 | \r | |
248 | ## Retrieve GUID definitions (name/value pairs)\r | |
71cac3f7 CJ |
249 | @property\r |
250 | def Guids(self):\r | |
4231a819 | 251 | if self._Guids is None:\r |
ae7b6df8 LG |
252 | #\r |
253 | # tdict is a special kind of dict, used for selecting correct\r | |
254 | # GUID defition for given ARCH\r | |
255 | #\r | |
256 | GuidDict = tdict(True)\r | |
257 | PrivateGuidDict = tdict(True)\r | |
258 | NameList = []\r | |
259 | PrivateNameList = []\r | |
260 | PublicNameList = []\r | |
261 | # find out all protocol definitions for specific and 'common' arch\r | |
262 | RecordList = self._RawData[MODEL_EFI_GUID, self._Arch]\r | |
263 | for Name, Guid, Dummy, Arch, PrivateFlag, ID, LineNo in RecordList:\r | |
264 | if PrivateFlag == 'PRIVATE':\r | |
265 | if Name not in PrivateNameList:\r | |
266 | PrivateNameList.append(Name)\r | |
267 | PrivateGuidDict[Arch, Name] = Guid\r | |
268 | if Name in PublicNameList:\r | |
269 | EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % Name, File=self.MetaFile, Line=LineNo)\r | |
270 | else:\r | |
271 | if Name not in PublicNameList:\r | |
272 | PublicNameList.append(Name)\r | |
273 | if Name in PrivateNameList:\r | |
274 | EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % Name, File=self.MetaFile, Line=LineNo)\r | |
275 | if Name not in NameList:\r | |
276 | NameList.append(Name)\r | |
277 | GuidDict[Arch, Name] = Guid\r | |
6e6d767e CJ |
278 | # use OrderedDict to keep the order\r |
279 | self._Guids = OrderedDict()\r | |
280 | self._PrivateGuids = OrderedDict()\r | |
ae7b6df8 LG |
281 | for Name in NameList:\r |
282 | #\r | |
283 | # limit the ARCH to self._Arch, if no self._Arch found, tdict\r | |
284 | # will automatically turn to 'common' ARCH for trying\r | |
285 | #\r | |
286 | self._Guids[Name] = GuidDict[self._Arch, Name]\r | |
287 | for Name in PrivateNameList:\r | |
288 | self._PrivateGuids[Name] = PrivateGuidDict[self._Arch, Name]\r | |
289 | return self._Guids\r | |
290 | \r | |
291 | ## Retrieve public include paths declared in this package\r | |
71cac3f7 CJ |
292 | @property\r |
293 | def Includes(self):\r | |
4231a819 | 294 | if self._Includes is None or self._CommonIncludes is None:\r |
0a57a978 | 295 | self._CommonIncludes = []\r |
ae7b6df8 LG |
296 | self._Includes = []\r |
297 | self._PrivateIncludes = []\r | |
298 | PublicInclues = []\r | |
299 | RecordList = self._RawData[MODEL_EFI_INCLUDE, self._Arch]\r | |
300 | Macros = self._Macros\r | |
301 | Macros["EDK_SOURCE"] = GlobalData.gEcpSource\r | |
302 | for Record in RecordList:\r | |
303 | File = PathClass(NormPath(Record[0], Macros), self._PackageDir, Arch=self._Arch)\r | |
304 | LineNo = Record[-1]\r | |
305 | # validate the path\r | |
306 | ErrorCode, ErrorInfo = File.Validate()\r | |
307 | if ErrorCode != 0:\r | |
308 | EdkLogger.error('build', ErrorCode, ExtraData=ErrorInfo, File=self.MetaFile, Line=LineNo)\r | |
309 | \r | |
310 | # avoid duplicate include path\r | |
311 | if File not in self._Includes:\r | |
312 | self._Includes.append(File)\r | |
313 | if Record[4] == 'PRIVATE':\r | |
314 | if File not in self._PrivateIncludes:\r | |
315 | self._PrivateIncludes.append(File)\r | |
316 | if File in PublicInclues:\r | |
317 | EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % File, File=self.MetaFile, Line=LineNo)\r | |
318 | else:\r | |
319 | if File not in PublicInclues:\r | |
320 | PublicInclues.append(File)\r | |
321 | if File in self._PrivateIncludes:\r | |
322 | EdkLogger.error('build', OPTION_CONFLICT, "Can't determine %s's attribute, it is both defined as Private and non-Private attribute in DEC file." % File, File=self.MetaFile, Line=LineNo)\r | |
55c84777 | 323 | if Record[3] == TAB_COMMON:\r |
0a57a978 | 324 | self._CommonIncludes.append(File)\r |
ae7b6df8 LG |
325 | return self._Includes\r |
326 | \r | |
327 | ## Retrieve library class declarations (not used in build at present)\r | |
71cac3f7 CJ |
328 | @property\r |
329 | def LibraryClasses(self):\r | |
4231a819 | 330 | if self._LibraryClasses is None:\r |
ae7b6df8 LG |
331 | #\r |
332 | # tdict is a special kind of dict, used for selecting correct\r | |
333 | # library class declaration for given ARCH\r | |
334 | #\r | |
335 | LibraryClassDict = tdict(True)\r | |
336 | LibraryClassSet = set()\r | |
337 | RecordList = self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Arch]\r | |
338 | Macros = self._Macros\r | |
339 | for LibraryClass, File, Dummy, Arch, PrivateFlag, ID, LineNo in RecordList:\r | |
340 | File = PathClass(NormPath(File, Macros), self._PackageDir, Arch=self._Arch)\r | |
341 | # check the file validation\r | |
342 | ErrorCode, ErrorInfo = File.Validate()\r | |
343 | if ErrorCode != 0:\r | |
344 | EdkLogger.error('build', ErrorCode, ExtraData=ErrorInfo, File=self.MetaFile, Line=LineNo)\r | |
345 | LibraryClassSet.add(LibraryClass)\r | |
346 | LibraryClassDict[Arch, LibraryClass] = File\r | |
6e6d767e | 347 | self._LibraryClasses = OrderedDict()\r |
ae7b6df8 LG |
348 | for LibraryClass in LibraryClassSet:\r |
349 | self._LibraryClasses[LibraryClass] = LibraryClassDict[self._Arch, LibraryClass]\r | |
350 | return self._LibraryClasses\r | |
351 | \r | |
352 | ## Retrieve PCD declarations\r | |
71cac3f7 CJ |
353 | @property\r |
354 | def Pcds(self):\r | |
4231a819 | 355 | if self._Pcds is None:\r |
6e6d767e | 356 | self._Pcds = OrderedDict()\r |
ae7b6df8 LG |
357 | self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))\r |
358 | self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE))\r | |
359 | self._Pcds.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG))\r | |
360 | self._Pcds.update(self._GetPcd(MODEL_PCD_DYNAMIC))\r | |
361 | self._Pcds.update(self._GetPcd(MODEL_PCD_DYNAMIC_EX))\r | |
362 | return self._Pcds\r | |
363 | \r | |
72a1d776 | 364 | def ParsePcdName(self,TokenCName):\r |
365 | TokenCName = TokenCName.strip()\r | |
366 | if TokenCName.startswith("["):\r | |
367 | if "." in TokenCName:\r | |
368 | Demesionattr = TokenCName[:TokenCName.index(".")]\r | |
369 | Fields = TokenCName[TokenCName.index(".")+1:]\r | |
370 | else:\r | |
371 | Demesionattr = TokenCName\r | |
372 | Fields = ""\r | |
373 | else:\r | |
374 | Demesionattr = ""\r | |
375 | Fields = TokenCName\r | |
376 | \r | |
377 | return Demesionattr,Fields\r | |
378 | \r | |
ae7b6df8 | 379 | def ProcessStructurePcd(self, StructurePcdRawDataSet):\r |
79820e32 | 380 | s_pcd_set = OrderedDict()\r |
ccaa7754 | 381 | for s_pcd, LineNo in StructurePcdRawDataSet:\r |
ae7b6df8 LG |
382 | if s_pcd.TokenSpaceGuidCName not in s_pcd_set:\r |
383 | s_pcd_set[s_pcd.TokenSpaceGuidCName] = []\r | |
ccaa7754 | 384 | s_pcd_set[s_pcd.TokenSpaceGuidCName].append((s_pcd, LineNo))\r |
ae7b6df8 LG |
385 | \r |
386 | str_pcd_set = []\r | |
387 | for pcdname in s_pcd_set:\r | |
388 | dep_pkgs = []\r | |
389 | struct_pcd = StructurePcd()\r | |
ccaa7754 | 390 | for item, LineNo in s_pcd_set[pcdname]:\r |
72a1d776 | 391 | if not item.TokenCName:\r |
392 | continue\r | |
ae7b6df8 | 393 | if "<HeaderFiles>" in item.TokenCName:\r |
81add864 | 394 | struct_pcd.StructuredPcdIncludeFile.append(item.DefaultValue)\r |
ae7b6df8 LG |
395 | elif "<Packages>" in item.TokenCName:\r |
396 | dep_pkgs.append(item.DefaultValue)\r | |
397 | elif item.DatumType == item.TokenCName:\r | |
398 | struct_pcd.copy(item)\r | |
399 | struct_pcd.TokenValue = struct_pcd.TokenValue.strip("{").strip()\r | |
400 | struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName = pcdname.split(".")\r | |
6a103440 FB |
401 | struct_pcd.PcdDefineLineNo = LineNo\r |
402 | struct_pcd.PkgPath = self.MetaFile.File\r | |
06140766 | 403 | struct_pcd.SetDecDefaultValue(item.DefaultValue)\r |
ae7b6df8 | 404 | else:\r |
72a1d776 | 405 | DemesionAttr, Fields = self.ParsePcdName(item.TokenCName)\r |
406 | struct_pcd.AddDefaultValue(Fields, item.DefaultValue, self.MetaFile.File, LineNo,DemesionAttr)\r | |
ae7b6df8 LG |
407 | \r |
408 | struct_pcd.PackageDecs = dep_pkgs\r | |
ae7b6df8 | 409 | str_pcd_set.append(struct_pcd)\r |
ae7b6df8 LG |
410 | return str_pcd_set\r |
411 | \r | |
412 | ## Retrieve PCD declarations for given type\r | |
413 | def _GetPcd(self, Type):\r | |
6e6d767e | 414 | Pcds = OrderedDict()\r |
ae7b6df8 LG |
415 | #\r |
416 | # tdict is a special kind of dict, used for selecting correct\r | |
417 | # PCD declaration for given ARCH\r | |
418 | #\r | |
419 | PcdDict = tdict(True, 3)\r | |
420 | # for summarizing PCD\r | |
e651d06c | 421 | PcdSet = []\r |
ae7b6df8 LG |
422 | # find out all PCDs of the 'type'\r |
423 | \r | |
424 | StrPcdSet = []\r | |
425 | RecordList = self._RawData[Type, self._Arch]\r | |
426 | for TokenSpaceGuid, PcdCName, Setting, Arch, PrivateFlag, Dummy1, Dummy2 in RecordList:\r | |
ccaa7754 | 427 | PcdDict[Arch, PcdCName, TokenSpaceGuid] = (Setting, Dummy2)\r |
e651d06c LG |
428 | if not (PcdCName, TokenSpaceGuid) in PcdSet:\r |
429 | PcdSet.append((PcdCName, TokenSpaceGuid))\r | |
ae7b6df8 | 430 | \r |
6f73a036 | 431 | DefinitionPosition = {}\r |
ae7b6df8 LG |
432 | for PcdCName, TokenSpaceGuid in PcdSet:\r |
433 | #\r | |
434 | # limit the ARCH to self._Arch, if no self._Arch found, tdict\r | |
435 | # will automatically turn to 'common' ARCH and try again\r | |
436 | #\r | |
ccaa7754 | 437 | Setting, LineNo = PcdDict[self._Arch, PcdCName, TokenSpaceGuid]\r |
4231a819 | 438 | if Setting is None:\r |
ae7b6df8 LG |
439 | continue\r |
440 | \r | |
441 | DefaultValue, DatumType, TokenNumber = AnalyzePcdData(Setting)\r | |
442 | validateranges, validlists, expressions = self._RawData.GetValidExpression(TokenSpaceGuid, PcdCName)\r | |
443 | PcdObj = PcdClassObject(\r | |
444 | PcdCName,\r | |
445 | TokenSpaceGuid,\r | |
446 | self._PCD_TYPE_STRING_[Type],\r | |
447 | DatumType,\r | |
448 | DefaultValue,\r | |
449 | TokenNumber,\r | |
450 | '',\r | |
451 | {},\r | |
452 | False,\r | |
453 | None,\r | |
454 | list(validateranges),\r | |
455 | list(validlists),\r | |
456 | list(expressions)\r | |
457 | )\r | |
6f73a036 | 458 | DefinitionPosition[PcdObj] = (self.MetaFile.File, LineNo)\r |
ae7b6df8 | 459 | if "." in TokenSpaceGuid:\r |
ccaa7754 | 460 | StrPcdSet.append((PcdObj, LineNo))\r |
ae7b6df8 LG |
461 | else:\r |
462 | Pcds[PcdCName, TokenSpaceGuid, self._PCD_TYPE_STRING_[Type]] = PcdObj\r | |
463 | \r | |
464 | StructurePcds = self.ProcessStructurePcd(StrPcdSet)\r | |
465 | for pcd in StructurePcds:\r | |
466 | Pcds[pcd.TokenCName, pcd.TokenSpaceGuidCName, self._PCD_TYPE_STRING_[Type]] = pcd\r | |
065a7d40 FB |
467 | for pcd in Pcds.values():\r |
468 | if pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r | |
72a1d776 | 469 | if not pcd.IsAggregateDatumType():\r |
6f73a036 | 470 | EdkLogger.error('build', FORMAT_INVALID, "DatumType only support BOOLEAN, UINT8, UINT16, UINT32, UINT64, VOID* or a valid struct name.", DefinitionPosition[pcd][0], DefinitionPosition[pcd][1])\r |
72a1d776 | 471 | elif not pcd.IsArray() and not pcd.StructuredPcdIncludeFile:\r |
472 | EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The structure Pcd %s.%s header file is not found in %s line %s \n" % (pcd.TokenSpaceGuidCName, pcd.TokenCName, pcd.DefinitionPosition[0], pcd.DefinitionPosition[1] ))\r | |
ae7b6df8 | 473 | return Pcds\r |
71cac3f7 | 474 | \r |
0a57a978 FB |
475 | @property\r |
476 | def CommonIncludes(self):\r | |
477 | if self._CommonIncludes is None:\r | |
478 | self.Includes\r | |
479 | return self._CommonIncludes\r |