BaseTool: GUID format PCD value assignment fail in Structure PCD field
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / DscBuildData.py
CommitLineData
ae7b6df8
LG
1## @file\r
2# This file is used to create a database used by build tool\r
3#\r
e6b10112 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
14\r
15## Platform build information from DSC file\r
16#\r
17# This class is used to retrieve information stored in database and convert them\r
18# into PlatformBuildClassObject form for easier use for AutoGen.\r
19#\r
20from Common.String import *\r
21from Common.DataType import *\r
22from Common.Misc import *\r
23from types import *\r
24\r
25from CommonDataClass.CommonClass import SkuInfoClass\r
68ba919f
YZ
26from Common.TargetTxtClassObject import *\r
27from Common.ToolDefClassObject import *\r
ae7b6df8
LG
28from MetaDataTable import *\r
29from MetaFileTable import *\r
30from MetaFileParser import *\r
31\r
32from WorkspaceCommon import GetDeclaredPcd\r
33from Common.Misc import AnalyzeDscPcd\r
34from Common.Misc import ProcessDuplicatedInf\r
35import re\r
36from Common.Parsing import IsValidWord\r
37from Common.VariableAttributes import VariableAttributes\r
38import Common.GlobalData as GlobalData\r
39import subprocess\r
0a57a978 40from Common.Misc import SaveFileOnChange\r
ae7b6df8 41from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, PcdClassObject, ModuleBuildClassObject\r
79820e32 42from collections import OrderedDict\r
ae7b6df8
LG
43\r
44#\r
45# Treat CHAR16 as a synonym for UINT16. CHAR16 support is required for VFR C structs\r
46#\r
47PcdValueInitName = 'PcdValueInit'\r
48PcdSupportedBaseTypes = ['BOOLEAN', 'UINT8', 'UINT16', 'UINT32', 'UINT64', 'CHAR16']\r
49PcdSupportedBaseTypeWidth = {'BOOLEAN':8, 'UINT8':8, 'UINT16':16, 'UINT32':32, 'UINT64':64}\r
50PcdUnsupportedBaseTypes = ['INT8', 'INT16', 'INT32', 'INT64', 'CHAR8', 'UINTN', 'INTN', 'VOID']\r
51\r
52PcdMainCHeader = '''\r
53/**\r
54 DO NOT EDIT\r
55 FILE auto-generated\r
56**/\r
57\r
58#include <stdio.h>\r
59#include <stdlib.h>\r
60#include <string.h>\r
61#include <PcdValueCommon.h>\r
62'''\r
63\r
64PcdMainCEntry = '''\r
65int\r
66main (\r
67 int argc,\r
68 char *argv[]\r
69 )\r
70{\r
71 return PcdValueMain (argc, argv);\r
72}\r
73'''\r
74\r
75PcdMakefileHeader = '''\r
76#\r
77# DO NOT EDIT\r
78# This file is auto-generated by build utility\r
79#\r
80\r
81'''\r
82\r
68ba919f
YZ
83WindowsCFLAGS = 'CFLAGS = $(CFLAGS) /wd4200 /wd4034 /wd4101 '\r
84LinuxCFLAGS = 'BUILD_CFLAGS += -Wno-pointer-to-int-cast -Wno-unused-variable '\r
ae7b6df8
LG
85PcdMakefileEnd = '''\r
86!INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.common\r
87\r
ae7b6df8
LG
88LIBS = $(LIB_PATH)\Common.lib\r
89\r
90!INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app\r
91'''\r
92\r
93PcdGccMakefile = '''\r
ae7b6df8
LG
94MAKEROOT ?= $(EDK_TOOLS_PATH)/Source/C\r
95LIBS = -lCommon\r
96'''\r
97\r
98class DscBuildData(PlatformBuildClassObject):\r
99 # dict used to convert PCD type in database to string used by build tool\r
100 _PCD_TYPE_STRING_ = {\r
101 MODEL_PCD_FIXED_AT_BUILD : "FixedAtBuild",\r
102 MODEL_PCD_PATCHABLE_IN_MODULE : "PatchableInModule",\r
103 MODEL_PCD_FEATURE_FLAG : "FeatureFlag",\r
104 MODEL_PCD_DYNAMIC : "Dynamic",\r
105 MODEL_PCD_DYNAMIC_DEFAULT : "Dynamic",\r
106 MODEL_PCD_DYNAMIC_HII : "DynamicHii",\r
107 MODEL_PCD_DYNAMIC_VPD : "DynamicVpd",\r
108 MODEL_PCD_DYNAMIC_EX : "DynamicEx",\r
109 MODEL_PCD_DYNAMIC_EX_DEFAULT : "DynamicEx",\r
110 MODEL_PCD_DYNAMIC_EX_HII : "DynamicExHii",\r
111 MODEL_PCD_DYNAMIC_EX_VPD : "DynamicExVpd",\r
112 }\r
113\r
114 # dict used to convert part of [Defines] to members of DscBuildData directly\r
115 _PROPERTY_ = {\r
116 #\r
117 # Required Fields\r
118 #\r
119 TAB_DSC_DEFINES_PLATFORM_NAME : "_PlatformName",\r
120 TAB_DSC_DEFINES_PLATFORM_GUID : "_Guid",\r
121 TAB_DSC_DEFINES_PLATFORM_VERSION : "_Version",\r
122 TAB_DSC_DEFINES_DSC_SPECIFICATION : "_DscSpecification",\r
123 # TAB_DSC_DEFINES_OUTPUT_DIRECTORY : "_OutputDirectory",\r
124 # TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES : "_SupArchList",\r
125 # TAB_DSC_DEFINES_BUILD_TARGETS : "_BuildTargets",\r
126 TAB_DSC_DEFINES_SKUID_IDENTIFIER : "_SkuName",\r
127 # TAB_DSC_DEFINES_FLASH_DEFINITION : "_FlashDefinition",\r
128 TAB_DSC_DEFINES_BUILD_NUMBER : "_BuildNumber",\r
129 TAB_DSC_DEFINES_MAKEFILE_NAME : "_MakefileName",\r
130 TAB_DSC_DEFINES_BS_BASE_ADDRESS : "_BsBaseAddress",\r
131 TAB_DSC_DEFINES_RT_BASE_ADDRESS : "_RtBaseAddress",\r
132 # TAB_DSC_DEFINES_RFC_LANGUAGES : "_RFCLanguages",\r
133 # TAB_DSC_DEFINES_ISO_LANGUAGES : "_ISOLanguages",\r
134 }\r
135\r
136 # used to compose dummy library class name for those forced library instances\r
137 _NullLibraryNumber = 0\r
138\r
139 ## Constructor of DscBuildData\r
140 #\r
141 # Initialize object of DscBuildData\r
142 #\r
143 # @param FilePath The path of platform description file\r
144 # @param RawData The raw data of DSC file\r
145 # @param BuildDataBase Database used to retrieve module/package information\r
146 # @param Arch The target architecture\r
147 # @param Platform (not used for DscBuildData)\r
148 # @param Macros Macros used for replacement in DSC file\r
149 #\r
150 def __init__(self, FilePath, RawData, BuildDataBase, Arch='COMMON', Target=None, Toolchain=None):\r
151 self.MetaFile = FilePath\r
152 self._RawData = RawData\r
153 self._Bdb = BuildDataBase\r
154 self._Arch = Arch\r
155 self._Target = Target\r
156 self._Toolchain = Toolchain\r
68ba919f 157 self._ToolChainFamily = None\r
ae7b6df8
LG
158 self._Clear()\r
159 self._HandleOverridePath()\r
0a57a978 160 self.WorkspaceDir = os.getenv("WORKSPACE") if os.getenv("WORKSPACE") else ""\r
8518bf0b 161 self.DefaultStores = None\r
e651d06c 162 self.SkuIdMgr = SkuClass(self.SkuName, self.SkuIds)\r
0a57a978
FB
163 @property\r
164 def OutputPath(self):\r
165 if os.getenv("WORKSPACE"):\r
166 return os.path.join(os.getenv("WORKSPACE"), self.OutputDirectory, self._Target + "_" + self._Toolchain,PcdValueInitName)\r
167 else:\r
168 return os.path.dirname(self.DscFile)\r
ae7b6df8
LG
169\r
170 ## XXX[key] = value\r
171 def __setitem__(self, key, value):\r
172 self.__dict__[self._PROPERTY_[key]] = value\r
173\r
174 ## value = XXX[key]\r
175 def __getitem__(self, key):\r
176 return self.__dict__[self._PROPERTY_[key]]\r
177\r
178 ## "in" test support\r
179 def __contains__(self, key):\r
180 return key in self._PROPERTY_\r
181\r
182 ## Set all internal used members of DscBuildData to None\r
183 def _Clear(self):\r
184 self._Header = None\r
185 self._PlatformName = None\r
186 self._Guid = None\r
187 self._Version = None\r
188 self._DscSpecification = None\r
189 self._OutputDirectory = None\r
190 self._SupArchList = None\r
191 self._BuildTargets = None\r
192 self._SkuName = None\r
ae7b6df8
LG
193 self._PcdInfoFlag = None\r
194 self._VarCheckFlag = None\r
195 self._FlashDefinition = None\r
196 self._Prebuild = None\r
197 self._Postbuild = None\r
198 self._BuildNumber = None\r
199 self._MakefileName = None\r
200 self._BsBaseAddress = None\r
201 self._RtBaseAddress = None\r
202 self._SkuIds = None\r
203 self._Modules = None\r
204 self._LibraryInstances = None\r
205 self._LibraryClasses = None\r
206 self._Pcds = None\r
207 self._DecPcds = None\r
208 self._BuildOptions = None\r
209 self._ModuleTypeOptions = None\r
210 self._LoadFixAddress = None\r
211 self._RFCLanguages = None\r
212 self._ISOLanguages = None\r
213 self._VpdToolGuid = None\r
214 self.__Macros = None\r
8518bf0b 215 self.DefaultStores = None\r
ae7b6df8
LG
216\r
217\r
218 ## handle Override Path of Module\r
219 def _HandleOverridePath(self):\r
220 RecordList = self._RawData[MODEL_META_DATA_COMPONENT, self._Arch]\r
221 Macros = self._Macros\r
222 Macros["EDK_SOURCE"] = GlobalData.gEcpSource\r
223 for Record in RecordList:\r
8518bf0b
LG
224 ModuleId = Record[6]\r
225 LineNo = Record[7]\r
ae7b6df8
LG
226 ModuleFile = PathClass(NormPath(Record[0]), GlobalData.gWorkspace, Arch=self._Arch)\r
227 RecordList = self._RawData[MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH, self._Arch, None, ModuleId]\r
228 if RecordList != []:\r
229 SourceOverridePath = mws.join(GlobalData.gWorkspace, NormPath(RecordList[0][0]))\r
230\r
231 # Check if the source override path exists\r
232 if not os.path.isdir(SourceOverridePath):\r
233 EdkLogger.error('build', FILE_NOT_FOUND, Message='Source override path does not exist:', File=self.MetaFile, ExtraData=SourceOverridePath, Line=LineNo)\r
234\r
235 # Add to GlobalData Variables\r
236 GlobalData.gOverrideDir[ModuleFile.Key] = SourceOverridePath\r
237\r
238 ## Get current effective macros\r
239 def _GetMacros(self):\r
240 if self.__Macros == None:\r
241 self.__Macros = {}\r
242 self.__Macros.update(GlobalData.gPlatformDefines)\r
243 self.__Macros.update(GlobalData.gGlobalDefines)\r
244 self.__Macros.update(GlobalData.gCommandLineDefines)\r
245 return self.__Macros\r
246\r
247 ## Get architecture\r
248 def _GetArch(self):\r
249 return self._Arch\r
250\r
251 ## Set architecture\r
252 #\r
253 # Changing the default ARCH to another may affect all other information\r
254 # because all information in a platform may be ARCH-related. That's\r
255 # why we need to clear all internal used members, in order to cause all\r
256 # information to be re-retrieved.\r
257 #\r
258 # @param Value The value of ARCH\r
259 #\r
260 def _SetArch(self, Value):\r
261 if self._Arch == Value:\r
262 return\r
263 self._Arch = Value\r
264 self._Clear()\r
265\r
266 ## Retrieve all information in [Defines] section\r
267 #\r
268 # (Retriving all [Defines] information in one-shot is just to save time.)\r
269 #\r
270 def _GetHeaderInfo(self):\r
271 RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch]\r
272 for Record in RecordList:\r
273 Name = Record[1]\r
274 # items defined _PROPERTY_ don't need additional processing\r
275\r
276 # some special items in [Defines] section need special treatment\r
277 if Name == TAB_DSC_DEFINES_OUTPUT_DIRECTORY:\r
278 self._OutputDirectory = NormPath(Record[2], self._Macros)\r
279 if ' ' in self._OutputDirectory:\r
280 EdkLogger.error("build", FORMAT_NOT_SUPPORTED, "No space is allowed in OUTPUT_DIRECTORY",\r
281 File=self.MetaFile, Line=Record[-1],\r
282 ExtraData=self._OutputDirectory)\r
283 elif Name == TAB_DSC_DEFINES_FLASH_DEFINITION:\r
284 self._FlashDefinition = PathClass(NormPath(Record[2], self._Macros), GlobalData.gWorkspace)\r
285 ErrorCode, ErrorInfo = self._FlashDefinition.Validate('.fdf')\r
286 if ErrorCode != 0:\r
287 EdkLogger.error('build', ErrorCode, File=self.MetaFile, Line=Record[-1],\r
288 ExtraData=ErrorInfo)\r
289 elif Name == TAB_DSC_PREBUILD:\r
290 PrebuildValue = Record[2]\r
291 if Record[2][0] == '"':\r
292 if Record[2][-1] != '"':\r
293 EdkLogger.error('build', FORMAT_INVALID, 'Missing double quotes in the end of %s statement.' % TAB_DSC_PREBUILD,\r
294 File=self.MetaFile, Line=Record[-1])\r
295 PrebuildValue = Record[2][1:-1]\r
296 self._Prebuild = PrebuildValue\r
297 elif Name == TAB_DSC_POSTBUILD:\r
298 PostbuildValue = Record[2]\r
299 if Record[2][0] == '"':\r
300 if Record[2][-1] != '"':\r
301 EdkLogger.error('build', FORMAT_INVALID, 'Missing double quotes in the end of %s statement.' % TAB_DSC_POSTBUILD,\r
302 File=self.MetaFile, Line=Record[-1])\r
303 PostbuildValue = Record[2][1:-1]\r
304 self._Postbuild = PostbuildValue\r
305 elif Name == TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES:\r
306 self._SupArchList = GetSplitValueList(Record[2], TAB_VALUE_SPLIT)\r
307 elif Name == TAB_DSC_DEFINES_BUILD_TARGETS:\r
308 self._BuildTargets = GetSplitValueList(Record[2])\r
309 elif Name == TAB_DSC_DEFINES_SKUID_IDENTIFIER:\r
310 if self._SkuName == None:\r
311 self._SkuName = Record[2]\r
e651d06c
LG
312 if GlobalData.gSKUID_CMD:\r
313 self._SkuName = GlobalData.gSKUID_CMD\r
ae7b6df8
LG
314 elif Name == TAB_DSC_DEFINES_PCD_INFO_GENERATION:\r
315 self._PcdInfoFlag = Record[2]\r
316 elif Name == TAB_DSC_DEFINES_PCD_VAR_CHECK_GENERATION:\r
317 self._VarCheckFlag = Record[2]\r
318 elif Name == TAB_FIX_LOAD_TOP_MEMORY_ADDRESS:\r
319 try:\r
320 self._LoadFixAddress = int (Record[2], 0)\r
321 except:\r
322 EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_MEMORY_ADDRESS %s is not valid dec or hex string" % (Record[2]))\r
323 elif Name == TAB_DSC_DEFINES_RFC_LANGUAGES:\r
324 if not Record[2] or Record[2][0] != '"' or Record[2][-1] != '"' or len(Record[2]) == 1:\r
325 EdkLogger.error('build', FORMAT_NOT_SUPPORTED, 'language code for RFC_LANGUAGES must have double quotes around it, for example: RFC_LANGUAGES = "en-us;zh-hans"',\r
326 File=self.MetaFile, Line=Record[-1])\r
327 LanguageCodes = Record[2][1:-1]\r
328 if not LanguageCodes:\r
329 EdkLogger.error('build', FORMAT_NOT_SUPPORTED, 'one or more RFC4646 format language code must be provided for RFC_LANGUAGES statement',\r
330 File=self.MetaFile, Line=Record[-1])\r
331 LanguageList = GetSplitValueList(LanguageCodes, TAB_SEMI_COLON_SPLIT)\r
332 # check whether there is empty entries in the list\r
333 if None in LanguageList:\r
334 EdkLogger.error('build', FORMAT_NOT_SUPPORTED, 'one or more empty language code is in RFC_LANGUAGES statement',\r
335 File=self.MetaFile, Line=Record[-1])\r
336 self._RFCLanguages = LanguageList\r
337 elif Name == TAB_DSC_DEFINES_ISO_LANGUAGES:\r
338 if not Record[2] or Record[2][0] != '"' or Record[2][-1] != '"' or len(Record[2]) == 1:\r
339 EdkLogger.error('build', FORMAT_NOT_SUPPORTED, 'language code for ISO_LANGUAGES must have double quotes around it, for example: ISO_LANGUAGES = "engchn"',\r
340 File=self.MetaFile, Line=Record[-1])\r
341 LanguageCodes = Record[2][1:-1]\r
342 if not LanguageCodes:\r
343 EdkLogger.error('build', FORMAT_NOT_SUPPORTED, 'one or more ISO639-2 format language code must be provided for ISO_LANGUAGES statement',\r
344 File=self.MetaFile, Line=Record[-1])\r
345 if len(LanguageCodes) % 3:\r
346 EdkLogger.error('build', FORMAT_NOT_SUPPORTED, 'bad ISO639-2 format for ISO_LANGUAGES',\r
347 File=self.MetaFile, Line=Record[-1])\r
348 LanguageList = []\r
349 for i in range(0, len(LanguageCodes), 3):\r
350 LanguageList.append(LanguageCodes[i:i + 3])\r
351 self._ISOLanguages = LanguageList\r
352 elif Name == TAB_DSC_DEFINES_VPD_TOOL_GUID:\r
353 #\r
354 # try to convert GUID to a real UUID value to see whether the GUID is format\r
355 # for VPD_TOOL_GUID is correct.\r
356 #\r
357 try:\r
358 uuid.UUID(Record[2])\r
359 except:\r
360 EdkLogger.error("build", FORMAT_INVALID, "Invalid GUID format for VPD_TOOL_GUID", File=self.MetaFile)\r
361 self._VpdToolGuid = Record[2]\r
362 elif Name in self:\r
363 self[Name] = Record[2]\r
364 # set _Header to non-None in order to avoid database re-querying\r
365 self._Header = 'DUMMY'\r
366\r
367 ## Retrieve platform name\r
368 def _GetPlatformName(self):\r
369 if self._PlatformName == None:\r
370 if self._Header == None:\r
371 self._GetHeaderInfo()\r
372 if self._PlatformName == None:\r
373 EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No PLATFORM_NAME", File=self.MetaFile)\r
374 return self._PlatformName\r
375\r
376 ## Retrieve file guid\r
377 def _GetFileGuid(self):\r
378 if self._Guid == None:\r
379 if self._Header == None:\r
380 self._GetHeaderInfo()\r
381 if self._Guid == None:\r
382 EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No PLATFORM_GUID", File=self.MetaFile)\r
383 return self._Guid\r
384\r
385 ## Retrieve platform version\r
386 def _GetVersion(self):\r
387 if self._Version == None:\r
388 if self._Header == None:\r
389 self._GetHeaderInfo()\r
390 if self._Version == None:\r
391 EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No PLATFORM_VERSION", File=self.MetaFile)\r
392 return self._Version\r
393\r
394 ## Retrieve platform description file version\r
395 def _GetDscSpec(self):\r
396 if self._DscSpecification == None:\r
397 if self._Header == None:\r
398 self._GetHeaderInfo()\r
399 if self._DscSpecification == None:\r
400 EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No DSC_SPECIFICATION", File=self.MetaFile)\r
401 return self._DscSpecification\r
402\r
403 ## Retrieve OUTPUT_DIRECTORY\r
404 def _GetOutpuDir(self):\r
405 if self._OutputDirectory == None:\r
406 if self._Header == None:\r
407 self._GetHeaderInfo()\r
408 if self._OutputDirectory == None:\r
409 self._OutputDirectory = os.path.join("Build", self._PlatformName)\r
410 return self._OutputDirectory\r
411\r
412 ## Retrieve SUPPORTED_ARCHITECTURES\r
413 def _GetSupArch(self):\r
414 if self._SupArchList == None:\r
415 if self._Header == None:\r
416 self._GetHeaderInfo()\r
417 if self._SupArchList == None:\r
418 EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No SUPPORTED_ARCHITECTURES", File=self.MetaFile)\r
419 return self._SupArchList\r
420\r
421 ## Retrieve BUILD_TARGETS\r
422 def _GetBuildTarget(self):\r
423 if self._BuildTargets == None:\r
424 if self._Header == None:\r
425 self._GetHeaderInfo()\r
426 if self._BuildTargets == None:\r
427 EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No BUILD_TARGETS", File=self.MetaFile)\r
428 return self._BuildTargets\r
429\r
430 def _GetPcdInfoFlag(self):\r
431 if self._PcdInfoFlag == None or self._PcdInfoFlag.upper() == 'FALSE':\r
432 return False\r
433 elif self._PcdInfoFlag.upper() == 'TRUE':\r
434 return True\r
435 else:\r
436 return False\r
437 def _GetVarCheckFlag(self):\r
438 if self._VarCheckFlag == None or self._VarCheckFlag.upper() == 'FALSE':\r
439 return False\r
440 elif self._VarCheckFlag.upper() == 'TRUE':\r
441 return True\r
442 else:\r
443 return False\r
e651d06c
LG
444\r
445 # # Retrieve SKUID_IDENTIFIER\r
ae7b6df8
LG
446 def _GetSkuName(self):\r
447 if self._SkuName == None:\r
448 if self._Header == None:\r
449 self._GetHeaderInfo()\r
e651d06c 450 if self._SkuName == None:\r
ae7b6df8
LG
451 self._SkuName = 'DEFAULT'\r
452 return self._SkuName\r
453\r
454 ## Override SKUID_IDENTIFIER\r
455 def _SetSkuName(self, Value):\r
456 self._SkuName = Value\r
ae7b6df8
LG
457\r
458 def _GetFdfFile(self):\r
459 if self._FlashDefinition == None:\r
460 if self._Header == None:\r
461 self._GetHeaderInfo()\r
462 if self._FlashDefinition == None:\r
463 self._FlashDefinition = ''\r
464 return self._FlashDefinition\r
465\r
466 def _GetPrebuild(self):\r
467 if self._Prebuild == None:\r
468 if self._Header == None:\r
469 self._GetHeaderInfo()\r
470 if self._Prebuild == None:\r
471 self._Prebuild = ''\r
472 return self._Prebuild\r
473\r
474 def _GetPostbuild(self):\r
475 if self._Postbuild == None:\r
476 if self._Header == None:\r
477 self._GetHeaderInfo()\r
478 if self._Postbuild == None:\r
479 self._Postbuild = ''\r
480 return self._Postbuild\r
481\r
482 ## Retrieve FLASH_DEFINITION\r
483 def _GetBuildNumber(self):\r
484 if self._BuildNumber == None:\r
485 if self._Header == None:\r
486 self._GetHeaderInfo()\r
487 if self._BuildNumber == None:\r
488 self._BuildNumber = ''\r
489 return self._BuildNumber\r
490\r
491 ## Retrieve MAKEFILE_NAME\r
492 def _GetMakefileName(self):\r
493 if self._MakefileName == None:\r
494 if self._Header == None:\r
495 self._GetHeaderInfo()\r
496 if self._MakefileName == None:\r
497 self._MakefileName = ''\r
498 return self._MakefileName\r
499\r
500 ## Retrieve BsBaseAddress\r
501 def _GetBsBaseAddress(self):\r
502 if self._BsBaseAddress == None:\r
503 if self._Header == None:\r
504 self._GetHeaderInfo()\r
505 if self._BsBaseAddress == None:\r
506 self._BsBaseAddress = ''\r
507 return self._BsBaseAddress\r
508\r
509 ## Retrieve RtBaseAddress\r
510 def _GetRtBaseAddress(self):\r
511 if self._RtBaseAddress == None:\r
512 if self._Header == None:\r
513 self._GetHeaderInfo()\r
514 if self._RtBaseAddress == None:\r
515 self._RtBaseAddress = ''\r
516 return self._RtBaseAddress\r
517\r
518 ## Retrieve the top address for the load fix address\r
519 def _GetLoadFixAddress(self):\r
520 if self._LoadFixAddress == None:\r
521 if self._Header == None:\r
522 self._GetHeaderInfo()\r
523\r
524 if self._LoadFixAddress == None:\r
525 self._LoadFixAddress = self._Macros.get(TAB_FIX_LOAD_TOP_MEMORY_ADDRESS, '0')\r
526\r
527 try:\r
528 self._LoadFixAddress = int (self._LoadFixAddress, 0)\r
529 except:\r
530 EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_MEMORY_ADDRESS %s is not valid dec or hex string" % (self._LoadFixAddress))\r
531\r
532 #\r
533 # If command line defined, should override the value in DSC file.\r
534 #\r
535 if 'FIX_LOAD_TOP_MEMORY_ADDRESS' in GlobalData.gCommandLineDefines.keys():\r
536 try:\r
537 self._LoadFixAddress = int(GlobalData.gCommandLineDefines['FIX_LOAD_TOP_MEMORY_ADDRESS'], 0)\r
538 except:\r
539 EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_MEMORY_ADDRESS %s is not valid dec or hex string" % (GlobalData.gCommandLineDefines['FIX_LOAD_TOP_MEMORY_ADDRESS']))\r
540\r
541 if self._LoadFixAddress < 0:\r
542 EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_MEMORY_ADDRESS is set to the invalid negative value 0x%x" % (self._LoadFixAddress))\r
543 if self._LoadFixAddress != 0xFFFFFFFFFFFFFFFF and self._LoadFixAddress % 0x1000 != 0:\r
544 EdkLogger.error("build", PARAMETER_INVALID, "FIX_LOAD_TOP_MEMORY_ADDRESS is set to the invalid unaligned 4K value 0x%x" % (self._LoadFixAddress))\r
545\r
546 return self._LoadFixAddress\r
547\r
548 ## Retrieve RFCLanguage filter\r
549 def _GetRFCLanguages(self):\r
550 if self._RFCLanguages == None:\r
551 if self._Header == None:\r
552 self._GetHeaderInfo()\r
553 if self._RFCLanguages == None:\r
554 self._RFCLanguages = []\r
555 return self._RFCLanguages\r
556\r
557 ## Retrieve ISOLanguage filter\r
558 def _GetISOLanguages(self):\r
559 if self._ISOLanguages == None:\r
560 if self._Header == None:\r
561 self._GetHeaderInfo()\r
562 if self._ISOLanguages == None:\r
563 self._ISOLanguages = []\r
564 return self._ISOLanguages\r
565 ## Retrieve the GUID string for VPD tool\r
566 def _GetVpdToolGuid(self):\r
567 if self._VpdToolGuid == None:\r
568 if self._Header == None:\r
569 self._GetHeaderInfo()\r
570 if self._VpdToolGuid == None:\r
571 self._VpdToolGuid = ''\r
572 return self._VpdToolGuid\r
573\r
574 ## Retrieve [SkuIds] section information\r
575 def _GetSkuIds(self):\r
576 if self._SkuIds == None:\r
577 self._SkuIds = sdict()\r
578 RecordList = self._RawData[MODEL_EFI_SKU_ID, self._Arch]\r
579 for Record in RecordList:\r
580 if Record[0] in [None, '']:\r
581 EdkLogger.error('build', FORMAT_INVALID, 'No Sku ID number',\r
582 File=self.MetaFile, Line=Record[-1])\r
583 if Record[1] in [None, '']:\r
584 EdkLogger.error('build', FORMAT_INVALID, 'No Sku ID name',\r
585 File=self.MetaFile, Line=Record[-1])\r
8518bf0b 586 Pattern = re.compile('^[1-9]\d*|0$')\r
e6b10112
YZ
587 HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$')\r
588 if Pattern.match(Record[0]) == None and HexPattern.match(Record[0]) == None:\r
589 EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID number is invalid. It only support Integer and HexNumber",\r
8518bf0b
LG
590 File=self.MetaFile, Line=Record[-1])\r
591 if not IsValidWord(Record[1]):\r
592 EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID name is invalid. The correct format is '(a-zA-Z0-9_)(a-zA-Z0-9_-.)*'",\r
593 File=self.MetaFile, Line=Record[-1])\r
e6b10112 594 self._SkuIds[Record[1].upper()] = (str(self.ToInt(Record[0])), Record[1].upper(), Record[2].upper())\r
ae7b6df8 595 if 'DEFAULT' not in self._SkuIds:\r
8518bf0b 596 self._SkuIds['DEFAULT'] = ("0","DEFAULT","DEFAULT")\r
ae7b6df8 597 if 'COMMON' not in self._SkuIds:\r
8518bf0b 598 self._SkuIds['COMMON'] = ("0","DEFAULT","DEFAULT")\r
ae7b6df8 599 return self._SkuIds\r
8518bf0b
LG
600 def ToInt(self,intstr):\r
601 return int(intstr,16) if intstr.upper().startswith("0X") else int(intstr)\r
602 def _GetDefaultStores(self):\r
603 if self.DefaultStores == None:\r
604 self.DefaultStores = sdict()\r
605 RecordList = self._RawData[MODEL_EFI_DEFAULT_STORES, self._Arch]\r
606 for Record in RecordList:\r
607 if Record[0] in [None, '']:\r
608 EdkLogger.error('build', FORMAT_INVALID, 'No DefaultStores ID number',\r
609 File=self.MetaFile, Line=Record[-1])\r
610 if Record[1] in [None, '']:\r
611 EdkLogger.error('build', FORMAT_INVALID, 'No DefaultStores ID name',\r
612 File=self.MetaFile, Line=Record[-1])\r
767ddbe8
YZ
613 Pattern = re.compile('^[1-9]\d*|0$')\r
614 HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$')\r
615 if Pattern.match(Record[0]) == None and HexPattern.match(Record[0]) == None:\r
616 EdkLogger.error('build', FORMAT_INVALID, "The format of the DefaultStores ID number is invalid. It only support Integer and HexNumber",\r
617 File=self.MetaFile, Line=Record[-1])\r
618 if not IsValidWord(Record[1]):\r
619 EdkLogger.error('build', FORMAT_INVALID, "The format of the DefaultStores ID name is invalid. The correct format is '(a-zA-Z0-9_)(a-zA-Z0-9_-.)*'",\r
620 File=self.MetaFile, Line=Record[-1])\r
2b8a6c44 621 self.DefaultStores[Record[1].upper()] = (self.ToInt(Record[0]),Record[1].upper())\r
8518bf0b
LG
622 if TAB_DEFAULT_STORES_DEFAULT not in self.DefaultStores:\r
623 self.DefaultStores[TAB_DEFAULT_STORES_DEFAULT] = (0,TAB_DEFAULT_STORES_DEFAULT)\r
e651d06c
LG
624 GlobalData.gDefaultStores = self.DefaultStores.keys()\r
625 if GlobalData.gDefaultStores:\r
626 GlobalData.gDefaultStores.sort()\r
8518bf0b 627 return self.DefaultStores\r
ae7b6df8
LG
628\r
629 ## Retrieve [Components] section information\r
630 def _GetModules(self):\r
631 if self._Modules != None:\r
632 return self._Modules\r
633\r
634 self._Modules = sdict()\r
635 RecordList = self._RawData[MODEL_META_DATA_COMPONENT, self._Arch]\r
636 Macros = self._Macros\r
637 Macros["EDK_SOURCE"] = GlobalData.gEcpSource\r
638 for Record in RecordList:\r
639 DuplicatedFile = False\r
640\r
641 ModuleFile = PathClass(NormPath(Record[0], Macros), GlobalData.gWorkspace, Arch=self._Arch)\r
8518bf0b
LG
642 ModuleId = Record[6]\r
643 LineNo = Record[7]\r
ae7b6df8
LG
644\r
645 # check the file validation\r
646 ErrorCode, ErrorInfo = ModuleFile.Validate('.inf')\r
647 if ErrorCode != 0:\r
648 EdkLogger.error('build', ErrorCode, File=self.MetaFile, Line=LineNo,\r
649 ExtraData=ErrorInfo)\r
650 # Check duplication\r
651 # If arch is COMMON, no duplicate module is checked since all modules in all component sections are selected\r
652 if self._Arch != 'COMMON' and ModuleFile in self._Modules:\r
653 DuplicatedFile = True\r
654\r
655 Module = ModuleBuildClassObject()\r
656 Module.MetaFile = ModuleFile\r
657\r
658 # get module private library instance\r
659 RecordList = self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Arch, None, ModuleId]\r
660 for Record in RecordList:\r
661 LibraryClass = Record[0]\r
662 LibraryPath = PathClass(NormPath(Record[1], Macros), GlobalData.gWorkspace, Arch=self._Arch)\r
663 LineNo = Record[-1]\r
664\r
665 # check the file validation\r
666 ErrorCode, ErrorInfo = LibraryPath.Validate('.inf')\r
667 if ErrorCode != 0:\r
668 EdkLogger.error('build', ErrorCode, File=self.MetaFile, Line=LineNo,\r
669 ExtraData=ErrorInfo)\r
670\r
671 if LibraryClass == '' or LibraryClass == 'NULL':\r
672 self._NullLibraryNumber += 1\r
673 LibraryClass = 'NULL%d' % self._NullLibraryNumber\r
674 EdkLogger.verbose("Found forced library for %s\n\t%s [%s]" % (ModuleFile, LibraryPath, LibraryClass))\r
675 Module.LibraryClasses[LibraryClass] = LibraryPath\r
676 if LibraryPath not in self.LibraryInstances:\r
677 self.LibraryInstances.append(LibraryPath)\r
678\r
679 # get module private PCD setting\r
680 for Type in [MODEL_PCD_FIXED_AT_BUILD, MODEL_PCD_PATCHABLE_IN_MODULE, \\r
681 MODEL_PCD_FEATURE_FLAG, MODEL_PCD_DYNAMIC, MODEL_PCD_DYNAMIC_EX]:\r
682 RecordList = self._RawData[Type, self._Arch, None, ModuleId]\r
8518bf0b 683 for TokenSpaceGuid, PcdCName, Setting, Dummy1, Dummy2, Dummy3, Dummy4,Dummy5 in RecordList:\r
ae7b6df8
LG
684 TokenList = GetSplitValueList(Setting)\r
685 DefaultValue = TokenList[0]\r
cdbf45ad
YZ
686 # the format is PcdName| Value | VOID* | MaxDatumSize\r
687 if len(TokenList) > 2:\r
688 MaxDatumSize = TokenList[2]\r
ae7b6df8
LG
689 else:\r
690 MaxDatumSize = ''\r
691 TypeString = self._PCD_TYPE_STRING_[Type]\r
692 Pcd = PcdClassObject(\r
693 PcdCName,\r
694 TokenSpaceGuid,\r
695 TypeString,\r
696 '',\r
697 DefaultValue,\r
698 '',\r
699 MaxDatumSize,\r
700 {},\r
701 False,\r
702 None\r
703 )\r
704 Module.Pcds[PcdCName, TokenSpaceGuid] = Pcd\r
705\r
706 # get module private build options\r
707 RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, None, ModuleId]\r
8518bf0b 708 for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3, Dummy4,Dummy5 in RecordList:\r
ae7b6df8
LG
709 if (ToolChainFamily, ToolChain) not in Module.BuildOptions:\r
710 Module.BuildOptions[ToolChainFamily, ToolChain] = Option\r
711 else:\r
712 OptionString = Module.BuildOptions[ToolChainFamily, ToolChain]\r
713 Module.BuildOptions[ToolChainFamily, ToolChain] = OptionString + " " + Option\r
714\r
715 RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch, None, ModuleId]\r
716 if DuplicatedFile and not RecordList:\r
717 EdkLogger.error('build', FILE_DUPLICATED, File=self.MetaFile, ExtraData=str(ModuleFile), Line=LineNo)\r
718 if RecordList:\r
719 if len(RecordList) != 1:\r
720 EdkLogger.error('build', OPTION_UNKNOWN, 'Only FILE_GUID can be listed in <Defines> section.',\r
721 File=self.MetaFile, ExtraData=str(ModuleFile), Line=LineNo)\r
722 ModuleFile = ProcessDuplicatedInf(ModuleFile, RecordList[0][2], GlobalData.gWorkspace)\r
723 ModuleFile.Arch = self._Arch\r
724\r
725 self._Modules[ModuleFile] = Module\r
726 return self._Modules\r
727\r
728 ## Retrieve all possible library instances used in this platform\r
729 def _GetLibraryInstances(self):\r
730 if self._LibraryInstances == None:\r
731 self._GetLibraryClasses()\r
732 return self._LibraryInstances\r
733\r
734 ## Retrieve [LibraryClasses] information\r
735 def _GetLibraryClasses(self):\r
736 if self._LibraryClasses == None:\r
737 self._LibraryInstances = []\r
738 #\r
739 # tdict is a special dict kind of type, used for selecting correct\r
740 # library instance for given library class and module type\r
741 #\r
742 LibraryClassDict = tdict(True, 3)\r
743 # track all library class names\r
744 LibraryClassSet = set()\r
745 RecordList = self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Arch, None, -1]\r
746 Macros = self._Macros\r
747 for Record in RecordList:\r
8518bf0b 748 LibraryClass, LibraryInstance, Dummy, Arch, ModuleType, Dummy,Dummy, LineNo = Record\r
ae7b6df8
LG
749 if LibraryClass == '' or LibraryClass == 'NULL':\r
750 self._NullLibraryNumber += 1\r
751 LibraryClass = 'NULL%d' % self._NullLibraryNumber\r
752 EdkLogger.verbose("Found forced library for arch=%s\n\t%s [%s]" % (Arch, LibraryInstance, LibraryClass))\r
753 LibraryClassSet.add(LibraryClass)\r
754 LibraryInstance = PathClass(NormPath(LibraryInstance, Macros), GlobalData.gWorkspace, Arch=self._Arch)\r
755 # check the file validation\r
756 ErrorCode, ErrorInfo = LibraryInstance.Validate('.inf')\r
757 if ErrorCode != 0:\r
758 EdkLogger.error('build', ErrorCode, File=self.MetaFile, Line=LineNo,\r
759 ExtraData=ErrorInfo)\r
760\r
761 if ModuleType != 'COMMON' and ModuleType not in SUP_MODULE_LIST:\r
762 EdkLogger.error('build', OPTION_UNKNOWN, "Unknown module type [%s]" % ModuleType,\r
763 File=self.MetaFile, ExtraData=LibraryInstance, Line=LineNo)\r
764 LibraryClassDict[Arch, ModuleType, LibraryClass] = LibraryInstance\r
765 if LibraryInstance not in self._LibraryInstances:\r
766 self._LibraryInstances.append(LibraryInstance)\r
767\r
768 # resolve the specific library instance for each class and each module type\r
769 self._LibraryClasses = tdict(True)\r
770 for LibraryClass in LibraryClassSet:\r
771 # try all possible module types\r
772 for ModuleType in SUP_MODULE_LIST:\r
773 LibraryInstance = LibraryClassDict[self._Arch, ModuleType, LibraryClass]\r
774 if LibraryInstance == None:\r
775 continue\r
776 self._LibraryClasses[LibraryClass, ModuleType] = LibraryInstance\r
777\r
778 # for Edk style library instances, which are listed in different section\r
779 Macros["EDK_SOURCE"] = GlobalData.gEcpSource\r
780 RecordList = self._RawData[MODEL_EFI_LIBRARY_INSTANCE, self._Arch]\r
781 for Record in RecordList:\r
782 File = PathClass(NormPath(Record[0], Macros), GlobalData.gWorkspace, Arch=self._Arch)\r
783 LineNo = Record[-1]\r
784 # check the file validation\r
785 ErrorCode, ErrorInfo = File.Validate('.inf')\r
786 if ErrorCode != 0:\r
787 EdkLogger.error('build', ErrorCode, File=self.MetaFile, Line=LineNo,\r
788 ExtraData=ErrorInfo)\r
789 if File not in self._LibraryInstances:\r
790 self._LibraryInstances.append(File)\r
791 #\r
792 # we need the module name as the library class name, so we have\r
793 # to parse it here. (self._Bdb[] will trigger a file parse if it\r
794 # hasn't been parsed)\r
795 #\r
796 Library = self._Bdb[File, self._Arch, self._Target, self._Toolchain]\r
797 self._LibraryClasses[Library.BaseName, ':dummy:'] = Library\r
798 return self._LibraryClasses\r
799\r
800 def _ValidatePcd(self, PcdCName, TokenSpaceGuid, Setting, PcdType, LineNo):\r
801 if self._DecPcds == None:\r
2b8a6c44 802\r
ae7b6df8
LG
803 FdfInfList = []\r
804 if GlobalData.gFdfParser:\r
805 FdfInfList = GlobalData.gFdfParser.Profile.InfList\r
806\r
807 PkgSet = set()\r
808 for Inf in FdfInfList:\r
809 ModuleFile = PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch=self._Arch)\r
810 if ModuleFile in self._Modules:\r
811 continue\r
812 ModuleData = self._Bdb[ModuleFile, self._Arch, self._Target, self._Toolchain]\r
813 PkgSet.update(ModuleData.Packages)\r
ae7b6df8 814\r
726c501c 815 self._DecPcds, self._GuidDict = GetDeclaredPcd(self, self._Bdb, self._Arch, self._Target, self._Toolchain,PkgSet)\r
9efe8d60 816 self._GuidDict.update(GlobalData.gPlatformPcds)\r
2b8a6c44
LG
817\r
818 if (PcdCName, TokenSpaceGuid) not in self._DecPcds:\r
ae7b6df8
LG
819 EdkLogger.error('build', PARSER_ERROR,\r
820 "Pcd (%s.%s) defined in DSC is not declared in DEC files. Arch: ['%s']" % (TokenSpaceGuid, PcdCName, self._Arch),\r
821 File=self.MetaFile, Line=LineNo)\r
822 ValueList, IsValid, Index = AnalyzeDscPcd(Setting, PcdType, self._DecPcds[PcdCName, TokenSpaceGuid].DatumType)\r
520365de
B
823 if not IsValid:\r
824 if PcdType not in [MODEL_PCD_FEATURE_FLAG, MODEL_PCD_FIXED_AT_BUILD]:\r
825 EdkLogger.error('build', FORMAT_INVALID, "Pcd format incorrect.", File=self.MetaFile, Line=LineNo,\r
826 ExtraData="%s.%s|%s" % (TokenSpaceGuid, PcdCName, Setting))\r
827 else:\r
828 if ValueList[2] == '-1':\r
829 EdkLogger.error('build', FORMAT_INVALID, "Pcd format incorrect.", File=self.MetaFile, Line=LineNo,\r
830 ExtraData="%s.%s|%s" % (TokenSpaceGuid, PcdCName, Setting))\r
35f613d9
YF
831 if ValueList[Index]:\r
832 DatumType = self._DecPcds[PcdCName, TokenSpaceGuid].DatumType\r
ae7b6df8 833 try:\r
35f613d9 834 ValueList[Index] = ValueExpressionEx(ValueList[Index], DatumType, self._GuidDict)(True)\r
726c501c 835 except BadExpression, Value:\r
35f613d9
YF
836 EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=LineNo,\r
837 ExtraData="PCD [%s.%s] Value \"%s\" " % (\r
838 TokenSpaceGuid, PcdCName, ValueList[Index]))\r
ae7b6df8
LG
839 except EvaluationException, Excpt:\r
840 if hasattr(Excpt, 'Pcd'):\r
841 if Excpt.Pcd in GlobalData.gPlatformOtherPcds:\r
842 EdkLogger.error('Parser', FORMAT_INVALID, "Cannot use this PCD (%s) in an expression as"\r
843 " it must be defined in a [PcdsFixedAtBuild] or [PcdsFeatureFlag] section"\r
844 " of the DSC file" % Excpt.Pcd,\r
845 File=self.MetaFile, Line=LineNo)\r
846 else:\r
847 EdkLogger.error('Parser', FORMAT_INVALID, "PCD (%s) is not defined in DSC file" % Excpt.Pcd,\r
848 File=self.MetaFile, Line=LineNo)\r
849 else:\r
850 EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt),\r
851 File=self.MetaFile, Line=LineNo)\r
35f613d9 852\r
ae7b6df8
LG
853 if ValueList[Index]:\r
854 Valid, ErrStr = CheckPcdDatum(self._DecPcds[PcdCName, TokenSpaceGuid].DatumType, ValueList[Index])\r
855 if not Valid:\r
856 EdkLogger.error('build', FORMAT_INVALID, ErrStr, File=self.MetaFile, Line=LineNo,\r
857 ExtraData="%s.%s" % (TokenSpaceGuid, PcdCName))\r
520365de
B
858 if PcdType in (MODEL_PCD_DYNAMIC_DEFAULT, MODEL_PCD_DYNAMIC_EX_DEFAULT):\r
859 if self._DecPcds[PcdCName, TokenSpaceGuid].DatumType.strip() != ValueList[1].strip():\r
5db9414c 860 EdkLogger.error('build', FORMAT_INVALID, "Pcd datumtype used in DSC file is not the same as its declaration in DEC file." , File=self.MetaFile, Line=LineNo,\r
520365de 861 ExtraData="%s.%s|%s" % (TokenSpaceGuid, PcdCName, Setting))\r
35f613d9
YF
862 if (TokenSpaceGuid + '.' + PcdCName) in GlobalData.gPlatformPcds:\r
863 if GlobalData.gPlatformPcds[TokenSpaceGuid + '.' + PcdCName] != ValueList[Index]:\r
864 GlobalData.gPlatformPcds[TokenSpaceGuid + '.' + PcdCName] = ValueList[Index]\r
ae7b6df8
LG
865 return ValueList\r
866\r
8518bf0b
LG
867 def _FilterPcdBySkuUsage(self,Pcds):\r
868 available_sku = self.SkuIdMgr.AvailableSkuIdSet\r
869 sku_usage = self.SkuIdMgr.SkuUsageType\r
870 if sku_usage == SkuClass.SINGLE:\r
871 for pcdname in Pcds:\r
872 pcd = Pcds[pcdname]\r
873 Pcds[pcdname].SkuInfoList = {"DEFAULT":pcd.SkuInfoList[skuid] for skuid in pcd.SkuInfoList if skuid in available_sku}\r
65eff519
LG
874 if type(pcd) is StructurePcd and pcd.SkuOverrideValues:\r
875 Pcds[pcdname].SkuOverrideValues = {"DEFAULT":pcd.SkuOverrideValues[skuid] for skuid in pcd.SkuOverrideValues if skuid in available_sku}\r
8518bf0b
LG
876 else:\r
877 for pcdname in Pcds:\r
878 pcd = Pcds[pcdname]\r
879 Pcds[pcdname].SkuInfoList = {skuid:pcd.SkuInfoList[skuid] for skuid in pcd.SkuInfoList if skuid in available_sku}\r
65eff519
LG
880 if type(pcd) is StructurePcd and pcd.SkuOverrideValues:\r
881 Pcds[pcdname].SkuOverrideValues = {skuid:pcd.SkuOverrideValues[skuid] for skuid in pcd.SkuOverrideValues if skuid in available_sku}\r
8518bf0b 882 return Pcds\r
2b8a6c44
LG
883 def CompleteHiiPcdsDefaultStores(self,Pcds):\r
884 HiiPcd = [Pcds[pcd] for pcd in Pcds if Pcds[pcd].Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]]\r
885 DefaultStoreMgr = DefaultStore(self.DefaultStores)\r
886 for pcd in HiiPcd:\r
887 for skuid in pcd.SkuInfoList:\r
888 skuobj = pcd.SkuInfoList.get(skuid)\r
889 if "STANDARD" not in skuobj.DefaultStoreDict:\r
890 PcdDefaultStoreSet = set([defaultstorename for defaultstorename in skuobj.DefaultStoreDict])\r
891 mindefaultstorename = DefaultStoreMgr.GetMin(PcdDefaultStoreSet)\r
892 skuobj.DefaultStoreDict['STANDARD'] = copy.deepcopy(skuobj.DefaultStoreDict[mindefaultstorename])\r
893 return Pcds\r
894\r
6f49996c
FB
895 def RecoverCommandLinePcd(self):\r
896 pcdset = []\r
897 if GlobalData.BuildOptionPcd:\r
898 for pcd in GlobalData.BuildOptionPcd:\r
899 if pcd[2] == "":\r
900 pcdset.append((pcd[0],pcd[1],pcd[3]))\r
901 else:\r
06140766 902 if (pcd[1],pcd[0]) not in self._Pcds:\r
e1511113
B
903 pcdvalue = pcd[3] if len(pcd) == 4 else pcd[2]\r
904 pcdset.append((pcd[0],pcd[1],pcdvalue))\r
06140766
FB
905 #else:\r
906 # remove the settings from command line since it has been handled.\r
6f49996c
FB
907 GlobalData.BuildOptionPcd = pcdset\r
908 def GetFieldValueFromComm(self,ValueStr,TokenSpaceGuidCName, TokenCName, FieldName):\r
909 PredictedFieldType = "VOID*"\r
910 if ValueStr.startswith('L'):\r
911 if not ValueStr[1]:\r
912 EdkLogger.error("build", FORMAT_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", H"{...}"')\r
913 ValueStr = ValueStr[0] + '"' + ValueStr[1:] + '"'\r
914 PredictedFieldType = "VOID*"\r
915 elif ValueStr.startswith('H') or ValueStr.startswith('{'):\r
916 EdkLogger.error("build", FORMAT_INVALID, 'Currently we do not support assign H"{...}" format for Pcd field.', ExtraData="%s.%s.%s from command line" % (TokenSpaceGuidCName, TokenCName, FieldName))\r
917 ValueStr = ValueStr[1:]\r
918 PredictedFieldType = "VOID*"\r
919 elif ValueStr.upper() in ['TRUE', '0X1', '0X01', '1', 'FALSE', '0X0', '0X00', '0']:\r
920 PredictedFieldType = "BOOLEAN"\r
921 elif ValueStr.isdigit() or ValueStr.upper().startswith('0X'):\r
922 PredictedFieldType = TAB_UINT16\r
923 else:\r
924 if not ValueStr[0]:\r
925 EdkLogger.error("build", FORMAT_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", H"{...}"')\r
926 ValueStr = '"' + ValueStr + '"'\r
927 PredictedFieldType = "VOID*"\r
928 IsValid, Cause = CheckPcdDatum(PredictedFieldType, ValueStr)\r
929 if not IsValid:\r
930 EdkLogger.error("build", FORMAT_INVALID, Cause, ExtraData="%s.%s.%s from command line" % (TokenSpaceGuidCName, TokenCName, FieldName))\r
931 if PredictedFieldType == 'BOOLEAN':\r
932 ValueStr = ValueStr.upper()\r
933 if ValueStr == 'TRUE' or ValueStr == '1':\r
934 ValueStr = '1'\r
935 elif ValueStr == 'FALSE' or ValueStr == '0':\r
936 ValueStr = '0'\r
937 return ValueStr\r
938 def __ParsePcdFromCommandLine(self):\r
939 if GlobalData.BuildOptionPcd:\r
940 for i, pcd in enumerate(GlobalData.BuildOptionPcd):\r
941 if type(pcd) is tuple:\r
942 continue\r
943 (pcdname, pcdvalue) = pcd.split('=')\r
944 if not pcdvalue:\r
945 EdkLogger.error('build', AUTOGEN_ERROR, "No Value specified for the PCD %s." % (pcdname))\r
946 if '.' in pcdname:\r
947 (Name1, Name2) = pcdname.split('.',1)\r
948 if "." in Name2:\r
949 (Name3, FieldName) = Name2.split(".",1)\r
950 if ((Name3,Name1)) in self.DecPcds:\r
951 HasTokenSpace = True\r
952 TokenCName = Name3\r
953 TokenSpaceGuidCName = Name1\r
954 else:\r
955 FieldName = Name2\r
956 TokenCName = Name1\r
957 TokenSpaceGuidCName = ''\r
958 HasTokenSpace = False\r
959 else:\r
960 if ((Name2,Name1)) in self.DecPcds:\r
961 HasTokenSpace = True\r
962 TokenCName = Name2\r
963 TokenSpaceGuidCName = Name1\r
964 FieldName =""\r
965 else:\r
966 FieldName = Name2\r
967 TokenCName = Name1\r
968 TokenSpaceGuidCName = ''\r
969 HasTokenSpace = False\r
970 else:\r
971 FieldName = ""\r
972 TokenCName = pcdname\r
973 TokenSpaceGuidCName = ''\r
974 HasTokenSpace = False\r
975 TokenSpaceGuidCNameList = []\r
976 FoundFlag = False\r
977 PcdDatumType = ''\r
978 NewValue = ''\r
979 if not HasTokenSpace:\r
980 for key in self.DecPcds:\r
981 if TokenCName == key[0]:\r
982 if TokenSpaceGuidCName:\r
983 EdkLogger.error(\r
984 'build',\r
985 AUTOGEN_ERROR,\r
986 "The Pcd %s is found under multiple different TokenSpaceGuid: %s and %s." % (TokenCName, TokenSpaceGuidCName, key[1])\r
987 )\r
988 else:\r
989 TokenSpaceGuidCName = key[1]\r
990 FoundFlag = True\r
991 else:\r
992 if (TokenCName, TokenSpaceGuidCName) in self.DecPcds:\r
993 FoundFlag = True\r
994 if FieldName:\r
995 NewValue = self.GetFieldValueFromComm(pcdvalue, TokenSpaceGuidCName, TokenCName, FieldName)\r
996 GlobalData.BuildOptionPcd[i] = (TokenSpaceGuidCName, TokenCName, FieldName,NewValue,("build command options",1))\r
997 else:\r
ea927d2f
FY
998 # Replace \' to ', \\\' to \'\r
999 pcdvalue = pcdvalue.replace("\\\\\\'", '\\\\\\"').replace('\\\'', '\'').replace('\\\\\\"', "\\'")\r
6f49996c
FB
1000 for key in self.DecPcds:\r
1001 PcdItem = self.DecPcds[key]\r
1002 if HasTokenSpace:\r
1003 if (PcdItem.TokenCName, PcdItem.TokenSpaceGuidCName) == (TokenCName, TokenSpaceGuidCName):\r
1004 PcdDatumType = PcdItem.DatumType\r
1005 if pcdvalue.startswith('H'):\r
1006 try:\r
1007 pcdvalue = ValueExpressionEx(pcdvalue[1:], PcdDatumType, self._GuidDict)(True)\r
1008 except BadExpression, Value:\r
f9bba774
FY
1009 EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %\r
1010 (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
ea927d2f 1011 if PcdDatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, 'BOOLEAN']:\r
f9bba774
FY
1012 pcdvalue = 'H' + pcdvalue\r
1013 elif pcdvalue.startswith("L'"):\r
1014 try:\r
1015 pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(True)\r
1016 except BadExpression, Value:\r
1017 EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %\r
1018 (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
ea927d2f 1019 if PcdDatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, 'BOOLEAN']:\r
f9bba774
FY
1020 pcdvalue = 'H' + pcdvalue\r
1021 elif pcdvalue.startswith("'"):\r
1022 try:\r
1023 pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(True)\r
1024 except BadExpression, Value:\r
1025 EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %\r
1026 (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
ea927d2f 1027 if PcdDatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, 'BOOLEAN']:\r
f9bba774
FY
1028 pcdvalue = 'H' + pcdvalue\r
1029 elif pcdvalue.startswith('L'):\r
1030 pcdvalue = 'L"' + pcdvalue[1:] + '"'\r
1031 try:\r
1032 pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(True)\r
1033 except BadExpression, Value:\r
1034 EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %\r
1035 (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
1036 else:\r
1037 try:\r
1038 pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(True)\r
1039 except BadExpression, Value:\r
ea927d2f
FY
1040 try:\r
1041 pcdvalue = '"' + pcdvalue + '"'\r
1042 pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(True)\r
1043 except BadExpression, Value:\r
1044 EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %\r
1045 (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
6f49996c
FB
1046 NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)\r
1047 FoundFlag = True\r
1048 else:\r
1049 if PcdItem.TokenCName == TokenCName:\r
1050 if not PcdItem.TokenSpaceGuidCName in TokenSpaceGuidCNameList:\r
1051 if len (TokenSpaceGuidCNameList) < 1:\r
1052 TokenSpaceGuidCNameList.append(PcdItem.TokenSpaceGuidCName)\r
1053 PcdDatumType = PcdItem.DatumType\r
1054 TokenSpaceGuidCName = PcdItem.TokenSpaceGuidCName\r
1055 if pcdvalue.startswith('H'):\r
1056 try:\r
1057 pcdvalue = ValueExpressionEx(pcdvalue[1:], PcdDatumType, self._GuidDict)(True)\r
1058 except BadExpression, Value:\r
1059 EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %\r
1060 (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
ea927d2f 1061 if PcdDatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64,'BOOLEAN']:\r
f9bba774
FY
1062 pcdvalue = 'H' + pcdvalue\r
1063 elif pcdvalue.startswith("L'"):\r
1064 try:\r
1065 pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(\r
1066 True)\r
1067 except BadExpression, Value:\r
1068 EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %\r
1069 (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
ea927d2f 1070 if PcdDatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, 'BOOLEAN']:\r
f9bba774
FY
1071 pcdvalue = 'H' + pcdvalue\r
1072 elif pcdvalue.startswith("'"):\r
1073 try:\r
1074 pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(\r
1075 True)\r
1076 except BadExpression, Value:\r
1077 EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %\r
1078 (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
ea927d2f 1079 if PcdDatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, 'BOOLEAN']:\r
f9bba774
FY
1080 pcdvalue = 'H' + pcdvalue\r
1081 elif pcdvalue.startswith('L'):\r
1082 pcdvalue = 'L"' + pcdvalue[1:] + '"'\r
1083 try:\r
1084 pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(\r
1085 True)\r
1086 except BadExpression, Value:\r
1087 EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %\r
1088 (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
1089 else:\r
1090 try:\r
1091 pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(True)\r
1092 except BadExpression, Value:\r
ea927d2f
FY
1093 try:\r
1094 pcdvalue = '"' + pcdvalue + '"'\r
1095 pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(True)\r
1096 except BadExpression, Value:\r
1097 EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %\r
1098 (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
6f49996c
FB
1099 NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)\r
1100 FoundFlag = True\r
1101 else:\r
1102 EdkLogger.error(\r
1103 'build',\r
1104 AUTOGEN_ERROR,\r
1105 "The Pcd %s is found under multiple different TokenSpaceGuid: %s and %s." % (TokenCName, PcdItem.TokenSpaceGuidCName, TokenSpaceGuidCNameList[0])\r
1106 )\r
1107 GlobalData.BuildOptionPcd[i] = (TokenSpaceGuidCName, TokenCName, FieldName,NewValue,("build command options",1))\r
1108 if not FoundFlag:\r
1109 if HasTokenSpace:\r
1110 EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %s.%s is not found in the DEC file." % (TokenSpaceGuidCName, TokenCName))\r
1111 else:\r
1112 EdkLogger.error('build', AUTOGEN_ERROR, "The Pcd %s is not found in the DEC file." % (TokenCName))\r
1113 for BuildData in self._Bdb._CACHE_.values():\r
1114 if BuildData.MetaFile.Ext == '.dec' or BuildData.MetaFile.Ext == '.dsc':\r
1115 continue\r
1116 for key in BuildData.Pcds:\r
1117 PcdItem = BuildData.Pcds[key]\r
1118 if (TokenSpaceGuidCName, TokenCName) == (PcdItem.TokenSpaceGuidCName, PcdItem.TokenCName) and FieldName =="":\r
1119 PcdItem.DefaultValue = NewValue\r
ae7b6df8
LG
1120 ## Retrieve all PCD settings in platform\r
1121 def _GetPcds(self):\r
1122 if self._Pcds == None:\r
1123 self._Pcds = sdict()\r
6f49996c 1124 self.__ParsePcdFromCommandLine()\r
ae7b6df8
LG
1125 self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))\r
1126 self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE))\r
1127 self._Pcds.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG))\r
1128 self._Pcds.update(self._GetDynamicPcd(MODEL_PCD_DYNAMIC_DEFAULT))\r
1129 self._Pcds.update(self._GetDynamicHiiPcd(MODEL_PCD_DYNAMIC_HII))\r
1130 self._Pcds.update(self._GetDynamicVpdPcd(MODEL_PCD_DYNAMIC_VPD))\r
1131 self._Pcds.update(self._GetDynamicPcd(MODEL_PCD_DYNAMIC_EX_DEFAULT))\r
1132 self._Pcds.update(self._GetDynamicHiiPcd(MODEL_PCD_DYNAMIC_EX_HII))\r
1133 self._Pcds.update(self._GetDynamicVpdPcd(MODEL_PCD_DYNAMIC_EX_VPD))\r
1134\r
8518bf0b 1135 self._Pcds = self.CompletePcdValues(self._Pcds)\r
ae7b6df8 1136 self._Pcds = self.UpdateStructuredPcds(MODEL_PCD_TYPE_LIST, self._Pcds)\r
2b8a6c44 1137 self._Pcds = self.CompleteHiiPcdsDefaultStores(self._Pcds)\r
8518bf0b 1138 self._Pcds = self._FilterPcdBySkuUsage(self._Pcds)\r
6f49996c
FB
1139 self._Pcds = self.OverrideByFdfCommOverAll(self._Pcds)\r
1140 self.RecoverCommandLinePcd()\r
ae7b6df8
LG
1141 return self._Pcds\r
1142\r
8518bf0b
LG
1143 def _dumpPcdInfo(self,Pcds):\r
1144 for pcd in Pcds:\r
1145 pcdobj = Pcds[pcd]\r
1146 if not pcdobj.TokenCName.startswith("Test"):\r
1147 continue\r
1148 for skuid in pcdobj.SkuInfoList:\r
1149 if pcdobj.Type in (self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]):\r
1150 for storename in pcdobj.SkuInfoList[skuid].DefaultStoreDict:\r
1151 print "PcdCName: %s, SkuName: %s, StoreName: %s, Value: %s" % (".".join((pcdobj.TokenSpaceGuidCName, pcdobj.TokenCName)), skuid,storename,str(pcdobj.SkuInfoList[skuid].DefaultStoreDict[storename]))\r
1152 else:\r
1153 print "PcdCName: %s, SkuName: %s, Value: %s" % (".".join((pcdobj.TokenSpaceGuidCName, pcdobj.TokenCName)), skuid,str(pcdobj.SkuInfoList[skuid].DefaultValue))\r
ae7b6df8
LG
1154 ## Retrieve [BuildOptions]\r
1155 def _GetBuildOptions(self):\r
1156 if self._BuildOptions == None:\r
1157 self._BuildOptions = sdict()\r
1158 #\r
1159 # Retrieve build option for EDKII and EDK style module\r
1160 #\r
1161 for CodeBase in (EDKII_NAME, EDK_NAME):\r
1162 RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, CodeBase]\r
8518bf0b 1163 for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3, Dummy4,Dummy5 in RecordList:\r
c05c2c05
LG
1164 if Dummy3.upper() != 'COMMON':\r
1165 continue\r
ae7b6df8
LG
1166 CurKey = (ToolChainFamily, ToolChain, CodeBase)\r
1167 #\r
1168 # Only flags can be appended\r
1169 #\r
1170 if CurKey not in self._BuildOptions or not ToolChain.endswith('_FLAGS') or Option.startswith('='):\r
1171 self._BuildOptions[CurKey] = Option\r
1172 else:\r
c05c2c05
LG
1173 if ' ' + Option not in self._BuildOptions[CurKey]:\r
1174 self._BuildOptions[CurKey] += ' ' + Option\r
ae7b6df8
LG
1175 return self._BuildOptions\r
1176\r
1177 def GetBuildOptionsByModuleType(self, Edk, ModuleType):\r
1178 if self._ModuleTypeOptions == None:\r
1179 self._ModuleTypeOptions = sdict()\r
1180 if (Edk, ModuleType) not in self._ModuleTypeOptions:\r
1181 options = sdict()\r
1182 self._ModuleTypeOptions[Edk, ModuleType] = options\r
1183 DriverType = '%s.%s' % (Edk, ModuleType)\r
1184 CommonDriverType = '%s.%s' % ('COMMON', ModuleType)\r
c05c2c05
LG
1185 RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch]\r
1186 for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3, Dummy4,Dummy5 in RecordList:\r
1187 Type = Dummy2 + '.' + Dummy3\r
1188 if Type.upper() == DriverType.upper() or Type.upper() == CommonDriverType.upper():\r
ae7b6df8
LG
1189 Key = (ToolChainFamily, ToolChain, Edk)\r
1190 if Key not in options or not ToolChain.endswith('_FLAGS') or Option.startswith('='):\r
1191 options[Key] = Option\r
1192 else:\r
c05c2c05
LG
1193 if ' ' + Option not in options[Key]:\r
1194 options[Key] += ' ' + Option\r
ae7b6df8
LG
1195 return self._ModuleTypeOptions[Edk, ModuleType]\r
1196\r
1197 def GetStructurePcdInfo(self, PcdSet):\r
1198 structure_pcd_data = {}\r
1199 for item in PcdSet:\r
8518bf0b
LG
1200 if (item[0],item[1]) not in structure_pcd_data:\r
1201 structure_pcd_data[(item[0],item[1])] = []\r
1202 structure_pcd_data[(item[0],item[1])].append(item)\r
ae7b6df8
LG
1203\r
1204 return structure_pcd_data\r
6f49996c
FB
1205 def OverrideByFdfComm(self,StruPcds):\r
1206 StructurePcdInCom = {(item[0],item[1],item[2] ):(item[3],item[4]) for item in GlobalData.BuildOptionPcd if len(item) == 5 and (item[1],item[0]) in StruPcds } if GlobalData.BuildOptionPcd else {}\r
1207 GlobalPcds = set([(item[0],item[1]) for item in StructurePcdInCom.keys()])\r
1208 for Pcd in StruPcds.values():\r
1209 if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) not in GlobalPcds:\r
1210 continue\r
1211 FieldValues = {item[2]:StructurePcdInCom[item] for item in StructurePcdInCom if (Pcd.TokenSpaceGuidCName,Pcd.TokenCName) == (item[0],item[1]) and item[2]}\r
1212 for sku in Pcd.SkuOverrideValues:\r
1213 for defaultstore in Pcd.SkuOverrideValues[sku]:\r
1214 for field in FieldValues:\r
1215 if field not in Pcd.SkuOverrideValues[sku][defaultstore]:\r
1216 Pcd.SkuOverrideValues[sku][defaultstore][field] = ["","",""]\r
1217 Pcd.SkuOverrideValues[sku][defaultstore][field][0] = FieldValues[field][0]\r
1218 Pcd.SkuOverrideValues[sku][defaultstore][field][1] = FieldValues[field][1][0]\r
1219 Pcd.SkuOverrideValues[sku][defaultstore][field][2] = FieldValues[field][1][1]\r
1220 return StruPcds\r
1221 def OverrideByFdfCommOverAll(self,AllPcds):\r
1222 def CheckStructureInComm(commpcds):\r
1223 if not commpcds:\r
1224 return False\r
1225 if len(commpcds[0]) == 5:\r
1226 return True\r
1227 return False\r
ae7b6df8 1228\r
6f49996c
FB
1229 if CheckStructureInComm(GlobalData.BuildOptionPcd):\r
1230 StructurePcdInCom = {(item[0],item[1],item[2] ):(item[3],item[4]) for item in GlobalData.BuildOptionPcd } if GlobalData.BuildOptionPcd else {}\r
1231 NoFiledValues = {(item[0],item[1]):StructurePcdInCom[item] for item in StructurePcdInCom if not item[2]}\r
1232 else:\r
1233 NoFiledValues = {(item[0],item[1]):[item[2]] for item in GlobalData.BuildOptionPcd}\r
1234 for Guid,Name in NoFiledValues:\r
1235 if (Name,Guid) in AllPcds:\r
1236 Pcd = AllPcds.get((Name,Guid))\r
1237 Pcd.DefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]\r
1238 for sku in Pcd.SkuInfoList:\r
1239 SkuInfo = Pcd.SkuInfoList[sku]\r
1240 if SkuInfo.DefaultValue:\r
1241 SkuInfo.DefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]\r
1242 else:\r
1243 SkuInfo.HiiDefaultValue = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]\r
1244 for defaultstore in SkuInfo.DefaultStoreDict:\r
1245 SkuInfo.DefaultStoreDict[defaultstore] = NoFiledValues[(Pcd.TokenSpaceGuidCName,Pcd.TokenCName)][0]\r
1246 else:\r
1247 PcdInDec = self.DecPcds.get((Name,Guid))\r
1248 if PcdInDec:\r
1249 if PcdInDec.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],\r
1250 self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:\r
1251 self.Pcds[Name, Guid] = copy.deepcopy(PcdInDec)\r
1252 self.Pcds[Name, Guid].DefaultValue = NoFiledValues[( Guid,Name)][0]\r
1253 return AllPcds\r
ae7b6df8 1254 def UpdateStructuredPcds(self, TypeList, AllPcds):\r
65eff519
LG
1255\r
1256 DynamicPcdType = [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_DEFAULT],\r
1257 self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],\r
1258 self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_VPD],\r
1259 self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_DEFAULT],\r
1260 self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII],\r
1261 self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_VPD]]\r
1262\r
ae7b6df8 1263 Pcds = AllPcds\r
8518bf0b 1264 DefaultStoreMgr = DefaultStore(self.DefaultStores)\r
65eff519
LG
1265 SkuIds = self.SkuIdMgr.AvailableSkuIdSet\r
1266 SkuIds.update({'DEFAULT':0})\r
8518bf0b 1267 DefaultStores = set([storename for pcdobj in AllPcds.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict.keys()])\r
ae7b6df8
LG
1268\r
1269 S_PcdSet = []\r
1270 # Find out all possible PCD candidates for self._Arch\r
1271 RecordList = []\r
2b8a6c44 1272\r
ae7b6df8
LG
1273 for Type in TypeList:\r
1274 RecordList.extend(self._RawData[Type, self._Arch])\r
1275\r
8518bf0b 1276 for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, default_store, Dummy4,Dummy5 in RecordList:\r
2b8a6c44
LG
1277 SkuName = SkuName.upper()\r
1278 default_store = default_store.upper()\r
1279 SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName\r
8518bf0b
LG
1280 if SkuName not in SkuIds:\r
1281 continue\r
2b8a6c44 1282\r
8518bf0b 1283 if SkuName in SkuIds and "." in TokenSpaceGuid:\r
6f49996c 1284 S_PcdSet.append([ TokenSpaceGuid.split(".")[0],TokenSpaceGuid.split(".")[1], PcdCName,SkuName, default_store,Dummy5, AnalyzePcdExpression(Setting)[0]])\r
ae7b6df8
LG
1285\r
1286 # handle pcd value override\r
1287 StrPcdSet = self.GetStructurePcdInfo(S_PcdSet)\r
79820e32 1288 S_pcd_set = OrderedDict()\r
ae7b6df8 1289 for str_pcd in StrPcdSet:\r
8518bf0b
LG
1290 str_pcd_obj = Pcds.get((str_pcd[1], str_pcd[0]), None)\r
1291 str_pcd_dec = self._DecPcds.get((str_pcd[1], str_pcd[0]), None)\r
5db9414c
B
1292 if not isinstance (str_pcd_dec, StructurePcd):\r
1293 EdkLogger.error('build', PARSER_ERROR,\r
1294 "Pcd (%s.%s) is not declared as Structure PCD in DEC files. Arch: ['%s']" % (str_pcd[0], str_pcd[1], self._Arch),\r
1295 File=self.MetaFile,Line = StrPcdSet[str_pcd][0][5])\r
ae7b6df8
LG
1296 if str_pcd_dec:\r
1297 str_pcd_obj_str = StructurePcd()\r
1298 str_pcd_obj_str.copy(str_pcd_dec)\r
1299 if str_pcd_obj:\r
1300 str_pcd_obj_str.copy(str_pcd_obj)\r
77204d60
FB
1301 if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:\r
1302 str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}\r
1303 else:\r
1304 str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}\r
ae7b6df8 1305 for str_pcd_data in StrPcdSet[str_pcd]:\r
8518bf0b 1306 if str_pcd_data[3] in SkuIds:\r
0a57a978 1307 str_pcd_obj_str.AddOverrideValue(str_pcd_data[2], str(str_pcd_data[6]), 'DEFAULT' if str_pcd_data[3] == 'COMMON' else str_pcd_data[3],'STANDARD' if str_pcd_data[4] == 'COMMON' else str_pcd_data[4], self.MetaFile.File if self.WorkspaceDir not in self.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir) if self.WorkspaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:],LineNo=str_pcd_data[5])\r
8518bf0b 1308 S_pcd_set[str_pcd[1], str_pcd[0]] = str_pcd_obj_str\r
2b8a6c44
LG
1309 else:\r
1310 EdkLogger.error('build', PARSER_ERROR,\r
1311 "Pcd (%s.%s) defined in DSC is not declared in DEC files. Arch: ['%s']" % (str_pcd[0], str_pcd[1], self._Arch),\r
1312 File=self.MetaFile,Line = StrPcdSet[str_pcd][0][5])\r
ae7b6df8 1313 # Add the Structure PCD that only defined in DEC, don't have override in DSC file\r
5644e5ce 1314 for Pcd in self.DecPcds:\r
ae7b6df8
LG
1315 if type (self._DecPcds[Pcd]) is StructurePcd:\r
1316 if Pcd not in S_pcd_set:\r
1317 str_pcd_obj_str = StructurePcd()\r
1318 str_pcd_obj_str.copy(self._DecPcds[Pcd])\r
1319 str_pcd_obj = Pcds.get(Pcd, None)\r
1320 if str_pcd_obj:\r
1321 str_pcd_obj_str.copy(str_pcd_obj)\r
77204d60
FB
1322 if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:\r
1323 str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}\r
1324 else:\r
1325 str_pcd_obj_str.DefaultFromDSC = {skuname:{defaultstore: str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore, str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in DefaultStores} for skuname in str_pcd_obj.SkuInfoList}\r
ae7b6df8
LG
1326 S_pcd_set[Pcd] = str_pcd_obj_str\r
1327 if S_pcd_set:\r
1328 GlobalData.gStructurePcd[self.Arch] = S_pcd_set\r
8518bf0b 1329 for stru_pcd in S_pcd_set.values():\r
67e63e9a
LG
1330 for skuid in SkuIds:\r
1331 if skuid in stru_pcd.SkuOverrideValues:\r
1332 continue\r
1333 nextskuid = self.SkuIdMgr.GetNextSkuId(skuid)\r
1334 NoDefault = False\r
1335 while nextskuid not in stru_pcd.SkuOverrideValues:\r
1336 if nextskuid == "DEFAULT":\r
1337 NoDefault = True\r
1338 break\r
1339 nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid)\r
1340 stru_pcd.SkuOverrideValues[skuid] = copy.deepcopy(stru_pcd.SkuOverrideValues[nextskuid]) if not NoDefault else copy.deepcopy({defaultstorename: stru_pcd.DefaultValues for defaultstorename in DefaultStores} if DefaultStores else {'STANDARD':stru_pcd.DefaultValues})\r
8518bf0b
LG
1341 if stru_pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:\r
1342 for skuid in SkuIds:\r
1343 nextskuid = skuid\r
2b8a6c44 1344 NoDefault = False\r
8518bf0b
LG
1345 if skuid not in stru_pcd.SkuOverrideValues:\r
1346 while nextskuid not in stru_pcd.SkuOverrideValues:\r
2b8a6c44
LG
1347 if nextskuid == "DEFAULT":\r
1348 NoDefault = True\r
1349 break\r
8518bf0b 1350 nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid)\r
2b8a6c44
LG
1351 if NoDefault:\r
1352 continue\r
1353 PcdDefaultStoreSet = set([defaultstorename for defaultstorename in stru_pcd.SkuOverrideValues[nextskuid]])\r
8518bf0b 1354 mindefaultstorename = DefaultStoreMgr.GetMin(PcdDefaultStoreSet)\r
2b8a6c44 1355\r
8518bf0b
LG
1356 for defaultstoreid in DefaultStores:\r
1357 if defaultstoreid not in stru_pcd.SkuOverrideValues[skuid]:\r
2b8a6c44 1358 stru_pcd.SkuOverrideValues[skuid][defaultstoreid] = copy.deepcopy(stru_pcd.SkuOverrideValues[nextskuid][mindefaultstorename])\r
6f49996c 1359 S_pcd_set = self.OverrideByFdfComm(S_pcd_set)\r
ae7b6df8
LG
1360 Str_Pcd_Values = self.GenerateByteArrayValue(S_pcd_set)\r
1361 if Str_Pcd_Values:\r
8518bf0b
LG
1362 for (skuname,StoreName,PcdGuid,PcdName,PcdValue) in Str_Pcd_Values:\r
1363 str_pcd_obj = S_pcd_set.get((PcdName, PcdGuid))\r
ae7b6df8 1364 if str_pcd_obj is None:\r
67e63e9a 1365 print PcdName, PcdGuid\r
ae7b6df8
LG
1366 raise\r
1367 if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],\r
1368 self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:\r
8518bf0b
LG
1369 if skuname not in str_pcd_obj.SkuInfoList:\r
1370 str_pcd_obj.SkuInfoList[skuname] = SkuInfoClass(SkuIdName=skuname, SkuId=self.SkuIds[skuname][0], HiiDefaultValue=PcdValue, DefaultStore = {StoreName:PcdValue})\r
ae7b6df8 1371 else:\r
8518bf0b
LG
1372 str_pcd_obj.SkuInfoList[skuname].HiiDefaultValue = PcdValue\r
1373 str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.update({StoreName:PcdValue})\r
ae7b6df8
LG
1374 elif str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],\r
1375 self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:\r
8518bf0b
LG
1376 if skuname in (self.SkuIdMgr.SystemSkuId, 'DEFAULT', 'COMMON'):\r
1377 str_pcd_obj.DefaultValue = PcdValue\r
ae7b6df8 1378 else:\r
8518bf0b 1379 if skuname not in str_pcd_obj.SkuInfoList:\r
65eff519
LG
1380 nextskuid = self.SkuIdMgr.GetNextSkuId(skuname)\r
1381 NoDefault = False\r
1382 while nextskuid not in str_pcd_obj.SkuInfoList:\r
1383 if nextskuid == "DEFAULT":\r
1384 NoDefault = True\r
1385 break\r
1386 nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid)\r
1387 str_pcd_obj.SkuInfoList[skuname] = copy.deepcopy(str_pcd_obj.SkuInfoList[nextskuid]) if not NoDefault else SkuInfoClass(SkuIdName=skuname, SkuId=self.SkuIds[skuname][0], DefaultValue=PcdValue)\r
1388 str_pcd_obj.SkuInfoList[skuname].SkuId = self.SkuIds[skuname][0]\r
1389 str_pcd_obj.SkuInfoList[skuname].SkuIdName = skuname\r
ae7b6df8 1390 else:\r
8518bf0b
LG
1391 str_pcd_obj.SkuInfoList[skuname].DefaultValue = PcdValue\r
1392 for str_pcd_obj in S_pcd_set.values():\r
1393 if str_pcd_obj.Type not in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],\r
1394 self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:\r
1395 continue\r
1396 PcdDefaultStoreSet = set([defaultstorename for skuobj in str_pcd_obj.SkuInfoList.values() for defaultstorename in skuobj.DefaultStoreDict])\r
1397 DefaultStoreObj = DefaultStore(self._GetDefaultStores())\r
1398 mindefaultstorename = DefaultStoreObj.GetMin(PcdDefaultStoreSet)\r
1399 str_pcd_obj.SkuInfoList[self.SkuIdMgr.SystemSkuId].HiiDefaultValue = str_pcd_obj.SkuInfoList[self.SkuIdMgr.SystemSkuId].DefaultStoreDict[mindefaultstorename]\r
ae7b6df8
LG
1400\r
1401 for str_pcd_obj in S_pcd_set.values():\r
2b8a6c44 1402\r
ae7b6df8
LG
1403 str_pcd_obj.MaxDatumSize = self.GetStructurePcdMaxSize(str_pcd_obj)\r
1404 Pcds[str_pcd_obj.TokenCName, str_pcd_obj.TokenSpaceGuidCName] = str_pcd_obj\r
1405\r
65eff519
LG
1406 for pcdkey in Pcds:\r
1407 pcd = Pcds[pcdkey]\r
1408 if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():\r
1409 pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']\r
1410 del(pcd.SkuInfoList['COMMON'])\r
1411 elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():\r
1412 del(pcd.SkuInfoList['COMMON'])\r
1413\r
1414 map(self.FilterSkuSettings,[Pcds[pcdkey] for pcdkey in Pcds if Pcds[pcdkey].Type in DynamicPcdType])\r
ae7b6df8
LG
1415 return Pcds\r
1416\r
1417 ## Retrieve non-dynamic PCD settings\r
1418 #\r
1419 # @param Type PCD type\r
1420 #\r
1421 # @retval a dict object contains settings of given PCD type\r
1422 #\r
1423 def _GetPcd(self, Type):\r
1424 Pcds = sdict()\r
1425 #\r
1426 # tdict is a special dict kind of type, used for selecting correct\r
1427 # PCD settings for certain ARCH\r
1428 #\r
2b8a6c44 1429 AvailableSkuIdSet = copy.copy(self.SkuIds)\r
ae7b6df8
LG
1430\r
1431 PcdDict = tdict(True, 3)\r
1432 PcdSet = set()\r
1433 # Find out all possible PCD candidates for self._Arch\r
1434 RecordList = self._RawData[Type, self._Arch]\r
ae7b6df8 1435 PcdValueDict = sdict()\r
8518bf0b 1436 for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4,Dummy5 in RecordList:\r
2b8a6c44
LG
1437 SkuName = SkuName.upper()\r
1438 SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName\r
1439 if SkuName not in AvailableSkuIdSet:\r
1440 EdkLogger.error('build ', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName,\r
1441 File=self.MetaFile, Line=Dummy5)\r
8518bf0b
LG
1442 if SkuName in (self.SkuIdMgr.SystemSkuId, 'DEFAULT', 'COMMON'):\r
1443 if "." not in TokenSpaceGuid:\r
5db9414c 1444 PcdSet.add((PcdCName, TokenSpaceGuid, SkuName, Dummy5))\r
ae7b6df8 1445 PcdDict[Arch, PcdCName, TokenSpaceGuid, SkuName] = Setting\r
ae7b6df8
LG
1446\r
1447 for PcdCName, TokenSpaceGuid, SkuName, Dummy4 in PcdSet:\r
1448 Setting = PcdDict[self._Arch, PcdCName, TokenSpaceGuid, SkuName]\r
1449 if Setting == None:\r
1450 continue\r
1451 PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)\r
1452 if (PcdCName, TokenSpaceGuid) in PcdValueDict:\r
1453 PcdValueDict[PcdCName, TokenSpaceGuid][SkuName] = (PcdValue, DatumType, MaxDatumSize)\r
1454 else:\r
1455 PcdValueDict[PcdCName, TokenSpaceGuid] = {SkuName:(PcdValue, DatumType, MaxDatumSize)}\r
1456\r
1457 PcdsKeys = PcdValueDict.keys()\r
1458 for PcdCName, TokenSpaceGuid in PcdsKeys:\r
1459\r
1460 PcdSetting = PcdValueDict[PcdCName, TokenSpaceGuid]\r
1461 PcdValue = None\r
1462 DatumType = None\r
1463 MaxDatumSize = None\r
1464 if 'COMMON' in PcdSetting:\r
1465 PcdValue, DatumType, MaxDatumSize = PcdSetting['COMMON']\r
1466 if 'DEFAULT' in PcdSetting:\r
1467 PcdValue, DatumType, MaxDatumSize = PcdSetting['DEFAULT']\r
8518bf0b
LG
1468 if self.SkuIdMgr.SystemSkuId in PcdSetting:\r
1469 PcdValue, DatumType, MaxDatumSize = PcdSetting[self.SkuIdMgr.SystemSkuId]\r
ae7b6df8
LG
1470\r
1471 Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(\r
1472 PcdCName,\r
1473 TokenSpaceGuid,\r
1474 self._PCD_TYPE_STRING_[Type],\r
1475 DatumType,\r
1476 PcdValue,\r
1477 '',\r
1478 MaxDatumSize,\r
1479 {},\r
1480 False,\r
1481 None,\r
1482 IsDsc=True)\r
1483\r
1484\r
1485 return Pcds\r
1486\r
8518bf0b
LG
1487 def __UNICODE2OCTList(self,Value):\r
1488 Value = Value.strip()\r
1489 Value = Value[2:-1]\r
1490 List = []\r
1491 for Item in Value:\r
1492 Temp = '%04X' % ord(Item)\r
1493 List.append('0x' + Temp[2:4])\r
1494 List.append('0x' + Temp[0:2])\r
1495 List.append('0x00')\r
1496 List.append('0x00')\r
1497 return List\r
1498 def __STRING2OCTList(self,Value):\r
1499 OCTList = []\r
1500 Value = Value.strip('"')\r
1501 for char in Value:\r
1502 Temp = '%02X' % ord(char)\r
1503 OCTList.append('0x' + Temp)\r
1504 OCTList.append('0x00')\r
1505 return OCTList\r
1506\r
ae7b6df8
LG
1507 def GetStructurePcdMaxSize(self, str_pcd):\r
1508 pcd_default_value = str_pcd.DefaultValue\r
1509 sku_values = [skuobj.HiiDefaultValue if str_pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]] else skuobj.DefaultValue for skuobj in str_pcd.SkuInfoList.values()]\r
1510 sku_values.append(pcd_default_value)\r
1511\r
1512 def get_length(value):\r
1513 Value = value.strip()\r
a0939593
LG
1514 if len(value) > 1:\r
1515 if Value.startswith('GUID') and Value.endswith(')'):\r
1516 return 16\r
1517 if Value.startswith('L"') and Value.endswith('"'):\r
1518 return len(Value[2:-1])\r
1519 if Value[0] == '"' and Value[-1] == '"':\r
1520 return len(Value) - 2\r
1521 if Value[0] == '{' and Value[-1] == '}':\r
1522 return len(Value.split(","))\r
1523 if Value.startswith("L'") and Value.endswith("'") and len(list(Value[2:-1])) > 1:\r
1524 return len(list(Value[2:-1]))\r
1525 if Value[0] == "'" and Value[-1] == "'" and len(list(Value[1:-1])) > 1:\r
1526 return len(Value) - 2\r
ae7b6df8
LG
1527 return len(Value)\r
1528\r
1529 return str(max([pcd_size for pcd_size in [get_length(item) for item in sku_values]]))\r
1530\r
1531 def IsFieldValueAnArray (self, Value):\r
1532 Value = Value.strip()\r
1533 if Value.startswith('GUID') and Value.endswith(')'):\r
1534 return True\r
1535 if Value.startswith('L"') and Value.endswith('"') and len(list(Value[2:-1])) > 1:\r
1536 return True\r
1537 if Value[0] == '"' and Value[-1] == '"' and len(list(Value[1:-1])) > 1:\r
1538 return True\r
1539 if Value[0] == '{' and Value[-1] == '}':\r
1540 return True\r
1541 if Value.startswith("L'") and Value.endswith("'") and len(list(Value[2:-1])) > 1:\r
1542 print 'foo = ', list(Value[2:-1])\r
1543 return True\r
1544 if Value[0] == "'" and Value[-1] == "'" and len(list(Value[1:-1])) > 1:\r
1545 print 'bar = ', list(Value[1:-1])\r
1546 return True\r
1547 return False\r
1548\r
1549 def ExecuteCommand (self, Command):\r
1550 try:\r
1551 Process = subprocess.Popen(Command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
1552 except:\r
5db9414c 1553 EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute command: %s' % Command)\r
ae7b6df8 1554 Result = Process.communicate()\r
5db9414c 1555 return Process.returncode, Result[0], Result[1]\r
ae7b6df8
LG
1556\r
1557 def IntToCString(self, Value, ValueSize):\r
1558 Result = '"'\r
1559 if not isinstance (Value, str):\r
1560 for Index in range(0, ValueSize):\r
1561 Result = Result + '\\x%02x' % (Value & 0xff)\r
1562 Value = Value >> 8\r
1563 Result = Result + '"'\r
1564 return Result\r
1565\r
79820e32
B
1566 def GenerateSizeFunction(self,Pcd):\r
1567 CApp = "// Default Value in Dec \n"\r
1568 CApp = CApp + "void Cal_%s_%s_Size(UINT32 *Size){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
1569 for FieldList in [Pcd.DefaultValues]:\r
1570 if not FieldList:\r
1571 continue\r
1572 for FieldName in FieldList:\r
1573 FieldName = "." + FieldName\r
1574 IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])\r
1575 if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')):\r
1576 try:\r
1577 Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True)\r
1578 except BadExpression:\r
1579 EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %\r
1580 (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2]))\r
1581 Value, ValueSize = ParseFieldValue(Value)\r
1582 CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);\r
1583 else:\r
1584 NewFieldName = ''\r
1585 FieldName_ori = FieldName.strip('.')\r
1586 while '[' in FieldName:\r
1587 NewFieldName = NewFieldName + FieldName.split('[', 1)[0] + '[0]'\r
1588 ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0])\r
1589 FieldName = FieldName.split(']', 1)[1]\r
1590 FieldName = NewFieldName + FieldName\r
1591 while '[' in FieldName:\r
1592 FieldName = FieldName.rsplit('[', 1)[0]\r
1593 CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0])\r
1594 for skuname in Pcd.SkuOverrideValues:\r
1595 if skuname == "COMMON":\r
1596 continue\r
1597 for defaultstorenameitem in Pcd.SkuOverrideValues[skuname]:\r
1598 CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (skuname, defaultstorenameitem)\r
1599 for FieldList in [Pcd.SkuOverrideValues[skuname].get(defaultstorenameitem)]:\r
1600 if not FieldList:\r
1601 continue\r
1602 for FieldName in FieldList:\r
1603 FieldName = "." + FieldName\r
1604 IsArray = self.IsFieldValueAnArray(FieldList[FieldName.strip(".")][0])\r
1605 if IsArray and not (FieldList[FieldName.strip(".")][0].startswith('{GUID') and FieldList[FieldName.strip(".")][0].endswith('}')):\r
1606 try:\r
1607 Value = ValueExpressionEx(FieldList[FieldName.strip(".")][0], "VOID*", self._GuidDict)(True)\r
1608 except BadExpression:\r
1609 EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %\r
1610 (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName.strip('.'))), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2]))\r
1611 Value, ValueSize = ParseFieldValue(Value)\r
1612 CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s) + ((%d %% __ARRAY_ELEMENT_SIZE(%s, %s)) ? 1 : 0)); // From %s Line %d Value %s\n' % (Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), ValueSize, Pcd.DatumType, FieldName.strip("."), FieldList[FieldName.strip(".")][1], FieldList[FieldName.strip(".")][2], FieldList[FieldName.strip(".")][0]);\r
1613 else:\r
1614 NewFieldName = ''\r
1615 FieldName_ori = FieldName.strip('.')\r
1616 while '[' in FieldName:\r
1617 NewFieldName = NewFieldName + FieldName.split('[', 1)[0] + '[0]'\r
1618 ArrayIndex = int(FieldName.split('[', 1)[1].split(']', 1)[0])\r
1619 FieldName = FieldName.split(']', 1)[1]\r
1620 FieldName = NewFieldName + FieldName\r
1621 while '[' in FieldName:\r
1622 FieldName = FieldName.rsplit('[', 1)[0]\r
1623 CApp = CApp + ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd.DatumType, FieldName.strip("."), ArrayIndex + 1, FieldList[FieldName_ori][1], FieldList[FieldName_ori][2], FieldList[FieldName_ori][0])\r
1624 CApp = CApp + "}\n"\r
1625 return CApp\r
1626 def GenerateSizeStatments(self,Pcd):\r
1627 CApp = ' Size = sizeof(%s);\n' % (Pcd.DatumType)\r
1628 CApp = CApp + ' Cal_%s_%s_Size(&Size);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
1629 return CApp\r
1630 def GenerateDefaultValueAssignFunction(self,Pcd):\r
1631 CApp = "// Default value in Dec \n"\r
1632 CApp = CApp + "void Assign_%s_%s_Default_Value(%s *Pcd){\n" % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName,Pcd.DatumType)\r
1633 CApp = CApp + ' UINT32 FieldSize;\n'\r
1634 CApp = CApp + ' CHAR8 *Value;\n'\r
1635 DefaultValueFromDec = Pcd.DefaultValueFromDec\r
1636 IsArray = self.IsFieldValueAnArray(Pcd.DefaultValueFromDec)\r
1637 if IsArray:\r
1638 try:\r
1639 DefaultValueFromDec = ValueExpressionEx(Pcd.DefaultValueFromDec, "VOID*")(True)\r
1640 except BadExpression:\r
1641 EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DEC: %s" %\r
1642 (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, DefaultValueFromDec))\r
1643 Value, ValueSize = ParseFieldValue (DefaultValueFromDec)\r
1644 if isinstance(Value, str):\r
1645 CApp = CApp + ' Pcd = %s; // From DEC Default Value %s\n' % (Value, Pcd.DefaultValueFromDec)\r
1646 elif IsArray:\r
1647 #\r
1648 # Use memcpy() to copy value into field\r
1649 #\r
1650 CApp = CApp + ' Value = %s; // From DEC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultValueFromDec)\r
1651 CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)\r
1652 for FieldList in [Pcd.DefaultValues]:\r
1653 if not FieldList:\r
1654 continue\r
1655 for FieldName in FieldList:\r
1656 IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0])\r
1657 if IsArray:\r
1658 try:\r
1659 FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True)\r
1660 except BadExpression:\r
1661 EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %\r
1662 (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1],FieldList[FieldName][2]))\r
1663\r
1664 try:\r
1665 Value, ValueSize = ParseFieldValue (FieldList[FieldName][0])\r
1666 except Exception:\r
1667 EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName,FieldName)),FieldList[FieldName][1], FieldList[FieldName][2]))\r
1668 if isinstance(Value, str):\r
1669 CApp = CApp + ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
1670 elif IsArray:\r
1671 #\r
1672 # Use memcpy() to copy value into field\r
1673 #\r
1674 CApp = CApp + ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd.DatumType, FieldName)\r
1675 CApp = CApp + ' Value = %s; // From %s Line %d Value %s\n' % (self.IntToCString(Value, ValueSize), FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
1676 CApp = CApp + ' memcpy (&Pcd->%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)\r
1677 else:\r
1678 if ValueSize > 4:\r
1679 CApp = CApp + ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
1680 else:\r
1681 CApp = CApp + ' Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
1682 CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % ('DEFAULT', 'STANDARD')\r
1683 inherit_OverrideValues = Pcd.SkuOverrideValues['DEFAULT']\r
1684 pcddefaultvalue = Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue\r
1685 for FieldList in [pcddefaultvalue,inherit_OverrideValues.get('STANDARD')]:\r
1686 if not FieldList:\r
1687 continue\r
1688 if pcddefaultvalue and FieldList == pcddefaultvalue:\r
1689 IsArray = self.IsFieldValueAnArray(FieldList)\r
1690 if IsArray:\r
1691 try:\r
1692 FieldList = ValueExpressionEx(FieldList, "VOID*")(True)\r
1693 except BadExpression:\r
1694 EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DSC: %s" %\r
1695 (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList))\r
1696 Value, ValueSize = ParseFieldValue (FieldList)\r
1697 if isinstance(Value, str):\r
1698 CApp = CApp + ' Pcd = %s; // From DSC Default Value %s\n' % (Value, Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)\r
1699 elif IsArray:\r
1700 #\r
1701 # Use memcpy() to copy value into field\r
1702 #\r
1703 CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultFromDSC.get('DEFAULT',{}).get('STANDARD', Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)\r
1704 CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)\r
1705 continue\r
1706 for FieldName in FieldList:\r
1707 IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0])\r
1708 if IsArray:\r
1709 try:\r
1710 FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True)\r
1711 except BadExpression:\r
1712 EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %\r
1713 (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName][2]))\r
1714 try:\r
1715 Value, ValueSize = ParseFieldValue (FieldList[FieldName][0])\r
1716 except Exception:\r
1717 EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName,FieldName)),FieldList[FieldName][1], FieldList[FieldName][2]))\r
1718 if isinstance(Value, str):\r
1719 CApp = CApp + ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
1720 elif IsArray:\r
1721 #\r
1722 # Use memcpy() to copy value into field\r
1723 #\r
1724 CApp = CApp + ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd.DatumType, FieldName)\r
1725 CApp = CApp + ' Value = %s; // From %s Line %d Value %s\n' % (self.IntToCString(Value, ValueSize), FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
1726 CApp = CApp + ' memcpy (&Pcd->%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)\r
1727 else:\r
1728 if ValueSize > 4:\r
1729 CApp = CApp + ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
1730 else:\r
1731 CApp = CApp + ' Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
1732 CApp = CApp + "}\n"\r
1733 return CApp\r
1734 def GenerateDefaultValueAssignStatement(self,Pcd):\r
1735 CApp = ' Assign_%s_%s_Default_Value(Pcd);\n' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
1736 return CApp\r
ae7b6df8 1737 def GenerateInitializeFunc(self, SkuName, DefaultStoreName, Pcd, InitByteValue, CApp):\r
8518bf0b 1738 OverrideValues = {DefaultStoreName:""}\r
ae7b6df8
LG
1739 if Pcd.SkuOverrideValues:\r
1740 OverrideValues = Pcd.SkuOverrideValues[SkuName]\r
8518bf0b
LG
1741 for DefaultStoreName in OverrideValues.keys():\r
1742 CApp = CApp + 'void\n'\r
1743 CApp = CApp + 'Initialize_%s_%s_%s_%s(\n' % (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
1744 CApp = CApp + ' void\n'\r
1745 CApp = CApp + ' )\n'\r
1746 CApp = CApp + '{\n'\r
1747 CApp = CApp + ' UINT32 Size;\n'\r
1748 CApp = CApp + ' UINT32 FieldSize;\n'\r
b2395724 1749 CApp = CApp + ' CHAR8 *Value;\n'\r
8518bf0b
LG
1750 CApp = CApp + ' UINT32 OriginalSize;\n'\r
1751 CApp = CApp + ' VOID *OriginalPcd;\n'\r
6a103440 1752 CApp = CApp + ' %s *Pcd; // From %s Line %d \n' % (Pcd.DatumType, Pcd.PkgPath, Pcd.PcdDefineLineNo)\r
8518bf0b 1753 CApp = CApp + '\n'\r
47854fd5 1754\r
8e011d83
FB
1755 if SkuName in Pcd.SkuInfoList:\r
1756 DefaultValue = Pcd.SkuInfoList[SkuName].DefaultStoreDict.get(DefaultStoreName,Pcd.SkuInfoList[SkuName].HiiDefaultValue) if Pcd.SkuInfoList[SkuName].HiiDefaultValue else Pcd.SkuInfoList[SkuName].DefaultValue\r
1757 else:\r
1758 DefaultValue = Pcd.DefaultValue\r
1759 PcdDefaultValue = StringToArray(DefaultValue.strip())\r
47854fd5 1760\r
8518bf0b 1761 InitByteValue += '%s.%s.%s.%s|%s|%s\n' % (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Pcd.DatumType, PcdDefaultValue)\r
ae7b6df8 1762\r
8518bf0b
LG
1763 #\r
1764 # Get current PCD value and size\r
1765 #\r
1766 CApp = CApp + ' OriginalPcd = PcdGetPtr (%s, %s, %s, %s, &OriginalSize);\n' % (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
ae7b6df8 1767\r
8518bf0b
LG
1768 #\r
1769 # Determine the size of the PCD. For simple structures, sizeof(TYPE) provides\r
1770 # the correct value. For structures with a flexible array member, the flexible\r
1771 # array member is detected, and the size is based on the highest index used with\r
1772 # the flexible array member. The flexible array member must be the last field\r
1773 # in a structure. The size formula for this case is:\r
1774 # OFFSET_OF(FlexbleArrayField) + sizeof(FlexibleArray[0]) * (HighestIndex + 1)\r
1775 #\r
79820e32 1776 CApp = CApp + self.GenerateSizeStatments(Pcd)\r
ae7b6df8 1777\r
8518bf0b
LG
1778 #\r
1779 # Allocate and zero buffer for the PCD\r
1780 # Must handle cases where current value is smaller, larger, or same size\r
1781 # Always keep that larger one as the current size\r
1782 #\r
1783 CApp = CApp + ' Size = (OriginalSize > Size ? OriginalSize : Size);\n'\r
1784 CApp = CApp + ' Pcd = (%s *)malloc (Size);\n' % (Pcd.DatumType)\r
1785 CApp = CApp + ' memset (Pcd, 0, Size);\n'\r
ae7b6df8 1786\r
8518bf0b
LG
1787 #\r
1788 # Copy current PCD value into allocated buffer.\r
1789 #\r
1790 CApp = CApp + ' memcpy (Pcd, OriginalPcd, OriginalSize);\n'\r
ae7b6df8 1791\r
8518bf0b
LG
1792 #\r
1793 # Assign field values in PCD\r
1794 #\r
79820e32 1795 CApp = CApp + self.GenerateDefaultValueAssignStatement(Pcd)\r
09c80b07 1796 for skuname in self.SkuIdMgr.GetSkuChain(SkuName):\r
79820e32
B
1797 if skuname == "DEFAULT":\r
1798 continue\r
c05c2c05 1799 inherit_OverrideValues = Pcd.SkuOverrideValues[skuname]\r
8aa4db4b
FB
1800 storeset = [DefaultStoreName] if DefaultStoreName == 'STANDARD' else ['STANDARD', DefaultStoreName]\r
1801 for defaultstorenameitem in storeset:\r
1802 CApp = CApp + "// SkuName: %s, DefaultStoreName: %s \n" % (skuname, defaultstorenameitem)\r
77204d60
FB
1803 pcddefaultvalue = Pcd.DefaultFromDSC.get(skuname,{}).get(defaultstorenameitem, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue\r
1804 for FieldList in [pcddefaultvalue,inherit_OverrideValues.get(defaultstorenameitem)]:\r
8aa4db4b
FB
1805 if not FieldList:\r
1806 continue\r
77204d60 1807 if pcddefaultvalue and FieldList == pcddefaultvalue:\r
8aa4db4b
FB
1808 IsArray = self.IsFieldValueAnArray(FieldList)\r
1809 if IsArray:\r
1810 try:\r
1811 FieldList = ValueExpressionEx(FieldList, "VOID*")(True)\r
1812 except BadExpression:\r
1813 EdkLogger.error("Build", FORMAT_INVALID, "Invalid value format for %s.%s, from DSC: %s" %\r
1814 (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldList))\r
1815 Value, ValueSize = ParseFieldValue (FieldList)\r
1816 if isinstance(Value, str):\r
77204d60 1817 CApp = CApp + ' Pcd = %s; // From DSC Default Value %s\n' % (Value, Pcd.DefaultFromDSC.get(skuname,{}).get(defaultstorenameitem, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)\r
8aa4db4b
FB
1818 elif IsArray:\r
1819 #\r
1820 # Use memcpy() to copy value into field\r
1821 #\r
77204d60 1822 CApp = CApp + ' Value = %s; // From DSC Default Value %s\n' % (self.IntToCString(Value, ValueSize), Pcd.DefaultFromDSC.get(skuname,{}).get(defaultstorenameitem, Pcd.DefaultValue) if Pcd.DefaultFromDSC else Pcd.DefaultValue)\r
8aa4db4b
FB
1823 CApp = CApp + ' memcpy (Pcd, Value, %d);\n' % (ValueSize)\r
1824 continue\r
1825 for FieldName in FieldList:\r
1826 IsArray = self.IsFieldValueAnArray(FieldList[FieldName][0])\r
1827 if IsArray:\r
1828 try:\r
1829 FieldList[FieldName][0] = ValueExpressionEx(FieldList[FieldName][0], "VOID*", self._GuidDict)(True)\r
1830 except BadExpression:\r
1831 EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %\r
1832 (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName][2]))\r
bee0f2f1 1833 try:\r
8aa4db4b
FB
1834 Value, ValueSize = ParseFieldValue (FieldList[FieldName][0])\r
1835 except Exception:\r
1836 EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " % (".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName,FieldName)),FieldList[FieldName][1], FieldList[FieldName][2]))\r
1837 if isinstance(Value, str):\r
1838 CApp = CApp + ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
1839 elif IsArray:\r
1840 #\r
1841 # Use memcpy() to copy value into field\r
1842 #\r
1843 CApp = CApp + ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd.DatumType, FieldName)\r
1844 CApp = CApp + ' Value = %s; // From %s Line %d Value %s\n' % (self.IntToCString(Value, ValueSize), FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
79820e32 1845 CApp = CApp + ' memcpy (&Pcd->%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName, ValueSize, ValueSize)\r
c05c2c05 1846 else:\r
8aa4db4b
FB
1847 if ValueSize > 4:\r
1848 CApp = CApp + ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
1849 else:\r
1850 CApp = CApp + ' Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])\r
c05c2c05
LG
1851 if skuname == SkuName:\r
1852 break\r
8518bf0b
LG
1853 #\r
1854 # Set new PCD value and size\r
1855 #\r
1856 CApp = CApp + ' PcdSetPtr (%s, %s, %s, %s, Size, (UINT8 *)Pcd);\n' % (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
ae7b6df8 1857\r
8518bf0b
LG
1858 #\r
1859 # Free PCD\r
1860 #\r
1861 CApp = CApp + ' free (Pcd);\n'\r
1862 CApp = CApp + '}\n'\r
1863 CApp = CApp + '\n'\r
ae7b6df8
LG
1864 return InitByteValue, CApp\r
1865\r
1866 def GenerateByteArrayValue (self, StructuredPcds):\r
1867 #\r
1868 # Generate/Compile/Run C application to determine if there are any flexible array members\r
1869 #\r
1870 if not StructuredPcds:\r
1871 return\r
1872\r
1873 InitByteValue = ""\r
1874 CApp = PcdMainCHeader\r
1875\r
1876 Includes = {}\r
1877 for PcdName in StructuredPcds:\r
1878 Pcd = StructuredPcds[PcdName]\r
81add864
FB
1879 for IncludeFile in Pcd.StructuredPcdIncludeFile:\r
1880 if IncludeFile not in Includes:\r
1881 Includes[IncludeFile] = True\r
1882 CApp = CApp + '#include <%s>\n' % (IncludeFile)\r
ae7b6df8 1883 CApp = CApp + '\n'\r
ae7b6df8
LG
1884 for PcdName in StructuredPcds:\r
1885 Pcd = StructuredPcds[PcdName]\r
79820e32
B
1886 CApp = CApp + self.GenerateSizeFunction(Pcd)\r
1887 CApp = CApp + self.GenerateDefaultValueAssignFunction(Pcd)\r
0a57a978
FB
1888 if not Pcd.SkuOverrideValues or Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],\r
1889 self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:\r
8518bf0b 1890 InitByteValue, CApp = self.GenerateInitializeFunc(self.SkuIdMgr.SystemSkuId, 'STANDARD', Pcd, InitByteValue, CApp)\r
ae7b6df8 1891 else:\r
c05c2c05
LG
1892 for SkuName in self.SkuIdMgr.SkuOverrideOrder():\r
1893 if SkuName not in Pcd.SkuOverrideValues:\r
1894 continue\r
ae7b6df8
LG
1895 for DefaultStoreName in Pcd.DefaultStoreName:\r
1896 Pcd = StructuredPcds[PcdName]\r
1897 InitByteValue, CApp = self.GenerateInitializeFunc(SkuName, DefaultStoreName, Pcd, InitByteValue, CApp)\r
1898\r
1899 CApp = CApp + 'VOID\n'\r
1900 CApp = CApp + 'PcdEntryPoint(\n'\r
1901 CApp = CApp + ' VOID\n'\r
1902 CApp = CApp + ' )\n'\r
1903 CApp = CApp + '{\n'\r
1904 for Pcd in StructuredPcds.values():\r
0a57a978 1905 if not Pcd.SkuOverrideValues or Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:\r
8518bf0b 1906 CApp = CApp + ' Initialize_%s_%s_%s_%s();\n' % (self.SkuIdMgr.SystemSkuId, 'STANDARD', Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
ae7b6df8 1907 else:\r
c05c2c05
LG
1908 for SkuName in self.SkuIdMgr.SkuOverrideOrder():\r
1909 if SkuName not in Pcd.SkuOverrideValues:\r
1910 continue\r
8518bf0b 1911 for DefaultStoreName in Pcd.SkuOverrideValues[SkuName]:\r
ae7b6df8
LG
1912 CApp = CApp + ' Initialize_%s_%s_%s_%s();\n' % (SkuName, DefaultStoreName, Pcd.TokenSpaceGuidCName, Pcd.TokenCName)\r
1913 CApp = CApp + '}\n'\r
1914\r
1915 CApp = CApp + PcdMainCEntry + '\n'\r
1916\r
1917 if not os.path.exists(self.OutputPath):\r
1918 os.makedirs(self.OutputPath)\r
1919 CAppBaseFileName = os.path.join(self.OutputPath, PcdValueInitName)\r
0a57a978 1920 SaveFileOnChange(CAppBaseFileName + '.c', CApp, False)\r
ae7b6df8
LG
1921\r
1922 MakeApp = PcdMakefileHeader\r
1923 if sys.platform == "win32":\r
0a57a978 1924 MakeApp = MakeApp + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s\%s.obj\n' % (self.OutputPath, PcdValueInitName) + 'INC = '\r
ae7b6df8
LG
1925 else:\r
1926 MakeApp = MakeApp + PcdGccMakefile\r
1927 MakeApp = MakeApp + 'APPNAME = %s\n' % (PcdValueInitName) + 'OBJECTS = %s/%s.o\n' % (self.OutputPath, PcdValueInitName) + \\r
68ba919f 1928 'include $(MAKEROOT)/Makefiles/app.makefile\n' + 'INCLUDE +='\r
ae7b6df8
LG
1929\r
1930 PlatformInc = {}\r
1931 for Cache in self._Bdb._CACHE_.values():\r
1932 if Cache.MetaFile.Ext.lower() != '.dec':\r
1933 continue\r
1934 if Cache.Includes:\r
1935 if str(Cache.MetaFile.Path) not in PlatformInc:\r
0a57a978 1936 PlatformInc[str(Cache.MetaFile.Path)] = Cache.CommonIncludes\r
ae7b6df8
LG
1937\r
1938 PcdDependDEC = []\r
1939 for Pcd in StructuredPcds.values():\r
1940 for PackageDec in Pcd.PackageDecs:\r
1941 Package = os.path.normpath(mws.join(GlobalData.gWorkspace, PackageDec))\r
1942 if not os.path.exists(Package):\r
1943 EdkLogger.error('Build', RESOURCE_NOT_AVAILABLE, "The dependent Package %s of PCD %s.%s is not exist." % (PackageDec, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))\r
1944 if Package not in PcdDependDEC:\r
1945 PcdDependDEC.append(Package)\r
1946\r
1947 if PlatformInc and PcdDependDEC:\r
1948 for pkg in PcdDependDEC:\r
1949 if pkg in PlatformInc:\r
1950 for inc in PlatformInc[pkg]:\r
1951 MakeApp += '-I' + str(inc) + ' '\r
1952 MakeApp = MakeApp + '\n'\r
68ba919f
YZ
1953\r
1954 CC_FLAGS = LinuxCFLAGS\r
1955 if sys.platform == "win32":\r
1956 CC_FLAGS = WindowsCFLAGS\r
1957 BuildOptions = {}\r
1958 for Options in self.BuildOptions:\r
1959 if Options[2] != EDKII_NAME:\r
1960 continue\r
1961 Family = Options[0]\r
1962 if Family and Family != self.ToolChainFamily:\r
1963 continue\r
1964 Target, Tag, Arch, Tool, Attr = Options[1].split("_")\r
1965 if Tool != 'CC':\r
1966 continue\r
1967\r
1968 if Target == "*" or Target == self._Target:\r
1969 if Tag == "*" or Tag == self._Toolchain:\r
1970 if Arch == "*" or Arch == self.Arch:\r
1971 if Tool not in BuildOptions:\r
1972 BuildOptions[Tool] = {}\r
1973 if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or self.BuildOptions[Options].startswith('='):\r
1974 BuildOptions[Tool][Attr] = self.BuildOptions[Options]\r
1975 else:\r
1976 # append options for the same tool except PATH\r
1977 if Attr != 'PATH':\r
1978 BuildOptions[Tool][Attr] += " " + self.BuildOptions[Options]\r
1979 else:\r
1980 BuildOptions[Tool][Attr] = self.BuildOptions[Options]\r
1981 if BuildOptions:\r
1982 for Tool in BuildOptions:\r
1983 for Attr in BuildOptions[Tool]:\r
1984 if Attr == "FLAGS":\r
1985 Value = BuildOptions[Tool][Attr]\r
1986 ValueList = Value.split()\r
1987 if ValueList:\r
1988 for Id, Item in enumerate(ValueList):\r
1989 if Item == '-D' or Item == '/D':\r
1990 CC_FLAGS += ' ' + Item\r
1991 if Id + 1 < len(ValueList):\r
1992 CC_FLAGS += ' ' + ValueList[Id + 1]\r
1993 elif Item.startswith('/D') or Item.startswith('-D'):\r
1994 CC_FLAGS += ' ' + Item\r
1995 MakeApp += CC_FLAGS\r
1996\r
ae7b6df8
LG
1997 if sys.platform == "win32":\r
1998 MakeApp = MakeApp + PcdMakefileEnd\r
1999 MakeFileName = os.path.join(self.OutputPath, 'Makefile')\r
0a57a978 2000 SaveFileOnChange(MakeFileName, MakeApp, False)\r
ae7b6df8
LG
2001\r
2002 InputValueFile = os.path.join(self.OutputPath, 'Input.txt')\r
2003 OutputValueFile = os.path.join(self.OutputPath, 'Output.txt')\r
0a57a978 2004 SaveFileOnChange(InputValueFile, InitByteValue, False)\r
ae7b6df8
LG
2005\r
2006 PcdValueInitExe = PcdValueInitName\r
2007 if not sys.platform == "win32":\r
2008 PcdValueInitExe = os.path.join(os.getenv("EDK_TOOLS_PATH"), 'Source', 'C', 'bin', PcdValueInitName)\r
5db9414c 2009 else:\r
0a57a978
FB
2010 PcdValueInitExe = os.path.join(os.getenv("EDK_TOOLS_PATH"), 'Bin', 'Win32', PcdValueInitName) +".exe"\r
2011 if not os.path.exists(PcdValueInitExe) or self.NeedUpdateOutput(OutputValueFile, CAppBaseFileName + '.c',MakeFileName,InputValueFile):\r
2012 Messages = ''\r
2013 if sys.platform == "win32":\r
2014 MakeCommand = 'nmake clean & nmake -f %s' % (MakeFileName)\r
2015 returncode, StdOut, StdErr = self.ExecuteCommand (MakeCommand)\r
2016 Messages = StdOut\r
2017 else:\r
2018 MakeCommand = 'make clean & make -f %s' % (MakeFileName)\r
2019 returncode, StdOut, StdErr = self.ExecuteCommand (MakeCommand)\r
2020 Messages = StdErr\r
2021 Messages = Messages.split('\n')\r
2022 MessageGroup = []\r
2023 if returncode <>0:\r
2024 CAppBaseFileName = os.path.join(self.OutputPath, PcdValueInitName)\r
2025 File = open (CAppBaseFileName + '.c', 'r')\r
2026 FileData = File.readlines()\r
2027 File.close()\r
2028 for Message in Messages:\r
2029 if " error" in Message or "warning" in Message:\r
2030 FileInfo = Message.strip().split('(')\r
2031 if len (FileInfo) > 1:\r
2032 FileName = FileInfo [0]\r
2033 FileLine = FileInfo [1].split (')')[0]\r
2034 else:\r
2035 FileInfo = Message.strip().split(':')\r
2036 FileName = FileInfo [0]\r
2037 FileLine = FileInfo [1]\r
2038 if FileLine.isdigit():\r
2039 error_line = FileData[int (FileLine) - 1]\r
2040 if r"//" in error_line:\r
2041 c_line,dsc_line = error_line.split(r"//")\r
2042 else:\r
2043 dsc_line = error_line\r
2044 message_itmes = Message.split(":")\r
2045 Index = 0\r
2046 if "PcdValueInit.c" not in Message:\r
2047 if not MessageGroup:\r
2048 MessageGroup.append(Message)\r
2049 break\r
2050 else:\r
2051 for item in message_itmes:\r
2052 if "PcdValueInit.c" in item:\r
2053 Index = message_itmes.index(item)\r
2054 message_itmes[Index] = dsc_line.strip()\r
2055 break\r
2056 MessageGroup.append(":".join(message_itmes[Index:]).strip())\r
2057 continue\r
2058 else:\r
2059 MessageGroup.append(Message)\r
2060 if MessageGroup:\r
2061 EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "\n".join(MessageGroup) )\r
2062 else:\r
2063 EdkLogger.error('Build', COMMAND_FAILURE, 'Can not execute command: %s' % MakeCommand)\r
2064 Command = PcdValueInitExe + ' -i %s -o %s' % (InputValueFile, OutputValueFile)\r
2065 returncode, StdOut, StdErr = self.ExecuteCommand (Command)\r
2066 if returncode <> 0:\r
2067 EdkLogger.warn('Build', COMMAND_FAILURE, 'Can not collect output from command: %s' % Command)\r
2068\r
2069 File = open (OutputValueFile, 'r')\r
2070 FileBuffer = File.readlines()\r
2071 File.close()\r
ae7b6df8
LG
2072\r
2073 StructurePcdSet = []\r
2074 for Pcd in FileBuffer:\r
2075 PcdValue = Pcd.split ('|')\r
2076 PcdInfo = PcdValue[0].split ('.')\r
8518bf0b 2077 StructurePcdSet.append((PcdInfo[0],PcdInfo[1], PcdInfo[2], PcdInfo[3], PcdValue[2].strip()))\r
ae7b6df8
LG
2078 return StructurePcdSet\r
2079\r
0a57a978
FB
2080 def NeedUpdateOutput(self,OutputFile, ValueCFile, MakeFile, StructureInput):\r
2081 if not os.path.exists(OutputFile):\r
2082 return True\r
2083 if os.stat(OutputFile).st_mtime <= os.stat(ValueCFile).st_mtime:\r
2084 return True\r
2085 if os.stat(OutputFile).st_mtime <= os.stat(MakeFile).st_mtime:\r
2086 return True\r
2087 if os.stat(OutputFile).st_mtime <= os.stat(StructureInput).st_mtime:\r
2088 return True\r
2089 return False\r
2090\r
ae7b6df8
LG
2091 ## Retrieve dynamic PCD settings\r
2092 #\r
2093 # @param Type PCD type\r
2094 #\r
2095 # @retval a dict object contains settings of given PCD type\r
2096 #\r
2097 def _GetDynamicPcd(self, Type):\r
2098\r
ae7b6df8
LG
2099\r
2100 Pcds = sdict()\r
2101 #\r
2102 # tdict is a special dict kind of type, used for selecting correct\r
2103 # PCD settings for certain ARCH and SKU\r
2104 #\r
2105 PcdDict = tdict(True, 4)\r
2106 PcdList = []\r
2107 # Find out all possible PCD candidates for self._Arch\r
2108 RecordList = self._RawData[Type, self._Arch]\r
8518bf0b 2109 AvailableSkuIdSet = copy.copy(self.SkuIds)\r
ae7b6df8 2110\r
ae7b6df8 2111\r
8518bf0b 2112 for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4,Dummy5 in RecordList:\r
2b8a6c44
LG
2113 SkuName = SkuName.upper()\r
2114 SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName\r
ae7b6df8 2115 if SkuName not in AvailableSkuIdSet:\r
2b8a6c44
LG
2116 EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName,\r
2117 File=self.MetaFile, Line=Dummy5)\r
ae7b6df8 2118 if "." not in TokenSpaceGuid:\r
5db9414c 2119 PcdList.append((PcdCName, TokenSpaceGuid, SkuName, Dummy5))\r
ae7b6df8
LG
2120 PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting\r
2121\r
2122 # Remove redundant PCD candidates, per the ARCH and SKU\r
2123 for PcdCName, TokenSpaceGuid, SkuName, Dummy4 in PcdList:\r
2124\r
2125 Setting = PcdDict[self._Arch, SkuName, PcdCName, TokenSpaceGuid]\r
2126 if Setting == None:\r
2127 continue\r
2128\r
2129 PcdValue, DatumType, MaxDatumSize = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)\r
8518bf0b 2130 SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName][0], '', '', '', '', '', PcdValue)\r
ae7b6df8
LG
2131 if (PcdCName, TokenSpaceGuid) in Pcds.keys():\r
2132 pcdObject = Pcds[PcdCName, TokenSpaceGuid]\r
2133 pcdObject.SkuInfoList[SkuName] = SkuInfo\r
2134 if MaxDatumSize.strip():\r
2135 CurrentMaxSize = int(MaxDatumSize.strip(), 0)\r
2136 else:\r
2137 CurrentMaxSize = 0\r
2138 if pcdObject.MaxDatumSize:\r
2139 PcdMaxSize = int(pcdObject.MaxDatumSize, 0)\r
2140 else:\r
2141 PcdMaxSize = 0\r
2142 if CurrentMaxSize > PcdMaxSize:\r
2143 pcdObject.MaxDatumSize = str(CurrentMaxSize)\r
2144 else:\r
2145 Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(\r
2146 PcdCName,\r
2147 TokenSpaceGuid,\r
2148 self._PCD_TYPE_STRING_[Type],\r
2149 DatumType,\r
2150 PcdValue,\r
2151 '',\r
2152 MaxDatumSize,\r
2153 {SkuName : SkuInfo},\r
2154 False,\r
2155 None,\r
2156 IsDsc=True)\r
2157\r
2158 for pcd in Pcds.values():\r
2159 pcdDecObject = self._DecPcds[pcd.TokenCName, pcd.TokenSpaceGuidCName]\r
e651d06c
LG
2160 # Only fix the value while no value provided in DSC file.\r
2161 for sku in pcd.SkuInfoList.values():\r
2162 if (sku.DefaultValue == "" or sku.DefaultValue==None):\r
2163 sku.DefaultValue = pcdDecObject.DefaultValue\r
ae7b6df8
LG
2164 if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys():\r
2165 valuefromDec = pcdDecObject.DefaultValue\r
2166 SkuInfo = SkuInfoClass('DEFAULT', '0', '', '', '', '', '', valuefromDec)\r
2167 pcd.SkuInfoList['DEFAULT'] = SkuInfo\r
2168 elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():\r
2169 pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']\r
2170 del(pcd.SkuInfoList['COMMON'])\r
2171 elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():\r
2172 del(pcd.SkuInfoList['COMMON'])\r
65eff519
LG
2173\r
2174 map(self.FilterSkuSettings,Pcds.values())\r
ae7b6df8
LG
2175\r
2176 return Pcds\r
2177\r
65eff519
LG
2178 def FilterSkuSettings(self, PcdObj):\r
2179\r
2180 if self.SkuIdMgr.SkuUsageType == self.SkuIdMgr.SINGLE:\r
2181 if 'DEFAULT' in PcdObj.SkuInfoList.keys() and self.SkuIdMgr.SystemSkuId not in PcdObj.SkuInfoList.keys():\r
2182 PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId] = PcdObj.SkuInfoList['DEFAULT']\r
2183 PcdObj.SkuInfoList = {'DEFAULT':PcdObj.SkuInfoList[self.SkuIdMgr.SystemSkuId]}\r
2184 PcdObj.SkuInfoList['DEFAULT'].SkuIdName = 'DEFAULT'\r
2185 PcdObj.SkuInfoList['DEFAULT'].SkuId = '0'\r
2186\r
2187 elif self.SkuIdMgr.SkuUsageType == self.SkuIdMgr.DEFAULT:\r
2188 PcdObj.SkuInfoList = {'DEFAULT':PcdObj.SkuInfoList['DEFAULT']}\r
2189\r
2190 return PcdObj\r
2191\r
2192\r
ae7b6df8
LG
2193 def CompareVarAttr(self, Attr1, Attr2):\r
2194 if not Attr1 or not Attr2: # for empty string\r
2195 return True\r
2196 Attr1s = [attr.strip() for attr in Attr1.split(",")]\r
2197 Attr1Set = set(Attr1s)\r
2198 Attr2s = [attr.strip() for attr in Attr2.split(",")]\r
2199 Attr2Set = set(Attr2s)\r
2200 if Attr2Set == Attr1Set:\r
2201 return True\r
2202 else:\r
2203 return False\r
8518bf0b
LG
2204 def CompletePcdValues(self,PcdSet):\r
2205 Pcds = {}\r
2206 DefaultStoreObj = DefaultStore(self._GetDefaultStores())\r
98eb1364 2207 SkuIds = {skuname:skuid for skuname,skuid in self.SkuIdMgr.AvailableSkuIdSet.items() if skuname !='COMMON'}\r
8518bf0b
LG
2208 DefaultStores = set([storename for pcdobj in PcdSet.values() for skuobj in pcdobj.SkuInfoList.values() for storename in skuobj.DefaultStoreDict.keys()])\r
2209 for PcdCName, TokenSpaceGuid in PcdSet:\r
2210 PcdObj = PcdSet[(PcdCName, TokenSpaceGuid)]\r
2211 if PcdObj.Type not in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_DEFAULT],\r
2212 self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],\r
2213 self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_VPD],\r
2214 self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_DEFAULT],\r
2215 self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII],\r
2216 self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_VPD]]:\r
2217 Pcds[PcdCName, TokenSpaceGuid]= PcdObj\r
2218 continue\r
2219 PcdType = PcdObj.Type\r
2220 if PcdType in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:\r
2221 for skuid in PcdObj.SkuInfoList:\r
2222 skuobj = PcdObj.SkuInfoList[skuid]\r
2223 mindefaultstorename = DefaultStoreObj.GetMin(set([defaultstorename for defaultstorename in skuobj.DefaultStoreDict]))\r
2224 for defaultstorename in DefaultStores:\r
2225 if defaultstorename not in skuobj.DefaultStoreDict:\r
2b8a6c44 2226 skuobj.DefaultStoreDict[defaultstorename] = copy.deepcopy(skuobj.DefaultStoreDict[mindefaultstorename])\r
8518bf0b 2227 skuobj.HiiDefaultValue = skuobj.DefaultStoreDict[mindefaultstorename]\r
8ac16789 2228 for skuname,skuid in SkuIds.items():\r
2b8a6c44
LG
2229 if skuname not in PcdObj.SkuInfoList:\r
2230 nextskuid = self.SkuIdMgr.GetNextSkuId(skuname)\r
8518bf0b
LG
2231 while nextskuid not in PcdObj.SkuInfoList:\r
2232 nextskuid = self.SkuIdMgr.GetNextSkuId(nextskuid)\r
2b8a6c44
LG
2233 PcdObj.SkuInfoList[skuname] = copy.deepcopy(PcdObj.SkuInfoList[nextskuid])\r
2234 PcdObj.SkuInfoList[skuname].SkuId = skuid\r
2235 PcdObj.SkuInfoList[skuname].SkuIdName = skuname\r
8518bf0b
LG
2236 if PcdType in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:\r
2237 PcdObj.DefaultValue = PcdObj.SkuInfoList.values()[0].HiiDefaultValue if self.SkuIdMgr.SkuUsageType == self.SkuIdMgr.SINGLE else PcdObj.SkuInfoList["DEFAULT"].HiiDefaultValue\r
2238 Pcds[PcdCName, TokenSpaceGuid]= PcdObj\r
2239 return Pcds\r
ae7b6df8
LG
2240 ## Retrieve dynamic HII PCD settings\r
2241 #\r
2242 # @param Type PCD type\r
2243 #\r
2244 # @retval a dict object contains settings of given PCD type\r
2245 #\r
2246 def _GetDynamicHiiPcd(self, Type):\r
2247\r
ae7b6df8
LG
2248 VariableAttrs = {}\r
2249\r
2250 Pcds = sdict()\r
2251 #\r
2252 # tdict is a special dict kind of type, used for selecting correct\r
2253 # PCD settings for certain ARCH and SKU\r
2254 #\r
8518bf0b 2255 PcdDict = tdict(True, 5)\r
ae7b6df8
LG
2256 PcdSet = set()\r
2257 RecordList = self._RawData[Type, self._Arch]\r
2258 # Find out all possible PCD candidates for self._Arch\r
8518bf0b 2259 AvailableSkuIdSet = copy.copy(self.SkuIds)\r
2b8a6c44 2260 DefaultStoresDefine = self._GetDefaultStores()\r
ae7b6df8 2261\r
8518bf0b 2262 for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, DefaultStore, Dummy4,Dummy5 in RecordList:\r
2b8a6c44
LG
2263 SkuName = SkuName.upper()\r
2264 SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName\r
2265 DefaultStore = DefaultStore.upper()\r
8518bf0b
LG
2266 if DefaultStore == "COMMON":\r
2267 DefaultStore = "STANDARD"\r
ae7b6df8 2268 if SkuName not in AvailableSkuIdSet:\r
2b8a6c44
LG
2269 EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName,\r
2270 File=self.MetaFile, Line=Dummy5)\r
2271 if DefaultStore not in DefaultStoresDefine:\r
2272 EdkLogger.error('build', PARAMETER_INVALID, 'DefaultStores %s is not defined in [DefaultStores] section' % DefaultStore,\r
2273 File=self.MetaFile, Line=Dummy5)\r
ae7b6df8 2274 if "." not in TokenSpaceGuid:\r
5db9414c 2275 PcdSet.add((PcdCName, TokenSpaceGuid, SkuName,DefaultStore, Dummy5))\r
8518bf0b 2276 PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid,DefaultStore] = Setting\r
ae7b6df8
LG
2277\r
2278\r
2279 # Remove redundant PCD candidates, per the ARCH and SKU\r
8518bf0b 2280 for PcdCName, TokenSpaceGuid, SkuName,DefaultStore, Dummy4 in PcdSet:\r
ae7b6df8 2281\r
8518bf0b 2282 Setting = PcdDict[self._Arch, SkuName, PcdCName, TokenSpaceGuid,DefaultStore]\r
ae7b6df8
LG
2283 if Setting == None:\r
2284 continue\r
2285 VariableName, VariableGuid, VariableOffset, DefaultValue, VarAttribute = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)\r
2286\r
2287 rt, Msg = VariableAttributes.ValidateVarAttributes(VarAttribute)\r
2288 if not rt:\r
2289 EdkLogger.error("build", PCD_VARIABLE_ATTRIBUTES_ERROR, "Variable attributes settings for %s is incorrect.\n %s" % (".".join((TokenSpaceGuid, PcdCName)), Msg),\r
2290 ExtraData="[%s]" % VarAttribute)\r
2291 ExceedMax = False\r
2292 FormatCorrect = True\r
2293 if VariableOffset.isdigit():\r
2294 if int(VariableOffset, 10) > 0xFFFF:\r
2295 ExceedMax = True\r
2296 elif re.match(r'[\t\s]*0[xX][a-fA-F0-9]+$', VariableOffset):\r
2297 if int(VariableOffset, 16) > 0xFFFF:\r
2298 ExceedMax = True\r
2299 # For Offset written in "A.B"\r
2300 elif VariableOffset.find('.') > -1:\r
2301 VariableOffsetList = VariableOffset.split(".")\r
2302 if not (len(VariableOffsetList) == 2\r
2303 and IsValidWord(VariableOffsetList[0])\r
2304 and IsValidWord(VariableOffsetList[1])):\r
2305 FormatCorrect = False\r
2306 else:\r
2307 FormatCorrect = False\r
2308 if not FormatCorrect:\r
2309 EdkLogger.error('Build', FORMAT_INVALID, "Invalid syntax or format of the variable offset value is incorrect for %s." % ".".join((TokenSpaceGuid, PcdCName)))\r
2310\r
2311 if ExceedMax:\r
2312 EdkLogger.error('Build', OPTION_VALUE_INVALID, "The variable offset value must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join((TokenSpaceGuid, PcdCName)))\r
2313 if (VariableName, VariableGuid) not in VariableAttrs:\r
2314 VariableAttrs[(VariableName, VariableGuid)] = VarAttribute\r
2315 else:\r
2316 if not self.CompareVarAttr(VariableAttrs[(VariableName, VariableGuid)], VarAttribute):\r
2317 EdkLogger.error('Build', PCD_VARIABLE_ATTRIBUTES_CONFLICT_ERROR, "The variable %s.%s for DynamicHii PCDs has conflicting attributes [%s] and [%s] " % (VariableGuid, VariableName, VarAttribute, VariableAttrs[(VariableName, VariableGuid)]))\r
2318\r
ae7b6df8
LG
2319 pcdDecObject = self._DecPcds[PcdCName, TokenSpaceGuid]\r
2320 if (PcdCName, TokenSpaceGuid) in Pcds.keys():\r
2321 pcdObject = Pcds[PcdCName, TokenSpaceGuid]\r
8518bf0b
LG
2322 if SkuName in pcdObject.SkuInfoList:\r
2323 Skuitem = pcdObject.SkuInfoList[SkuName]\r
2324 Skuitem.DefaultStoreDict.update({DefaultStore:DefaultValue})\r
2325 else:\r
2326 SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName][0], VariableName, VariableGuid, VariableOffset, DefaultValue, VariableAttribute=VarAttribute,DefaultStore={DefaultStore:DefaultValue})\r
2327 pcdObject.SkuInfoList[SkuName] = SkuInfo\r
ae7b6df8 2328 else:\r
8518bf0b 2329 SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName][0], VariableName, VariableGuid, VariableOffset, DefaultValue, VariableAttribute=VarAttribute,DefaultStore={DefaultStore:DefaultValue})\r
ae7b6df8
LG
2330 Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(\r
2331 PcdCName,\r
2332 TokenSpaceGuid,\r
2333 self._PCD_TYPE_STRING_[Type],\r
2334 '',\r
2335 DefaultValue,\r
2336 '',\r
2337 '',\r
2338 {SkuName : SkuInfo},\r
2339 False,\r
2340 None,\r
2341 pcdDecObject.validateranges,\r
2342 pcdDecObject.validlists,\r
2343 pcdDecObject.expressions,\r
2344 IsDsc=True)\r
2345\r
2346\r
2347 for pcd in Pcds.values():\r
2348 SkuInfoObj = pcd.SkuInfoList.values()[0]\r
2349 pcdDecObject = self._DecPcds[pcd.TokenCName, pcd.TokenSpaceGuidCName]\r
e1511113 2350 pcd.DatumType = pcdDecObject.DatumType\r
ae7b6df8
LG
2351 # Only fix the value while no value provided in DSC file.\r
2352 for sku in pcd.SkuInfoList.values():\r
2353 if (sku.HiiDefaultValue == "" or sku.HiiDefaultValue == None):\r
2354 sku.HiiDefaultValue = pcdDecObject.DefaultValue\r
e1511113
B
2355 for default_store in sku.DefaultStoreDict:\r
2356 sku.DefaultStoreDict[default_store]=pcdDecObject.DefaultValue\r
2357 pcd.DefaultValue = pcdDecObject.DefaultValue\r
ae7b6df8
LG
2358 if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys():\r
2359 valuefromDec = pcdDecObject.DefaultValue\r
2b8a6c44 2360 SkuInfo = SkuInfoClass('DEFAULT', '0', SkuInfoObj.VariableName, SkuInfoObj.VariableGuid, SkuInfoObj.VariableOffset, valuefromDec,VariableAttribute=SkuInfoObj.VariableAttribute,DefaultStore={DefaultStore:valuefromDec})\r
ae7b6df8
LG
2361 pcd.SkuInfoList['DEFAULT'] = SkuInfo\r
2362 elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():\r
2363 pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']\r
2364 del(pcd.SkuInfoList['COMMON'])\r
2365 elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():\r
2366 del(pcd.SkuInfoList['COMMON'])\r
2367\r
ae7b6df8
LG
2368 if pcd.MaxDatumSize.strip():\r
2369 MaxSize = int(pcd.MaxDatumSize, 0)\r
2370 else:\r
2371 MaxSize = 0\r
2372 if pcdDecObject.DatumType == 'VOID*':\r
2b8a6c44 2373 for (_, skuobj) in pcd.SkuInfoList.items():\r
ae7b6df8 2374 datalen = 0\r
47854fd5
LG
2375 skuobj.HiiDefaultValue = StringToArray(skuobj.HiiDefaultValue)\r
2376 datalen = len(skuobj.HiiDefaultValue.split(","))\r
ae7b6df8
LG
2377 if datalen > MaxSize:\r
2378 MaxSize = datalen\r
47854fd5
LG
2379 for defaultst in skuobj.DefaultStoreDict:\r
2380 skuobj.DefaultStoreDict[defaultst] = StringToArray(skuobj.DefaultStoreDict[defaultst])\r
2381 pcd.DefaultValue = StringToArray(pcd.DefaultValue)\r
ae7b6df8 2382 pcd.MaxDatumSize = str(MaxSize)\r
2b8a6c44
LG
2383 rt, invalidhii = self.CheckVariableNameAssignment(Pcds)\r
2384 if not rt:\r
2385 invalidpcd = ",".join(invalidhii)\r
2386 EdkLogger.error('build', PCD_VARIABLE_INFO_ERROR, Message='The same HII PCD must map to the same EFI variable for all SKUs', File=self.MetaFile, ExtraData=invalidpcd)\r
65eff519
LG
2387\r
2388 map(self.FilterSkuSettings,Pcds.values())\r
2389\r
ae7b6df8
LG
2390 return Pcds\r
2391\r
2b8a6c44
LG
2392 def CheckVariableNameAssignment(self,Pcds):\r
2393 invalidhii = []\r
2394 for pcdname in Pcds:\r
2395 pcd = Pcds[pcdname]\r
2396 varnameset = set([sku.VariableName for (skuid,sku) in pcd.SkuInfoList.items()])\r
2397 if len(varnameset) > 1:\r
2398 invalidhii.append(".".join((pcdname[1],pcdname[0])))\r
2399 if len(invalidhii):\r
2400 return False,invalidhii\r
2401 else:\r
2402 return True, []\r
ae7b6df8
LG
2403 ## Retrieve dynamic VPD PCD settings\r
2404 #\r
2405 # @param Type PCD type\r
2406 #\r
2407 # @retval a dict object contains settings of given PCD type\r
2408 #\r
2409 def _GetDynamicVpdPcd(self, Type):\r
2410\r
ae7b6df8
LG
2411\r
2412 Pcds = sdict()\r
2413 #\r
2414 # tdict is a special dict kind of type, used for selecting correct\r
2415 # PCD settings for certain ARCH and SKU\r
2416 #\r
2417 PcdDict = tdict(True, 4)\r
2418 PcdList = []\r
2419\r
2420 # Find out all possible PCD candidates for self._Arch\r
2421 RecordList = self._RawData[Type, self._Arch]\r
8518bf0b 2422 AvailableSkuIdSet = copy.copy(self.SkuIds)\r
ae7b6df8 2423\r
8518bf0b 2424 for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4,Dummy5 in RecordList:\r
2b8a6c44
LG
2425 SkuName = SkuName.upper()\r
2426 SkuName = 'DEFAULT' if SkuName == 'COMMON' else SkuName\r
ae7b6df8 2427 if SkuName not in AvailableSkuIdSet:\r
2b8a6c44
LG
2428 EdkLogger.error('build', PARAMETER_INVALID, 'Sku %s is not defined in [SkuIds] section' % SkuName,\r
2429 File=self.MetaFile, Line=Dummy5)\r
ae7b6df8 2430 if "." not in TokenSpaceGuid:\r
5db9414c 2431 PcdList.append((PcdCName, TokenSpaceGuid, SkuName, Dummy5))\r
ae7b6df8
LG
2432 PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting\r
2433\r
2434 # Remove redundant PCD candidates, per the ARCH and SKU\r
2435 for PcdCName, TokenSpaceGuid, SkuName, Dummy4 in PcdList:\r
2436 Setting = PcdDict[self._Arch, SkuName, PcdCName, TokenSpaceGuid]\r
2437 if Setting == None:\r
2438 continue\r
2439 #\r
2440 # For the VOID* type, it can have optional data of MaxDatumSize and InitialValue\r
2441 # For the Integer & Boolean type, the optional data can only be InitialValue.\r
2442 # At this point, we put all the data into the PcdClssObject for we don't know the PCD's datumtype\r
2443 # until the DEC parser has been called.\r
2444 #\r
2445 VpdOffset, MaxDatumSize, InitialValue = self._ValidatePcd(PcdCName, TokenSpaceGuid, Setting, Type, Dummy4)\r
8518bf0b 2446 SkuInfo = SkuInfoClass(SkuName, self.SkuIds[SkuName][0], '', '', '', '', VpdOffset, InitialValue)\r
ae7b6df8
LG
2447 if (PcdCName, TokenSpaceGuid) in Pcds.keys():\r
2448 pcdObject = Pcds[PcdCName, TokenSpaceGuid]\r
2449 pcdObject.SkuInfoList[SkuName] = SkuInfo\r
2450 if MaxDatumSize.strip():\r
2451 CurrentMaxSize = int(MaxDatumSize.strip(), 0)\r
2452 else:\r
2453 CurrentMaxSize = 0\r
2454 if pcdObject.MaxDatumSize:\r
2455 PcdMaxSize = int(pcdObject.MaxDatumSize, 0)\r
2456 else:\r
2457 PcdMaxSize = 0\r
2458 if CurrentMaxSize > PcdMaxSize:\r
2459 pcdObject.MaxDatumSize = str(CurrentMaxSize)\r
2460 else:\r
2461 Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(\r
2462 PcdCName,\r
2463 TokenSpaceGuid,\r
2464 self._PCD_TYPE_STRING_[Type],\r
2465 '',\r
2466 InitialValue,\r
2467 '',\r
2468 MaxDatumSize,\r
2469 {SkuName : SkuInfo},\r
2470 False,\r
2471 None,\r
2472 IsDsc=True)\r
2473 for pcd in Pcds.values():\r
2474 SkuInfoObj = pcd.SkuInfoList.values()[0]\r
2475 pcdDecObject = self._DecPcds[pcd.TokenCName, pcd.TokenSpaceGuidCName]\r
8aa4db4b 2476 pcd.DatumType = pcdDecObject.DatumType\r
e651d06c
LG
2477 # Only fix the value while no value provided in DSC file.\r
2478 for sku in pcd.SkuInfoList.values():\r
2479 if (sku.DefaultValue == "" or sku.DefaultValue==None):\r
2480 sku.DefaultValue = pcdDecObject.DefaultValue\r
ae7b6df8
LG
2481 if 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' not in pcd.SkuInfoList.keys():\r
2482 valuefromDec = pcdDecObject.DefaultValue\r
2483 SkuInfo = SkuInfoClass('DEFAULT', '0', '', '', '', '', SkuInfoObj.VpdOffset, valuefromDec)\r
2484 pcd.SkuInfoList['DEFAULT'] = SkuInfo\r
2485 elif 'DEFAULT' not in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():\r
2486 pcd.SkuInfoList['DEFAULT'] = pcd.SkuInfoList['COMMON']\r
2487 del(pcd.SkuInfoList['COMMON'])\r
2488 elif 'DEFAULT' in pcd.SkuInfoList.keys() and 'COMMON' in pcd.SkuInfoList.keys():\r
2489 del(pcd.SkuInfoList['COMMON'])\r
ae7b6df8 2490\r
65eff519
LG
2491\r
2492 map(self.FilterSkuSettings,Pcds.values())\r
ae7b6df8
LG
2493 return Pcds\r
2494\r
2495 ## Add external modules\r
2496 #\r
2497 # The external modules are mostly those listed in FDF file, which don't\r
2498 # need "build".\r
2499 #\r
2500 # @param FilePath The path of module description file\r
2501 #\r
2502 def AddModule(self, FilePath):\r
2503 FilePath = NormPath(FilePath)\r
2504 if FilePath not in self.Modules:\r
2505 Module = ModuleBuildClassObject()\r
2506 Module.MetaFile = FilePath\r
2507 self.Modules.append(Module)\r
2508\r
68ba919f
YZ
2509 def _GetToolChainFamily(self):\r
2510 self._ToolChainFamily = "MSFT"\r
2511 BuildConfigurationFile = os.path.normpath(os.path.join(GlobalData.gConfDirectory, "target.txt"))\r
2512 if os.path.isfile(BuildConfigurationFile) == True:\r
2513 TargetTxt = TargetTxtClassObject()\r
2514 TargetTxt.LoadTargetTxtFile(BuildConfigurationFile)\r
2515 ToolDefinitionFile = TargetTxt.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF]\r
2516 if ToolDefinitionFile == '':\r
2517 ToolDefinitionFile = "tools_def.txt"\r
2518 ToolDefinitionFile = os.path.normpath(mws.join(self.WorkspaceDir, 'Conf', ToolDefinitionFile))\r
2519 if os.path.isfile(ToolDefinitionFile) == True:\r
2520 ToolDef = ToolDefClassObject()\r
2521 ToolDef.LoadToolDefFile(ToolDefinitionFile)\r
2522 ToolDefinition = ToolDef.ToolsDefTxtDatabase\r
2523 if TAB_TOD_DEFINES_FAMILY not in ToolDefinition \\r
2524 or self._Toolchain not in ToolDefinition[TAB_TOD_DEFINES_FAMILY] \\r
2525 or not ToolDefinition[TAB_TOD_DEFINES_FAMILY][self._Toolchain]:\r
2526 self._ToolChainFamily = "MSFT"\r
2527 else:\r
2528 self._ToolChainFamily = ToolDefinition[TAB_TOD_DEFINES_FAMILY][self._Toolchain]\r
2529 return self._ToolChainFamily\r
2530\r
ae7b6df8
LG
2531 ## Add external PCDs\r
2532 #\r
2533 # The external PCDs are mostly those listed in FDF file to specify address\r
2534 # or offset information.\r
2535 #\r
2536 # @param Name Name of the PCD\r
2537 # @param Guid Token space guid of the PCD\r
2538 # @param Value Value of the PCD\r
2539 #\r
2540 def AddPcd(self, Name, Guid, Value):\r
2541 if (Name, Guid) not in self.Pcds:\r
2542 self.Pcds[Name, Guid] = PcdClassObject(Name, Guid, '', '', '', '', '', {}, False, None)\r
2543 self.Pcds[Name, Guid].DefaultValue = Value\r
5644e5ce
FB
2544 @property\r
2545 def DecPcds(self):\r
2546 if self._DecPcds == None:\r
2547 FdfInfList = []\r
2548 if GlobalData.gFdfParser:\r
2549 FdfInfList = GlobalData.gFdfParser.Profile.InfList\r
2550 PkgSet = set()\r
2551 for Inf in FdfInfList:\r
2552 ModuleFile = PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch=self._Arch)\r
2553 if ModuleFile in self._Modules:\r
2554 continue\r
2555 ModuleData = self._Bdb[ModuleFile, self._Arch, self._Target, self._Toolchain]\r
2556 PkgSet.update(ModuleData.Packages)\r
726c501c 2557 self._DecPcds, self._GuidDict = GetDeclaredPcd(self, self._Bdb, self._Arch, self._Target, self._Toolchain,PkgSet)\r
5644e5ce 2558 return self._DecPcds\r
ae7b6df8
LG
2559 _Macros = property(_GetMacros)\r
2560 Arch = property(_GetArch, _SetArch)\r
2561 Platform = property(_GetPlatformName)\r
2562 PlatformName = property(_GetPlatformName)\r
2563 Guid = property(_GetFileGuid)\r
2564 Version = property(_GetVersion)\r
2565 DscSpecification = property(_GetDscSpec)\r
2566 OutputDirectory = property(_GetOutpuDir)\r
2567 SupArchList = property(_GetSupArch)\r
2568 BuildTargets = property(_GetBuildTarget)\r
2569 SkuName = property(_GetSkuName, _SetSkuName)\r
ae7b6df8
LG
2570 PcdInfoFlag = property(_GetPcdInfoFlag)\r
2571 VarCheckFlag = property(_GetVarCheckFlag)\r
2572 FlashDefinition = property(_GetFdfFile)\r
2573 Prebuild = property(_GetPrebuild)\r
2574 Postbuild = property(_GetPostbuild)\r
2575 BuildNumber = property(_GetBuildNumber)\r
2576 MakefileName = property(_GetMakefileName)\r
2577 BsBaseAddress = property(_GetBsBaseAddress)\r
2578 RtBaseAddress = property(_GetRtBaseAddress)\r
2579 LoadFixAddress = property(_GetLoadFixAddress)\r
2580 RFCLanguages = property(_GetRFCLanguages)\r
2581 ISOLanguages = property(_GetISOLanguages)\r
2582 VpdToolGuid = property(_GetVpdToolGuid)\r
2583 SkuIds = property(_GetSkuIds)\r
2584 Modules = property(_GetModules)\r
2585 LibraryInstances = property(_GetLibraryInstances)\r
2586 LibraryClasses = property(_GetLibraryClasses)\r
2587 Pcds = property(_GetPcds)\r
2588 BuildOptions = property(_GetBuildOptions)\r
68ba919f 2589 ToolChainFamily = property(_GetToolChainFamily)\r