2 # This file is used to create a database used by build tool
4 # Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
5 # (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
6 # This program and the accompanying materials
7 # are licensed and made available under the terms and conditions of the BSD License
8 # which accompanies this distribution. The full text of the license may be found at
9 # http://opensource.org/licenses/bsd-license.php
11 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 ## Platform build information from DSC file
17 # This class is used to retrieve information stored in database and convert them
18 # into PlatformBuildClassObject form for easier use for AutoGen.
20 from Common
.String
import *
21 from Common
.DataType
import *
22 from Common
.Misc
import *
25 from CommonDataClass
.CommonClass
import SkuInfoClass
27 from MetaDataTable
import *
28 from MetaFileTable
import *
29 from MetaFileParser
import *
31 from WorkspaceCommon
import GetDeclaredPcd
32 from Common
.Misc
import AnalyzeDscPcd
33 from Common
.Misc
import ProcessDuplicatedInf
35 from Common
.Parsing
import IsValidWord
36 from Common
.VariableAttributes
import VariableAttributes
37 import Common
.GlobalData
as GlobalData
39 from Workspace
.BuildClassObject
import PlatformBuildClassObject
, StructurePcd
, PcdClassObject
, ModuleBuildClassObject
42 # Treat CHAR16 as a synonym for UINT16. CHAR16 support is required for VFR C structs
44 PcdValueInitName
= 'PcdValueInit'
45 PcdSupportedBaseTypes
= ['BOOLEAN', 'UINT8', 'UINT16', 'UINT32', 'UINT64', 'CHAR16']
46 PcdSupportedBaseTypeWidth
= {'BOOLEAN':8, 'UINT8':8, 'UINT16':16, 'UINT32':32, 'UINT64':64}
47 PcdUnsupportedBaseTypes
= ['INT8', 'INT16', 'INT32', 'INT64', 'CHAR8', 'UINTN', 'INTN', 'VOID']
58 #include <PcdValueCommon.h>
68 return PcdValueMain (argc, argv);
72 PcdMakefileHeader
= '''
75 # This file is auto-generated by build utility
81 !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.common
83 CFLAGS = $(CFLAGS) /wd4200 /wd4034 /wd4101
85 LIBS = $(LIB_PATH)\Common.lib
87 !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app
92 MAKEROOT ?= $(EDK_TOOLS_PATH)/Source/C
96 class DscBuildData(PlatformBuildClassObject
):
97 # dict used to convert PCD type in database to string used by build tool
99 MODEL_PCD_FIXED_AT_BUILD
: "FixedAtBuild",
100 MODEL_PCD_PATCHABLE_IN_MODULE
: "PatchableInModule",
101 MODEL_PCD_FEATURE_FLAG
: "FeatureFlag",
102 MODEL_PCD_DYNAMIC
: "Dynamic",
103 MODEL_PCD_DYNAMIC_DEFAULT
: "Dynamic",
104 MODEL_PCD_DYNAMIC_HII
: "DynamicHii",
105 MODEL_PCD_DYNAMIC_VPD
: "DynamicVpd",
106 MODEL_PCD_DYNAMIC_EX
: "DynamicEx",
107 MODEL_PCD_DYNAMIC_EX_DEFAULT
: "DynamicEx",
108 MODEL_PCD_DYNAMIC_EX_HII
: "DynamicExHii",
109 MODEL_PCD_DYNAMIC_EX_VPD
: "DynamicExVpd",
112 # dict used to convert part of [Defines] to members of DscBuildData directly
117 TAB_DSC_DEFINES_PLATFORM_NAME
: "_PlatformName",
118 TAB_DSC_DEFINES_PLATFORM_GUID
: "_Guid",
119 TAB_DSC_DEFINES_PLATFORM_VERSION
: "_Version",
120 TAB_DSC_DEFINES_DSC_SPECIFICATION
: "_DscSpecification",
121 # TAB_DSC_DEFINES_OUTPUT_DIRECTORY : "_OutputDirectory",
122 # TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES : "_SupArchList",
123 # TAB_DSC_DEFINES_BUILD_TARGETS : "_BuildTargets",
124 TAB_DSC_DEFINES_SKUID_IDENTIFIER
: "_SkuName",
125 # TAB_DSC_DEFINES_FLASH_DEFINITION : "_FlashDefinition",
126 TAB_DSC_DEFINES_BUILD_NUMBER
: "_BuildNumber",
127 TAB_DSC_DEFINES_MAKEFILE_NAME
: "_MakefileName",
128 TAB_DSC_DEFINES_BS_BASE_ADDRESS
: "_BsBaseAddress",
129 TAB_DSC_DEFINES_RT_BASE_ADDRESS
: "_RtBaseAddress",
130 # TAB_DSC_DEFINES_RFC_LANGUAGES : "_RFCLanguages",
131 # TAB_DSC_DEFINES_ISO_LANGUAGES : "_ISOLanguages",
134 # used to compose dummy library class name for those forced library instances
135 _NullLibraryNumber
= 0
137 ## Constructor of DscBuildData
139 # Initialize object of DscBuildData
141 # @param FilePath The path of platform description file
142 # @param RawData The raw data of DSC file
143 # @param BuildDataBase Database used to retrieve module/package information
144 # @param Arch The target architecture
145 # @param Platform (not used for DscBuildData)
146 # @param Macros Macros used for replacement in DSC file
148 def __init__(self
, FilePath
, RawData
, BuildDataBase
, Arch
='COMMON', Target
=None, Toolchain
=None):
149 self
.MetaFile
= FilePath
150 self
._RawData
= RawData
151 self
._Bdb
= BuildDataBase
153 self
._Target
= Target
154 self
._Toolchain
= Toolchain
156 self
._HandleOverridePath
()
157 if os
.getenv("WORKSPACE"):
158 self
.OutputPath
= os
.path
.join(os
.getenv("WORKSPACE"), 'Build', PcdValueInitName
)
160 self
.OutputPath
= os
.path
.dirname(self
.DscFile
)
161 self
.DefaultStores
= None
162 self
.SkuIdMgr
= SkuClass(self
.SkuIdentifier
, self
.SkuIds
)
163 arraystr
= self
.SkuIdMgr
.DumpSkuIdArrary()
166 def __setitem__(self
, key
, value
):
167 self
.__dict
__[self
._PROPERTY
_[key
]] = value
170 def __getitem__(self
, key
):
171 return self
.__dict
__[self
._PROPERTY
_[key
]]
174 def __contains__(self
, key
):
175 return key
in self
._PROPERTY
_
177 ## Set all internal used members of DscBuildData to None
180 self
._PlatformName
= None
183 self
._DscSpecification
= None
184 self
._OutputDirectory
= None
185 self
._SupArchList
= None
186 self
._BuildTargets
= None
188 self
._SkuIdentifier
= None
189 self
._AvilableSkuIds
= None
190 self
._PcdInfoFlag
= None
191 self
._VarCheckFlag
= None
192 self
._FlashDefinition
= None
193 self
._Prebuild
= None
194 self
._Postbuild
= None
195 self
._BuildNumber
= None
196 self
._MakefileName
= None
197 self
._BsBaseAddress
= None
198 self
._RtBaseAddress
= None
201 self
._LibraryInstances
= None
202 self
._LibraryClasses
= None
205 self
._BuildOptions
= None
206 self
._ModuleTypeOptions
= None
207 self
._LoadFixAddress
= None
208 self
._RFCLanguages
= None
209 self
._ISOLanguages
= None
210 self
._VpdToolGuid
= None
212 self
.DefaultStores
= None
215 ## handle Override Path of Module
216 def _HandleOverridePath(self
):
217 RecordList
= self
._RawData
[MODEL_META_DATA_COMPONENT
, self
._Arch
]
218 Macros
= self
._Macros
219 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
220 for Record
in RecordList
:
223 ModuleFile
= PathClass(NormPath(Record
[0]), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
224 RecordList
= self
._RawData
[MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH
, self
._Arch
, None, ModuleId
]
226 SourceOverridePath
= mws
.join(GlobalData
.gWorkspace
, NormPath(RecordList
[0][0]))
228 # Check if the source override path exists
229 if not os
.path
.isdir(SourceOverridePath
):
230 EdkLogger
.error('build', FILE_NOT_FOUND
, Message
='Source override path does not exist:', File
=self
.MetaFile
, ExtraData
=SourceOverridePath
, Line
=LineNo
)
232 # Add to GlobalData Variables
233 GlobalData
.gOverrideDir
[ModuleFile
.Key
] = SourceOverridePath
235 ## Get current effective macros
236 def _GetMacros(self
):
237 if self
.__Macros
== None:
239 self
.__Macros
.update(GlobalData
.gPlatformDefines
)
240 self
.__Macros
.update(GlobalData
.gGlobalDefines
)
241 self
.__Macros
.update(GlobalData
.gCommandLineDefines
)
250 # Changing the default ARCH to another may affect all other information
251 # because all information in a platform may be ARCH-related. That's
252 # why we need to clear all internal used members, in order to cause all
253 # information to be re-retrieved.
255 # @param Value The value of ARCH
257 def _SetArch(self
, Value
):
258 if self
._Arch
== Value
:
263 ## Retrieve all information in [Defines] section
265 # (Retriving all [Defines] information in one-shot is just to save time.)
267 def _GetHeaderInfo(self
):
268 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER
, self
._Arch
]
269 for Record
in RecordList
:
271 # items defined _PROPERTY_ don't need additional processing
273 # some special items in [Defines] section need special treatment
274 if Name
== TAB_DSC_DEFINES_OUTPUT_DIRECTORY
:
275 self
._OutputDirectory
= NormPath(Record
[2], self
._Macros
)
276 if ' ' in self
._OutputDirectory
:
277 EdkLogger
.error("build", FORMAT_NOT_SUPPORTED
, "No space is allowed in OUTPUT_DIRECTORY",
278 File
=self
.MetaFile
, Line
=Record
[-1],
279 ExtraData
=self
._OutputDirectory
)
280 elif Name
== TAB_DSC_DEFINES_FLASH_DEFINITION
:
281 self
._FlashDefinition
= PathClass(NormPath(Record
[2], self
._Macros
), GlobalData
.gWorkspace
)
282 ErrorCode
, ErrorInfo
= self
._FlashDefinition
.Validate('.fdf')
284 EdkLogger
.error('build', ErrorCode
, File
=self
.MetaFile
, Line
=Record
[-1],
286 elif Name
== TAB_DSC_PREBUILD
:
287 PrebuildValue
= Record
[2]
288 if Record
[2][0] == '"':
289 if Record
[2][-1] != '"':
290 EdkLogger
.error('build', FORMAT_INVALID
, 'Missing double quotes in the end of %s statement.' % TAB_DSC_PREBUILD
,
291 File
=self
.MetaFile
, Line
=Record
[-1])
292 PrebuildValue
= Record
[2][1:-1]
293 self
._Prebuild
= PrebuildValue
294 elif Name
== TAB_DSC_POSTBUILD
:
295 PostbuildValue
= Record
[2]
296 if Record
[2][0] == '"':
297 if Record
[2][-1] != '"':
298 EdkLogger
.error('build', FORMAT_INVALID
, 'Missing double quotes in the end of %s statement.' % TAB_DSC_POSTBUILD
,
299 File
=self
.MetaFile
, Line
=Record
[-1])
300 PostbuildValue
= Record
[2][1:-1]
301 self
._Postbuild
= PostbuildValue
302 elif Name
== TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES
:
303 self
._SupArchList
= GetSplitValueList(Record
[2], TAB_VALUE_SPLIT
)
304 elif Name
== TAB_DSC_DEFINES_BUILD_TARGETS
:
305 self
._BuildTargets
= GetSplitValueList(Record
[2])
306 elif Name
== TAB_DSC_DEFINES_SKUID_IDENTIFIER
:
307 if self
._SkuName
== None:
308 self
._SkuName
= Record
[2]
309 self
._SkuIdentifier
= Record
[2]
310 self
._AvilableSkuIds
= Record
[2]
311 elif Name
== TAB_DSC_DEFINES_PCD_INFO_GENERATION
:
312 self
._PcdInfoFlag
= Record
[2]
313 elif Name
== TAB_DSC_DEFINES_PCD_VAR_CHECK_GENERATION
:
314 self
._VarCheckFlag
= Record
[2]
315 elif Name
== TAB_FIX_LOAD_TOP_MEMORY_ADDRESS
:
317 self
._LoadFixAddress
= int (Record
[2], 0)
319 EdkLogger
.error("build", PARAMETER_INVALID
, "FIX_LOAD_TOP_MEMORY_ADDRESS %s is not valid dec or hex string" % (Record
[2]))
320 elif Name
== TAB_DSC_DEFINES_RFC_LANGUAGES
:
321 if not Record
[2] or Record
[2][0] != '"' or Record
[2][-1] != '"' or len(Record
[2]) == 1:
322 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"',
323 File
=self
.MetaFile
, Line
=Record
[-1])
324 LanguageCodes
= Record
[2][1:-1]
325 if not LanguageCodes
:
326 EdkLogger
.error('build', FORMAT_NOT_SUPPORTED
, 'one or more RFC4646 format language code must be provided for RFC_LANGUAGES statement',
327 File
=self
.MetaFile
, Line
=Record
[-1])
328 LanguageList
= GetSplitValueList(LanguageCodes
, TAB_SEMI_COLON_SPLIT
)
329 # check whether there is empty entries in the list
330 if None in LanguageList
:
331 EdkLogger
.error('build', FORMAT_NOT_SUPPORTED
, 'one or more empty language code is in RFC_LANGUAGES statement',
332 File
=self
.MetaFile
, Line
=Record
[-1])
333 self
._RFCLanguages
= LanguageList
334 elif Name
== TAB_DSC_DEFINES_ISO_LANGUAGES
:
335 if not Record
[2] or Record
[2][0] != '"' or Record
[2][-1] != '"' or len(Record
[2]) == 1:
336 EdkLogger
.error('build', FORMAT_NOT_SUPPORTED
, 'language code for ISO_LANGUAGES must have double quotes around it, for example: ISO_LANGUAGES = "engchn"',
337 File
=self
.MetaFile
, Line
=Record
[-1])
338 LanguageCodes
= Record
[2][1:-1]
339 if not LanguageCodes
:
340 EdkLogger
.error('build', FORMAT_NOT_SUPPORTED
, 'one or more ISO639-2 format language code must be provided for ISO_LANGUAGES statement',
341 File
=self
.MetaFile
, Line
=Record
[-1])
342 if len(LanguageCodes
) % 3:
343 EdkLogger
.error('build', FORMAT_NOT_SUPPORTED
, 'bad ISO639-2 format for ISO_LANGUAGES',
344 File
=self
.MetaFile
, Line
=Record
[-1])
346 for i
in range(0, len(LanguageCodes
), 3):
347 LanguageList
.append(LanguageCodes
[i
:i
+ 3])
348 self
._ISOLanguages
= LanguageList
349 elif Name
== TAB_DSC_DEFINES_VPD_TOOL_GUID
:
351 # try to convert GUID to a real UUID value to see whether the GUID is format
352 # for VPD_TOOL_GUID is correct.
357 EdkLogger
.error("build", FORMAT_INVALID
, "Invalid GUID format for VPD_TOOL_GUID", File
=self
.MetaFile
)
358 self
._VpdToolGuid
= Record
[2]
360 self
[Name
] = Record
[2]
361 # set _Header to non-None in order to avoid database re-querying
362 self
._Header
= 'DUMMY'
364 ## Retrieve platform name
365 def _GetPlatformName(self
):
366 if self
._PlatformName
== None:
367 if self
._Header
== None:
368 self
._GetHeaderInfo
()
369 if self
._PlatformName
== None:
370 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No PLATFORM_NAME", File
=self
.MetaFile
)
371 return self
._PlatformName
373 ## Retrieve file guid
374 def _GetFileGuid(self
):
375 if self
._Guid
== None:
376 if self
._Header
== None:
377 self
._GetHeaderInfo
()
378 if self
._Guid
== None:
379 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No PLATFORM_GUID", File
=self
.MetaFile
)
382 ## Retrieve platform version
383 def _GetVersion(self
):
384 if self
._Version
== None:
385 if self
._Header
== None:
386 self
._GetHeaderInfo
()
387 if self
._Version
== None:
388 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No PLATFORM_VERSION", File
=self
.MetaFile
)
391 ## Retrieve platform description file version
392 def _GetDscSpec(self
):
393 if self
._DscSpecification
== None:
394 if self
._Header
== None:
395 self
._GetHeaderInfo
()
396 if self
._DscSpecification
== None:
397 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No DSC_SPECIFICATION", File
=self
.MetaFile
)
398 return self
._DscSpecification
400 ## Retrieve OUTPUT_DIRECTORY
401 def _GetOutpuDir(self
):
402 if self
._OutputDirectory
== None:
403 if self
._Header
== None:
404 self
._GetHeaderInfo
()
405 if self
._OutputDirectory
== None:
406 self
._OutputDirectory
= os
.path
.join("Build", self
._PlatformName
)
407 return self
._OutputDirectory
409 ## Retrieve SUPPORTED_ARCHITECTURES
410 def _GetSupArch(self
):
411 if self
._SupArchList
== None:
412 if self
._Header
== None:
413 self
._GetHeaderInfo
()
414 if self
._SupArchList
== None:
415 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No SUPPORTED_ARCHITECTURES", File
=self
.MetaFile
)
416 return self
._SupArchList
418 ## Retrieve BUILD_TARGETS
419 def _GetBuildTarget(self
):
420 if self
._BuildTargets
== None:
421 if self
._Header
== None:
422 self
._GetHeaderInfo
()
423 if self
._BuildTargets
== None:
424 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No BUILD_TARGETS", File
=self
.MetaFile
)
425 return self
._BuildTargets
427 def _GetPcdInfoFlag(self
):
428 if self
._PcdInfoFlag
== None or self
._PcdInfoFlag
.upper() == 'FALSE':
430 elif self
._PcdInfoFlag
.upper() == 'TRUE':
434 def _GetVarCheckFlag(self
):
435 if self
._VarCheckFlag
== None or self
._VarCheckFlag
.upper() == 'FALSE':
437 elif self
._VarCheckFlag
.upper() == 'TRUE':
441 def _GetAviableSkuIds(self
):
442 if self
._AvilableSkuIds
:
443 return self
._AvilableSkuIds
444 return self
.SkuIdentifier
445 def _GetSkuIdentifier(self
):
448 if self
._SkuIdentifier
== None:
449 if self
._Header
== None:
450 self
._GetHeaderInfo
()
451 return self
._SkuIdentifier
452 ## Retrieve SKUID_IDENTIFIER
453 def _GetSkuName(self
):
454 if self
._SkuName
== None:
455 if self
._Header
== None:
456 self
._GetHeaderInfo
()
457 if (self
._SkuName
== None or self
._SkuName
not in self
.SkuIds
):
458 self
._SkuName
= 'DEFAULT'
461 ## Override SKUID_IDENTIFIER
462 def _SetSkuName(self
, Value
):
463 self
._SkuName
= Value
466 def _GetFdfFile(self
):
467 if self
._FlashDefinition
== None:
468 if self
._Header
== None:
469 self
._GetHeaderInfo
()
470 if self
._FlashDefinition
== None:
471 self
._FlashDefinition
= ''
472 return self
._FlashDefinition
474 def _GetPrebuild(self
):
475 if self
._Prebuild
== None:
476 if self
._Header
== None:
477 self
._GetHeaderInfo
()
478 if self
._Prebuild
== None:
480 return self
._Prebuild
482 def _GetPostbuild(self
):
483 if self
._Postbuild
== None:
484 if self
._Header
== None:
485 self
._GetHeaderInfo
()
486 if self
._Postbuild
== None:
488 return self
._Postbuild
490 ## Retrieve FLASH_DEFINITION
491 def _GetBuildNumber(self
):
492 if self
._BuildNumber
== None:
493 if self
._Header
== None:
494 self
._GetHeaderInfo
()
495 if self
._BuildNumber
== None:
496 self
._BuildNumber
= ''
497 return self
._BuildNumber
499 ## Retrieve MAKEFILE_NAME
500 def _GetMakefileName(self
):
501 if self
._MakefileName
== None:
502 if self
._Header
== None:
503 self
._GetHeaderInfo
()
504 if self
._MakefileName
== None:
505 self
._MakefileName
= ''
506 return self
._MakefileName
508 ## Retrieve BsBaseAddress
509 def _GetBsBaseAddress(self
):
510 if self
._BsBaseAddress
== None:
511 if self
._Header
== None:
512 self
._GetHeaderInfo
()
513 if self
._BsBaseAddress
== None:
514 self
._BsBaseAddress
= ''
515 return self
._BsBaseAddress
517 ## Retrieve RtBaseAddress
518 def _GetRtBaseAddress(self
):
519 if self
._RtBaseAddress
== None:
520 if self
._Header
== None:
521 self
._GetHeaderInfo
()
522 if self
._RtBaseAddress
== None:
523 self
._RtBaseAddress
= ''
524 return self
._RtBaseAddress
526 ## Retrieve the top address for the load fix address
527 def _GetLoadFixAddress(self
):
528 if self
._LoadFixAddress
== None:
529 if self
._Header
== None:
530 self
._GetHeaderInfo
()
532 if self
._LoadFixAddress
== None:
533 self
._LoadFixAddress
= self
._Macros
.get(TAB_FIX_LOAD_TOP_MEMORY_ADDRESS
, '0')
536 self
._LoadFixAddress
= int (self
._LoadFixAddress
, 0)
538 EdkLogger
.error("build", PARAMETER_INVALID
, "FIX_LOAD_TOP_MEMORY_ADDRESS %s is not valid dec or hex string" % (self
._LoadFixAddress
))
541 # If command line defined, should override the value in DSC file.
543 if 'FIX_LOAD_TOP_MEMORY_ADDRESS' in GlobalData
.gCommandLineDefines
.keys():
545 self
._LoadFixAddress
= int(GlobalData
.gCommandLineDefines
['FIX_LOAD_TOP_MEMORY_ADDRESS'], 0)
547 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']))
549 if self
._LoadFixAddress
< 0:
550 EdkLogger
.error("build", PARAMETER_INVALID
, "FIX_LOAD_TOP_MEMORY_ADDRESS is set to the invalid negative value 0x%x" % (self
._LoadFixAddress
))
551 if self
._LoadFixAddress
!= 0xFFFFFFFFFFFFFFFF and self
._LoadFixAddress
% 0x1000 != 0:
552 EdkLogger
.error("build", PARAMETER_INVALID
, "FIX_LOAD_TOP_MEMORY_ADDRESS is set to the invalid unaligned 4K value 0x%x" % (self
._LoadFixAddress
))
554 return self
._LoadFixAddress
556 ## Retrieve RFCLanguage filter
557 def _GetRFCLanguages(self
):
558 if self
._RFCLanguages
== None:
559 if self
._Header
== None:
560 self
._GetHeaderInfo
()
561 if self
._RFCLanguages
== None:
562 self
._RFCLanguages
= []
563 return self
._RFCLanguages
565 ## Retrieve ISOLanguage filter
566 def _GetISOLanguages(self
):
567 if self
._ISOLanguages
== None:
568 if self
._Header
== None:
569 self
._GetHeaderInfo
()
570 if self
._ISOLanguages
== None:
571 self
._ISOLanguages
= []
572 return self
._ISOLanguages
573 ## Retrieve the GUID string for VPD tool
574 def _GetVpdToolGuid(self
):
575 if self
._VpdToolGuid
== None:
576 if self
._Header
== None:
577 self
._GetHeaderInfo
()
578 if self
._VpdToolGuid
== None:
579 self
._VpdToolGuid
= ''
580 return self
._VpdToolGuid
582 ## Retrieve [SkuIds] section information
583 def _GetSkuIds(self
):
584 if self
._SkuIds
== None:
585 self
._SkuIds
= sdict()
586 RecordList
= self
._RawData
[MODEL_EFI_SKU_ID
, self
._Arch
]
587 for Record
in RecordList
:
588 if Record
[0] in [None, '']:
589 EdkLogger
.error('build', FORMAT_INVALID
, 'No Sku ID number',
590 File
=self
.MetaFile
, Line
=Record
[-1])
591 if Record
[1] in [None, '']:
592 EdkLogger
.error('build', FORMAT_INVALID
, 'No Sku ID name',
593 File
=self
.MetaFile
, Line
=Record
[-1])
594 Pattern
= re
.compile('^[1-9]\d*|0$')
595 if Pattern
.match(Record
[0]) == None:
596 EdkLogger
.error('build', FORMAT_INVALID
, "The format of the Sku ID number is invalid. The correct format is '{(0-9)} {(1-9)(0-9)+}'",
597 File
=self
.MetaFile
, Line
=Record
[-1])
598 if not IsValidWord(Record
[1]):
599 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_-.)*'",
600 File
=self
.MetaFile
, Line
=Record
[-1])
601 self
._SkuIds
[Record
[1]] = (Record
[0],Record
[1],Record
[2])
602 if 'DEFAULT' not in self
._SkuIds
:
603 self
._SkuIds
['DEFAULT'] = ("0","DEFAULT","DEFAULT")
604 if 'COMMON' not in self
._SkuIds
:
605 self
._SkuIds
['COMMON'] = ("0","DEFAULT","DEFAULT")
607 def ToInt(self
,intstr
):
608 return int(intstr
,16) if intstr
.upper().startswith("0X") else int(intstr
)
609 def _GetDefaultStores(self
):
610 if self
.DefaultStores
== None:
611 self
.DefaultStores
= sdict()
612 RecordList
= self
._RawData
[MODEL_EFI_DEFAULT_STORES
, self
._Arch
]
613 for Record
in RecordList
:
614 if Record
[0] in [None, '']:
615 EdkLogger
.error('build', FORMAT_INVALID
, 'No DefaultStores ID number',
616 File
=self
.MetaFile
, Line
=Record
[-1])
617 if Record
[1] in [None, '']:
618 EdkLogger
.error('build', FORMAT_INVALID
, 'No DefaultStores ID name',
619 File
=self
.MetaFile
, Line
=Record
[-1])
620 self
.DefaultStores
[Record
[1]] = (self
.ToInt(Record
[0]),Record
[1])
621 if TAB_DEFAULT_STORES_DEFAULT
not in self
.DefaultStores
:
622 self
.DefaultStores
[TAB_DEFAULT_STORES_DEFAULT
] = (0,TAB_DEFAULT_STORES_DEFAULT
)
623 return self
.DefaultStores
625 ## Retrieve [Components] section information
626 def _GetModules(self
):
627 if self
._Modules
!= None:
630 self
._Modules
= sdict()
631 RecordList
= self
._RawData
[MODEL_META_DATA_COMPONENT
, self
._Arch
]
632 Macros
= self
._Macros
633 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
634 for Record
in RecordList
:
635 DuplicatedFile
= False
637 ModuleFile
= PathClass(NormPath(Record
[0], Macros
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
641 # check the file validation
642 ErrorCode
, ErrorInfo
= ModuleFile
.Validate('.inf')
644 EdkLogger
.error('build', ErrorCode
, File
=self
.MetaFile
, Line
=LineNo
,
647 # If arch is COMMON, no duplicate module is checked since all modules in all component sections are selected
648 if self
._Arch
!= 'COMMON' and ModuleFile
in self
._Modules
:
649 DuplicatedFile
= True
651 Module
= ModuleBuildClassObject()
652 Module
.MetaFile
= ModuleFile
654 # get module private library instance
655 RecordList
= self
._RawData
[MODEL_EFI_LIBRARY_CLASS
, self
._Arch
, None, ModuleId
]
656 for Record
in RecordList
:
657 LibraryClass
= Record
[0]
658 LibraryPath
= PathClass(NormPath(Record
[1], Macros
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
661 # check the file validation
662 ErrorCode
, ErrorInfo
= LibraryPath
.Validate('.inf')
664 EdkLogger
.error('build', ErrorCode
, File
=self
.MetaFile
, Line
=LineNo
,
667 if LibraryClass
== '' or LibraryClass
== 'NULL':
668 self
._NullLibraryNumber
+= 1
669 LibraryClass
= 'NULL%d' % self
._NullLibraryNumber
670 EdkLogger
.verbose("Found forced library for %s\n\t%s [%s]" % (ModuleFile
, LibraryPath
, LibraryClass
))
671 Module
.LibraryClasses
[LibraryClass
] = LibraryPath
672 if LibraryPath
not in self
.LibraryInstances
:
673 self
.LibraryInstances
.append(LibraryPath
)
675 # get module private PCD setting
676 for Type
in [MODEL_PCD_FIXED_AT_BUILD
, MODEL_PCD_PATCHABLE_IN_MODULE
, \
677 MODEL_PCD_FEATURE_FLAG
, MODEL_PCD_DYNAMIC
, MODEL_PCD_DYNAMIC_EX
]:
678 RecordList
= self
._RawData
[Type
, self
._Arch
, None, ModuleId
]
679 for TokenSpaceGuid
, PcdCName
, Setting
, Dummy1
, Dummy2
, Dummy3
, Dummy4
,Dummy5
in RecordList
:
680 TokenList
= GetSplitValueList(Setting
)
681 DefaultValue
= TokenList
[0]
682 if len(TokenList
) > 1:
683 MaxDatumSize
= TokenList
[1]
686 TypeString
= self
._PCD
_TYPE
_STRING
_[Type
]
687 Pcd
= PcdClassObject(
699 Module
.Pcds
[PcdCName
, TokenSpaceGuid
] = Pcd
701 # get module private build options
702 RecordList
= self
._RawData
[MODEL_META_DATA_BUILD_OPTION
, self
._Arch
, None, ModuleId
]
703 for ToolChainFamily
, ToolChain
, Option
, Dummy1
, Dummy2
, Dummy3
, Dummy4
,Dummy5
in RecordList
:
704 if (ToolChainFamily
, ToolChain
) not in Module
.BuildOptions
:
705 Module
.BuildOptions
[ToolChainFamily
, ToolChain
] = Option
707 OptionString
= Module
.BuildOptions
[ToolChainFamily
, ToolChain
]
708 Module
.BuildOptions
[ToolChainFamily
, ToolChain
] = OptionString
+ " " + Option
710 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER
, self
._Arch
, None, ModuleId
]
711 if DuplicatedFile
and not RecordList
:
712 EdkLogger
.error('build', FILE_DUPLICATED
, File
=self
.MetaFile
, ExtraData
=str(ModuleFile
), Line
=LineNo
)
714 if len(RecordList
) != 1:
715 EdkLogger
.error('build', OPTION_UNKNOWN
, 'Only FILE_GUID can be listed in <Defines> section.',
716 File
=self
.MetaFile
, ExtraData
=str(ModuleFile
), Line
=LineNo
)
717 ModuleFile
= ProcessDuplicatedInf(ModuleFile
, RecordList
[0][2], GlobalData
.gWorkspace
)
718 ModuleFile
.Arch
= self
._Arch
720 self
._Modules
[ModuleFile
] = Module
723 ## Retrieve all possible library instances used in this platform
724 def _GetLibraryInstances(self
):
725 if self
._LibraryInstances
== None:
726 self
._GetLibraryClasses
()
727 return self
._LibraryInstances
729 ## Retrieve [LibraryClasses] information
730 def _GetLibraryClasses(self
):
731 if self
._LibraryClasses
== None:
732 self
._LibraryInstances
= []
734 # tdict is a special dict kind of type, used for selecting correct
735 # library instance for given library class and module type
737 LibraryClassDict
= tdict(True, 3)
738 # track all library class names
739 LibraryClassSet
= set()
740 RecordList
= self
._RawData
[MODEL_EFI_LIBRARY_CLASS
, self
._Arch
, None, -1]
741 Macros
= self
._Macros
742 for Record
in RecordList
:
743 LibraryClass
, LibraryInstance
, Dummy
, Arch
, ModuleType
, Dummy
,Dummy
, LineNo
= Record
744 if LibraryClass
== '' or LibraryClass
== 'NULL':
745 self
._NullLibraryNumber
+= 1
746 LibraryClass
= 'NULL%d' % self
._NullLibraryNumber
747 EdkLogger
.verbose("Found forced library for arch=%s\n\t%s [%s]" % (Arch
, LibraryInstance
, LibraryClass
))
748 LibraryClassSet
.add(LibraryClass
)
749 LibraryInstance
= PathClass(NormPath(LibraryInstance
, Macros
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
750 # check the file validation
751 ErrorCode
, ErrorInfo
= LibraryInstance
.Validate('.inf')
753 EdkLogger
.error('build', ErrorCode
, File
=self
.MetaFile
, Line
=LineNo
,
756 if ModuleType
!= 'COMMON' and ModuleType
not in SUP_MODULE_LIST
:
757 EdkLogger
.error('build', OPTION_UNKNOWN
, "Unknown module type [%s]" % ModuleType
,
758 File
=self
.MetaFile
, ExtraData
=LibraryInstance
, Line
=LineNo
)
759 LibraryClassDict
[Arch
, ModuleType
, LibraryClass
] = LibraryInstance
760 if LibraryInstance
not in self
._LibraryInstances
:
761 self
._LibraryInstances
.append(LibraryInstance
)
763 # resolve the specific library instance for each class and each module type
764 self
._LibraryClasses
= tdict(True)
765 for LibraryClass
in LibraryClassSet
:
766 # try all possible module types
767 for ModuleType
in SUP_MODULE_LIST
:
768 LibraryInstance
= LibraryClassDict
[self
._Arch
, ModuleType
, LibraryClass
]
769 if LibraryInstance
== None:
771 self
._LibraryClasses
[LibraryClass
, ModuleType
] = LibraryInstance
773 # for Edk style library instances, which are listed in different section
774 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
775 RecordList
= self
._RawData
[MODEL_EFI_LIBRARY_INSTANCE
, self
._Arch
]
776 for Record
in RecordList
:
777 File
= PathClass(NormPath(Record
[0], Macros
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
779 # check the file validation
780 ErrorCode
, ErrorInfo
= File
.Validate('.inf')
782 EdkLogger
.error('build', ErrorCode
, File
=self
.MetaFile
, Line
=LineNo
,
784 if File
not in self
._LibraryInstances
:
785 self
._LibraryInstances
.append(File
)
787 # we need the module name as the library class name, so we have
788 # to parse it here. (self._Bdb[] will trigger a file parse if it
789 # hasn't been parsed)
791 Library
= self
._Bdb
[File
, self
._Arch
, self
._Target
, self
._Toolchain
]
792 self
._LibraryClasses
[Library
.BaseName
, ':dummy:'] = Library
793 return self
._LibraryClasses
795 def _ValidatePcd(self
, PcdCName
, TokenSpaceGuid
, Setting
, PcdType
, LineNo
):
796 if self
._DecPcds
== None:
797 self
._DecPcds
= GetDeclaredPcd(self
, self
._Bdb
, self
._Arch
, self
._Target
, self
._Toolchain
)
799 if GlobalData
.gFdfParser
:
800 FdfInfList
= GlobalData
.gFdfParser
.Profile
.InfList
803 for Inf
in FdfInfList
:
804 ModuleFile
= PathClass(NormPath(Inf
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
805 if ModuleFile
in self
._Modules
:
807 ModuleData
= self
._Bdb
[ModuleFile
, self
._Arch
, self
._Target
, self
._Toolchain
]
808 PkgSet
.update(ModuleData
.Packages
)
812 DecPcds
[Pcd
[0], Pcd
[1]] = Pkg
.Pcds
[Pcd
]
813 self
._DecPcds
.update(DecPcds
)
815 if (PcdCName
, TokenSpaceGuid
) not in self
._DecPcds
and "." in TokenSpaceGuid
and (TokenSpaceGuid
.split(".")[1], TokenSpaceGuid
.split(".")[0]) not in self
._DecPcds
:
816 EdkLogger
.error('build', PARSER_ERROR
,
817 "Pcd (%s.%s) defined in DSC is not declared in DEC files. Arch: ['%s']" % (TokenSpaceGuid
, PcdCName
, self
._Arch
),
818 File
=self
.MetaFile
, Line
=LineNo
)
819 ValueList
, IsValid
, Index
= AnalyzeDscPcd(Setting
, PcdType
, self
._DecPcds
[PcdCName
, TokenSpaceGuid
].DatumType
)
820 if not IsValid
and PcdType
not in [MODEL_PCD_FEATURE_FLAG
, MODEL_PCD_FIXED_AT_BUILD
]:
821 EdkLogger
.error('build', FORMAT_INVALID
, "Pcd format incorrect.", File
=self
.MetaFile
, Line
=LineNo
,
822 ExtraData
="%s.%s|%s" % (TokenSpaceGuid
, PcdCName
, Setting
))
823 if ValueList
[Index
] and PcdType
not in [MODEL_PCD_FEATURE_FLAG
, MODEL_PCD_FIXED_AT_BUILD
]:
825 ValueList
[Index
] = ValueExpression(ValueList
[Index
], GlobalData
.gPlatformPcds
)(True)
826 except WrnExpression
, Value
:
827 ValueList
[Index
] = Value
.result
828 except EvaluationException
, Excpt
:
829 if hasattr(Excpt
, 'Pcd'):
830 if Excpt
.Pcd
in GlobalData
.gPlatformOtherPcds
:
831 EdkLogger
.error('Parser', FORMAT_INVALID
, "Cannot use this PCD (%s) in an expression as"
832 " it must be defined in a [PcdsFixedAtBuild] or [PcdsFeatureFlag] section"
833 " of the DSC file" % Excpt
.Pcd
,
834 File
=self
.MetaFile
, Line
=LineNo
)
836 EdkLogger
.error('Parser', FORMAT_INVALID
, "PCD (%s) is not defined in DSC file" % Excpt
.Pcd
,
837 File
=self
.MetaFile
, Line
=LineNo
)
839 EdkLogger
.error('Parser', FORMAT_INVALID
, "Invalid expression: %s" % str(Excpt
),
840 File
=self
.MetaFile
, Line
=LineNo
)
841 if ValueList
[Index
] == 'True':
842 ValueList
[Index
] = '1'
843 elif ValueList
[Index
] == 'False':
844 ValueList
[Index
] = '0'
846 Valid
, ErrStr
= CheckPcdDatum(self
._DecPcds
[PcdCName
, TokenSpaceGuid
].DatumType
, ValueList
[Index
])
848 EdkLogger
.error('build', FORMAT_INVALID
, ErrStr
, File
=self
.MetaFile
, Line
=LineNo
,
849 ExtraData
="%s.%s" % (TokenSpaceGuid
, PcdCName
))
852 def _FilterPcdBySkuUsage(self
,Pcds
):
853 available_sku
= self
.SkuIdMgr
.AvailableSkuIdSet
854 sku_usage
= self
.SkuIdMgr
.SkuUsageType
855 if sku_usage
== SkuClass
.SINGLE
:
858 Pcds
[pcdname
].SkuInfoList
= {"DEFAULT":pcd
.SkuInfoList
[skuid
] for skuid
in pcd
.SkuInfoList
if skuid
in available_sku
}
862 Pcds
[pcdname
].SkuInfoList
= {skuid
:pcd
.SkuInfoList
[skuid
] for skuid
in pcd
.SkuInfoList
if skuid
in available_sku
}
864 ## Retrieve all PCD settings in platform
866 if self
._Pcds
== None:
868 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_FIXED_AT_BUILD
))
869 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_PATCHABLE_IN_MODULE
))
870 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_FEATURE_FLAG
))
871 self
._Pcds
.update(self
._GetDynamicPcd
(MODEL_PCD_DYNAMIC_DEFAULT
))
872 self
._Pcds
.update(self
._GetDynamicHiiPcd
(MODEL_PCD_DYNAMIC_HII
))
873 self
._Pcds
.update(self
._GetDynamicVpdPcd
(MODEL_PCD_DYNAMIC_VPD
))
874 self
._Pcds
.update(self
._GetDynamicPcd
(MODEL_PCD_DYNAMIC_EX_DEFAULT
))
875 self
._Pcds
.update(self
._GetDynamicHiiPcd
(MODEL_PCD_DYNAMIC_EX_HII
))
876 self
._Pcds
.update(self
._GetDynamicVpdPcd
(MODEL_PCD_DYNAMIC_EX_VPD
))
878 self
._Pcds
= self
.CompletePcdValues(self
._Pcds
)
879 self
._Pcds
= self
.UpdateStructuredPcds(MODEL_PCD_TYPE_LIST
, self
._Pcds
)
880 self
._Pcds
= self
._FilterPcdBySkuUsage
(self
._Pcds
)
883 def _dumpPcdInfo(self
,Pcds
):
886 if not pcdobj
.TokenCName
.startswith("Test"):
888 for skuid
in pcdobj
.SkuInfoList
:
889 if pcdobj
.Type
in (self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
],self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]):
890 for storename
in pcdobj
.SkuInfoList
[skuid
].DefaultStoreDict
:
891 print "PcdCName: %s, SkuName: %s, StoreName: %s, Value: %s" % (".".join((pcdobj
.TokenSpaceGuidCName
, pcdobj
.TokenCName
)), skuid
,storename
,str(pcdobj
.SkuInfoList
[skuid
].DefaultStoreDict
[storename
]))
893 print "PcdCName: %s, SkuName: %s, Value: %s" % (".".join((pcdobj
.TokenSpaceGuidCName
, pcdobj
.TokenCName
)), skuid
,str(pcdobj
.SkuInfoList
[skuid
].DefaultValue
))
894 ## Retrieve [BuildOptions]
895 def _GetBuildOptions(self
):
896 if self
._BuildOptions
== None:
897 self
._BuildOptions
= sdict()
899 # Retrieve build option for EDKII and EDK style module
901 for CodeBase
in (EDKII_NAME
, EDK_NAME
):
902 RecordList
= self
._RawData
[MODEL_META_DATA_BUILD_OPTION
, self
._Arch
, CodeBase
]
903 for ToolChainFamily
, ToolChain
, Option
, Dummy1
, Dummy2
, Dummy3
, Dummy4
,Dummy5
in RecordList
:
904 CurKey
= (ToolChainFamily
, ToolChain
, CodeBase
)
906 # Only flags can be appended
908 if CurKey
not in self
._BuildOptions
or not ToolChain
.endswith('_FLAGS') or Option
.startswith('='):
909 self
._BuildOptions
[CurKey
] = Option
911 self
._BuildOptions
[CurKey
] += ' ' + Option
912 return self
._BuildOptions
914 def GetBuildOptionsByModuleType(self
, Edk
, ModuleType
):
915 if self
._ModuleTypeOptions
== None:
916 self
._ModuleTypeOptions
= sdict()
917 if (Edk
, ModuleType
) not in self
._ModuleTypeOptions
:
919 self
._ModuleTypeOptions
[Edk
, ModuleType
] = options
920 DriverType
= '%s.%s' % (Edk
, ModuleType
)
921 CommonDriverType
= '%s.%s' % ('COMMON', ModuleType
)
922 RecordList
= self
._RawData
[MODEL_META_DATA_BUILD_OPTION
, self
._Arch
, DriverType
]
923 for ToolChainFamily
, ToolChain
, Option
, Arch
, Type
, Dummy3
, Dummy4
,Dummy5
in RecordList
:
924 if Type
== DriverType
or Type
== CommonDriverType
:
925 Key
= (ToolChainFamily
, ToolChain
, Edk
)
926 if Key
not in options
or not ToolChain
.endswith('_FLAGS') or Option
.startswith('='):
927 options
[Key
] = Option
929 options
[Key
] += ' ' + Option
930 return self
._ModuleTypeOptions
[Edk
, ModuleType
]
932 def GetStructurePcdInfo(self
, PcdSet
):
933 structure_pcd_data
= {}
935 if (item
[0],item
[1]) not in structure_pcd_data
:
936 structure_pcd_data
[(item
[0],item
[1])] = []
937 structure_pcd_data
[(item
[0],item
[1])].append(item
)
939 return structure_pcd_data
941 def CompleteStructurePcdValue(self
,pcdset
):
942 skuset
= set([item
[3] for item
in pcdset
])
943 pcddatamap
= {(item
[0],item
[1],item
[2],item
[3]):item
for item
in pcdset
}
946 if (item
[0],item
[1]) not in FieldSet
:
947 FieldSet
[(item
[0],item
[1])] = set()
948 FieldSet
[(item
[0],item
[1])].add(item
[2])
950 for tockenspacename
,pcdname
, in FieldSet
:
951 for field
in FieldSet
[(tockenspacename
,pcdname
)]:
954 while (tockenspacename
,pcdname
,field
,nextskuid
) not in pcddatamap
:
955 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(nextskuid
)
956 if nextskuid
== "DEFAULT":
958 if (tockenspacename
,pcdname
,field
,nextskuid
) not in pcddatamap
:
960 item
= pcddatamap
[tockenspacename
,pcdname
,field
,nextskuid
]
961 completeset
.append((tockenspacename
,pcdname
,field
,skuid
, item
[4],item
[5], item
[6]))
963 def UpdateStructuredPcds(self
, TypeList
, AllPcds
):
965 DefaultStoreMgr
= DefaultStore(self
.DefaultStores
)
966 SkuIds
= set([skuid
for pcdobj
in AllPcds
.values() for skuid
in pcdobj
.SkuInfoList
.keys()])
967 DefaultStores
= set([storename
for pcdobj
in AllPcds
.values() for skuobj
in pcdobj
.SkuInfoList
.values() for storename
in skuobj
.DefaultStoreDict
.keys()])
970 # Find out all possible PCD candidates for self._Arch
972 for Type
in TypeList
:
973 RecordList
.extend(self
._RawData
[Type
, self
._Arch
])
975 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, SkuName
, default_store
, Dummy4
,Dummy5
in RecordList
:
976 if SkuName
not in SkuIds
:
978 SkuName
= 'DEFAULT' if SkuName
== 'COMMON' else SkuName
979 if SkuName
in SkuIds
and "." in TokenSpaceGuid
:
980 S_PcdSet
.append(( TokenSpaceGuid
.split(".")[0],TokenSpaceGuid
.split(".")[1], PcdCName
,SkuName
, default_store
,Dummy5
, AnalyzePcdExpression(Setting
)[0]))
981 S_PcdSet
= self
.CompleteStructurePcdValue(S_PcdSet
)
983 # handle pcd value override
984 StrPcdSet
= self
.GetStructurePcdInfo(S_PcdSet
)
986 for str_pcd
in StrPcdSet
:
987 str_pcd_obj
= Pcds
.get((str_pcd
[1], str_pcd
[0]), None)
988 str_pcd_dec
= self
._DecPcds
.get((str_pcd
[1], str_pcd
[0]), None)
990 str_pcd_obj_str
= StructurePcd()
991 str_pcd_obj_str
.copy(str_pcd_dec
)
993 str_pcd_obj_str
.copy(str_pcd_obj
)
994 if str_pcd_obj
.DefaultValue
:
995 str_pcd_obj_str
.DefaultFromDSC
= str_pcd_obj
.DefaultValue
996 for str_pcd_data
in StrPcdSet
[str_pcd
]:
997 if str_pcd_data
[3] in SkuIds
:
998 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
,LineNo
=str_pcd_data
[5])
999 S_pcd_set
[str_pcd
[1], str_pcd
[0]] = str_pcd_obj_str
1000 # Add the Structure PCD that only defined in DEC, don't have override in DSC file
1001 for Pcd
in self
._DecPcds
:
1002 if type (self
._DecPcds
[Pcd
]) is StructurePcd
:
1003 if Pcd
not in S_pcd_set
:
1004 str_pcd_obj_str
= StructurePcd()
1005 str_pcd_obj_str
.copy(self
._DecPcds
[Pcd
])
1006 str_pcd_obj
= Pcds
.get(Pcd
, None)
1008 str_pcd_obj_str
.copy(str_pcd_obj
)
1009 if str_pcd_obj
.DefaultValue
:
1010 str_pcd_obj_str
.DefaultFromDSC
= str_pcd_obj
.DefaultValue
1011 S_pcd_set
[Pcd
] = str_pcd_obj_str
1013 GlobalData
.gStructurePcd
[self
.Arch
] = S_pcd_set
1014 for stru_pcd
in S_pcd_set
.values():
1015 if stru_pcd
.Type
not in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_DEFAULT
],
1016 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
],
1017 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_VPD
],
1018 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_DEFAULT
],
1019 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
],
1020 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_VPD
]]:
1022 if stru_pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
1023 for skuid
in SkuIds
:
1025 if skuid
not in stru_pcd
.SkuOverrideValues
:
1026 while nextskuid
not in stru_pcd
.SkuOverrideValues
:
1027 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(nextskuid
)
1028 stru_pcd
.SkuOverrideValues
[skuid
] = {}
1029 PcdDefaultStoreSet
= set([defaultstorename
for defaultstorename
in stru_pcd
.SkuOverrideValues
[skuid
]])
1030 mindefaultstorename
= DefaultStoreMgr
.GetMin(PcdDefaultStoreSet
)
1031 for defaultstoreid
in DefaultStores
:
1032 if defaultstoreid
not in stru_pcd
.SkuOverrideValues
[skuid
]:
1033 stru_pcd
.SkuOverrideValues
[skuid
][defaultstoreid
] = stru_pcd
.SkuOverrideValues
[nextskuid
][mindefaultstorename
]
1034 for skuid
in SkuIds
:
1035 if skuid
in stru_pcd
.SkuOverrideValues
:
1037 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(skuid
)
1038 while nextskuid
not in stru_pcd
.SkuOverrideValues
:
1039 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(nextskuid
)
1040 stru_pcd
.SkuOverrideValues
[skuid
] = stru_pcd
.SkuOverrideValues
[nextskuid
]
1041 Str_Pcd_Values
= self
.GenerateByteArrayValue(S_pcd_set
)
1043 for (skuname
,StoreName
,PcdGuid
,PcdName
,PcdValue
) in Str_Pcd_Values
:
1044 str_pcd_obj
= S_pcd_set
.get((PcdName
, PcdGuid
))
1045 if str_pcd_obj
is None:
1047 if str_pcd_obj
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
],
1048 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
1049 if skuname
not in str_pcd_obj
.SkuInfoList
:
1050 str_pcd_obj
.SkuInfoList
[skuname
] = SkuInfoClass(SkuIdName
=skuname
, SkuId
=self
.SkuIds
[skuname
][0], HiiDefaultValue
=PcdValue
, DefaultStore
= {StoreName
:PcdValue
})
1052 str_pcd_obj
.SkuInfoList
[skuname
].HiiDefaultValue
= PcdValue
1053 str_pcd_obj
.SkuInfoList
[skuname
].DefaultStoreDict
.update({StoreName
:PcdValue
})
1054 elif str_pcd_obj
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FIXED_AT_BUILD
],
1055 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_PATCHABLE_IN_MODULE
]]:
1056 if skuname
in (self
.SkuIdMgr
.SystemSkuId
, 'DEFAULT', 'COMMON'):
1057 str_pcd_obj
.DefaultValue
= PcdValue
1059 if skuname
not in str_pcd_obj
.SkuInfoList
:
1060 str_pcd_obj
.SkuInfoList
[skuname
] = SkuInfoClass(SkuIdName
=skuname
, SkuId
=self
.SkuIds
[skuname
][0], DefaultValue
=PcdValue
)
1062 str_pcd_obj
.SkuInfoList
[skuname
].DefaultValue
= PcdValue
1063 for str_pcd_obj
in S_pcd_set
.values():
1064 if str_pcd_obj
.Type
not in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
],
1065 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
1067 PcdDefaultStoreSet
= set([defaultstorename
for skuobj
in str_pcd_obj
.SkuInfoList
.values() for defaultstorename
in skuobj
.DefaultStoreDict
])
1068 DefaultStoreObj
= DefaultStore(self
._GetDefaultStores
())
1069 mindefaultstorename
= DefaultStoreObj
.GetMin(PcdDefaultStoreSet
)
1070 str_pcd_obj
.SkuInfoList
[self
.SkuIdMgr
.SystemSkuId
].HiiDefaultValue
= str_pcd_obj
.SkuInfoList
[self
.SkuIdMgr
.SystemSkuId
].DefaultStoreDict
[mindefaultstorename
]
1072 for str_pcd_obj
in S_pcd_set
.values():
1073 if not str_pcd_obj
.OverrideValues
:
1075 str_pcd_obj
.MaxDatumSize
= self
.GetStructurePcdMaxSize(str_pcd_obj
)
1076 Pcds
[str_pcd_obj
.TokenCName
, str_pcd_obj
.TokenSpaceGuidCName
] = str_pcd_obj
1080 ## Retrieve non-dynamic PCD settings
1082 # @param Type PCD type
1084 # @retval a dict object contains settings of given PCD type
1086 def _GetPcd(self
, Type
):
1089 # tdict is a special dict kind of type, used for selecting correct
1090 # PCD settings for certain ARCH
1094 PcdDict
= tdict(True, 3)
1096 # Find out all possible PCD candidates for self._Arch
1097 RecordList
= self
._RawData
[Type
, self
._Arch
]
1098 PcdValueDict
= sdict()
1099 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, SkuName
, Dummy3
, Dummy4
,Dummy5
in RecordList
:
1100 if SkuName
in (self
.SkuIdMgr
.SystemSkuId
, 'DEFAULT', 'COMMON'):
1101 if "." not in TokenSpaceGuid
:
1102 PcdSet
.add((PcdCName
, TokenSpaceGuid
, SkuName
, Dummy4
))
1103 PcdDict
[Arch
, PcdCName
, TokenSpaceGuid
, SkuName
] = Setting
1105 for PcdCName
, TokenSpaceGuid
, SkuName
, Dummy4
in PcdSet
:
1106 Setting
= PcdDict
[self
._Arch
, PcdCName
, TokenSpaceGuid
, SkuName
]
1109 PcdValue
, DatumType
, MaxDatumSize
= self
._ValidatePcd
(PcdCName
, TokenSpaceGuid
, Setting
, Type
, Dummy4
)
1110 if (PcdCName
, TokenSpaceGuid
) in PcdValueDict
:
1111 PcdValueDict
[PcdCName
, TokenSpaceGuid
][SkuName
] = (PcdValue
, DatumType
, MaxDatumSize
)
1113 PcdValueDict
[PcdCName
, TokenSpaceGuid
] = {SkuName
:(PcdValue
, DatumType
, MaxDatumSize
)}
1115 PcdsKeys
= PcdValueDict
.keys()
1116 for PcdCName
, TokenSpaceGuid
in PcdsKeys
:
1118 PcdSetting
= PcdValueDict
[PcdCName
, TokenSpaceGuid
]
1122 if 'COMMON' in PcdSetting
:
1123 PcdValue
, DatumType
, MaxDatumSize
= PcdSetting
['COMMON']
1124 if 'DEFAULT' in PcdSetting
:
1125 PcdValue
, DatumType
, MaxDatumSize
= PcdSetting
['DEFAULT']
1126 if self
.SkuIdMgr
.SystemSkuId
in PcdSetting
:
1127 PcdValue
, DatumType
, MaxDatumSize
= PcdSetting
[self
.SkuIdMgr
.SystemSkuId
]
1129 Pcds
[PcdCName
, TokenSpaceGuid
] = PcdClassObject(
1132 self
._PCD
_TYPE
_STRING
_[Type
],
1145 def __UNICODE2OCTList(self
,Value
):
1146 Value
= Value
.strip()
1150 Temp
= '%04X' % ord(Item
)
1151 List
.append('0x' + Temp
[2:4])
1152 List
.append('0x' + Temp
[0:2])
1156 def __STRING2OCTList(self
,Value
):
1158 Value
= Value
.strip('"')
1160 Temp
= '%02X' % ord(char
)
1161 OCTList
.append('0x' + Temp
)
1162 OCTList
.append('0x00')
1165 def GetStructurePcdMaxSize(self
, str_pcd
):
1166 pcd_default_value
= str_pcd
.DefaultValue
1167 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()]
1168 sku_values
.append(pcd_default_value
)
1170 def get_length(value
):
1171 Value
= value
.strip()
1172 if Value
.startswith('GUID') and Value
.endswith(')'):
1174 if Value
.startswith('L"') and Value
.endswith('"'):
1175 return len(Value
[2:-1])
1176 if Value
[0] == '"' and Value
[-1] == '"':
1177 return len(Value
) - 2
1178 if Value
[0] == '{' and Value
[-1] == '}':
1179 return len(Value
.split(","))
1180 if Value
.startswith("L'") and Value
.endswith("'") and len(list(Value
[2:-1])) > 1:
1181 return len(list(Value
[2:-1]))
1182 if Value
[0] == "'" and Value
[-1] == "'" and len(list(Value
[1:-1])) > 1:
1183 return len(Value
) - 2
1186 return str(max([pcd_size
for pcd_size
in [get_length(item
) for item
in sku_values
]]))
1188 def IsFieldValueAnArray (self
, Value
):
1189 Value
= Value
.strip()
1190 if Value
.startswith('GUID') and Value
.endswith(')'):
1192 if Value
.startswith('L"') and Value
.endswith('"') and len(list(Value
[2:-1])) > 1:
1194 if Value
[0] == '"' and Value
[-1] == '"' and len(list(Value
[1:-1])) > 1:
1196 if Value
[0] == '{' and Value
[-1] == '}':
1198 if Value
.startswith("L'") and Value
.endswith("'") and len(list(Value
[2:-1])) > 1:
1199 print 'foo = ', list(Value
[2:-1])
1201 if Value
[0] == "'" and Value
[-1] == "'" and len(list(Value
[1:-1])) > 1:
1202 print 'bar = ', list(Value
[1:-1])
1206 def ExecuteCommand (self
, Command
):
1208 Process
= subprocess
.Popen(Command
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
, shell
=True)
1210 print 'ERROR: Can not execute command:', Command
1212 Result
= Process
.communicate()
1213 if Process
.returncode
<> 0:
1214 print 'ERROR: Can not collect output from command:', Command
1215 return Result
[0], Result
[1]
1217 def IntToCString(self
, Value
, ValueSize
):
1219 if not isinstance (Value
, str):
1220 for Index
in range(0, ValueSize
):
1221 Result
= Result
+ '\\x%02x' % (Value
& 0xff)
1223 Result
= Result
+ '"'
1226 def GenerateInitializeFunc(self
, SkuName
, DefaultStoreName
, Pcd
, InitByteValue
, CApp
):
1227 OverrideValues
= {DefaultStoreName
:""}
1228 if Pcd
.SkuOverrideValues
:
1229 OverrideValues
= Pcd
.SkuOverrideValues
[SkuName
]
1230 for DefaultStoreName
in OverrideValues
.keys():
1231 CApp
= CApp
+ 'void\n'
1232 CApp
= CApp
+ 'Initialize_%s_%s_%s_%s(\n' % (SkuName
, DefaultStoreName
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
1233 CApp
= CApp
+ ' void\n'
1234 CApp
= CApp
+ ' )\n'
1236 CApp
= CApp
+ ' UINT32 Size;\n'
1237 CApp
= CApp
+ ' UINT32 FieldSize;\n'
1238 CApp
= CApp
+ ' UINT8 *Value;\n'
1239 CApp
= CApp
+ ' UINT32 OriginalSize;\n'
1240 CApp
= CApp
+ ' VOID *OriginalPcd;\n'
1241 CApp
= CApp
+ ' %s *Pcd;\n' % (Pcd
.DatumType
)
1243 Pcd
.DefaultValue
= Pcd
.DefaultValue
.strip()
1244 if Pcd
.DefaultValue
.startswith('L"') and Pcd
.DefaultValue
.endswith('"'):
1245 PcdDefaultValue
= "{" + ",".join(self
.__UNICODE
2OCTList
(Pcd
.DefaultValue
)) + "}"
1246 elif Pcd
.DefaultValue
.startswith('"') and Pcd
.DefaultValue
.endswith('"'):
1247 PcdDefaultValue
= "{" + ",".join(self
.__STRING
2OCTList
(Pcd
.DefaultValue
)) + "}"
1249 PcdDefaultValue
= Pcd
.DefaultValue
1250 InitByteValue
+= '%s.%s.%s.%s|%s|%s\n' % (SkuName
, DefaultStoreName
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, Pcd
.DatumType
, PcdDefaultValue
)
1253 # Get current PCD value and size
1255 CApp
= CApp
+ ' OriginalPcd = PcdGetPtr (%s, %s, %s, %s, &OriginalSize);\n' % (SkuName
, DefaultStoreName
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
1258 # Determine the size of the PCD. For simple structures, sizeof(TYPE) provides
1259 # the correct value. For structures with a flexible array member, the flexible
1260 # array member is detected, and the size is based on the highest index used with
1261 # the flexible array member. The flexible array member must be the last field
1262 # in a structure. The size formula for this case is:
1263 # OFFSET_OF(FlexbleArrayField) + sizeof(FlexibleArray[0]) * (HighestIndex + 1)
1265 CApp
= CApp
+ ' Size = sizeof(%s);\n' % (Pcd
.DatumType
)
1266 for FieldList
in [Pcd
.DefaultValues
, OverrideValues
.get(DefaultStoreName
)]:
1269 for FieldName
in FieldList
:
1270 FieldName
= "." + FieldName
1271 IsArray
= self
.IsFieldValueAnArray(FieldList
[FieldName
.strip(".")][0])
1273 Value
, ValueSize
= ParseFieldValue (FieldList
[FieldName
.strip(".")][0])
1274 CApp
= CApp
+ ' __FLEXIBLE_SIZE(Size, %s, %s, %d / __ARRAY_ELEMENT_SIZE(%s, %s));\n' % (Pcd
.DatumType
, FieldName
.strip("."), ValueSize
, Pcd
.DatumType
, FieldName
.strip("."));
1277 while '[' in FieldName
:
1278 NewFieldName
= NewFieldName
+ FieldName
.split('[', 1)[0] + '[0]'
1279 ArrayIndex
= int(FieldName
.split('[', 1)[1].split(']', 1)[0])
1280 FieldName
= FieldName
.split(']', 1)[1]
1281 FieldName
= NewFieldName
+ FieldName
1282 while '[' in FieldName
:
1283 FieldName
= FieldName
.rsplit('[', 1)[0]
1284 CApp
= CApp
+ ' __FLEXIBLE_SIZE(Size, %s, %s, %d);\n' % (Pcd
.DatumType
, FieldName
.strip("."), ArrayIndex
+ 1)
1287 # Allocate and zero buffer for the PCD
1288 # Must handle cases where current value is smaller, larger, or same size
1289 # Always keep that larger one as the current size
1291 CApp
= CApp
+ ' Size = (OriginalSize > Size ? OriginalSize : Size);\n'
1292 CApp
= CApp
+ ' Pcd = (%s *)malloc (Size);\n' % (Pcd
.DatumType
)
1293 CApp
= CApp
+ ' memset (Pcd, 0, Size);\n'
1296 # Copy current PCD value into allocated buffer.
1298 CApp
= CApp
+ ' memcpy (Pcd, OriginalPcd, OriginalSize);\n'
1301 # Assign field values in PCD
1303 for FieldList
in [Pcd
.DefaultValues
, Pcd
.DefaultFromDSC
,OverrideValues
.get(DefaultStoreName
)]:
1306 if Pcd
.DefaultFromDSC
and FieldList
== Pcd
.DefaultFromDSC
:
1307 IsArray
= self
.IsFieldValueAnArray(FieldList
)
1308 Value
, ValueSize
= ParseFieldValue (FieldList
)
1309 if isinstance(Value
, str):
1310 CApp
= CApp
+ ' Pcd = %s; // From DSC Default Value %s\n' % (Value
, Pcd
.DefaultFromDSC
)
1313 # Use memcpy() to copy value into field
1315 CApp
= CApp
+ ' Value = %s; // From DSC Default Value %s\n' % (self
.IntToCString(Value
, ValueSize
), Pcd
.DefaultFromDSC
)
1316 CApp
= CApp
+ ' memcpy (Pcd, Value, %d);\n' % (ValueSize
)
1319 for FieldName
in FieldList
:
1320 IsArray
= self
.IsFieldValueAnArray(FieldList
[FieldName
][0])
1322 Value
, ValueSize
= ParseFieldValue (FieldList
[FieldName
][0])
1324 print FieldList
[FieldName
][0]
1325 if isinstance(Value
, str):
1326 CApp
= CApp
+ ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1329 # Use memcpy() to copy value into field
1331 CApp
= CApp
+ ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd
.DatumType
, FieldName
)
1332 CApp
= CApp
+ ' Value = %s; // From %s Line %d Value %s\n' % (self
.IntToCString(Value
, ValueSize
), FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1333 CApp
= CApp
+ ' memcpy (&Pcd->%s[0], Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName
, ValueSize
, ValueSize
)
1336 CApp
= CApp
+ ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1338 CApp
= CApp
+ ' Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1341 # Set new PCD value and size
1343 CApp
= CApp
+ ' PcdSetPtr (%s, %s, %s, %s, Size, (UINT8 *)Pcd);\n' % (SkuName
, DefaultStoreName
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
1348 CApp
= CApp
+ ' free (Pcd);\n'
1351 return InitByteValue
, CApp
1353 def GenerateByteArrayValue (self
, StructuredPcds
):
1355 # Generate/Compile/Run C application to determine if there are any flexible array members
1357 if not StructuredPcds
:
1361 CApp
= PcdMainCHeader
1364 for PcdName
in StructuredPcds
:
1365 Pcd
= StructuredPcds
[PcdName
]
1366 IncludeFile
= Pcd
.StructuredPcdIncludeFile
1367 if IncludeFile
not in Includes
:
1368 Includes
[IncludeFile
] = True
1369 CApp
= CApp
+ '#include <%s>\n' % (IncludeFile
)
1372 for PcdName
in StructuredPcds
:
1373 Pcd
= StructuredPcds
[PcdName
]
1374 if not Pcd
.SkuOverrideValues
:
1375 InitByteValue
, CApp
= self
.GenerateInitializeFunc(self
.SkuIdMgr
.SystemSkuId
, 'STANDARD', Pcd
, InitByteValue
, CApp
)
1377 for SkuName
in Pcd
.SkuOverrideValues
:
1378 for DefaultStoreName
in Pcd
.DefaultStoreName
:
1379 Pcd
= StructuredPcds
[PcdName
]
1380 InitByteValue
, CApp
= self
.GenerateInitializeFunc(SkuName
, DefaultStoreName
, Pcd
, InitByteValue
, CApp
)
1382 CApp
= CApp
+ 'VOID\n'
1383 CApp
= CApp
+ 'PcdEntryPoint(\n'
1384 CApp
= CApp
+ ' VOID\n'
1385 CApp
= CApp
+ ' )\n'
1387 for Pcd
in StructuredPcds
.values():
1388 if not Pcd
.SkuOverrideValues
:
1389 CApp
= CApp
+ ' Initialize_%s_%s_%s_%s();\n' % (self
.SkuIdMgr
.SystemSkuId
, 'STANDARD', Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
1391 for SkuName
in Pcd
.SkuOverrideValues
:
1392 for DefaultStoreName
in Pcd
.SkuOverrideValues
[SkuName
]:
1393 CApp
= CApp
+ ' Initialize_%s_%s_%s_%s();\n' % (SkuName
, DefaultStoreName
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
1396 CApp
= CApp
+ PcdMainCEntry
+ '\n'
1398 if not os
.path
.exists(self
.OutputPath
):
1399 os
.makedirs(self
.OutputPath
)
1400 CAppBaseFileName
= os
.path
.join(self
.OutputPath
, PcdValueInitName
)
1401 File
= open (CAppBaseFileName
+ '.c', 'w')
1405 MakeApp
= PcdMakefileHeader
1406 if sys
.platform
== "win32":
1407 MakeApp
= MakeApp
+ 'ARCH = IA32\nAPPNAME = %s\n' % (PcdValueInitName
) + 'OBJECTS = %s\%s.obj\n' % (self
.OutputPath
, PcdValueInitName
) + 'INC = '
1409 MakeApp
= MakeApp
+ PcdGccMakefile
1410 MakeApp
= MakeApp
+ 'APPNAME = %s\n' % (PcdValueInitName
) + 'OBJECTS = %s/%s.o\n' % (self
.OutputPath
, PcdValueInitName
) + \
1411 'include $(MAKEROOT)/Makefiles/app.makefile\n' + 'BUILD_CFLAGS += -Wno-error\n' + 'INCLUDE +='
1414 for Cache
in self
._Bdb
._CACHE
_.values():
1415 if Cache
.MetaFile
.Ext
.lower() != '.dec':
1418 if str(Cache
.MetaFile
.Path
) not in PlatformInc
:
1419 PlatformInc
[str(Cache
.MetaFile
.Path
)] = Cache
.Includes
1422 for Pcd
in StructuredPcds
.values():
1423 for PackageDec
in Pcd
.PackageDecs
:
1424 Package
= os
.path
.normpath(mws
.join(GlobalData
.gWorkspace
, PackageDec
))
1425 if not os
.path
.exists(Package
):
1426 EdkLogger
.error('Build', RESOURCE_NOT_AVAILABLE
, "The dependent Package %s of PCD %s.%s is not exist." % (PackageDec
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
))
1427 if Package
not in PcdDependDEC
:
1428 PcdDependDEC
.append(Package
)
1430 if PlatformInc
and PcdDependDEC
:
1431 for pkg
in PcdDependDEC
:
1432 if pkg
in PlatformInc
:
1433 for inc
in PlatformInc
[pkg
]:
1434 MakeApp
+= '-I' + str(inc
) + ' '
1435 MakeApp
= MakeApp
+ '\n'
1436 if sys
.platform
== "win32":
1437 MakeApp
= MakeApp
+ PcdMakefileEnd
1438 MakeFileName
= os
.path
.join(self
.OutputPath
, 'Makefile')
1439 File
= open (MakeFileName
, 'w')
1443 InputValueFile
= os
.path
.join(self
.OutputPath
, 'Input.txt')
1444 OutputValueFile
= os
.path
.join(self
.OutputPath
, 'Output.txt')
1445 File
= open (InputValueFile
, 'w')
1446 File
.write(InitByteValue
)
1449 if sys
.platform
== "win32":
1450 StdOut
, StdErr
= self
.ExecuteCommand ('nmake clean & nmake -f %s' % (MakeFileName
))
1452 StdOut
, StdErr
= self
.ExecuteCommand ('make clean & make -f %s' % (MakeFileName
))
1453 Messages
= StdOut
.split('\r')
1454 for Message
in Messages
:
1455 if " error " in Message
:
1456 FileInfo
= Message
.strip().split('(')
1457 if len (FileInfo
) > 0:
1458 FileName
= FileInfo
[0]
1459 FileLine
= FileInfo
[1].split (')')[0]
1461 FileInfo
= Message
.strip().split(':')
1462 FileName
= FileInfo
[0]
1463 FileLine
= FileInfo
[1]
1465 File
= open (FileName
, 'r')
1466 FileData
= File
.readlines()
1468 error_line
= FileData
[int (FileLine
) - 1]
1469 if r
"//" in error_line
:
1470 c_line
,dsc_line
= error_line
.split(r
"//")
1472 dsc_line
= error_line
1474 message_itmes
= Message
.split(":")
1475 for item
in message_itmes
:
1476 if "PcdValueInit.c" in item
:
1477 message_itmes
[message_itmes
.index(item
)] = dsc_line
.strip()
1479 EdkLogger
.error("build", PCD_STRUCTURE_PCD_ERROR
, ":".join(message_itmes
[1:]))
1481 PcdValueInitExe
= PcdValueInitName
1482 if not sys
.platform
== "win32":
1483 PcdValueInitExe
= os
.path
.join(os
.getenv("EDK_TOOLS_PATH"), 'Source', 'C', 'bin', PcdValueInitName
)
1485 StdOut
, StdErr
= self
.ExecuteCommand (PcdValueInitExe
+ ' -i %s -o %s' % (InputValueFile
, OutputValueFile
))
1486 File
= open (OutputValueFile
, 'r')
1487 FileBuffer
= File
.readlines()
1490 StructurePcdSet
= []
1491 for Pcd
in FileBuffer
:
1492 PcdValue
= Pcd
.split ('|')
1493 PcdInfo
= PcdValue
[0].split ('.')
1494 StructurePcdSet
.append((PcdInfo
[0],PcdInfo
[1], PcdInfo
[2], PcdInfo
[3], PcdValue
[2].strip()))
1495 return StructurePcdSet
1497 ## Retrieve dynamic PCD settings
1499 # @param Type PCD type
1501 # @retval a dict object contains settings of given PCD type
1503 def _GetDynamicPcd(self
, Type
):
1508 # tdict is a special dict kind of type, used for selecting correct
1509 # PCD settings for certain ARCH and SKU
1511 PcdDict
= tdict(True, 4)
1513 # Find out all possible PCD candidates for self._Arch
1514 RecordList
= self
._RawData
[Type
, self
._Arch
]
1515 AvailableSkuIdSet
= copy
.copy(self
.SkuIds
)
1518 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, SkuName
, Dummy3
, Dummy4
,Dummy5
in RecordList
:
1519 if SkuName
not in AvailableSkuIdSet
:
1521 if "." not in TokenSpaceGuid
:
1522 PcdList
.append((PcdCName
, TokenSpaceGuid
, SkuName
, Dummy4
))
1523 PcdDict
[Arch
, SkuName
, PcdCName
, TokenSpaceGuid
] = Setting
1525 # Remove redundant PCD candidates, per the ARCH and SKU
1526 for PcdCName
, TokenSpaceGuid
, SkuName
, Dummy4
in PcdList
:
1528 Setting
= PcdDict
[self
._Arch
, SkuName
, PcdCName
, TokenSpaceGuid
]
1532 PcdValue
, DatumType
, MaxDatumSize
= self
._ValidatePcd
(PcdCName
, TokenSpaceGuid
, Setting
, Type
, Dummy4
)
1533 SkuInfo
= SkuInfoClass(SkuName
, self
.SkuIds
[SkuName
][0], '', '', '', '', '', PcdValue
)
1534 if (PcdCName
, TokenSpaceGuid
) in Pcds
.keys():
1535 pcdObject
= Pcds
[PcdCName
, TokenSpaceGuid
]
1536 pcdObject
.SkuInfoList
[SkuName
] = SkuInfo
1537 if MaxDatumSize
.strip():
1538 CurrentMaxSize
= int(MaxDatumSize
.strip(), 0)
1541 if pcdObject
.MaxDatumSize
:
1542 PcdMaxSize
= int(pcdObject
.MaxDatumSize
, 0)
1545 if CurrentMaxSize
> PcdMaxSize
:
1546 pcdObject
.MaxDatumSize
= str(CurrentMaxSize
)
1548 Pcds
[PcdCName
, TokenSpaceGuid
] = PcdClassObject(
1551 self
._PCD
_TYPE
_STRING
_[Type
],
1556 {SkuName
: SkuInfo
},
1561 for pcd
in Pcds
.values():
1562 pcdDecObject
= self
._DecPcds
[pcd
.TokenCName
, pcd
.TokenSpaceGuidCName
]
1563 if 'DEFAULT' not in pcd
.SkuInfoList
.keys() and 'COMMON' not in pcd
.SkuInfoList
.keys():
1564 valuefromDec
= pcdDecObject
.DefaultValue
1565 SkuInfo
= SkuInfoClass('DEFAULT', '0', '', '', '', '', '', valuefromDec
)
1566 pcd
.SkuInfoList
['DEFAULT'] = SkuInfo
1567 elif 'DEFAULT' not in pcd
.SkuInfoList
.keys() and 'COMMON' in pcd
.SkuInfoList
.keys():
1568 pcd
.SkuInfoList
['DEFAULT'] = pcd
.SkuInfoList
['COMMON']
1569 del(pcd
.SkuInfoList
['COMMON'])
1570 elif 'DEFAULT' in pcd
.SkuInfoList
.keys() and 'COMMON' in pcd
.SkuInfoList
.keys():
1571 del(pcd
.SkuInfoList
['COMMON'])
1572 if self
.SkuIdMgr
.SkuUsageType
== self
.SkuIdMgr
.SINGLE
:
1573 if 'DEFAULT' in pcd
.SkuInfoList
.keys() and self
.SkuIdMgr
.SystemSkuId
not in pcd
.SkuInfoList
.keys():
1574 pcd
.SkuInfoList
[self
.SkuIdMgr
.SystemSkuId
] = pcd
.SkuInfoList
['DEFAULT']
1575 del(pcd
.SkuInfoList
['DEFAULT'])
1579 def CompareVarAttr(self
, Attr1
, Attr2
):
1580 if not Attr1
or not Attr2
: # for empty string
1582 Attr1s
= [attr
.strip() for attr
in Attr1
.split(",")]
1583 Attr1Set
= set(Attr1s
)
1584 Attr2s
= [attr
.strip() for attr
in Attr2
.split(",")]
1585 Attr2Set
= set(Attr2s
)
1586 if Attr2Set
== Attr1Set
:
1590 def CompletePcdValues(self
,PcdSet
):
1592 DefaultStoreObj
= DefaultStore(self
._GetDefaultStores
())
1593 SkuIds
= set([skuid
for pcdobj
in PcdSet
.values() for skuid
in pcdobj
.SkuInfoList
.keys()])
1594 DefaultStores
= set([storename
for pcdobj
in PcdSet
.values() for skuobj
in pcdobj
.SkuInfoList
.values() for storename
in skuobj
.DefaultStoreDict
.keys()])
1595 for PcdCName
, TokenSpaceGuid
in PcdSet
:
1596 PcdObj
= PcdSet
[(PcdCName
, TokenSpaceGuid
)]
1597 if PcdObj
.Type
not in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_DEFAULT
],
1598 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
],
1599 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_VPD
],
1600 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_DEFAULT
],
1601 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
],
1602 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_VPD
]]:
1603 Pcds
[PcdCName
, TokenSpaceGuid
]= PcdObj
1605 PcdType
= PcdObj
.Type
1606 if PcdType
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
1607 for skuid
in PcdObj
.SkuInfoList
:
1608 skuobj
= PcdObj
.SkuInfoList
[skuid
]
1609 mindefaultstorename
= DefaultStoreObj
.GetMin(set([defaultstorename
for defaultstorename
in skuobj
.DefaultStoreDict
]))
1610 for defaultstorename
in DefaultStores
:
1611 if defaultstorename
not in skuobj
.DefaultStoreDict
:
1612 skuobj
.DefaultStoreDict
[defaultstorename
] = skuobj
.DefaultStoreDict
[mindefaultstorename
]
1613 skuobj
.HiiDefaultValue
= skuobj
.DefaultStoreDict
[mindefaultstorename
]
1614 for skuid
in SkuIds
:
1615 if skuid
not in PcdObj
.SkuInfoList
:
1616 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(skuid
)
1617 while nextskuid
not in PcdObj
.SkuInfoList
:
1618 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(nextskuid
)
1619 PcdObj
.SkuInfoList
[skuid
] = PcdObj
.SkuInfoList
[nextskuid
]
1620 if PcdType
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
1621 PcdObj
.DefaultValue
= PcdObj
.SkuInfoList
.values()[0].HiiDefaultValue
if self
.SkuIdMgr
.SkuUsageType
== self
.SkuIdMgr
.SINGLE
else PcdObj
.SkuInfoList
["DEFAULT"].HiiDefaultValue
1622 Pcds
[PcdCName
, TokenSpaceGuid
]= PcdObj
1624 ## Retrieve dynamic HII PCD settings
1626 # @param Type PCD type
1628 # @retval a dict object contains settings of given PCD type
1630 def _GetDynamicHiiPcd(self
, Type
):
1636 # tdict is a special dict kind of type, used for selecting correct
1637 # PCD settings for certain ARCH and SKU
1639 PcdDict
= tdict(True, 5)
1641 RecordList
= self
._RawData
[Type
, self
._Arch
]
1642 # Find out all possible PCD candidates for self._Arch
1643 AvailableSkuIdSet
= copy
.copy(self
.SkuIds
)
1645 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, SkuName
, DefaultStore
, Dummy4
,Dummy5
in RecordList
:
1646 if DefaultStore
== "COMMON":
1647 DefaultStore
= "STANDARD"
1648 if SkuName
not in AvailableSkuIdSet
:
1650 if "." not in TokenSpaceGuid
:
1651 PcdSet
.add((PcdCName
, TokenSpaceGuid
, SkuName
,DefaultStore
, Dummy4
))
1652 PcdDict
[Arch
, SkuName
, PcdCName
, TokenSpaceGuid
,DefaultStore
] = Setting
1655 # Remove redundant PCD candidates, per the ARCH and SKU
1656 for PcdCName
, TokenSpaceGuid
, SkuName
,DefaultStore
, Dummy4
in PcdSet
:
1658 Setting
= PcdDict
[self
._Arch
, SkuName
, PcdCName
, TokenSpaceGuid
,DefaultStore
]
1661 VariableName
, VariableGuid
, VariableOffset
, DefaultValue
, VarAttribute
= self
._ValidatePcd
(PcdCName
, TokenSpaceGuid
, Setting
, Type
, Dummy4
)
1663 rt
, Msg
= VariableAttributes
.ValidateVarAttributes(VarAttribute
)
1665 EdkLogger
.error("build", PCD_VARIABLE_ATTRIBUTES_ERROR
, "Variable attributes settings for %s is incorrect.\n %s" % (".".join((TokenSpaceGuid
, PcdCName
)), Msg
),
1666 ExtraData
="[%s]" % VarAttribute
)
1668 FormatCorrect
= True
1669 if VariableOffset
.isdigit():
1670 if int(VariableOffset
, 10) > 0xFFFF:
1672 elif re
.match(r
'[\t\s]*0[xX][a-fA-F0-9]+$', VariableOffset
):
1673 if int(VariableOffset
, 16) > 0xFFFF:
1675 # For Offset written in "A.B"
1676 elif VariableOffset
.find('.') > -1:
1677 VariableOffsetList
= VariableOffset
.split(".")
1678 if not (len(VariableOffsetList
) == 2
1679 and IsValidWord(VariableOffsetList
[0])
1680 and IsValidWord(VariableOffsetList
[1])):
1681 FormatCorrect
= False
1683 FormatCorrect
= False
1684 if not FormatCorrect
:
1685 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid syntax or format of the variable offset value is incorrect for %s." % ".".join((TokenSpaceGuid
, PcdCName
)))
1688 EdkLogger
.error('Build', OPTION_VALUE_INVALID
, "The variable offset value must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join((TokenSpaceGuid
, PcdCName
)))
1689 if (VariableName
, VariableGuid
) not in VariableAttrs
:
1690 VariableAttrs
[(VariableName
, VariableGuid
)] = VarAttribute
1692 if not self
.CompareVarAttr(VariableAttrs
[(VariableName
, VariableGuid
)], VarAttribute
):
1693 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
)]))
1695 pcdDecObject
= self
._DecPcds
[PcdCName
, TokenSpaceGuid
]
1696 if (PcdCName
, TokenSpaceGuid
) in Pcds
.keys():
1697 pcdObject
= Pcds
[PcdCName
, TokenSpaceGuid
]
1698 if SkuName
in pcdObject
.SkuInfoList
:
1699 Skuitem
= pcdObject
.SkuInfoList
[SkuName
]
1700 Skuitem
.DefaultStoreDict
.update({DefaultStore
:DefaultValue
})
1702 SkuInfo
= SkuInfoClass(SkuName
, self
.SkuIds
[SkuName
][0], VariableName
, VariableGuid
, VariableOffset
, DefaultValue
, VariableAttribute
=VarAttribute
,DefaultStore
={DefaultStore
:DefaultValue
})
1703 pcdObject
.SkuInfoList
[SkuName
] = SkuInfo
1705 SkuInfo
= SkuInfoClass(SkuName
, self
.SkuIds
[SkuName
][0], VariableName
, VariableGuid
, VariableOffset
, DefaultValue
, VariableAttribute
=VarAttribute
,DefaultStore
={DefaultStore
:DefaultValue
})
1706 Pcds
[PcdCName
, TokenSpaceGuid
] = PcdClassObject(
1709 self
._PCD
_TYPE
_STRING
_[Type
],
1714 {SkuName
: SkuInfo
},
1717 pcdDecObject
.validateranges
,
1718 pcdDecObject
.validlists
,
1719 pcdDecObject
.expressions
,
1723 for pcd
in Pcds
.values():
1724 SkuInfoObj
= pcd
.SkuInfoList
.values()[0]
1725 pcdDecObject
= self
._DecPcds
[pcd
.TokenCName
, pcd
.TokenSpaceGuidCName
]
1726 # Only fix the value while no value provided in DSC file.
1727 for sku
in pcd
.SkuInfoList
.values():
1728 if (sku
.HiiDefaultValue
== "" or sku
.HiiDefaultValue
== None):
1729 sku
.HiiDefaultValue
= pcdDecObject
.DefaultValue
1730 if 'DEFAULT' not in pcd
.SkuInfoList
.keys() and 'COMMON' not in pcd
.SkuInfoList
.keys():
1731 valuefromDec
= pcdDecObject
.DefaultValue
1732 SkuInfo
= SkuInfoClass('DEFAULT', '0', SkuInfoObj
.VariableName
, SkuInfoObj
.VariableGuid
, SkuInfoObj
.VariableOffset
, valuefromDec
)
1733 pcd
.SkuInfoList
['DEFAULT'] = SkuInfo
1734 elif 'DEFAULT' not in pcd
.SkuInfoList
.keys() and 'COMMON' in pcd
.SkuInfoList
.keys():
1735 pcd
.SkuInfoList
['DEFAULT'] = pcd
.SkuInfoList
['COMMON']
1736 del(pcd
.SkuInfoList
['COMMON'])
1737 elif 'DEFAULT' in pcd
.SkuInfoList
.keys() and 'COMMON' in pcd
.SkuInfoList
.keys():
1738 del(pcd
.SkuInfoList
['COMMON'])
1740 if self
.SkuIdMgr
.SkuUsageType
== self
.SkuIdMgr
.SINGLE
:
1741 if 'DEFAULT' in pcd
.SkuInfoList
.keys() and self
.SkuIdMgr
.SystemSkuId
not in pcd
.SkuInfoList
.keys():
1742 pcd
.SkuInfoList
[self
.SkuIdMgr
.SystemSkuId
] = pcd
.SkuInfoList
['DEFAULT']
1743 del(pcd
.SkuInfoList
['DEFAULT'])
1745 if pcd
.MaxDatumSize
.strip():
1746 MaxSize
= int(pcd
.MaxDatumSize
, 0)
1749 if pcdDecObject
.DatumType
== 'VOID*':
1750 for (skuname
, skuobj
) in pcd
.SkuInfoList
.items():
1752 if skuobj
.HiiDefaultValue
.startswith("L"):
1753 datalen
= (len(skuobj
.HiiDefaultValue
) - 3 + 1) * 2
1754 elif skuobj
.HiiDefaultValue
.startswith("{"):
1755 datalen
= len(skuobj
.HiiDefaultValue
.split(","))
1757 datalen
= len(skuobj
.HiiDefaultValue
) - 2 + 1
1758 if datalen
> MaxSize
:
1760 pcd
.MaxDatumSize
= str(MaxSize
)
1764 ## Retrieve dynamic VPD PCD settings
1766 # @param Type PCD type
1768 # @retval a dict object contains settings of given PCD type
1770 def _GetDynamicVpdPcd(self
, Type
):
1775 # tdict is a special dict kind of type, used for selecting correct
1776 # PCD settings for certain ARCH and SKU
1778 PcdDict
= tdict(True, 4)
1781 # Find out all possible PCD candidates for self._Arch
1782 RecordList
= self
._RawData
[Type
, self
._Arch
]
1783 AvailableSkuIdSet
= copy
.copy(self
.SkuIds
)
1785 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, SkuName
, Dummy3
, Dummy4
,Dummy5
in RecordList
:
1786 if SkuName
not in AvailableSkuIdSet
:
1788 if "." not in TokenSpaceGuid
:
1789 PcdList
.append((PcdCName
, TokenSpaceGuid
, SkuName
, Dummy4
))
1790 PcdDict
[Arch
, SkuName
, PcdCName
, TokenSpaceGuid
] = Setting
1792 # Remove redundant PCD candidates, per the ARCH and SKU
1793 for PcdCName
, TokenSpaceGuid
, SkuName
, Dummy4
in PcdList
:
1794 Setting
= PcdDict
[self
._Arch
, SkuName
, PcdCName
, TokenSpaceGuid
]
1798 # For the VOID* type, it can have optional data of MaxDatumSize and InitialValue
1799 # For the Integer & Boolean type, the optional data can only be InitialValue.
1800 # At this point, we put all the data into the PcdClssObject for we don't know the PCD's datumtype
1801 # until the DEC parser has been called.
1803 VpdOffset
, MaxDatumSize
, InitialValue
= self
._ValidatePcd
(PcdCName
, TokenSpaceGuid
, Setting
, Type
, Dummy4
)
1804 SkuInfo
= SkuInfoClass(SkuName
, self
.SkuIds
[SkuName
][0], '', '', '', '', VpdOffset
, InitialValue
)
1805 if (PcdCName
, TokenSpaceGuid
) in Pcds
.keys():
1806 pcdObject
= Pcds
[PcdCName
, TokenSpaceGuid
]
1807 pcdObject
.SkuInfoList
[SkuName
] = SkuInfo
1808 if MaxDatumSize
.strip():
1809 CurrentMaxSize
= int(MaxDatumSize
.strip(), 0)
1812 if pcdObject
.MaxDatumSize
:
1813 PcdMaxSize
= int(pcdObject
.MaxDatumSize
, 0)
1816 if CurrentMaxSize
> PcdMaxSize
:
1817 pcdObject
.MaxDatumSize
= str(CurrentMaxSize
)
1819 Pcds
[PcdCName
, TokenSpaceGuid
] = PcdClassObject(
1822 self
._PCD
_TYPE
_STRING
_[Type
],
1827 {SkuName
: SkuInfo
},
1831 for pcd
in Pcds
.values():
1832 SkuInfoObj
= pcd
.SkuInfoList
.values()[0]
1833 pcdDecObject
= self
._DecPcds
[pcd
.TokenCName
, pcd
.TokenSpaceGuidCName
]
1834 if 'DEFAULT' not in pcd
.SkuInfoList
.keys() and 'COMMON' not in pcd
.SkuInfoList
.keys():
1835 valuefromDec
= pcdDecObject
.DefaultValue
1836 SkuInfo
= SkuInfoClass('DEFAULT', '0', '', '', '', '', SkuInfoObj
.VpdOffset
, valuefromDec
)
1837 pcd
.SkuInfoList
['DEFAULT'] = SkuInfo
1838 elif 'DEFAULT' not in pcd
.SkuInfoList
.keys() and 'COMMON' in pcd
.SkuInfoList
.keys():
1839 pcd
.SkuInfoList
['DEFAULT'] = pcd
.SkuInfoList
['COMMON']
1840 del(pcd
.SkuInfoList
['COMMON'])
1841 elif 'DEFAULT' in pcd
.SkuInfoList
.keys() and 'COMMON' in pcd
.SkuInfoList
.keys():
1842 del(pcd
.SkuInfoList
['COMMON'])
1843 if self
.SkuIdMgr
.SkuUsageType
== self
.SkuIdMgr
.SINGLE
:
1844 if 'DEFAULT' in pcd
.SkuInfoList
.keys() and self
.SkuIdMgr
.SystemSkuId
not in pcd
.SkuInfoList
.keys():
1845 pcd
.SkuInfoList
[self
.SkuIdMgr
.SystemSkuId
] = pcd
.SkuInfoList
['DEFAULT']
1846 del(pcd
.SkuInfoList
['DEFAULT'])
1850 ## Add external modules
1852 # The external modules are mostly those listed in FDF file, which don't
1855 # @param FilePath The path of module description file
1857 def AddModule(self
, FilePath
):
1858 FilePath
= NormPath(FilePath
)
1859 if FilePath
not in self
.Modules
:
1860 Module
= ModuleBuildClassObject()
1861 Module
.MetaFile
= FilePath
1862 self
.Modules
.append(Module
)
1864 ## Add external PCDs
1866 # The external PCDs are mostly those listed in FDF file to specify address
1867 # or offset information.
1869 # @param Name Name of the PCD
1870 # @param Guid Token space guid of the PCD
1871 # @param Value Value of the PCD
1873 def AddPcd(self
, Name
, Guid
, Value
):
1874 if (Name
, Guid
) not in self
.Pcds
:
1875 self
.Pcds
[Name
, Guid
] = PcdClassObject(Name
, Guid
, '', '', '', '', '', {}, False, None)
1876 self
.Pcds
[Name
, Guid
].DefaultValue
= Value
1878 _Macros
= property(_GetMacros
)
1879 Arch
= property(_GetArch
, _SetArch
)
1880 Platform
= property(_GetPlatformName
)
1881 PlatformName
= property(_GetPlatformName
)
1882 Guid
= property(_GetFileGuid
)
1883 Version
= property(_GetVersion
)
1884 DscSpecification
= property(_GetDscSpec
)
1885 OutputDirectory
= property(_GetOutpuDir
)
1886 SupArchList
= property(_GetSupArch
)
1887 BuildTargets
= property(_GetBuildTarget
)
1888 SkuName
= property(_GetSkuName
, _SetSkuName
)
1889 SkuIdentifier
= property(_GetSkuIdentifier
)
1890 AvilableSkuIds
= property(_GetAviableSkuIds
)
1891 PcdInfoFlag
= property(_GetPcdInfoFlag
)
1892 VarCheckFlag
= property(_GetVarCheckFlag
)
1893 FlashDefinition
= property(_GetFdfFile
)
1894 Prebuild
= property(_GetPrebuild
)
1895 Postbuild
= property(_GetPostbuild
)
1896 BuildNumber
= property(_GetBuildNumber
)
1897 MakefileName
= property(_GetMakefileName
)
1898 BsBaseAddress
= property(_GetBsBaseAddress
)
1899 RtBaseAddress
= property(_GetRtBaseAddress
)
1900 LoadFixAddress
= property(_GetLoadFixAddress
)
1901 RFCLanguages
= property(_GetRFCLanguages
)
1902 ISOLanguages
= property(_GetISOLanguages
)
1903 VpdToolGuid
= property(_GetVpdToolGuid
)
1904 SkuIds
= property(_GetSkuIds
)
1905 Modules
= property(_GetModules
)
1906 LibraryInstances
= property(_GetLibraryInstances
)
1907 LibraryClasses
= property(_GetLibraryClasses
)
1908 Pcds
= property(_GetPcds
)
1909 BuildOptions
= property(_GetBuildOptions
)