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