2 # This file is used to create a database used by build tool
4 # Copyright (c) 2008 - 2018, 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 __future__
import print_function
21 from __future__
import absolute_import
22 from Common
.StringUtils
import *
23 from Common
.DataType
import *
24 from Common
.Misc
import *
26 from Common
.Expression
import *
27 from CommonDataClass
.CommonClass
import SkuInfoClass
28 from Common
.TargetTxtClassObject
import *
29 from Common
.ToolDefClassObject
import *
30 from .MetaDataTable
import *
31 from .MetaFileTable
import *
32 from .MetaFileParser
import *
34 from .WorkspaceCommon
import GetDeclaredPcd
35 from Common
.Misc
import AnalyzeDscPcd
36 from Common
.Misc
import ProcessDuplicatedInf
38 from Common
.Parsing
import IsValidWord
39 from Common
.VariableAttributes
import VariableAttributes
40 import Common
.GlobalData
as GlobalData
42 from Common
.Misc
import SaveFileOnChange
43 from Workspace
.BuildClassObject
import PlatformBuildClassObject
, StructurePcd
, PcdClassObject
, ModuleBuildClassObject
44 from collections
import OrderedDict
, defaultdict
46 PcdValueInitName
= 'PcdValueInit'
57 #include <PcdValueCommon.h>
67 return PcdValueMain (argc, argv);
71 PcdMakefileHeader
= '''
74 # This file is auto-generated by build utility
79 WindowsCFLAGS
= 'CFLAGS = $(CFLAGS) /wd4200 /wd4034 /wd4101 '
80 LinuxCFLAGS
= 'BUILD_CFLAGS += -Wno-pointer-to-int-cast -Wno-unused-variable '
82 !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.common
84 LIBS = $(LIB_PATH)\Common.lib
86 !INCLUDE $(BASE_TOOLS_PATH)\Source\C\Makefiles\ms.app
90 MAKEROOT ?= $(EDK_TOOLS_PATH)/Source/C
94 variablePattern
= re
.compile(r
'[\t\s]*0[xX][a-fA-F0-9]+$')
95 SkuIdPattern
= re
.compile(r
'^[a-zA-Z_][a-zA-Z0-9_]*$')
96 ## regular expressions for finding decimal and hex numbers
97 Pattern
= re
.compile('^[1-9]\d*|0$')
98 HexPattern
= re
.compile(r
'0[xX][0-9a-fA-F]+$')
99 ## Regular expression for finding header file inclusions
100 from AutoGen
.GenMake
import gIncludePattern
102 ## Find dependencies for one source file
104 # By searching recursively "#include" directive in file, find out all the
105 # files needed by given source file. The dependecies will be only searched
106 # in given search path list.
108 # @param SearchPathList The list of search path
110 # @retval list The list of files the given source file depends on
112 def GetDependencyList(FileStack
, SearchPathList
):
114 DependencySet
= set(FileStack
)
115 while len(FileStack
) > 0:
117 FullPathDependList
= []
118 CurrentFileDependencyList
= []
120 CurrentFileDependencyList
= DepDb
[F
]
124 FileContent
= Fd
.read()
125 except BaseException
as X
:
126 EdkLogger
.error("build", FILE_OPEN_FAILURE
, ExtraData
=F
+ "\n\t" + str(X
))
128 if "Fd" in dir(locals()):
131 if len(FileContent
) == 0:
134 if FileContent
[0] == 0xff or FileContent
[0] == 0xfe:
135 FileContent
= unicode(FileContent
, "utf-16")
136 IncludedFileList
= gIncludePattern
.findall(FileContent
)
138 for Inc
in IncludedFileList
:
140 Inc
= os
.path
.normpath(Inc
)
141 CurrentFileDependencyList
.append(Inc
)
142 DepDb
[F
] = CurrentFileDependencyList
144 CurrentFilePath
= os
.path
.dirname(F
)
145 PathList
= [CurrentFilePath
] + SearchPathList
146 for Inc
in CurrentFileDependencyList
:
147 for SearchPath
in PathList
:
148 FilePath
= os
.path
.join(SearchPath
, Inc
)
149 if not os
.path
.exists(FilePath
):
151 if FilePath
not in DependencySet
:
152 FileStack
.append(FilePath
)
153 FullPathDependList
.append(FilePath
)
155 DependencySet
.update(FullPathDependList
)
156 DependencyList
= list(DependencySet
) # remove duplicate ones
158 return DependencyList
160 class DscBuildData(PlatformBuildClassObject
):
161 # dict used to convert PCD type in database to string used by build tool
162 _PCD_TYPE_STRING_
= {
163 MODEL_PCD_FIXED_AT_BUILD
: TAB_PCDS_FIXED_AT_BUILD
,
164 MODEL_PCD_PATCHABLE_IN_MODULE
: TAB_PCDS_PATCHABLE_IN_MODULE
,
165 MODEL_PCD_FEATURE_FLAG
: TAB_PCDS_FEATURE_FLAG
,
166 MODEL_PCD_DYNAMIC
: TAB_PCDS_DYNAMIC
,
167 MODEL_PCD_DYNAMIC_DEFAULT
: TAB_PCDS_DYNAMIC
,
168 MODEL_PCD_DYNAMIC_HII
: TAB_PCDS_DYNAMIC_HII
,
169 MODEL_PCD_DYNAMIC_VPD
: TAB_PCDS_DYNAMIC_VPD
,
170 MODEL_PCD_DYNAMIC_EX
: TAB_PCDS_DYNAMIC_EX
,
171 MODEL_PCD_DYNAMIC_EX_DEFAULT
: TAB_PCDS_DYNAMIC_EX
,
172 MODEL_PCD_DYNAMIC_EX_HII
: TAB_PCDS_DYNAMIC_EX_HII
,
173 MODEL_PCD_DYNAMIC_EX_VPD
: TAB_PCDS_DYNAMIC_EX_VPD
,
176 # dict used to convert part of [Defines] to members of DscBuildData directly
181 TAB_DSC_DEFINES_PLATFORM_NAME
: "_PlatformName",
182 TAB_DSC_DEFINES_PLATFORM_GUID
: "_Guid",
183 TAB_DSC_DEFINES_PLATFORM_VERSION
: "_Version",
184 TAB_DSC_DEFINES_DSC_SPECIFICATION
: "_DscSpecification",
185 # TAB_DSC_DEFINES_OUTPUT_DIRECTORY : "_OutputDirectory",
186 # TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES : "_SupArchList",
187 # TAB_DSC_DEFINES_BUILD_TARGETS : "_BuildTargets",
188 TAB_DSC_DEFINES_SKUID_IDENTIFIER
: "_SkuName",
189 # TAB_DSC_DEFINES_FLASH_DEFINITION : "_FlashDefinition",
190 TAB_DSC_DEFINES_BUILD_NUMBER
: "_BuildNumber",
191 TAB_DSC_DEFINES_MAKEFILE_NAME
: "_MakefileName",
192 TAB_DSC_DEFINES_BS_BASE_ADDRESS
: "_BsBaseAddress",
193 TAB_DSC_DEFINES_RT_BASE_ADDRESS
: "_RtBaseAddress",
194 # TAB_DSC_DEFINES_RFC_LANGUAGES : "_RFCLanguages",
195 # TAB_DSC_DEFINES_ISO_LANGUAGES : "_ISOLanguages",
198 # used to compose dummy library class name for those forced library instances
199 _NullLibraryNumber
= 0
201 ## Constructor of DscBuildData
203 # Initialize object of DscBuildData
205 # @param FilePath The path of platform description file
206 # @param RawData The raw data of DSC file
207 # @param BuildDataBase Database used to retrieve module/package information
208 # @param Arch The target architecture
209 # @param Platform (not used for DscBuildData)
210 # @param Macros Macros used for replacement in DSC file
212 def __init__(self
, FilePath
, RawData
, BuildDataBase
, Arch
=TAB_ARCH_COMMON
, Target
=None, Toolchain
=None):
213 self
.MetaFile
= FilePath
214 self
._RawData
= RawData
215 self
._Bdb
= BuildDataBase
217 self
._Target
= Target
218 self
._Toolchain
= Toolchain
219 self
._ToolChainFamily
= None
221 self
._HandleOverridePath
()
222 self
.WorkspaceDir
= os
.getenv("WORKSPACE") if os
.getenv("WORKSPACE") else ""
223 self
.DefaultStores
= None
224 self
.SkuIdMgr
= SkuClass(self
.SkuName
, self
.SkuIds
)
226 def OutputPath(self
):
227 if os
.getenv("WORKSPACE"):
228 return os
.path
.join(os
.getenv("WORKSPACE"), self
.OutputDirectory
, self
._Target
+ "_" + self
._Toolchain
, PcdValueInitName
)
230 return os
.path
.dirname(self
.DscFile
)
233 def __setitem__(self
, key
, value
):
234 self
.__dict
__[self
._PROPERTY
_[key
]] = value
237 def __getitem__(self
, key
):
238 return self
.__dict
__[self
._PROPERTY
_[key
]]
241 def __contains__(self
, key
):
242 return key
in self
._PROPERTY
_
244 ## Set all internal used members of DscBuildData to None
247 self
._PlatformName
= None
250 self
._DscSpecification
= None
251 self
._OutputDirectory
= None
252 self
._SupArchList
= None
253 self
._BuildTargets
= None
255 self
._PcdInfoFlag
= None
256 self
._VarCheckFlag
= None
257 self
._FlashDefinition
= None
258 self
._Prebuild
= None
259 self
._Postbuild
= None
260 self
._BuildNumber
= None
261 self
._MakefileName
= None
262 self
._BsBaseAddress
= None
263 self
._RtBaseAddress
= None
266 self
._LibraryInstances
= None
267 self
._LibraryClasses
= None
270 self
._BuildOptions
= None
271 self
._ModuleTypeOptions
= None
272 self
._LoadFixAddress
= None
273 self
._RFCLanguages
= None
274 self
._ISOLanguages
= None
275 self
._VpdToolGuid
= None
277 self
.DefaultStores
= None
280 ## handle Override Path of Module
281 def _HandleOverridePath(self
):
282 RecordList
= self
._RawData
[MODEL_META_DATA_COMPONENT
, self
._Arch
]
283 for Record
in RecordList
:
286 ModuleFile
= PathClass(NormPath(Record
[0]), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
287 RecordList
= self
._RawData
[MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH
, self
._Arch
, None, ModuleId
]
289 SourceOverridePath
= mws
.join(GlobalData
.gWorkspace
, NormPath(RecordList
[0][0]))
291 # Check if the source override path exists
292 if not os
.path
.isdir(SourceOverridePath
):
293 EdkLogger
.error('build', FILE_NOT_FOUND
, Message
='Source override path does not exist:', File
=self
.MetaFile
, ExtraData
=SourceOverridePath
, Line
=LineNo
)
295 # Add to GlobalData Variables
296 GlobalData
.gOverrideDir
[ModuleFile
.Key
] = SourceOverridePath
298 ## Get current effective macros
299 def _GetMacros(self
):
300 if self
.__Macros
is None:
302 self
.__Macros
.update(GlobalData
.gPlatformDefines
)
303 self
.__Macros
.update(GlobalData
.gGlobalDefines
)
304 self
.__Macros
.update(GlobalData
.gCommandLineDefines
)
311 ## Retrieve all information in [Defines] section
313 # (Retriving all [Defines] information in one-shot is just to save time.)
315 def _GetHeaderInfo(self
):
316 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER
, self
._Arch
]
317 for Record
in RecordList
:
319 # items defined _PROPERTY_ don't need additional processing
321 # some special items in [Defines] section need special treatment
322 if Name
== TAB_DSC_DEFINES_OUTPUT_DIRECTORY
:
323 self
._OutputDirectory
= NormPath(Record
[2], self
._Macros
)
324 if ' ' in self
._OutputDirectory
:
325 EdkLogger
.error("build", FORMAT_NOT_SUPPORTED
, "No space is allowed in OUTPUT_DIRECTORY",
326 File
=self
.MetaFile
, Line
=Record
[-1],
327 ExtraData
=self
._OutputDirectory
)
328 elif Name
== TAB_DSC_DEFINES_FLASH_DEFINITION
:
329 self
._FlashDefinition
= PathClass(NormPath(Record
[2], self
._Macros
), GlobalData
.gWorkspace
)
330 ErrorCode
, ErrorInfo
= self
._FlashDefinition
.Validate('.fdf')
332 EdkLogger
.error('build', ErrorCode
, File
=self
.MetaFile
, Line
=Record
[-1],
334 elif Name
== TAB_DSC_PREBUILD
:
335 PrebuildValue
= Record
[2]
336 if Record
[2][0] == '"':
337 if Record
[2][-1] != '"':
338 EdkLogger
.error('build', FORMAT_INVALID
, 'Missing double quotes in the end of %s statement.' % TAB_DSC_PREBUILD
,
339 File
=self
.MetaFile
, Line
=Record
[-1])
340 PrebuildValue
= Record
[2][1:-1]
341 self
._Prebuild
= PrebuildValue
342 elif Name
== TAB_DSC_POSTBUILD
:
343 PostbuildValue
= Record
[2]
344 if Record
[2][0] == '"':
345 if Record
[2][-1] != '"':
346 EdkLogger
.error('build', FORMAT_INVALID
, 'Missing double quotes in the end of %s statement.' % TAB_DSC_POSTBUILD
,
347 File
=self
.MetaFile
, Line
=Record
[-1])
348 PostbuildValue
= Record
[2][1:-1]
349 self
._Postbuild
= PostbuildValue
350 elif Name
== TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES
:
351 self
._SupArchList
= GetSplitValueList(Record
[2], TAB_VALUE_SPLIT
)
352 elif Name
== TAB_DSC_DEFINES_BUILD_TARGETS
:
353 self
._BuildTargets
= GetSplitValueList(Record
[2])
354 elif Name
== TAB_DSC_DEFINES_SKUID_IDENTIFIER
:
355 if self
._SkuName
is None:
356 self
._SkuName
= Record
[2]
357 if GlobalData
.gSKUID_CMD
:
358 self
._SkuName
= GlobalData
.gSKUID_CMD
359 elif Name
== TAB_DSC_DEFINES_PCD_INFO_GENERATION
:
360 self
._PcdInfoFlag
= Record
[2]
361 elif Name
== TAB_DSC_DEFINES_PCD_VAR_CHECK_GENERATION
:
362 self
._VarCheckFlag
= Record
[2]
363 elif Name
== TAB_FIX_LOAD_TOP_MEMORY_ADDRESS
:
365 self
._LoadFixAddress
= int (Record
[2], 0)
367 EdkLogger
.error("build", PARAMETER_INVALID
, "FIX_LOAD_TOP_MEMORY_ADDRESS %s is not valid dec or hex string" % (Record
[2]))
368 elif Name
== TAB_DSC_DEFINES_RFC_LANGUAGES
:
369 if not Record
[2] or Record
[2][0] != '"' or Record
[2][-1] != '"' or len(Record
[2]) == 1:
370 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"',
371 File
=self
.MetaFile
, Line
=Record
[-1])
372 LanguageCodes
= Record
[2][1:-1]
373 if not LanguageCodes
:
374 EdkLogger
.error('build', FORMAT_NOT_SUPPORTED
, 'one or more RFC4646 format language code must be provided for RFC_LANGUAGES statement',
375 File
=self
.MetaFile
, Line
=Record
[-1])
376 LanguageList
= GetSplitValueList(LanguageCodes
, TAB_SEMI_COLON_SPLIT
)
377 # check whether there is empty entries in the list
378 if None in LanguageList
:
379 EdkLogger
.error('build', FORMAT_NOT_SUPPORTED
, 'one or more empty language code is in RFC_LANGUAGES statement',
380 File
=self
.MetaFile
, Line
=Record
[-1])
381 self
._RFCLanguages
= LanguageList
382 elif Name
== TAB_DSC_DEFINES_ISO_LANGUAGES
:
383 if not Record
[2] or Record
[2][0] != '"' or Record
[2][-1] != '"' or len(Record
[2]) == 1:
384 EdkLogger
.error('build', FORMAT_NOT_SUPPORTED
, 'language code for ISO_LANGUAGES must have double quotes around it, for example: ISO_LANGUAGES = "engchn"',
385 File
=self
.MetaFile
, Line
=Record
[-1])
386 LanguageCodes
= Record
[2][1:-1]
387 if not LanguageCodes
:
388 EdkLogger
.error('build', FORMAT_NOT_SUPPORTED
, 'one or more ISO639-2 format language code must be provided for ISO_LANGUAGES statement',
389 File
=self
.MetaFile
, Line
=Record
[-1])
390 if len(LanguageCodes
) % 3:
391 EdkLogger
.error('build', FORMAT_NOT_SUPPORTED
, 'bad ISO639-2 format for ISO_LANGUAGES',
392 File
=self
.MetaFile
, Line
=Record
[-1])
394 for i
in range(0, len(LanguageCodes
), 3):
395 LanguageList
.append(LanguageCodes
[i
:i
+ 3])
396 self
._ISOLanguages
= LanguageList
397 elif Name
== TAB_DSC_DEFINES_VPD_TOOL_GUID
:
399 # try to convert GUID to a real UUID value to see whether the GUID is format
400 # for VPD_TOOL_GUID is correct.
405 EdkLogger
.error("build", FORMAT_INVALID
, "Invalid GUID format for VPD_TOOL_GUID", File
=self
.MetaFile
)
406 self
._VpdToolGuid
= Record
[2]
408 self
[Name
] = Record
[2]
409 # set _Header to non-None in order to avoid database re-querying
410 self
._Header
= 'DUMMY'
412 ## Retrieve platform name
413 def _GetPlatformName(self
):
414 if self
._PlatformName
is None:
415 if self
._Header
is None:
416 self
._GetHeaderInfo
()
417 if self
._PlatformName
is None:
418 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No PLATFORM_NAME", File
=self
.MetaFile
)
419 return self
._PlatformName
421 ## Retrieve file guid
422 def _GetFileGuid(self
):
423 if self
._Guid
is None:
424 if self
._Header
is None:
425 self
._GetHeaderInfo
()
426 if self
._Guid
is None:
427 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No PLATFORM_GUID", File
=self
.MetaFile
)
430 ## Retrieve platform version
431 def _GetVersion(self
):
432 if self
._Version
is None:
433 if self
._Header
is None:
434 self
._GetHeaderInfo
()
435 if self
._Version
is None:
436 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No PLATFORM_VERSION", File
=self
.MetaFile
)
439 ## Retrieve platform description file version
440 def _GetDscSpec(self
):
441 if self
._DscSpecification
is None:
442 if self
._Header
is None:
443 self
._GetHeaderInfo
()
444 if self
._DscSpecification
is None:
445 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No DSC_SPECIFICATION", File
=self
.MetaFile
)
446 return self
._DscSpecification
448 ## Retrieve OUTPUT_DIRECTORY
449 def _GetOutpuDir(self
):
450 if self
._OutputDirectory
is None:
451 if self
._Header
is None:
452 self
._GetHeaderInfo
()
453 if self
._OutputDirectory
is None:
454 self
._OutputDirectory
= os
.path
.join("Build", self
._PlatformName
)
455 return self
._OutputDirectory
457 ## Retrieve SUPPORTED_ARCHITECTURES
458 def _GetSupArch(self
):
459 if self
._SupArchList
is None:
460 if self
._Header
is None:
461 self
._GetHeaderInfo
()
462 if self
._SupArchList
is None:
463 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No SUPPORTED_ARCHITECTURES", File
=self
.MetaFile
)
464 return self
._SupArchList
466 ## Retrieve BUILD_TARGETS
467 def _GetBuildTarget(self
):
468 if self
._BuildTargets
is None:
469 if self
._Header
is None:
470 self
._GetHeaderInfo
()
471 if self
._BuildTargets
is None:
472 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No BUILD_TARGETS", File
=self
.MetaFile
)
473 return self
._BuildTargets
475 def _GetPcdInfoFlag(self
):
476 if self
._PcdInfoFlag
is None or self
._PcdInfoFlag
.upper() == 'FALSE':
478 elif self
._PcdInfoFlag
.upper() == 'TRUE':
482 def _GetVarCheckFlag(self
):
483 if self
._VarCheckFlag
is None or self
._VarCheckFlag
.upper() == 'FALSE':
485 elif self
._VarCheckFlag
.upper() == 'TRUE':
490 # # Retrieve SKUID_IDENTIFIER
491 def _GetSkuName(self
):
492 if self
._SkuName
is None:
493 if self
._Header
is None:
494 self
._GetHeaderInfo
()
495 if self
._SkuName
is None:
496 self
._SkuName
= TAB_DEFAULT
499 ## Override SKUID_IDENTIFIER
500 def _SetSkuName(self
, Value
):
501 self
._SkuName
= Value
503 def _GetFdfFile(self
):
504 if self
._FlashDefinition
is None:
505 if self
._Header
is None:
506 self
._GetHeaderInfo
()
507 if self
._FlashDefinition
is None:
508 self
._FlashDefinition
= ''
509 return self
._FlashDefinition
511 def _GetPrebuild(self
):
512 if self
._Prebuild
is None:
513 if self
._Header
is None:
514 self
._GetHeaderInfo
()
515 if self
._Prebuild
is None:
517 return self
._Prebuild
519 def _GetPostbuild(self
):
520 if self
._Postbuild
is None:
521 if self
._Header
is None:
522 self
._GetHeaderInfo
()
523 if self
._Postbuild
is None:
525 return self
._Postbuild
527 ## Retrieve FLASH_DEFINITION
528 def _GetBuildNumber(self
):
529 if self
._BuildNumber
is None:
530 if self
._Header
is None:
531 self
._GetHeaderInfo
()
532 if self
._BuildNumber
is None:
533 self
._BuildNumber
= ''
534 return self
._BuildNumber
536 ## Retrieve MAKEFILE_NAME
537 def _GetMakefileName(self
):
538 if self
._MakefileName
is None:
539 if self
._Header
is None:
540 self
._GetHeaderInfo
()
541 if self
._MakefileName
is None:
542 self
._MakefileName
= ''
543 return self
._MakefileName
545 ## Retrieve BsBaseAddress
546 def _GetBsBaseAddress(self
):
547 if self
._BsBaseAddress
is None:
548 if self
._Header
is None:
549 self
._GetHeaderInfo
()
550 if self
._BsBaseAddress
is None:
551 self
._BsBaseAddress
= ''
552 return self
._BsBaseAddress
554 ## Retrieve RtBaseAddress
555 def _GetRtBaseAddress(self
):
556 if self
._RtBaseAddress
is None:
557 if self
._Header
is None:
558 self
._GetHeaderInfo
()
559 if self
._RtBaseAddress
is None:
560 self
._RtBaseAddress
= ''
561 return self
._RtBaseAddress
563 ## Retrieve the top address for the load fix address
564 def _GetLoadFixAddress(self
):
565 if self
._LoadFixAddress
is None:
566 if self
._Header
is None:
567 self
._GetHeaderInfo
()
569 if self
._LoadFixAddress
is None:
570 self
._LoadFixAddress
= self
._Macros
.get(TAB_FIX_LOAD_TOP_MEMORY_ADDRESS
, '0')
573 self
._LoadFixAddress
= int (self
._LoadFixAddress
, 0)
575 EdkLogger
.error("build", PARAMETER_INVALID
, "FIX_LOAD_TOP_MEMORY_ADDRESS %s is not valid dec or hex string" % (self
._LoadFixAddress
))
578 # If command line defined, should override the value in DSC file.
580 if 'FIX_LOAD_TOP_MEMORY_ADDRESS' in GlobalData
.gCommandLineDefines
:
582 self
._LoadFixAddress
= int(GlobalData
.gCommandLineDefines
['FIX_LOAD_TOP_MEMORY_ADDRESS'], 0)
584 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']))
586 if self
._LoadFixAddress
< 0:
587 EdkLogger
.error("build", PARAMETER_INVALID
, "FIX_LOAD_TOP_MEMORY_ADDRESS is set to the invalid negative value 0x%x" % (self
._LoadFixAddress
))
588 if self
._LoadFixAddress
!= 0xFFFFFFFFFFFFFFFF and self
._LoadFixAddress
% 0x1000 != 0:
589 EdkLogger
.error("build", PARAMETER_INVALID
, "FIX_LOAD_TOP_MEMORY_ADDRESS is set to the invalid unaligned 4K value 0x%x" % (self
._LoadFixAddress
))
591 return self
._LoadFixAddress
593 ## Retrieve RFCLanguage filter
594 def _GetRFCLanguages(self
):
595 if self
._RFCLanguages
is None:
596 if self
._Header
is None:
597 self
._GetHeaderInfo
()
598 if self
._RFCLanguages
is None:
599 self
._RFCLanguages
= []
600 return self
._RFCLanguages
602 ## Retrieve ISOLanguage filter
603 def _GetISOLanguages(self
):
604 if self
._ISOLanguages
is None:
605 if self
._Header
is None:
606 self
._GetHeaderInfo
()
607 if self
._ISOLanguages
is None:
608 self
._ISOLanguages
= []
609 return self
._ISOLanguages
610 ## Retrieve the GUID string for VPD tool
611 def _GetVpdToolGuid(self
):
612 if self
._VpdToolGuid
is None:
613 if self
._Header
is None:
614 self
._GetHeaderInfo
()
615 if self
._VpdToolGuid
is None:
616 self
._VpdToolGuid
= ''
617 return self
._VpdToolGuid
619 ## Retrieve [SkuIds] section information
620 def _GetSkuIds(self
):
621 if self
._SkuIds
is None:
622 self
._SkuIds
= OrderedDict()
623 RecordList
= self
._RawData
[MODEL_EFI_SKU_ID
, self
._Arch
]
624 for Record
in RecordList
:
626 EdkLogger
.error('build', FORMAT_INVALID
, 'No Sku ID number',
627 File
=self
.MetaFile
, Line
=Record
[-1])
629 EdkLogger
.error('build', FORMAT_INVALID
, 'No Sku ID name',
630 File
=self
.MetaFile
, Line
=Record
[-1])
631 if not Pattern
.match(Record
[0]) and not HexPattern
.match(Record
[0]):
632 EdkLogger
.error('build', FORMAT_INVALID
, "The format of the Sku ID number is invalid. It only support Integer and HexNumber",
633 File
=self
.MetaFile
, Line
=Record
[-1])
634 if not SkuIdPattern
.match(Record
[1]) or (Record
[2] and not SkuIdPattern
.match(Record
[2])):
635 EdkLogger
.error('build', FORMAT_INVALID
, "The format of the Sku ID name is invalid. The correct format is '(a-zA-Z_)(a-zA-Z0-9_)*'",
636 File
=self
.MetaFile
, Line
=Record
[-1])
637 self
._SkuIds
[Record
[1].upper()] = (str(DscBuildData
.ToInt(Record
[0])), Record
[1].upper(), Record
[2].upper())
638 if TAB_DEFAULT
not in self
._SkuIds
:
639 self
._SkuIds
[TAB_DEFAULT
] = ("0", TAB_DEFAULT
, TAB_DEFAULT
)
640 if TAB_COMMON
not in self
._SkuIds
:
641 self
._SkuIds
[TAB_COMMON
] = ("0", TAB_DEFAULT
, TAB_DEFAULT
)
646 return int(intstr
, 16) if intstr
.upper().startswith("0X") else int(intstr
)
648 def _GetDefaultStores(self
):
649 if self
.DefaultStores
is None:
650 self
.DefaultStores
= OrderedDict()
651 RecordList
= self
._RawData
[MODEL_EFI_DEFAULT_STORES
, self
._Arch
]
652 for Record
in RecordList
:
654 EdkLogger
.error('build', FORMAT_INVALID
, 'No DefaultStores ID number',
655 File
=self
.MetaFile
, Line
=Record
[-1])
657 EdkLogger
.error('build', FORMAT_INVALID
, 'No DefaultStores ID name',
658 File
=self
.MetaFile
, Line
=Record
[-1])
659 if not Pattern
.match(Record
[0]) and not HexPattern
.match(Record
[0]):
660 EdkLogger
.error('build', FORMAT_INVALID
, "The format of the DefaultStores ID number is invalid. It only support Integer and HexNumber",
661 File
=self
.MetaFile
, Line
=Record
[-1])
662 if not IsValidWord(Record
[1]):
663 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_-.)*'",
664 File
=self
.MetaFile
, Line
=Record
[-1])
665 self
.DefaultStores
[Record
[1].upper()] = (DscBuildData
.ToInt(Record
[0]), Record
[1].upper())
666 if TAB_DEFAULT_STORES_DEFAULT
not in self
.DefaultStores
:
667 self
.DefaultStores
[TAB_DEFAULT_STORES_DEFAULT
] = (0, TAB_DEFAULT_STORES_DEFAULT
)
668 GlobalData
.gDefaultStores
= sorted(self
.DefaultStores
.keys())
669 return self
.DefaultStores
671 ## Retrieve [Components] section information
672 def _GetModules(self
):
673 if self
._Modules
is not None:
676 self
._Modules
= OrderedDict()
677 RecordList
= self
._RawData
[MODEL_META_DATA_COMPONENT
, self
._Arch
]
678 Macros
= self
._Macros
679 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
680 for Record
in RecordList
:
681 DuplicatedFile
= False
683 ModuleFile
= PathClass(NormPath(Record
[0], Macros
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
687 # check the file validation
688 ErrorCode
, ErrorInfo
= ModuleFile
.Validate('.inf')
690 EdkLogger
.error('build', ErrorCode
, File
=self
.MetaFile
, Line
=LineNo
,
693 # If arch is COMMON, no duplicate module is checked since all modules in all component sections are selected
694 if self
._Arch
!= TAB_ARCH_COMMON
and ModuleFile
in self
._Modules
:
695 DuplicatedFile
= True
697 Module
= ModuleBuildClassObject()
698 Module
.MetaFile
= ModuleFile
700 # get module private library instance
701 RecordList
= self
._RawData
[MODEL_EFI_LIBRARY_CLASS
, self
._Arch
, None, ModuleId
]
702 for Record
in RecordList
:
703 LibraryClass
= Record
[0]
704 LibraryPath
= PathClass(NormPath(Record
[1], Macros
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
707 # check the file validation
708 ErrorCode
, ErrorInfo
= LibraryPath
.Validate('.inf')
710 EdkLogger
.error('build', ErrorCode
, File
=self
.MetaFile
, Line
=LineNo
,
713 if LibraryClass
== '' or LibraryClass
== 'NULL':
714 self
._NullLibraryNumber
+= 1
715 LibraryClass
= 'NULL%d' % self
._NullLibraryNumber
716 EdkLogger
.verbose("Found forced library for %s\n\t%s [%s]" % (ModuleFile
, LibraryPath
, LibraryClass
))
717 Module
.LibraryClasses
[LibraryClass
] = LibraryPath
718 if LibraryPath
not in self
.LibraryInstances
:
719 self
.LibraryInstances
.append(LibraryPath
)
721 # get module private PCD setting
722 for Type
in [MODEL_PCD_FIXED_AT_BUILD
, MODEL_PCD_PATCHABLE_IN_MODULE
, \
723 MODEL_PCD_FEATURE_FLAG
, MODEL_PCD_DYNAMIC
, MODEL_PCD_DYNAMIC_EX
]:
724 RecordList
= self
._RawData
[Type
, self
._Arch
, None, ModuleId
]
725 for TokenSpaceGuid
, PcdCName
, Setting
, Dummy1
, Dummy2
, Dummy3
, Dummy4
, Dummy5
in RecordList
:
726 TokenList
= GetSplitValueList(Setting
)
727 DefaultValue
= TokenList
[0]
728 # the format is PcdName| Value | VOID* | MaxDatumSize
729 if len(TokenList
) > 2:
730 MaxDatumSize
= TokenList
[2]
733 TypeString
= self
._PCD
_TYPE
_STRING
_[Type
]
734 Pcd
= PcdClassObject(
746 Module
.Pcds
[PcdCName
, TokenSpaceGuid
] = Pcd
748 # get module private build options
749 RecordList
= self
._RawData
[MODEL_META_DATA_BUILD_OPTION
, self
._Arch
, None, ModuleId
]
750 for ToolChainFamily
, ToolChain
, Option
, Dummy1
, Dummy2
, Dummy3
, Dummy4
, Dummy5
in RecordList
:
751 if (ToolChainFamily
, ToolChain
) not in Module
.BuildOptions
:
752 Module
.BuildOptions
[ToolChainFamily
, ToolChain
] = Option
754 OptionString
= Module
.BuildOptions
[ToolChainFamily
, ToolChain
]
755 Module
.BuildOptions
[ToolChainFamily
, ToolChain
] = OptionString
+ " " + Option
757 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER
, self
._Arch
, None, ModuleId
]
758 if DuplicatedFile
and not RecordList
:
759 EdkLogger
.error('build', FILE_DUPLICATED
, File
=self
.MetaFile
, ExtraData
=str(ModuleFile
), Line
=LineNo
)
761 if len(RecordList
) != 1:
762 EdkLogger
.error('build', OPTION_UNKNOWN
, 'Only FILE_GUID can be listed in <Defines> section.',
763 File
=self
.MetaFile
, ExtraData
=str(ModuleFile
), Line
=LineNo
)
764 ModuleFile
= ProcessDuplicatedInf(ModuleFile
, RecordList
[0][2], GlobalData
.gWorkspace
)
765 ModuleFile
.Arch
= self
._Arch
767 self
._Modules
[ModuleFile
] = Module
770 ## Retrieve all possible library instances used in this platform
771 def _GetLibraryInstances(self
):
772 if self
._LibraryInstances
is None:
773 self
._GetLibraryClasses
()
774 return self
._LibraryInstances
776 ## Retrieve [LibraryClasses] information
777 def _GetLibraryClasses(self
):
778 if self
._LibraryClasses
is None:
779 self
._LibraryInstances
= []
781 # tdict is a special dict kind of type, used for selecting correct
782 # library instance for given library class and module type
784 LibraryClassDict
= tdict(True, 3)
785 # track all library class names
786 LibraryClassSet
= set()
787 RecordList
= self
._RawData
[MODEL_EFI_LIBRARY_CLASS
, self
._Arch
, None, -1]
788 Macros
= self
._Macros
789 for Record
in RecordList
:
790 LibraryClass
, LibraryInstance
, Dummy
, Arch
, ModuleType
, Dummy
, Dummy
, LineNo
= Record
791 if LibraryClass
== '' or LibraryClass
== 'NULL':
792 self
._NullLibraryNumber
+= 1
793 LibraryClass
= 'NULL%d' % self
._NullLibraryNumber
794 EdkLogger
.verbose("Found forced library for arch=%s\n\t%s [%s]" % (Arch
, LibraryInstance
, LibraryClass
))
795 LibraryClassSet
.add(LibraryClass
)
796 LibraryInstance
= PathClass(NormPath(LibraryInstance
, Macros
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
797 # check the file validation
798 ErrorCode
, ErrorInfo
= LibraryInstance
.Validate('.inf')
800 EdkLogger
.error('build', ErrorCode
, File
=self
.MetaFile
, Line
=LineNo
,
803 if ModuleType
!= TAB_COMMON
and ModuleType
not in SUP_MODULE_LIST
:
804 EdkLogger
.error('build', OPTION_UNKNOWN
, "Unknown module type [%s]" % ModuleType
,
805 File
=self
.MetaFile
, ExtraData
=LibraryInstance
, Line
=LineNo
)
806 LibraryClassDict
[Arch
, ModuleType
, LibraryClass
] = LibraryInstance
807 if LibraryInstance
not in self
._LibraryInstances
:
808 self
._LibraryInstances
.append(LibraryInstance
)
810 # resolve the specific library instance for each class and each module type
811 self
._LibraryClasses
= tdict(True)
812 for LibraryClass
in LibraryClassSet
:
813 # try all possible module types
814 for ModuleType
in SUP_MODULE_LIST
:
815 LibraryInstance
= LibraryClassDict
[self
._Arch
, ModuleType
, LibraryClass
]
816 if LibraryInstance
is None:
818 self
._LibraryClasses
[LibraryClass
, ModuleType
] = LibraryInstance
820 # for Edk style library instances, which are listed in different section
821 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
822 RecordList
= self
._RawData
[MODEL_EFI_LIBRARY_INSTANCE
, self
._Arch
]
823 for Record
in RecordList
:
824 File
= PathClass(NormPath(Record
[0], Macros
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
826 # check the file validation
827 ErrorCode
, ErrorInfo
= File
.Validate('.inf')
829 EdkLogger
.error('build', ErrorCode
, File
=self
.MetaFile
, Line
=LineNo
,
831 if File
not in self
._LibraryInstances
:
832 self
._LibraryInstances
.append(File
)
834 # we need the module name as the library class name, so we have
835 # to parse it here. (self._Bdb[] will trigger a file parse if it
836 # hasn't been parsed)
838 Library
= self
._Bdb
[File
, self
._Arch
, self
._Target
, self
._Toolchain
]
839 self
._LibraryClasses
[Library
.BaseName
, ':dummy:'] = Library
840 return self
._LibraryClasses
842 def _ValidatePcd(self
, PcdCName
, TokenSpaceGuid
, Setting
, PcdType
, LineNo
):
843 if self
._DecPcds
is None:
846 if GlobalData
.gFdfParser
:
847 FdfInfList
= GlobalData
.gFdfParser
.Profile
.InfList
850 for Inf
in FdfInfList
:
851 ModuleFile
= PathClass(NormPath(Inf
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
852 if ModuleFile
in self
._Modules
:
854 ModuleData
= self
._Bdb
[ModuleFile
, self
._Arch
, self
._Target
, self
._Toolchain
]
855 PkgSet
.update(ModuleData
.Packages
)
857 self
._DecPcds
, self
._GuidDict
= GetDeclaredPcd(self
, self
._Bdb
, self
._Arch
, self
._Target
, self
._Toolchain
, PkgSet
)
858 self
._GuidDict
.update(GlobalData
.gPlatformPcds
)
860 if (PcdCName
, TokenSpaceGuid
) not in self
._DecPcds
:
861 EdkLogger
.error('build', PARSER_ERROR
,
862 "Pcd (%s.%s) defined in DSC is not declared in DEC files referenced in INF files in FDF. Arch: ['%s']" % (TokenSpaceGuid
, PcdCName
, self
._Arch
),
863 File
=self
.MetaFile
, Line
=LineNo
)
864 ValueList
, IsValid
, Index
= AnalyzeDscPcd(Setting
, PcdType
, self
._DecPcds
[PcdCName
, TokenSpaceGuid
].DatumType
)
866 if PcdType
not in [MODEL_PCD_FEATURE_FLAG
, MODEL_PCD_FIXED_AT_BUILD
]:
867 EdkLogger
.error('build', FORMAT_INVALID
, "Pcd format incorrect.", File
=self
.MetaFile
, Line
=LineNo
,
868 ExtraData
="%s.%s|%s" % (TokenSpaceGuid
, PcdCName
, Setting
))
870 if ValueList
[2] == '-1':
871 EdkLogger
.error('build', FORMAT_INVALID
, "Pcd format incorrect.", File
=self
.MetaFile
, Line
=LineNo
,
872 ExtraData
="%s.%s|%s" % (TokenSpaceGuid
, PcdCName
, Setting
))
874 DatumType
= self
._DecPcds
[PcdCName
, TokenSpaceGuid
].DatumType
876 ValueList
[Index
] = ValueExpressionEx(ValueList
[Index
], DatumType
, self
._GuidDict
)(True)
877 except BadExpression
as Value
:
878 EdkLogger
.error('Parser', FORMAT_INVALID
, Value
, File
=self
.MetaFile
, Line
=LineNo
,
879 ExtraData
="PCD [%s.%s] Value \"%s\" " % (
880 TokenSpaceGuid
, PcdCName
, ValueList
[Index
]))
881 except EvaluationException
as Excpt
:
882 if hasattr(Excpt
, 'Pcd'):
883 if Excpt
.Pcd
in GlobalData
.gPlatformOtherPcds
:
884 EdkLogger
.error('Parser', FORMAT_INVALID
, "Cannot use this PCD (%s) in an expression as"
885 " it must be defined in a [PcdsFixedAtBuild] or [PcdsFeatureFlag] section"
886 " of the DSC file" % Excpt
.Pcd
,
887 File
=self
.MetaFile
, Line
=LineNo
)
889 EdkLogger
.error('Parser', FORMAT_INVALID
, "PCD (%s) is not defined in DSC file" % Excpt
.Pcd
,
890 File
=self
.MetaFile
, Line
=LineNo
)
892 EdkLogger
.error('Parser', FORMAT_INVALID
, "Invalid expression: %s" % str(Excpt
),
893 File
=self
.MetaFile
, Line
=LineNo
)
896 Valid
, ErrStr
= CheckPcdDatum(self
._DecPcds
[PcdCName
, TokenSpaceGuid
].DatumType
, ValueList
[Index
])
898 EdkLogger
.error('build', FORMAT_INVALID
, ErrStr
, File
=self
.MetaFile
, Line
=LineNo
,
899 ExtraData
="%s.%s" % (TokenSpaceGuid
, PcdCName
))
900 if PcdType
in (MODEL_PCD_DYNAMIC_DEFAULT
, MODEL_PCD_DYNAMIC_EX_DEFAULT
, MODEL_PCD_FIXED_AT_BUILD
, MODEL_PCD_PATCHABLE_IN_MODULE
):
901 if self
._DecPcds
[PcdCName
, TokenSpaceGuid
].DatumType
.strip() != ValueList
[1].strip():
902 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
,
903 ExtraData
="%s.%s|%s" % (TokenSpaceGuid
, PcdCName
, Setting
))
904 if (TokenSpaceGuid
+ '.' + PcdCName
) in GlobalData
.gPlatformPcds
:
905 if GlobalData
.gPlatformPcds
[TokenSpaceGuid
+ '.' + PcdCName
] != ValueList
[Index
]:
906 GlobalData
.gPlatformPcds
[TokenSpaceGuid
+ '.' + PcdCName
] = ValueList
[Index
]
909 def _FilterPcdBySkuUsage(self
, Pcds
):
910 available_sku
= self
.SkuIdMgr
.AvailableSkuIdSet
911 sku_usage
= self
.SkuIdMgr
.SkuUsageType
912 if sku_usage
== SkuClass
.SINGLE
:
915 Pcds
[pcdname
].SkuInfoList
= {TAB_DEFAULT
:pcd
.SkuInfoList
[skuid
] for skuid
in pcd
.SkuInfoList
if skuid
in available_sku
}
916 if isinstance(pcd
, StructurePcd
) and pcd
.SkuOverrideValues
:
917 Pcds
[pcdname
].SkuOverrideValues
= {TAB_DEFAULT
:pcd
.SkuOverrideValues
[skuid
] for skuid
in pcd
.SkuOverrideValues
if skuid
in available_sku
}
921 Pcds
[pcdname
].SkuInfoList
= {skuid
:pcd
.SkuInfoList
[skuid
] for skuid
in pcd
.SkuInfoList
if skuid
in available_sku
}
922 if isinstance(pcd
, StructurePcd
) and pcd
.SkuOverrideValues
:
923 Pcds
[pcdname
].SkuOverrideValues
= {skuid
:pcd
.SkuOverrideValues
[skuid
] for skuid
in pcd
.SkuOverrideValues
if skuid
in available_sku
}
925 def CompleteHiiPcdsDefaultStores(self
, Pcds
):
926 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
]]]
927 DefaultStoreMgr
= DefaultStore(self
.DefaultStores
)
929 for skuid
in pcd
.SkuInfoList
:
930 skuobj
= pcd
.SkuInfoList
.get(skuid
)
931 if TAB_DEFAULT_STORES_DEFAULT
not in skuobj
.DefaultStoreDict
:
932 PcdDefaultStoreSet
= set(defaultstorename
for defaultstorename
in skuobj
.DefaultStoreDict
)
933 mindefaultstorename
= DefaultStoreMgr
.GetMin(PcdDefaultStoreSet
)
934 skuobj
.DefaultStoreDict
[TAB_DEFAULT_STORES_DEFAULT
] = copy
.deepcopy(skuobj
.DefaultStoreDict
[mindefaultstorename
])
937 def RecoverCommandLinePcd(self
):
938 def UpdateCommandLineValue(pcd
):
939 if pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FIXED_AT_BUILD
],
940 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_PATCHABLE_IN_MODULE
]]:
941 pcd
.PcdValueFromComm
= pcd
.DefaultValue
942 elif pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
943 pcd
.PcdValueFromComm
= pcd
.SkuInfoList
.get(TAB_DEFAULT
).HiiDefaultValue
945 pcd
.PcdValueFromComm
= pcd
.SkuInfoList
.get(TAB_DEFAULT
).DefaultValue
946 for pcd
in self
._Pcds
:
947 if isinstance(self
._Pcds
[pcd
], StructurePcd
) and (self
._Pcds
[pcd
].PcdValueFromComm
or self
._Pcds
[pcd
].PcdFieldValueFromComm
):
948 UpdateCommandLineValue(self
._Pcds
[pcd
])
950 def __ParsePcdFromCommandLine(self
):
951 if GlobalData
.BuildOptionPcd
:
952 for i
, pcd
in enumerate(GlobalData
.BuildOptionPcd
):
953 if isinstance(pcd
, tuple):
955 (pcdname
, pcdvalue
) = pcd
.split('=')
957 EdkLogger
.error('build', AUTOGEN_ERROR
, "No Value specified for the PCD %s." % (pcdname
))
959 (Name1
, Name2
) = pcdname
.split('.', 1)
961 (Name3
, FieldName
) = Name2
.split(".", 1)
962 if ((Name3
, Name1
)) in self
.DecPcds
:
965 TokenSpaceGuidCName
= Name1
969 TokenSpaceGuidCName
= ''
970 HasTokenSpace
= False
972 if ((Name2
, Name1
)) in self
.DecPcds
:
975 TokenSpaceGuidCName
= Name1
980 TokenSpaceGuidCName
= ''
981 HasTokenSpace
= False
985 TokenSpaceGuidCName
= ''
986 HasTokenSpace
= False
987 TokenSpaceGuidCNameList
= []
990 DisplayName
= TokenCName
992 DisplayName
= TokenCName
+ '.' + FieldName
993 if not HasTokenSpace
:
994 for key
in self
.DecPcds
:
995 PcdItem
= self
.DecPcds
[key
]
996 if TokenCName
== PcdItem
.TokenCName
:
997 if not PcdItem
.TokenSpaceGuidCName
in TokenSpaceGuidCNameList
:
998 if len (TokenSpaceGuidCNameList
) < 1:
999 TokenSpaceGuidCNameList
.append(PcdItem
.TokenSpaceGuidCName
)
1000 TokenSpaceGuidCName
= PcdItem
.TokenSpaceGuidCName
1001 PcdDatumType
= PcdItem
.DatumType
1007 "The Pcd %s is found under multiple different TokenSpaceGuid: %s and %s." % (DisplayName
, PcdItem
.TokenSpaceGuidCName
, TokenSpaceGuidCNameList
[0])
1010 if (TokenCName
, TokenSpaceGuidCName
) in self
.DecPcds
:
1011 PcdDatumType
= self
.DecPcds
[(TokenCName
, TokenSpaceGuidCName
)].DatumType
1015 EdkLogger
.error('build', AUTOGEN_ERROR
, "The Pcd %s.%s is not found in the DEC file." % (TokenSpaceGuidCName
, DisplayName
))
1017 EdkLogger
.error('build', AUTOGEN_ERROR
, "The Pcd %s is not found in the DEC file." % (DisplayName
))
1018 pcdvalue
= pcdvalue
.replace("\\\\\\'", '\\\\\\"').replace('\\\'', '\'').replace('\\\\\\"', "\\'")
1020 pcdvalue
= DscBuildData
.HandleFlexiblePcd(TokenSpaceGuidCName
, TokenCName
, pcdvalue
, PcdDatumType
, self
._GuidDict
, FieldName
)
1022 pcdvalue
= DscBuildData
.HandleFlexiblePcd(TokenSpaceGuidCName
, TokenCName
, pcdvalue
, PcdDatumType
, self
._GuidDict
)
1023 IsValid
, Cause
= CheckPcdDatum(PcdDatumType
, pcdvalue
)
1025 EdkLogger
.error("build", FORMAT_INVALID
, Cause
, ExtraData
="%s.%s" % (TokenSpaceGuidCName
, TokenCName
))
1026 GlobalData
.BuildOptionPcd
[i
] = (TokenSpaceGuidCName
, TokenCName
, FieldName
, pcdvalue
, ("build command options", 1))
1028 for BuildData
in self
._Bdb
._CACHE
_.values():
1029 if BuildData
.MetaFile
.Ext
== '.dec' or BuildData
.MetaFile
.Ext
== '.dsc':
1031 for key
in BuildData
.Pcds
:
1032 PcdItem
= BuildData
.Pcds
[key
]
1033 if (TokenSpaceGuidCName
, TokenCName
) == (PcdItem
.TokenSpaceGuidCName
, PcdItem
.TokenCName
) and FieldName
=="":
1034 PcdItem
.DefaultValue
= pcdvalue
1037 def HandleFlexiblePcd(TokenSpaceGuidCName
, TokenCName
, PcdValue
, PcdDatumType
, GuidDict
, FieldName
=''):
1040 TokenCName
+= '.' + FieldName
1041 if PcdValue
.startswith('H'):
1042 if FieldName
and IsFieldValueAnArray(PcdValue
[1:]):
1043 PcdDatumType
= TAB_VOID
1045 if FieldName
and not IsArray
:
1048 PcdValue
= ValueExpressionEx(PcdValue
[1:], PcdDatumType
, GuidDict
)(True)
1049 except BadExpression
as Value
:
1050 EdkLogger
.error('Parser', FORMAT_INVALID
, 'PCD [%s.%s] Value "%s", %s' %
1051 (TokenSpaceGuidCName
, TokenCName
, PcdValue
, Value
))
1052 elif PcdValue
.startswith("L'") or PcdValue
.startswith("'"):
1053 if FieldName
and IsFieldValueAnArray(PcdValue
):
1054 PcdDatumType
= TAB_VOID
1056 if FieldName
and not IsArray
:
1059 PcdValue
= ValueExpressionEx(PcdValue
, PcdDatumType
, GuidDict
)(True)
1060 except BadExpression
as Value
:
1061 EdkLogger
.error('Parser', FORMAT_INVALID
, 'PCD [%s.%s] Value "%s", %s' %
1062 (TokenSpaceGuidCName
, TokenCName
, PcdValue
, Value
))
1063 elif PcdValue
.startswith('L'):
1064 PcdValue
= 'L"' + PcdValue
[1:] + '"'
1065 if FieldName
and IsFieldValueAnArray(PcdValue
):
1066 PcdDatumType
= TAB_VOID
1068 if FieldName
and not IsArray
:
1071 PcdValue
= ValueExpressionEx(PcdValue
, PcdDatumType
, GuidDict
)(True)
1072 except BadExpression
as Value
:
1073 EdkLogger
.error('Parser', FORMAT_INVALID
, 'PCD [%s.%s] Value "%s", %s' %
1074 (TokenSpaceGuidCName
, TokenCName
, PcdValue
, Value
))
1076 if PcdValue
.upper() == 'FALSE':
1078 if PcdValue
.upper() == 'TRUE':
1081 if PcdDatumType
not in TAB_PCD_NUMERIC_TYPES
:
1082 PcdValue
= '"' + PcdValue
+ '"'
1086 if PcdValue
.upper().startswith('0X'):
1089 Num
= int(PcdValue
, Base
)
1091 PcdValue
= '"' + PcdValue
+ '"'
1092 if IsFieldValueAnArray(PcdValue
):
1093 PcdDatumType
= TAB_VOID
1098 PcdValue
= ValueExpressionEx(PcdValue
, PcdDatumType
, GuidDict
)(True)
1099 except BadExpression
as Value
:
1100 EdkLogger
.error('Parser', FORMAT_INVALID
, 'PCD [%s.%s] Value "%s", %s' %
1101 (TokenSpaceGuidCName
, TokenCName
, PcdValue
, Value
))
1104 ## Retrieve all PCD settings in platform
1106 if self
._Pcds
is None:
1107 self
._Pcds
= OrderedDict()
1108 self
.__ParsePcdFromCommandLine
()
1109 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_FIXED_AT_BUILD
))
1110 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_PATCHABLE_IN_MODULE
))
1111 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_FEATURE_FLAG
))
1112 self
._Pcds
.update(self
._GetDynamicPcd
(MODEL_PCD_DYNAMIC_DEFAULT
))
1113 self
._Pcds
.update(self
._GetDynamicHiiPcd
(MODEL_PCD_DYNAMIC_HII
))
1114 self
._Pcds
.update(self
._GetDynamicVpdPcd
(MODEL_PCD_DYNAMIC_VPD
))
1115 self
._Pcds
.update(self
._GetDynamicPcd
(MODEL_PCD_DYNAMIC_EX_DEFAULT
))
1116 self
._Pcds
.update(self
._GetDynamicHiiPcd
(MODEL_PCD_DYNAMIC_EX_HII
))
1117 self
._Pcds
.update(self
._GetDynamicVpdPcd
(MODEL_PCD_DYNAMIC_EX_VPD
))
1119 self
._Pcds
= self
.CompletePcdValues(self
._Pcds
)
1120 self
._Pcds
= self
.OverrideByFdfOverAll(self
._Pcds
)
1121 self
._Pcds
= self
.OverrideByCommOverAll(self
._Pcds
)
1122 self
._Pcds
= self
.UpdateStructuredPcds(MODEL_PCD_TYPE_LIST
, self
._Pcds
)
1123 self
._Pcds
= self
.CompleteHiiPcdsDefaultStores(self
._Pcds
)
1124 self
._Pcds
= self
._FilterPcdBySkuUsage
(self
._Pcds
)
1126 self
.RecoverCommandLinePcd()
1129 ## Retrieve [BuildOptions]
1130 def _GetBuildOptions(self
):
1131 if self
._BuildOptions
is None:
1132 self
._BuildOptions
= OrderedDict()
1134 # Retrieve build option for EDKII and EDK style module
1136 for CodeBase
in (EDKII_NAME
, EDK_NAME
):
1137 RecordList
= self
._RawData
[MODEL_META_DATA_BUILD_OPTION
, self
._Arch
, CodeBase
]
1138 for ToolChainFamily
, ToolChain
, Option
, Dummy1
, Dummy2
, Dummy3
, Dummy4
, Dummy5
in RecordList
:
1139 if Dummy3
.upper() != TAB_COMMON
:
1141 CurKey
= (ToolChainFamily
, ToolChain
, CodeBase
)
1143 # Only flags can be appended
1145 if CurKey
not in self
._BuildOptions
or not ToolChain
.endswith('_FLAGS') or Option
.startswith('='):
1146 self
._BuildOptions
[CurKey
] = Option
1148 if ' ' + Option
not in self
._BuildOptions
[CurKey
]:
1149 self
._BuildOptions
[CurKey
] += ' ' + Option
1150 return self
._BuildOptions
1152 def GetBuildOptionsByModuleType(self
, Edk
, ModuleType
):
1153 if self
._ModuleTypeOptions
is None:
1154 self
._ModuleTypeOptions
= OrderedDict()
1155 if (Edk
, ModuleType
) not in self
._ModuleTypeOptions
:
1156 options
= OrderedDict()
1157 self
._ModuleTypeOptions
[Edk
, ModuleType
] = options
1158 DriverType
= '%s.%s' % (Edk
, ModuleType
)
1159 CommonDriverType
= '%s.%s' % (TAB_COMMON
, ModuleType
)
1160 RecordList
= self
._RawData
[MODEL_META_DATA_BUILD_OPTION
, self
._Arch
]
1161 for ToolChainFamily
, ToolChain
, Option
, Dummy1
, Dummy2
, Dummy3
, Dummy4
, Dummy5
in RecordList
:
1162 Type
= Dummy2
+ '.' + Dummy3
1163 if Type
.upper() == DriverType
.upper() or Type
.upper() == CommonDriverType
.upper():
1164 Key
= (ToolChainFamily
, ToolChain
, Edk
)
1165 if Key
not in options
or not ToolChain
.endswith('_FLAGS') or Option
.startswith('='):
1166 options
[Key
] = Option
1168 if ' ' + Option
not in options
[Key
]:
1169 options
[Key
] += ' ' + Option
1170 return self
._ModuleTypeOptions
[Edk
, ModuleType
]
1173 def GetStructurePcdInfo(PcdSet
):
1174 structure_pcd_data
= defaultdict(list)
1176 structure_pcd_data
[(item
[0], item
[1])].append(item
)
1178 return structure_pcd_data
1181 def OverrideByFdf(StruPcds
,workspace
):
1182 if GlobalData
.gFdfParser
is None:
1184 StructurePcdInFdf
= OrderedDict()
1185 fdfpcd
= GlobalData
.gFdfParser
.Profile
.PcdDict
1186 fdfpcdlocation
= GlobalData
.gFdfParser
.Profile
.PcdLocalDict
1187 for item
in fdfpcd
:
1188 if len(item
[2]) and (item
[0],item
[1]) in StruPcds
:
1189 StructurePcdInFdf
[(item
[1],item
[0],item
[2] )] = fdfpcd
[item
]
1190 GlobalPcds
= {(item
[0],item
[1]) for item
in StructurePcdInFdf
}
1191 for Pcd
in StruPcds
.values():
1192 if (Pcd
.TokenSpaceGuidCName
,Pcd
.TokenCName
) not in GlobalPcds
:
1194 FieldValues
= OrderedDict()
1195 for item
in StructurePcdInFdf
:
1196 if (Pcd
.TokenSpaceGuidCName
,Pcd
.TokenCName
) == (item
[0],item
[1]) and item
[2]:
1197 FieldValues
[item
[2]] = StructurePcdInFdf
[item
]
1198 for field
in FieldValues
:
1199 if field
not in Pcd
.PcdFieldValueFromFdf
:
1200 Pcd
.PcdFieldValueFromFdf
[field
] = ["","",""]
1201 Pcd
.PcdFieldValueFromFdf
[field
][0] = FieldValues
[field
]
1202 Pcd
.PcdFieldValueFromFdf
[field
][1] = os
.path
.relpath(fdfpcdlocation
[(Pcd
.TokenCName
,Pcd
.TokenSpaceGuidCName
,field
)][0],workspace
)
1203 Pcd
.PcdFieldValueFromFdf
[field
][2] = fdfpcdlocation
[(Pcd
.TokenCName
,Pcd
.TokenSpaceGuidCName
,field
)][1]
1208 def OverrideByComm(StruPcds
):
1209 StructurePcdInCom
= OrderedDict()
1210 for item
in GlobalData
.BuildOptionPcd
:
1211 if len(item
) == 5 and (item
[1], item
[0]) in StruPcds
:
1212 StructurePcdInCom
[(item
[0], item
[1], item
[2] )] = (item
[3], item
[4])
1213 GlobalPcds
= {(item
[0], item
[1]) for item
in StructurePcdInCom
}
1214 for Pcd
in StruPcds
.values():
1215 if (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
) not in GlobalPcds
:
1217 FieldValues
= OrderedDict()
1218 for item
in StructurePcdInCom
:
1219 if (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
) == (item
[0], item
[1]) and item
[2]:
1220 FieldValues
[item
[2]] = StructurePcdInCom
[item
]
1221 for field
in FieldValues
:
1222 if field
not in Pcd
.PcdFieldValueFromComm
:
1223 Pcd
.PcdFieldValueFromComm
[field
] = ["", "", ""]
1224 Pcd
.PcdFieldValueFromComm
[field
][0] = FieldValues
[field
][0]
1225 Pcd
.PcdFieldValueFromComm
[field
][1] = FieldValues
[field
][1][0]
1226 Pcd
.PcdFieldValueFromComm
[field
][2] = FieldValues
[field
][1][1]
1230 def OverrideByCommOverAll(self
,AllPcds
):
1231 def CheckStructureInComm(commpcds
):
1234 if len(commpcds
[0]) == 5:
1238 if CheckStructureInComm(GlobalData
.BuildOptionPcd
):
1239 StructurePcdInCom
= {(item
[0], item
[1], item
[2] ):(item
[3], item
[4]) for item
in GlobalData
.BuildOptionPcd
} if GlobalData
.BuildOptionPcd
else {}
1240 NoFiledValues
= {(item
[0], item
[1]):StructurePcdInCom
[item
] for item
in StructurePcdInCom
if not item
[2]}
1242 NoFiledValues
= {(item
[0], item
[1]):[item
[2]] for item
in GlobalData
.BuildOptionPcd
}
1243 for Guid
, Name
in NoFiledValues
:
1244 if (Name
, Guid
) in AllPcds
:
1245 Pcd
= AllPcds
.get((Name
, Guid
))
1246 if isinstance(self
._DecPcds
.get((Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
), None), StructurePcd
):
1247 self
._DecPcds
.get((Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
)).PcdValueFromComm
= NoFiledValues
[(Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)][0]
1249 Pcd
.PcdValueFromComm
= NoFiledValues
[(Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)][0]
1250 Pcd
.DefaultValue
= NoFiledValues
[(Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)][0]
1251 for sku
in Pcd
.SkuInfoList
:
1252 SkuInfo
= Pcd
.SkuInfoList
[sku
]
1253 if SkuInfo
.DefaultValue
:
1254 SkuInfo
.DefaultValue
= NoFiledValues
[(Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)][0]
1256 SkuInfo
.HiiDefaultValue
= NoFiledValues
[(Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)][0]
1257 for defaultstore
in SkuInfo
.DefaultStoreDict
:
1258 SkuInfo
.DefaultStoreDict
[defaultstore
] = NoFiledValues
[(Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)][0]
1259 if Pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
]]:
1260 if Pcd
.DatumType
== TAB_VOID
:
1261 if not Pcd
.MaxDatumSize
:
1262 Pcd
.MaxDatumSize
= '0'
1263 CurrentSize
= int(Pcd
.MaxDatumSize
, 16) if Pcd
.MaxDatumSize
.upper().startswith("0X") else int(Pcd
.MaxDatumSize
)
1264 OptionSize
= len((StringToArray(Pcd
.PcdValueFromComm
)).split(","))
1265 MaxSize
= max(CurrentSize
, OptionSize
)
1266 Pcd
.MaxDatumSize
= str(MaxSize
)
1268 PcdInDec
= self
.DecPcds
.get((Name
, Guid
))
1270 PcdInDec
.PcdValueFromComm
= NoFiledValues
[(Guid
, Name
)][0]
1271 if PcdInDec
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FIXED_AT_BUILD
],
1272 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_PATCHABLE_IN_MODULE
],
1273 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FEATURE_FLAG
],
1274 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC
],
1275 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX
]]:
1276 self
.Pcds
[Name
, Guid
] = copy
.deepcopy(PcdInDec
)
1277 self
.Pcds
[Name
, Guid
].DefaultValue
= NoFiledValues
[( Guid
, Name
)][0]
1278 if PcdInDec
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC
],
1279 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX
]]:
1280 self
.Pcds
[Name
, Guid
].SkuInfoList
= {TAB_DEFAULT
:SkuInfoClass(TAB_DEFAULT
, self
.SkuIds
[TAB_DEFAULT
][0], '', '', '', '', '', NoFiledValues
[( Guid
, Name
)][0])}
1283 def OverrideByFdfOverAll(self
,AllPcds
):
1285 if GlobalData
.gFdfParser
is None:
1287 NoFiledValues
= GlobalData
.gFdfParser
.Profile
.PcdDict
1288 for Name
,Guid
,Field
in NoFiledValues
:
1291 Value
= NoFiledValues
[(Name
,Guid
,Field
)]
1292 if (Name
,Guid
) in AllPcds
:
1293 Pcd
= AllPcds
.get((Name
,Guid
))
1294 if isinstance(self
._DecPcds
.get((Pcd
.TokenCName
,Pcd
.TokenSpaceGuidCName
), None),StructurePcd
):
1295 self
._DecPcds
.get((Pcd
.TokenCName
,Pcd
.TokenSpaceGuidCName
)).PcdValueFromComm
= Value
1297 Pcd
.PcdValueFromComm
= Value
1298 Pcd
.DefaultValue
= Value
1299 for sku
in Pcd
.SkuInfoList
:
1300 SkuInfo
= Pcd
.SkuInfoList
[sku
]
1301 if SkuInfo
.DefaultValue
:
1302 SkuInfo
.DefaultValue
= Value
1304 SkuInfo
.HiiDefaultValue
= Value
1305 for defaultstore
in SkuInfo
.DefaultStoreDict
:
1306 SkuInfo
.DefaultStoreDict
[defaultstore
] = Value
1307 if Pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
]]:
1308 if Pcd
.DatumType
== TAB_VOID
:
1309 if not Pcd
.MaxDatumSize
:
1310 Pcd
.MaxDatumSize
= '0'
1311 CurrentSize
= int(Pcd
.MaxDatumSize
,16) if Pcd
.MaxDatumSize
.upper().startswith("0X") else int(Pcd
.MaxDatumSize
)
1312 OptionSize
= len((StringToArray(Pcd
.PcdValueFromComm
)).split(","))
1313 MaxSize
= max(CurrentSize
, OptionSize
)
1314 Pcd
.MaxDatumSize
= str(MaxSize
)
1316 PcdInDec
= self
.DecPcds
.get((Name
,Guid
))
1318 PcdInDec
.PcdValueFromFdf
= Value
1319 if PcdInDec
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FIXED_AT_BUILD
],
1320 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_PATCHABLE_IN_MODULE
],
1321 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FEATURE_FLAG
]]:
1322 self
.Pcds
[Name
, Guid
] = copy
.deepcopy(PcdInDec
)
1323 self
.Pcds
[Name
, Guid
].DefaultValue
= Value
1326 def UpdateStructuredPcds(self
, TypeList
, AllPcds
):
1328 DynamicPcdType
= [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_DEFAULT
],
1329 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
],
1330 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_VPD
],
1331 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_DEFAULT
],
1332 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
],
1333 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_VPD
]]
1336 DefaultStoreMgr
= DefaultStore(self
.DefaultStores
)
1337 SkuIds
= self
.SkuIds
1338 DefaultStores
= {storename
for pcdobj
in AllPcds
.values() for skuobj
in pcdobj
.SkuInfoList
.values() for storename
in skuobj
.DefaultStoreDict
}
1341 # Find out all possible PCD candidates for self._Arch
1344 for Type
in TypeList
:
1345 RecordList
.extend(self
._RawData
[Type
, self
._Arch
])
1347 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, SkuName
, default_store
, Dummy4
, Dummy5
in RecordList
:
1348 SkuName
= SkuName
.upper()
1349 default_store
= default_store
.upper()
1350 SkuName
= TAB_DEFAULT
if SkuName
== TAB_COMMON
else SkuName
1351 if SkuName
not in SkuIds
:
1354 if SkuName
in SkuIds
and "." in TokenSpaceGuid
:
1355 S_PcdSet
.append([ TokenSpaceGuid
.split(".")[0], TokenSpaceGuid
.split(".")[1], PcdCName
, SkuName
, default_store
, Dummy5
, AnalyzePcdExpression(Setting
)[0]])
1357 # handle pcd value override
1358 StrPcdSet
= DscBuildData
.GetStructurePcdInfo(S_PcdSet
)
1359 S_pcd_set
= OrderedDict()
1360 for str_pcd
in StrPcdSet
:
1361 str_pcd_obj
= Pcds
.get((str_pcd
[1], str_pcd
[0]), None)
1362 str_pcd_dec
= self
._DecPcds
.get((str_pcd
[1], str_pcd
[0]), None)
1363 if not isinstance (str_pcd_dec
, StructurePcd
):
1364 EdkLogger
.error('build', PARSER_ERROR
,
1365 "Pcd (%s.%s) is not declared as Structure PCD in DEC files. Arch: ['%s']" % (str_pcd
[0], str_pcd
[1], self
._Arch
),
1366 File
=self
.MetaFile
, Line
= StrPcdSet
[str_pcd
][0][5])
1368 str_pcd_obj_str
= StructurePcd()
1369 str_pcd_obj_str
.copy(str_pcd_dec
)
1371 str_pcd_obj_str
.copy(str_pcd_obj
)
1372 if str_pcd_obj
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
1373 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
}
1375 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
}
1376 for str_pcd_data
in StrPcdSet
[str_pcd
]:
1377 if str_pcd_data
[3] in SkuIds
:
1378 str_pcd_obj_str
.AddOverrideValue(str_pcd_data
[2], str(str_pcd_data
[6]), TAB_DEFAULT
if str_pcd_data
[3] == TAB_COMMON
else str_pcd_data
[3], TAB_DEFAULT_STORES_DEFAULT
if str_pcd_data
[4] == TAB_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])
1379 S_pcd_set
[str_pcd
[1], str_pcd
[0]] = str_pcd_obj_str
1381 EdkLogger
.error('build', PARSER_ERROR
,
1382 "Pcd (%s.%s) defined in DSC is not declared in DEC files. Arch: ['%s']" % (str_pcd
[0], str_pcd
[1], self
._Arch
),
1383 File
=self
.MetaFile
, Line
= StrPcdSet
[str_pcd
][0][5])
1384 # Add the Structure PCD that only defined in DEC, don't have override in DSC file
1385 for Pcd
in self
.DecPcds
:
1386 if isinstance(self
._DecPcds
[Pcd
], StructurePcd
):
1387 if Pcd
not in S_pcd_set
:
1388 str_pcd_obj_str
= StructurePcd()
1389 str_pcd_obj_str
.copy(self
._DecPcds
[Pcd
])
1390 str_pcd_obj
= Pcds
.get(Pcd
, None)
1392 str_pcd_obj_str
.copy(str_pcd_obj
)
1393 if str_pcd_obj
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
1394 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
}
1396 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
}
1397 S_pcd_set
[Pcd
] = str_pcd_obj_str
1399 GlobalData
.gStructurePcd
[self
.Arch
] = S_pcd_set
1400 for stru_pcd
in S_pcd_set
.values():
1401 for skuid
in SkuIds
:
1402 if skuid
in stru_pcd
.SkuOverrideValues
:
1404 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(skuid
)
1406 if skuid
not in stru_pcd
.SkuOverrideValues
:
1407 while nextskuid
not in stru_pcd
.SkuOverrideValues
:
1408 if nextskuid
== TAB_DEFAULT
:
1411 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(nextskuid
)
1412 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 {}) #{TAB_DEFAULT_STORES_DEFAULT:stru_pcd.DefaultValues})
1414 stru_pcd
.ValueChain
.add((skuid
, ''))
1415 if stru_pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
1416 for skuid
in SkuIds
:
1419 if skuid
not in stru_pcd
.SkuOverrideValues
:
1420 while nextskuid
not in stru_pcd
.SkuOverrideValues
:
1421 if nextskuid
== TAB_DEFAULT
:
1424 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(nextskuid
)
1427 PcdDefaultStoreSet
= set(defaultstorename
for defaultstorename
in stru_pcd
.SkuOverrideValues
[nextskuid
])
1428 mindefaultstorename
= DefaultStoreMgr
.GetMin(PcdDefaultStoreSet
)
1430 for defaultstoreid
in DefaultStores
:
1431 if defaultstoreid
not in stru_pcd
.SkuOverrideValues
[skuid
]:
1432 stru_pcd
.SkuOverrideValues
[skuid
][defaultstoreid
] = copy
.deepcopy(stru_pcd
.SkuOverrideValues
[nextskuid
][mindefaultstorename
])
1433 stru_pcd
.ValueChain
.add((skuid
, defaultstoreid
))
1434 S_pcd_set
= DscBuildData
.OverrideByFdf(S_pcd_set
,self
.WorkspaceDir
)
1435 S_pcd_set
= DscBuildData
.OverrideByComm(S_pcd_set
)
1436 Str_Pcd_Values
= self
.GenerateByteArrayValue(S_pcd_set
)
1438 for (skuname
, StoreName
, PcdGuid
, PcdName
, PcdValue
) in Str_Pcd_Values
:
1439 str_pcd_obj
= S_pcd_set
.get((PcdName
, PcdGuid
))
1440 if str_pcd_obj
is None:
1441 print(PcdName
, PcdGuid
)
1443 if str_pcd_obj
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
],
1444 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
1445 if skuname
not in str_pcd_obj
.SkuInfoList
:
1446 str_pcd_obj
.SkuInfoList
[skuname
] = SkuInfoClass(SkuIdName
=skuname
, SkuId
=self
.SkuIds
[skuname
][0], HiiDefaultValue
=PcdValue
, DefaultStore
= {StoreName
:PcdValue
})
1448 str_pcd_obj
.SkuInfoList
[skuname
].HiiDefaultValue
= PcdValue
1449 str_pcd_obj
.SkuInfoList
[skuname
].DefaultStoreDict
.update({StoreName
:PcdValue
})
1450 elif str_pcd_obj
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FIXED_AT_BUILD
],
1451 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_PATCHABLE_IN_MODULE
]]:
1452 if skuname
in (self
.SkuIdMgr
.SystemSkuId
, TAB_DEFAULT
, TAB_COMMON
):
1453 str_pcd_obj
.DefaultValue
= PcdValue
1455 if skuname
not in str_pcd_obj
.SkuInfoList
:
1456 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(skuname
)
1458 while nextskuid
not in str_pcd_obj
.SkuInfoList
:
1459 if nextskuid
== TAB_DEFAULT
:
1462 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(nextskuid
)
1463 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
)
1464 str_pcd_obj
.SkuInfoList
[skuname
].SkuId
= self
.SkuIds
[skuname
][0]
1465 str_pcd_obj
.SkuInfoList
[skuname
].SkuIdName
= skuname
1467 str_pcd_obj
.SkuInfoList
[skuname
].DefaultValue
= PcdValue
1468 for str_pcd_obj
in S_pcd_set
.values():
1469 if str_pcd_obj
.Type
not in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
],
1470 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
1472 PcdDefaultStoreSet
= set(defaultstorename
for skuobj
in str_pcd_obj
.SkuInfoList
.values() for defaultstorename
in skuobj
.DefaultStoreDict
)
1473 DefaultStoreObj
= DefaultStore(self
._GetDefaultStores
())
1474 mindefaultstorename
= DefaultStoreObj
.GetMin(PcdDefaultStoreSet
)
1475 str_pcd_obj
.SkuInfoList
[self
.SkuIdMgr
.SystemSkuId
].HiiDefaultValue
= str_pcd_obj
.SkuInfoList
[self
.SkuIdMgr
.SystemSkuId
].DefaultStoreDict
[mindefaultstorename
]
1477 for str_pcd_obj
in S_pcd_set
.values():
1479 str_pcd_obj
.MaxDatumSize
= self
.GetStructurePcdMaxSize(str_pcd_obj
)
1480 Pcds
[str_pcd_obj
.TokenCName
, str_pcd_obj
.TokenSpaceGuidCName
] = str_pcd_obj
1484 if TAB_DEFAULT
not in pcd
.SkuInfoList
and TAB_COMMON
in pcd
.SkuInfoList
:
1485 pcd
.SkuInfoList
[TAB_DEFAULT
] = pcd
.SkuInfoList
[TAB_COMMON
]
1486 del pcd
.SkuInfoList
[TAB_COMMON
]
1487 elif TAB_DEFAULT
in pcd
.SkuInfoList
and TAB_COMMON
in pcd
.SkuInfoList
:
1488 del pcd
.SkuInfoList
[TAB_COMMON
]
1490 map(self
.FilterSkuSettings
, [Pcds
[pcdkey
] for pcdkey
in Pcds
if Pcds
[pcdkey
].Type
in DynamicPcdType
])
1493 ## Retrieve non-dynamic PCD settings
1495 # @param Type PCD type
1497 # @retval a dict object contains settings of given PCD type
1499 def _GetPcd(self
, Type
):
1500 Pcds
= OrderedDict()
1502 # tdict is a special dict kind of type, used for selecting correct
1503 # PCD settings for certain ARCH
1505 AvailableSkuIdSet
= copy
.copy(self
.SkuIds
)
1507 PcdDict
= tdict(True, 3)
1509 # Find out all possible PCD candidates for self._Arch
1510 RecordList
= self
._RawData
[Type
, self
._Arch
]
1511 PcdValueDict
= OrderedDict()
1512 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, SkuName
, Dummy3
, Dummy4
, Dummy5
in RecordList
:
1513 SkuName
= SkuName
.upper()
1514 SkuName
= TAB_DEFAULT
if SkuName
== TAB_COMMON
else SkuName
1515 if SkuName
not in AvailableSkuIdSet
:
1516 EdkLogger
.error('build ', PARAMETER_INVALID
, 'Sku %s is not defined in [SkuIds] section' % SkuName
,
1517 File
=self
.MetaFile
, Line
=Dummy5
)
1518 if SkuName
in (self
.SkuIdMgr
.SystemSkuId
, TAB_DEFAULT
, TAB_COMMON
):
1519 if "." not in TokenSpaceGuid
:
1520 PcdSet
.add((PcdCName
, TokenSpaceGuid
, SkuName
, Dummy5
))
1521 PcdDict
[Arch
, PcdCName
, TokenSpaceGuid
, SkuName
] = Setting
1523 for PcdCName
, TokenSpaceGuid
, SkuName
, Dummy4
in PcdSet
:
1524 Setting
= PcdDict
[self
._Arch
, PcdCName
, TokenSpaceGuid
, SkuName
]
1527 PcdValue
, DatumType
, MaxDatumSize
= self
._ValidatePcd
(PcdCName
, TokenSpaceGuid
, Setting
, Type
, Dummy4
)
1529 if int(MaxDatumSize
, 0) > 0xFFFF:
1530 EdkLogger
.error('build', FORMAT_INVALID
, "The size value must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join((TokenSpaceGuid
, PcdCName
)),
1531 File
=self
.MetaFile
, Line
=Dummy4
)
1532 if int(MaxDatumSize
, 0) < 0:
1533 EdkLogger
.error('build', FORMAT_INVALID
, "The size value can't be set to negative value for %s." % ".".join((TokenSpaceGuid
, PcdCName
)),
1534 File
=self
.MetaFile
, Line
=Dummy4
)
1535 if (PcdCName
, TokenSpaceGuid
) in PcdValueDict
:
1536 PcdValueDict
[PcdCName
, TokenSpaceGuid
][SkuName
] = (PcdValue
, DatumType
, MaxDatumSize
)
1538 PcdValueDict
[PcdCName
, TokenSpaceGuid
] = {SkuName
:(PcdValue
, DatumType
, MaxDatumSize
)}
1540 for ((PcdCName
, TokenSpaceGuid
), PcdSetting
) in PcdValueDict
.iteritems():
1541 if self
.SkuIdMgr
.SystemSkuId
in PcdSetting
:
1542 PcdValue
, DatumType
, MaxDatumSize
= PcdSetting
[self
.SkuIdMgr
.SystemSkuId
]
1543 elif TAB_DEFAULT
in PcdSetting
:
1544 PcdValue
, DatumType
, MaxDatumSize
= PcdSetting
[TAB_DEFAULT
]
1545 elif TAB_COMMON
in PcdSetting
:
1546 PcdValue
, DatumType
, MaxDatumSize
= PcdSetting
[TAB_COMMON
]
1552 Pcds
[PcdCName
, TokenSpaceGuid
] = PcdClassObject(
1555 self
._PCD
_TYPE
_STRING
_[Type
],
1565 if self
.SkuIdMgr
.SystemSkuId
not in Pcds
[PcdCName
, TokenSpaceGuid
].DscRawValue
:
1566 Pcds
[PcdCName
, TokenSpaceGuid
].DscRawValue
[self
.SkuIdMgr
.SystemSkuId
] = {}
1567 Pcds
[PcdCName
, TokenSpaceGuid
].DscRawValue
[self
.SkuIdMgr
.SystemSkuId
][TAB_DEFAULT_STORES_DEFAULT
] = PcdValue
1570 def GetStructurePcdMaxSize(self
, str_pcd
):
1571 pcd_default_value
= str_pcd
.DefaultValue
1572 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()]
1573 sku_values
.append(pcd_default_value
)
1575 def get_length(value
):
1576 Value
= value
.strip()
1578 if Value
.startswith(TAB_GUID
) and Value
.endswith(')'):
1580 if Value
.startswith('L"') and Value
.endswith('"'):
1581 return len(Value
[2:-1])
1582 if Value
[0] == '"' and Value
[-1] == '"':
1583 return len(Value
) - 2
1584 if Value
[0] == '{' and Value
[-1] == '}':
1585 return len(Value
.split(","))
1586 if Value
.startswith("L'") and Value
.endswith("'") and len(list(Value
[2:-1])) > 1:
1587 return len(list(Value
[2:-1]))
1588 if Value
[0] == "'" and Value
[-1] == "'" and len(list(Value
[1:-1])) > 1:
1589 return len(Value
) - 2
1592 return str(max(get_length(item
) for item
in sku_values
))
1595 def ExecuteCommand (Command
):
1597 Process
= subprocess
.Popen(Command
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
, shell
=True)
1599 EdkLogger
.error('Build', COMMAND_FAILURE
, 'Can not execute command: %s' % Command
)
1600 Result
= Process
.communicate()
1601 return Process
.returncode
, Result
[0], Result
[1]
1604 def IntToCString(Value
, ValueSize
):
1606 if not isinstance (Value
, str):
1607 for Index
in range(0, ValueSize
):
1608 Result
= Result
+ '\\x%02x' % (Value
& 0xff)
1610 Result
= Result
+ '"'
1613 def GenerateSizeFunction(self
, Pcd
):
1614 CApp
= "// Default Value in Dec \n"
1615 CApp
= CApp
+ "void Cal_%s_%s_Size(UINT32 *Size){\n" % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
1616 for FieldList
in [Pcd
.DefaultValues
]:
1619 for FieldName
in FieldList
:
1620 FieldName
= "." + FieldName
1621 IsArray
= IsFieldValueAnArray(FieldList
[FieldName
.strip(".")][0])
1622 if IsArray
and not (FieldList
[FieldName
.strip(".")][0].startswith('{GUID') and FieldList
[FieldName
.strip(".")][0].endswith('}')):
1624 Value
= ValueExpressionEx(FieldList
[FieldName
.strip(".")][0], TAB_VOID
, self
._GuidDict
)(True)
1625 except BadExpression
:
1626 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid value format for %s. From %s Line %d " %
1627 (".".join((Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldName
.strip('.'))), FieldList
[FieldName
.strip(".")][1], FieldList
[FieldName
.strip(".")][2]))
1628 Value
, ValueSize
= ParseFieldValue(Value
)
1629 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]);
1632 FieldName_ori
= FieldName
.strip('.')
1633 while '[' in FieldName
:
1634 NewFieldName
= NewFieldName
+ FieldName
.split('[', 1)[0] + '[0]'
1635 ArrayIndex
= int(FieldName
.split('[', 1)[1].split(']', 1)[0])
1636 FieldName
= FieldName
.split(']', 1)[1]
1637 FieldName
= NewFieldName
+ FieldName
1638 while '[' in FieldName
:
1639 FieldName
= FieldName
.rsplit('[', 1)[0]
1640 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])
1641 for skuname
in Pcd
.SkuOverrideValues
:
1642 if skuname
== TAB_COMMON
:
1644 for defaultstorenameitem
in Pcd
.SkuOverrideValues
[skuname
]:
1645 CApp
= CApp
+ "// SkuName: %s, DefaultStoreName: %s \n" % (skuname
, defaultstorenameitem
)
1646 for FieldList
in [Pcd
.SkuOverrideValues
[skuname
].get(defaultstorenameitem
)]:
1649 for FieldName
in FieldList
:
1650 FieldName
= "." + FieldName
1651 IsArray
= IsFieldValueAnArray(FieldList
[FieldName
.strip(".")][0])
1652 if IsArray
and not (FieldList
[FieldName
.strip(".")][0].startswith('{GUID') and FieldList
[FieldName
.strip(".")][0].endswith('}')):
1654 Value
= ValueExpressionEx(FieldList
[FieldName
.strip(".")][0], TAB_VOID
, self
._GuidDict
)(True)
1655 except BadExpression
:
1656 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid value format for %s. From %s Line %d " %
1657 (".".join((Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldName
.strip('.'))), FieldList
[FieldName
.strip(".")][1], FieldList
[FieldName
.strip(".")][2]))
1658 Value
, ValueSize
= ParseFieldValue(Value
)
1659 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]);
1662 FieldName_ori
= FieldName
.strip('.')
1663 while '[' in FieldName
:
1664 NewFieldName
= NewFieldName
+ FieldName
.split('[', 1)[0] + '[0]'
1665 ArrayIndex
= int(FieldName
.split('[', 1)[1].split(']', 1)[0])
1666 FieldName
= FieldName
.split(']', 1)[1]
1667 FieldName
= NewFieldName
+ FieldName
1668 while '[' in FieldName
:
1669 FieldName
= FieldName
.rsplit('[', 1)[0]
1670 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])
1671 if Pcd
.PcdFieldValueFromFdf
:
1672 CApp
= CApp
+ "// From fdf \n"
1673 for FieldName
in Pcd
.PcdFieldValueFromFdf
:
1674 FieldName
= "." + FieldName
1675 IsArray
= IsFieldValueAnArray(Pcd
.PcdFieldValueFromFdf
[FieldName
.strip(".")][0])
1676 if IsArray
and not (Pcd
.PcdFieldValueFromFdf
[FieldName
.strip(".")][0].startswith('{GUID') and Pcd
.PcdFieldValueFromFdf
[FieldName
.strip(".")][0].endswith('}')):
1678 Value
= ValueExpressionEx(Pcd
.PcdFieldValueFromFdf
[FieldName
.strip(".")][0], TAB_VOID
, self
._GuidDict
)(True)
1679 except BadExpression
:
1680 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid value format for %s. From %s Line %d " %
1681 (".".join((Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldName
.strip('.'))), Pcd
.PcdFieldValueFromFdf
[FieldName
.strip(".")][1], Pcd
.PcdFieldValueFromFdf
[FieldName
.strip(".")][2]))
1682 Value
, ValueSize
= ParseFieldValue(Value
)
1683 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("."), Pcd
.PcdFieldValueFromFdf
[FieldName
.strip(".")][1], Pcd
.PcdFieldValueFromFdf
[FieldName
.strip(".")][2], Pcd
.PcdFieldValueFromFdf
[FieldName
.strip(".")][0]);
1686 FieldName_ori
= FieldName
.strip('.')
1687 while '[' in FieldName
:
1688 NewFieldName
= NewFieldName
+ FieldName
.split('[', 1)[0] + '[0]'
1689 ArrayIndex
= int(FieldName
.split('[', 1)[1].split(']', 1)[0])
1690 FieldName
= FieldName
.split(']', 1)[1]
1691 FieldName
= NewFieldName
+ FieldName
1692 while '[' in FieldName
:
1693 FieldName
= FieldName
.rsplit('[', 1)[0]
1694 CApp
= CApp
+ ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %s Value %s \n' % (Pcd
.DatumType
, FieldName
.strip("."), ArrayIndex
+ 1, Pcd
.PcdFieldValueFromFdf
[FieldName_ori
][1], Pcd
.PcdFieldValueFromFdf
[FieldName_ori
][2], Pcd
.PcdFieldValueFromFdf
[FieldName_ori
][0])
1695 if Pcd
.PcdFieldValueFromComm
:
1696 CApp
= CApp
+ "// From Command Line \n"
1697 for FieldName
in Pcd
.PcdFieldValueFromComm
:
1698 FieldName
= "." + FieldName
1699 IsArray
= IsFieldValueAnArray(Pcd
.PcdFieldValueFromComm
[FieldName
.strip(".")][0])
1700 if IsArray
and not (Pcd
.PcdFieldValueFromComm
[FieldName
.strip(".")][0].startswith('{GUID') and Pcd
.PcdFieldValueFromComm
[FieldName
.strip(".")][0].endswith('}')):
1702 Value
= ValueExpressionEx(Pcd
.PcdFieldValueFromComm
[FieldName
.strip(".")][0], TAB_VOID
, self
._GuidDict
)(True)
1703 except BadExpression
:
1704 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid value format for %s. From %s Line %d " %
1705 (".".join((Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldName
.strip('.'))), Pcd
.PcdFieldValueFromComm
[FieldName
.strip(".")][1], Pcd
.PcdFieldValueFromComm
[FieldName
.strip(".")][2]))
1706 Value
, ValueSize
= ParseFieldValue(Value
)
1707 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("."), Pcd
.PcdFieldValueFromComm
[FieldName
.strip(".")][1], Pcd
.PcdFieldValueFromComm
[FieldName
.strip(".")][2], Pcd
.PcdFieldValueFromComm
[FieldName
.strip(".")][0]);
1710 FieldName_ori
= FieldName
.strip('.')
1711 while '[' in FieldName
:
1712 NewFieldName
= NewFieldName
+ FieldName
.split('[', 1)[0] + '[0]'
1713 ArrayIndex
= int(FieldName
.split('[', 1)[1].split(']', 1)[0])
1714 FieldName
= FieldName
.split(']', 1)[1]
1715 FieldName
= NewFieldName
+ FieldName
1716 while '[' in FieldName
:
1717 FieldName
= FieldName
.rsplit('[', 1)[0]
1718 CApp
= CApp
+ ' __FLEXIBLE_SIZE(*Size, %s, %s, %d); // From %s Line %d Value %s \n' % (Pcd
.DatumType
, FieldName
.strip("."), ArrayIndex
+ 1, Pcd
.PcdFieldValueFromComm
[FieldName_ori
][1], Pcd
.PcdFieldValueFromComm
[FieldName_ori
][2], Pcd
.PcdFieldValueFromComm
[FieldName_ori
][0])
1719 CApp
= CApp
+ " *Size = (%d > *Size ? %d : *Size); // The Pcd maxsize is %d \n" % (Pcd
.GetPcdMaxSize(), Pcd
.GetPcdMaxSize(), Pcd
.GetPcdMaxSize())
1724 def GenerateSizeStatments(Pcd
):
1725 CApp
= ' Size = sizeof(%s);\n' % (Pcd
.DatumType
)
1726 CApp
= CApp
+ ' Cal_%s_%s_Size(&Size);\n' % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
1729 def GenerateDefaultValueAssignFunction(self
, Pcd
):
1730 CApp
= "// Default value in Dec \n"
1731 CApp
= CApp
+ "void Assign_%s_%s_Default_Value(%s *Pcd){\n" % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, Pcd
.DatumType
)
1732 CApp
= CApp
+ ' UINT32 FieldSize;\n'
1733 CApp
= CApp
+ ' CHAR8 *Value;\n'
1734 DefaultValueFromDec
= Pcd
.DefaultValueFromDec
1735 IsArray
= IsFieldValueAnArray(Pcd
.DefaultValueFromDec
)
1738 DefaultValueFromDec
= ValueExpressionEx(Pcd
.DefaultValueFromDec
, TAB_VOID
)(True)
1739 except BadExpression
:
1740 EdkLogger
.error("Build", FORMAT_INVALID
, "Invalid value format for %s.%s, from DEC: %s" %
1741 (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, DefaultValueFromDec
))
1742 DefaultValueFromDec
= StringToArray(DefaultValueFromDec
)
1743 Value
, ValueSize
= ParseFieldValue (DefaultValueFromDec
)
1744 if isinstance(Value
, str):
1745 CApp
= CApp
+ ' Pcd = %s; // From DEC Default Value %s\n' % (Value
, Pcd
.DefaultValueFromDec
)
1748 # Use memcpy() to copy value into field
1750 CApp
= CApp
+ ' Value = %s; // From DEC Default Value %s\n' % (DscBuildData
.IntToCString(Value
, ValueSize
), Pcd
.DefaultValueFromDec
)
1751 CApp
= CApp
+ ' memcpy (Pcd, Value, %d);\n' % (ValueSize
)
1752 for FieldList
in [Pcd
.DefaultValues
]:
1755 for FieldName
in FieldList
:
1756 IsArray
= IsFieldValueAnArray(FieldList
[FieldName
][0])
1759 FieldList
[FieldName
][0] = ValueExpressionEx(FieldList
[FieldName
][0], TAB_VOID
, self
._GuidDict
)(True)
1760 except BadExpression
:
1761 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid value format for %s. From %s Line %d " %
1762 (".".join((Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldName
)), FieldList
[FieldName
][1], FieldList
[FieldName
][2]))
1765 Value
, ValueSize
= ParseFieldValue (FieldList
[FieldName
][0])
1767 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]))
1768 if isinstance(Value
, str):
1769 CApp
= CApp
+ ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1772 # Use memcpy() to copy value into field
1774 CApp
= CApp
+ ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd
.DatumType
, FieldName
)
1775 CApp
= CApp
+ ' Value = %s; // From %s Line %d Value %s\n' % (DscBuildData
.IntToCString(Value
, ValueSize
), FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1776 CApp
= CApp
+ ' memcpy (&Pcd->%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName
, ValueSize
, ValueSize
)
1779 CApp
= CApp
+ ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1781 CApp
= CApp
+ ' Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1786 def GenerateDefaultValueAssignStatement(Pcd
):
1787 CApp
= ' Assign_%s_%s_Default_Value(Pcd);\n' % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
1790 def GenerateInitValueFunction(self
, Pcd
, SkuName
, DefaultStoreName
):
1791 CApp
= "// Value in Dsc for Sku: %s, DefaultStore %s\n" % (SkuName
, DefaultStoreName
)
1792 CApp
= CApp
+ "void Assign_%s_%s_%s_%s_Value(%s *Pcd){\n" % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, SkuName
, DefaultStoreName
, Pcd
.DatumType
)
1793 CApp
= CApp
+ ' UINT32 FieldSize;\n'
1794 CApp
= CApp
+ ' CHAR8 *Value;\n'
1796 CApp
= CApp
+ "// SkuName: %s, DefaultStoreName: %s \n" % (TAB_DEFAULT
, TAB_DEFAULT_STORES_DEFAULT
)
1797 inherit_OverrideValues
= Pcd
.SkuOverrideValues
[SkuName
]
1798 if (SkuName
, DefaultStoreName
) == (TAB_DEFAULT
, TAB_DEFAULT_STORES_DEFAULT
):
1799 pcddefaultvalue
= Pcd
.DefaultFromDSC
.get(TAB_DEFAULT
, {}).get(TAB_DEFAULT_STORES_DEFAULT
) if Pcd
.DefaultFromDSC
else None
1801 pcddefaultvalue
= Pcd
.DscRawValue
.get(SkuName
, {}).get(DefaultStoreName
)
1802 for FieldList
in [pcddefaultvalue
, inherit_OverrideValues
.get(DefaultStoreName
)]:
1805 if pcddefaultvalue
and FieldList
== pcddefaultvalue
:
1806 IsArray
= IsFieldValueAnArray(FieldList
)
1809 FieldList
= ValueExpressionEx(FieldList
, TAB_VOID
)(True)
1810 except BadExpression
:
1811 EdkLogger
.error("Build", FORMAT_INVALID
, "Invalid value format for %s.%s, from DSC: %s" %
1812 (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldList
))
1813 Value
, ValueSize
= ParseFieldValue (FieldList
)
1815 if (SkuName
, DefaultStoreName
) == (TAB_DEFAULT
, TAB_DEFAULT_STORES_DEFAULT
):
1816 if isinstance(Value
, str):
1817 CApp
= CApp
+ ' Pcd = %s; // From DSC Default Value %s\n' % (Value
, Pcd
.DefaultFromDSC
.get(TAB_DEFAULT
, {}).get(TAB_DEFAULT_STORES_DEFAULT
, Pcd
.DefaultValue
) if Pcd
.DefaultFromDSC
else Pcd
.DefaultValue
)
1820 # Use memcpy() to copy value into field
1822 CApp
= CApp
+ ' Value = %s; // From DSC Default Value %s\n' % (DscBuildData
.IntToCString(Value
, ValueSize
), Pcd
.DefaultFromDSC
.get(TAB_DEFAULT
, {}).get(TAB_DEFAULT_STORES_DEFAULT
, Pcd
.DefaultValue
) if Pcd
.DefaultFromDSC
else Pcd
.DefaultValue
)
1823 CApp
= CApp
+ ' memcpy (Pcd, Value, %d);\n' % (ValueSize
)
1825 if isinstance(Value
, str):
1826 CApp
= CApp
+ ' Pcd = %s; // From DSC Default Value %s\n' % (Value
, Pcd
.DscRawValue
.get(SkuName
, {}).get(DefaultStoreName
))
1829 # Use memcpy() to copy value into field
1831 CApp
= CApp
+ ' Value = %s; // From DSC Default Value %s\n' % (DscBuildData
.IntToCString(Value
, ValueSize
), Pcd
.DscRawValue
.get(SkuName
, {}).get(DefaultStoreName
))
1832 CApp
= CApp
+ ' memcpy (Pcd, Value, %d);\n' % (ValueSize
)
1834 if (SkuName
, DefaultStoreName
) == (TAB_DEFAULT
, TAB_DEFAULT_STORES_DEFAULT
) or (( (SkuName
, '') not in Pcd
.ValueChain
) and ( (SkuName
, DefaultStoreName
) not in Pcd
.ValueChain
)):
1835 for FieldName
in FieldList
:
1836 IsArray
= IsFieldValueAnArray(FieldList
[FieldName
][0])
1839 FieldList
[FieldName
][0] = ValueExpressionEx(FieldList
[FieldName
][0], TAB_VOID
, self
._GuidDict
)(True)
1840 except BadExpression
:
1841 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid value format for %s. From %s Line %d " %
1842 (".".join((Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldName
)), FieldList
[FieldName
][1], FieldList
[FieldName
][2]))
1844 Value
, ValueSize
= ParseFieldValue (FieldList
[FieldName
][0])
1846 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]))
1847 if isinstance(Value
, str):
1848 CApp
= CApp
+ ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1851 # Use memcpy() to copy value into field
1853 CApp
= CApp
+ ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd
.DatumType
, FieldName
)
1854 CApp
= CApp
+ ' Value = %s; // From %s Line %d Value %s\n' % (DscBuildData
.IntToCString(Value
, ValueSize
), FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1855 CApp
= CApp
+ ' memcpy (&Pcd->%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName
, ValueSize
, ValueSize
)
1858 CApp
= CApp
+ ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1860 CApp
= CApp
+ ' Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1865 def GenerateInitValueStatement(Pcd
, SkuName
, DefaultStoreName
):
1866 CApp
= ' Assign_%s_%s_%s_%s_Value(Pcd);\n' % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, SkuName
, DefaultStoreName
)
1869 def GenerateCommandLineValue(self
, Pcd
):
1870 CApp
= "// Value in CommandLine\n"
1871 CApp
= CApp
+ "void Assign_%s_%s_CommandLine_Value(%s *Pcd){\n" % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, Pcd
.DatumType
)
1872 CApp
= CApp
+ ' UINT32 FieldSize;\n'
1873 CApp
= CApp
+ ' CHAR8 *Value;\n'
1875 pcddefaultvalue
= Pcd
.PcdValueFromComm
1876 for FieldList
in [pcddefaultvalue
, Pcd
.PcdFieldValueFromComm
]:
1879 if pcddefaultvalue
and FieldList
== pcddefaultvalue
:
1880 IsArray
= IsFieldValueAnArray(FieldList
)
1883 FieldList
= ValueExpressionEx(FieldList
, TAB_VOID
)(True)
1884 except BadExpression
:
1885 EdkLogger
.error("Build", FORMAT_INVALID
, "Invalid value format for %s.%s, from Command: %s" %
1886 (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldList
))
1887 Value
, ValueSize
= ParseFieldValue (FieldList
)
1889 if isinstance(Value
, str):
1890 CApp
= CApp
+ ' Pcd = %s; // From Command Line \n' % (Value
)
1893 # Use memcpy() to copy value into field
1895 CApp
= CApp
+ ' Value = %s; // From Command Line.\n' % (DscBuildData
.IntToCString(Value
, ValueSize
))
1896 CApp
= CApp
+ ' memcpy (Pcd, Value, %d);\n' % (ValueSize
)
1898 for FieldName
in FieldList
:
1899 IsArray
= IsFieldValueAnArray(FieldList
[FieldName
][0])
1902 FieldList
[FieldName
][0] = ValueExpressionEx(FieldList
[FieldName
][0], TAB_VOID
, self
._GuidDict
)(True)
1903 except BadExpression
:
1904 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid value format for %s. From %s Line %d " %
1905 (".".join((Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldName
)), FieldList
[FieldName
][1], FieldList
[FieldName
][2]))
1909 Value
, ValueSize
= ParseFieldValue (FieldList
[FieldName
][0])
1911 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]))
1912 if isinstance(Value
, str):
1913 CApp
= CApp
+ ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1916 # Use memcpy() to copy value into field
1918 CApp
= CApp
+ ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd
.DatumType
, FieldName
)
1919 CApp
= CApp
+ ' Value = %s; // From %s Line %d Value %s\n' % (DscBuildData
.IntToCString(Value
, ValueSize
), FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1920 CApp
= CApp
+ ' memcpy (&Pcd->%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName
, ValueSize
, ValueSize
)
1923 CApp
= CApp
+ ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1925 CApp
= CApp
+ ' Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1930 def GenerateCommandLineValueStatement(Pcd
):
1931 CApp
= ' Assign_%s_%s_CommandLine_Value(Pcd);\n' % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
1933 def GenerateFdfValue(self
,Pcd
):
1934 CApp
= "// Value in Fdf\n"
1935 CApp
= CApp
+ "void Assign_%s_%s_Fdf_Value(%s *Pcd){\n" % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
,Pcd
.DatumType
)
1936 CApp
= CApp
+ ' UINT32 FieldSize;\n'
1937 CApp
= CApp
+ ' CHAR8 *Value;\n'
1939 pcddefaultvalue
= Pcd
.PcdValueFromFdf
1940 for FieldList
in [pcddefaultvalue
,Pcd
.PcdFieldValueFromFdf
]:
1943 if pcddefaultvalue
and FieldList
== pcddefaultvalue
:
1944 IsArray
= IsFieldValueAnArray(FieldList
)
1947 FieldList
= ValueExpressionEx(FieldList
, TAB_VOID
)(True)
1948 except BadExpression
:
1949 EdkLogger
.error("Build", FORMAT_INVALID
, "Invalid value format for %s.%s, from Fdf: %s" %
1950 (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldList
))
1951 Value
, ValueSize
= ParseFieldValue (FieldList
)
1953 if isinstance(Value
, str):
1954 CApp
= CApp
+ ' Pcd = %s; // From Fdf \n' % (Value
)
1957 # Use memcpy() to copy value into field
1959 CApp
= CApp
+ ' Value = %s; // From Fdf .\n' % (DscBuildData
.IntToCString(Value
, ValueSize
))
1960 CApp
= CApp
+ ' memcpy (Pcd, Value, %d);\n' % (ValueSize
)
1962 for FieldName
in FieldList
:
1963 IsArray
= IsFieldValueAnArray(FieldList
[FieldName
][0])
1966 FieldList
[FieldName
][0] = ValueExpressionEx(FieldList
[FieldName
][0], TAB_VOID
, self
._GuidDict
)(True)
1967 except BadExpression
:
1968 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid value format for %s. From %s Line %d " %
1969 (".".join((Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldName
)), FieldList
[FieldName
][1], FieldList
[FieldName
][2]))
1973 Value
, ValueSize
= ParseFieldValue (FieldList
[FieldName
][0])
1975 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]))
1976 if isinstance(Value
, str):
1977 CApp
= CApp
+ ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1980 # Use memcpy() to copy value into field
1982 CApp
= CApp
+ ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd
.DatumType
, FieldName
)
1983 CApp
= CApp
+ ' Value = %s; // From %s Line %d Value %s\n' % (DscBuildData
.IntToCString(Value
, ValueSize
), FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1984 CApp
= CApp
+ ' memcpy (&Pcd->%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName
, ValueSize
, ValueSize
)
1987 CApp
= CApp
+ ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1989 CApp
= CApp
+ ' Pcd->%s = %d; // From %s Line %s Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1994 def GenerateFdfValueStatement(Pcd
):
1995 CApp
= ' Assign_%s_%s_Fdf_Value(Pcd);\n' % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
1998 def GenerateInitializeFunc(self
, SkuName
, DefaultStore
, Pcd
, InitByteValue
, CApp
):
1999 OverrideValues
= {DefaultStore
:""}
2000 if Pcd
.SkuOverrideValues
:
2001 OverrideValues
= Pcd
.SkuOverrideValues
[SkuName
]
2002 if not OverrideValues
:
2003 OverrideValues
= {TAB_DEFAULT_STORES_DEFAULT
:Pcd
.DefaultValues
}
2004 for DefaultStoreName
in OverrideValues
:
2005 CApp
= CApp
+ 'void\n'
2006 CApp
= CApp
+ 'Initialize_%s_%s_%s_%s(\n' % (SkuName
, DefaultStoreName
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
2007 CApp
= CApp
+ ' void\n'
2008 CApp
= CApp
+ ' )\n'
2010 CApp
= CApp
+ ' UINT32 Size;\n'
2011 CApp
= CApp
+ ' UINT32 FieldSize;\n'
2012 CApp
= CApp
+ ' CHAR8 *Value;\n'
2013 CApp
= CApp
+ ' UINT32 OriginalSize;\n'
2014 CApp
= CApp
+ ' VOID *OriginalPcd;\n'
2015 CApp
= CApp
+ ' %s *Pcd; // From %s Line %d \n' % (Pcd
.DatumType
, Pcd
.PkgPath
, Pcd
.PcdDefineLineNo
)
2018 if SkuName
in Pcd
.SkuInfoList
:
2019 DefaultValue
= Pcd
.SkuInfoList
[SkuName
].DefaultStoreDict
.get(DefaultStoreName
, Pcd
.SkuInfoList
[SkuName
].HiiDefaultValue
if Pcd
.SkuInfoList
[SkuName
].HiiDefaultValue
else Pcd
.SkuInfoList
[SkuName
].DefaultValue
)
2021 DefaultValue
= Pcd
.DefaultValue
2022 PcdDefaultValue
= StringToArray(DefaultValue
.strip())
2024 InitByteValue
+= '%s.%s.%s.%s|%s|%s\n' % (SkuName
, DefaultStoreName
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, Pcd
.DatumType
, PcdDefaultValue
)
2027 # Get current PCD value and size
2029 CApp
= CApp
+ ' OriginalPcd = PcdGetPtr (%s, %s, %s, %s, &OriginalSize);\n' % (SkuName
, DefaultStoreName
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
2032 # Determine the size of the PCD. For simple structures, sizeof(TYPE) provides
2033 # the correct value. For structures with a flexible array member, the flexible
2034 # array member is detected, and the size is based on the highest index used with
2035 # the flexible array member. The flexible array member must be the last field
2036 # in a structure. The size formula for this case is:
2037 # OFFSET_OF(FlexbleArrayField) + sizeof(FlexibleArray[0]) * (HighestIndex + 1)
2039 CApp
= CApp
+ DscBuildData
.GenerateSizeStatments(Pcd
)
2042 # Allocate and zero buffer for the PCD
2043 # Must handle cases where current value is smaller, larger, or same size
2044 # Always keep that larger one as the current size
2046 CApp
= CApp
+ ' Size = (OriginalSize > Size ? OriginalSize : Size);\n'
2047 CApp
= CApp
+ ' Pcd = (%s *)malloc (Size);\n' % (Pcd
.DatumType
)
2048 CApp
= CApp
+ ' memset (Pcd, 0, Size);\n'
2051 # Copy current PCD value into allocated buffer.
2053 CApp
= CApp
+ ' memcpy (Pcd, OriginalPcd, OriginalSize);\n'
2056 # Assign field values in PCD
2058 CApp
= CApp
+ DscBuildData
.GenerateDefaultValueAssignStatement(Pcd
)
2059 if Pcd
.Type
not in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FIXED_AT_BUILD
],
2060 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_PATCHABLE_IN_MODULE
]]:
2061 for skuname
in self
.SkuIdMgr
.GetSkuChain(SkuName
):
2062 storeset
= [DefaultStoreName
] if DefaultStoreName
== TAB_DEFAULT_STORES_DEFAULT
else [TAB_DEFAULT_STORES_DEFAULT
, DefaultStoreName
]
2063 for defaultstorenameitem
in storeset
:
2064 CApp
= CApp
+ "// SkuName: %s, DefaultStoreName: %s \n" % (skuname
, defaultstorenameitem
)
2065 CApp
= CApp
+ DscBuildData
.GenerateInitValueStatement(Pcd
, skuname
, defaultstorenameitem
)
2066 if skuname
== SkuName
:
2069 CApp
= CApp
+ "// SkuName: %s, DefaultStoreName: STANDARD \n" % self
.SkuIdMgr
.SystemSkuId
2070 CApp
= CApp
+ DscBuildData
.GenerateInitValueStatement(Pcd
, self
.SkuIdMgr
.SystemSkuId
, TAB_DEFAULT_STORES_DEFAULT
)
2071 CApp
= CApp
+ DscBuildData
.GenerateFdfValueStatement(Pcd
)
2072 CApp
= CApp
+ DscBuildData
.GenerateCommandLineValueStatement(Pcd
)
2074 # Set new PCD value and size
2076 CApp
= CApp
+ ' PcdSetPtr (%s, %s, %s, %s, Size, (UINT8 *)Pcd);\n' % (SkuName
, DefaultStoreName
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
2081 CApp
= CApp
+ ' free (Pcd);\n'
2084 return InitByteValue
, CApp
2085 def SkuOverrideValuesEmpty(self
,OverrideValues
):
2086 if not OverrideValues
:
2088 for key
in OverrideValues
:
2089 if OverrideValues
[key
]:
2093 def GenerateByteArrayValue (self
, StructuredPcds
):
2095 # Generate/Compile/Run C application to determine if there are any flexible array members
2097 if not StructuredPcds
:
2101 CApp
= PcdMainCHeader
2103 IncludeFiles
= set()
2104 for PcdName
in StructuredPcds
:
2105 Pcd
= StructuredPcds
[PcdName
]
2106 for IncludeFile
in Pcd
.StructuredPcdIncludeFile
:
2107 if IncludeFile
not in IncludeFiles
:
2108 IncludeFiles
.add(IncludeFile
)
2109 CApp
= CApp
+ '#include <%s>\n' % (IncludeFile
)
2111 for PcdName
in StructuredPcds
:
2112 Pcd
= StructuredPcds
[PcdName
]
2113 CApp
= CApp
+ self
.GenerateSizeFunction(Pcd
)
2114 CApp
= CApp
+ self
.GenerateDefaultValueAssignFunction(Pcd
)
2115 CApp
= CApp
+ self
.GenerateFdfValue(Pcd
)
2116 CApp
= CApp
+ self
.GenerateCommandLineValue(Pcd
)
2117 if self
.SkuOverrideValuesEmpty(Pcd
.SkuOverrideValues
) or Pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FIXED_AT_BUILD
],
2118 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_PATCHABLE_IN_MODULE
]]:
2119 CApp
= CApp
+ self
.GenerateInitValueFunction(Pcd
, self
.SkuIdMgr
.SystemSkuId
, TAB_DEFAULT_STORES_DEFAULT
)
2121 for SkuName
in self
.SkuIdMgr
.SkuOverrideOrder():
2122 if SkuName
not in Pcd
.SkuOverrideValues
:
2124 for DefaultStoreName
in Pcd
.SkuOverrideValues
[SkuName
]:
2125 CApp
= CApp
+ self
.GenerateInitValueFunction(Pcd
, SkuName
, DefaultStoreName
)
2126 if self
.SkuOverrideValuesEmpty(Pcd
.SkuOverrideValues
) or Pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FIXED_AT_BUILD
],
2127 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_PATCHABLE_IN_MODULE
]]:
2128 InitByteValue
, CApp
= self
.GenerateInitializeFunc(self
.SkuIdMgr
.SystemSkuId
, TAB_DEFAULT_STORES_DEFAULT
, Pcd
, InitByteValue
, CApp
)
2130 for SkuName
in self
.SkuIdMgr
.SkuOverrideOrder():
2131 if SkuName
not in Pcd
.SkuOverrideValues
:
2133 for DefaultStoreName
in Pcd
.DefaultStoreName
:
2134 Pcd
= StructuredPcds
[PcdName
]
2135 InitByteValue
, CApp
= self
.GenerateInitializeFunc(SkuName
, DefaultStoreName
, Pcd
, InitByteValue
, CApp
)
2137 CApp
= CApp
+ 'VOID\n'
2138 CApp
= CApp
+ 'PcdEntryPoint(\n'
2139 CApp
= CApp
+ ' VOID\n'
2140 CApp
= CApp
+ ' )\n'
2142 for Pcd
in StructuredPcds
.values():
2143 if self
.SkuOverrideValuesEmpty(Pcd
.SkuOverrideValues
) or Pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FIXED_AT_BUILD
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_PATCHABLE_IN_MODULE
]]:
2144 CApp
= CApp
+ ' Initialize_%s_%s_%s_%s();\n' % (self
.SkuIdMgr
.SystemSkuId
, TAB_DEFAULT_STORES_DEFAULT
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
2146 for SkuName
in self
.SkuIdMgr
.SkuOverrideOrder():
2147 if SkuName
not in self
.SkuIdMgr
.AvailableSkuIdSet
:
2149 for DefaultStoreName
in Pcd
.SkuOverrideValues
[SkuName
]:
2150 CApp
= CApp
+ ' Initialize_%s_%s_%s_%s();\n' % (SkuName
, DefaultStoreName
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
2153 CApp
= CApp
+ PcdMainCEntry
+ '\n'
2155 if not os
.path
.exists(self
.OutputPath
):
2156 os
.makedirs(self
.OutputPath
)
2157 CAppBaseFileName
= os
.path
.join(self
.OutputPath
, PcdValueInitName
)
2158 SaveFileOnChange(CAppBaseFileName
+ '.c', CApp
, False)
2160 MakeApp
= PcdMakefileHeader
2161 if sys
.platform
== "win32":
2162 MakeApp
= MakeApp
+ 'APPNAME = %s\n' % (PcdValueInitName
) + 'OBJECTS = %s\%s.obj\n' % (self
.OutputPath
, PcdValueInitName
) + 'INC = '
2164 MakeApp
= MakeApp
+ PcdGccMakefile
2165 MakeApp
= MakeApp
+ 'APPNAME = %s\n' % (PcdValueInitName
) + 'OBJECTS = %s/%s.o\n' % (self
.OutputPath
, PcdValueInitName
) + \
2166 'include $(MAKEROOT)/Makefiles/app.makefile\n' + 'INCLUDE +='
2170 for Cache
in self
._Bdb
._CACHE
_.values():
2171 if Cache
.MetaFile
.Ext
.lower() != '.dec':
2174 if str(Cache
.MetaFile
.Path
) not in PlatformInc
:
2175 PlatformInc
[str(Cache
.MetaFile
.Path
)] = []
2176 PlatformInc
[str(Cache
.MetaFile
.Path
)].append (os
.path
.dirname(Cache
.MetaFile
.Path
))
2177 PlatformInc
[str(Cache
.MetaFile
.Path
)].extend (Cache
.CommonIncludes
)
2180 for Pcd
in StructuredPcds
.values():
2181 for PackageDec
in Pcd
.PackageDecs
:
2182 Package
= os
.path
.normpath(mws
.join(GlobalData
.gWorkspace
, PackageDec
))
2183 if not os
.path
.exists(Package
):
2184 EdkLogger
.error('Build', RESOURCE_NOT_AVAILABLE
, "The dependent Package %s of PCD %s.%s is not exist." % (PackageDec
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
))
2185 if Package
not in PcdDependDEC
:
2186 PcdDependDEC
.append(Package
)
2188 if PlatformInc
and PcdDependDEC
:
2189 for pkg
in PcdDependDEC
:
2190 if pkg
in PlatformInc
:
2191 for inc
in PlatformInc
[pkg
]:
2192 MakeApp
+= '-I' + str(inc
) + ' '
2193 IncSearchList
.append(inc
)
2194 MakeApp
= MakeApp
+ '\n'
2196 CC_FLAGS
= LinuxCFLAGS
2197 if sys
.platform
== "win32":
2198 CC_FLAGS
= WindowsCFLAGS
2200 for Options
in self
.BuildOptions
:
2201 if Options
[2] != EDKII_NAME
:
2204 if Family
and Family
!= self
.ToolChainFamily
:
2206 Target
, Tag
, Arch
, Tool
, Attr
= Options
[1].split("_")
2210 if Target
== "*" or Target
== self
._Target
:
2211 if Tag
== "*" or Tag
== self
._Toolchain
:
2212 if Arch
== "*" or Arch
== self
.Arch
:
2213 if Tool
not in BuildOptions
:
2214 BuildOptions
[Tool
] = {}
2215 if Attr
!= "FLAGS" or Attr
not in BuildOptions
[Tool
] or self
.BuildOptions
[Options
].startswith('='):
2216 BuildOptions
[Tool
][Attr
] = self
.BuildOptions
[Options
]
2218 # append options for the same tool except PATH
2220 BuildOptions
[Tool
][Attr
] += " " + self
.BuildOptions
[Options
]
2222 BuildOptions
[Tool
][Attr
] = self
.BuildOptions
[Options
]
2224 for Tool
in BuildOptions
:
2225 for Attr
in BuildOptions
[Tool
]:
2227 Value
= BuildOptions
[Tool
][Attr
]
2228 ValueList
= Value
.split()
2230 for Id
, Item
in enumerate(ValueList
):
2231 if Item
in ['-D', '/D', '-U', '/U']:
2232 CC_FLAGS
+= ' ' + Item
2233 if Id
+ 1 < len(ValueList
):
2234 CC_FLAGS
+= ' ' + ValueList
[Id
+ 1]
2235 elif Item
.startswith(('-D', '/D', '-U', '/U')):
2236 CC_FLAGS
+= ' ' + Item
2239 if sys
.platform
== "win32":
2240 MakeApp
= MakeApp
+ PcdMakefileEnd
2241 MakeApp
= MakeApp
+ '\n'
2242 IncludeFileFullPaths
= []
2243 for includefile
in IncludeFiles
:
2244 for includepath
in IncSearchList
:
2245 includefullpath
= os
.path
.join(str(includepath
), includefile
)
2246 if os
.path
.exists(includefullpath
):
2247 IncludeFileFullPaths
.append(os
.path
.normpath(includefullpath
))
2250 SearchPathList
.append(os
.path
.normpath(mws
.join(GlobalData
.gWorkspace
, "BaseTools/Source/C/Include")))
2251 SearchPathList
.append(os
.path
.normpath(mws
.join(GlobalData
.gWorkspace
, "BaseTools/Source/C/Common")))
2252 SearchPathList
.extend(str(item
) for item
in IncSearchList
)
2253 IncFileList
= GetDependencyList(IncludeFileFullPaths
, SearchPathList
)
2254 for include_file
in IncFileList
:
2255 MakeApp
+= "$(OBJECTS) : %s\n" % include_file
2256 MakeFileName
= os
.path
.join(self
.OutputPath
, 'Makefile')
2257 MakeApp
+= "$(OBJECTS) : %s\n" % MakeFileName
2258 SaveFileOnChange(MakeFileName
, MakeApp
, False)
2260 InputValueFile
= os
.path
.join(self
.OutputPath
, 'Input.txt')
2261 OutputValueFile
= os
.path
.join(self
.OutputPath
, 'Output.txt')
2262 SaveFileOnChange(InputValueFile
, InitByteValue
, False)
2264 PcdValueInitExe
= PcdValueInitName
2265 if not sys
.platform
== "win32":
2266 PcdValueInitExe
= os
.path
.join(os
.getenv("EDK_TOOLS_PATH"), 'Source', 'C', 'bin', PcdValueInitName
)
2268 PcdValueInitExe
= os
.path
.join(os
.getenv("EDK_TOOLS_PATH"), 'Bin', 'Win32', PcdValueInitName
) +".exe"
2271 if sys
.platform
== "win32":
2272 MakeCommand
= 'nmake -f %s' % (MakeFileName
)
2273 returncode
, StdOut
, StdErr
= DscBuildData
.ExecuteCommand (MakeCommand
)
2276 MakeCommand
= 'make -f %s' % (MakeFileName
)
2277 returncode
, StdOut
, StdErr
= DscBuildData
.ExecuteCommand (MakeCommand
)
2279 Messages
= Messages
.split('\n')
2282 CAppBaseFileName
= os
.path
.join(self
.OutputPath
, PcdValueInitName
)
2283 File
= open (CAppBaseFileName
+ '.c', 'r')
2284 FileData
= File
.readlines()
2286 for Message
in Messages
:
2287 if " error" in Message
or "warning" in Message
:
2288 FileInfo
= Message
.strip().split('(')
2289 if len (FileInfo
) > 1:
2290 FileName
= FileInfo
[0]
2291 FileLine
= FileInfo
[1].split (')')[0]
2293 FileInfo
= Message
.strip().split(':')
2294 FileName
= FileInfo
[0]
2295 FileLine
= FileInfo
[1]
2296 if FileLine
.isdigit():
2297 error_line
= FileData
[int (FileLine
) - 1]
2298 if r
"//" in error_line
:
2299 c_line
, dsc_line
= error_line
.split(r
"//")
2301 dsc_line
= error_line
2302 message_itmes
= Message
.split(":")
2304 if "PcdValueInit.c" not in Message
:
2305 if not MessageGroup
:
2306 MessageGroup
.append(Message
)
2309 for item
in message_itmes
:
2310 if "PcdValueInit.c" in item
:
2311 Index
= message_itmes
.index(item
)
2312 message_itmes
[Index
] = dsc_line
.strip()
2314 MessageGroup
.append(":".join(message_itmes
[Index
:]).strip())
2317 MessageGroup
.append(Message
)
2319 EdkLogger
.error("build", PCD_STRUCTURE_PCD_ERROR
, "\n".join(MessageGroup
) )
2321 EdkLogger
.error('Build', COMMAND_FAILURE
, 'Can not execute command: %s' % MakeCommand
)
2323 if DscBuildData
.NeedUpdateOutput(OutputValueFile
, PcdValueInitExe
, InputValueFile
):
2324 Command
= PcdValueInitExe
+ ' -i %s -o %s' % (InputValueFile
, OutputValueFile
)
2325 returncode
, StdOut
, StdErr
= DscBuildData
.ExecuteCommand (Command
)
2327 EdkLogger
.warn('Build', COMMAND_FAILURE
, 'Can not collect output from command: %s' % Command
)
2329 File
= open (OutputValueFile
, 'r')
2330 FileBuffer
= File
.readlines()
2333 StructurePcdSet
= []
2334 for Pcd
in FileBuffer
:
2335 PcdValue
= Pcd
.split ('|')
2336 PcdInfo
= PcdValue
[0].split ('.')
2337 StructurePcdSet
.append((PcdInfo
[0], PcdInfo
[1], PcdInfo
[2], PcdInfo
[3], PcdValue
[2].strip()))
2338 return StructurePcdSet
2341 def NeedUpdateOutput(OutputFile
, ValueCFile
, StructureInput
):
2342 if not os
.path
.exists(OutputFile
):
2344 if os
.stat(OutputFile
).st_mtime
<= os
.stat(ValueCFile
).st_mtime
:
2346 if os
.stat(OutputFile
).st_mtime
<= os
.stat(StructureInput
).st_mtime
:
2350 ## Retrieve dynamic PCD settings
2352 # @param Type PCD type
2354 # @retval a dict object contains settings of given PCD type
2356 def _GetDynamicPcd(self
, Type
):
2359 Pcds
= OrderedDict()
2361 # tdict is a special dict kind of type, used for selecting correct
2362 # PCD settings for certain ARCH and SKU
2364 PcdDict
= tdict(True, 4)
2366 # Find out all possible PCD candidates for self._Arch
2367 RecordList
= self
._RawData
[Type
, self
._Arch
]
2368 AvailableSkuIdSet
= copy
.copy(self
.SkuIds
)
2371 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, SkuName
, Dummy3
, Dummy4
, Dummy5
in RecordList
:
2372 SkuName
= SkuName
.upper()
2373 SkuName
= TAB_DEFAULT
if SkuName
== TAB_COMMON
else SkuName
2374 if SkuName
not in AvailableSkuIdSet
:
2375 EdkLogger
.error('build', PARAMETER_INVALID
, 'Sku %s is not defined in [SkuIds] section' % SkuName
,
2376 File
=self
.MetaFile
, Line
=Dummy5
)
2377 if "." not in TokenSpaceGuid
:
2378 PcdList
.append((PcdCName
, TokenSpaceGuid
, SkuName
, Dummy5
))
2379 PcdDict
[Arch
, SkuName
, PcdCName
, TokenSpaceGuid
] = Setting
2381 # Remove redundant PCD candidates, per the ARCH and SKU
2382 for PcdCName
, TokenSpaceGuid
, SkuName
, Dummy4
in PcdList
:
2384 Setting
= PcdDict
[self
._Arch
, SkuName
, PcdCName
, TokenSpaceGuid
]
2388 PcdValue
, DatumType
, MaxDatumSize
= self
._ValidatePcd
(PcdCName
, TokenSpaceGuid
, Setting
, Type
, Dummy4
)
2390 if int(MaxDatumSize
, 0) > 0xFFFF:
2391 EdkLogger
.error('build', FORMAT_INVALID
, "The size value must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join((TokenSpaceGuid
, PcdCName
)),
2392 File
=self
.MetaFile
, Line
=Dummy4
)
2393 if int(MaxDatumSize
, 0) < 0:
2394 EdkLogger
.error('build', FORMAT_INVALID
, "The size value can't be set to negative value for %s." % ".".join((TokenSpaceGuid
, PcdCName
)),
2395 File
=self
.MetaFile
, Line
=Dummy4
)
2396 SkuInfo
= SkuInfoClass(SkuName
, self
.SkuIds
[SkuName
][0], '', '', '', '', '', PcdValue
)
2397 if (PcdCName
, TokenSpaceGuid
) in Pcds
:
2398 pcdObject
= Pcds
[PcdCName
, TokenSpaceGuid
]
2399 pcdObject
.SkuInfoList
[SkuName
] = SkuInfo
2400 if MaxDatumSize
.strip():
2401 CurrentMaxSize
= int(MaxDatumSize
.strip(), 0)
2404 if pcdObject
.MaxDatumSize
:
2405 PcdMaxSize
= int(pcdObject
.MaxDatumSize
, 0)
2408 if CurrentMaxSize
> PcdMaxSize
:
2409 pcdObject
.MaxDatumSize
= str(CurrentMaxSize
)
2411 Pcds
[PcdCName
, TokenSpaceGuid
] = PcdClassObject(
2414 self
._PCD
_TYPE
_STRING
_[Type
],
2419 {SkuName
: SkuInfo
},
2424 if SkuName
not in Pcds
[PcdCName
, TokenSpaceGuid
].DscRawValue
:
2425 Pcds
[PcdCName
, TokenSpaceGuid
].DscRawValue
[SkuName
] = {}
2426 Pcds
[PcdCName
, TokenSpaceGuid
].DscRawValue
[SkuName
][TAB_DEFAULT_STORES_DEFAULT
] = PcdValue
2428 for pcd
in Pcds
.values():
2429 pcdDecObject
= self
._DecPcds
[pcd
.TokenCName
, pcd
.TokenSpaceGuidCName
]
2430 # Only fix the value while no value provided in DSC file.
2431 for sku
in pcd
.SkuInfoList
.values():
2432 if not sku
.DefaultValue
:
2433 sku
.DefaultValue
= pcdDecObject
.DefaultValue
2434 if TAB_DEFAULT
not in pcd
.SkuInfoList
and TAB_COMMON
not in pcd
.SkuInfoList
:
2435 valuefromDec
= pcdDecObject
.DefaultValue
2436 SkuInfo
= SkuInfoClass(TAB_DEFAULT
, '0', '', '', '', '', '', valuefromDec
)
2437 pcd
.SkuInfoList
[TAB_DEFAULT
] = SkuInfo
2438 elif TAB_DEFAULT
not in pcd
.SkuInfoList
and TAB_COMMON
in pcd
.SkuInfoList
:
2439 pcd
.SkuInfoList
[TAB_DEFAULT
] = pcd
.SkuInfoList
[TAB_COMMON
]
2440 del pcd
.SkuInfoList
[TAB_COMMON
]
2441 elif TAB_DEFAULT
in pcd
.SkuInfoList
and TAB_COMMON
in pcd
.SkuInfoList
:
2442 del pcd
.SkuInfoList
[TAB_COMMON
]
2444 map(self
.FilterSkuSettings
, Pcds
.values())
2448 def FilterSkuSettings(self
, PcdObj
):
2450 if self
.SkuIdMgr
.SkuUsageType
== self
.SkuIdMgr
.SINGLE
:
2451 if TAB_DEFAULT
in PcdObj
.SkuInfoList
and self
.SkuIdMgr
.SystemSkuId
not in PcdObj
.SkuInfoList
:
2452 PcdObj
.SkuInfoList
[self
.SkuIdMgr
.SystemSkuId
] = PcdObj
.SkuInfoList
[TAB_DEFAULT
]
2453 PcdObj
.SkuInfoList
= {TAB_DEFAULT
:PcdObj
.SkuInfoList
[self
.SkuIdMgr
.SystemSkuId
]}
2454 PcdObj
.SkuInfoList
[TAB_DEFAULT
].SkuIdName
= TAB_DEFAULT
2455 PcdObj
.SkuInfoList
[TAB_DEFAULT
].SkuId
= '0'
2457 elif self
.SkuIdMgr
.SkuUsageType
== self
.SkuIdMgr
.DEFAULT
:
2458 PcdObj
.SkuInfoList
= {TAB_DEFAULT
:PcdObj
.SkuInfoList
[TAB_DEFAULT
]}
2463 def CompareVarAttr(Attr1
, Attr2
):
2464 if not Attr1
or not Attr2
: # for empty string
2466 Attr1s
= [attr
.strip() for attr
in Attr1
.split(",")]
2467 Attr1Set
= set(Attr1s
)
2468 Attr2s
= [attr
.strip() for attr
in Attr2
.split(",")]
2469 Attr2Set
= set(Attr2s
)
2470 if Attr2Set
== Attr1Set
:
2475 def CompletePcdValues(self
, PcdSet
):
2477 DefaultStoreObj
= DefaultStore(self
._GetDefaultStores
())
2478 SkuIds
= {skuname
:skuid
for skuname
, skuid
in self
.SkuIdMgr
.AvailableSkuIdSet
.items() if skuname
!= TAB_COMMON
}
2479 DefaultStores
= set(storename
for pcdobj
in PcdSet
.values() for skuobj
in pcdobj
.SkuInfoList
.values() for storename
in skuobj
.DefaultStoreDict
)
2480 for PcdCName
, TokenSpaceGuid
in PcdSet
:
2481 PcdObj
= PcdSet
[(PcdCName
, TokenSpaceGuid
)]
2483 if PcdObj
.Type
not in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_DEFAULT
],
2484 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
],
2485 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_VPD
],
2486 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_DEFAULT
],
2487 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
],
2488 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_VPD
]]:
2489 Pcds
[PcdCName
, TokenSpaceGuid
]= PcdObj
2491 PcdType
= PcdObj
.Type
2492 if PcdType
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
2493 for skuid
in PcdObj
.SkuInfoList
:
2494 skuobj
= PcdObj
.SkuInfoList
[skuid
]
2495 mindefaultstorename
= DefaultStoreObj
.GetMin(set(defaultstorename
for defaultstorename
in skuobj
.DefaultStoreDict
))
2496 for defaultstorename
in DefaultStores
:
2497 if defaultstorename
not in skuobj
.DefaultStoreDict
:
2498 skuobj
.DefaultStoreDict
[defaultstorename
] = copy
.deepcopy(skuobj
.DefaultStoreDict
[mindefaultstorename
])
2499 skuobj
.HiiDefaultValue
= skuobj
.DefaultStoreDict
[mindefaultstorename
]
2500 for skuname
, skuid
in SkuIds
.items():
2501 if skuname
not in PcdObj
.SkuInfoList
:
2502 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(skuname
)
2503 while nextskuid
not in PcdObj
.SkuInfoList
:
2504 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(nextskuid
)
2505 PcdObj
.SkuInfoList
[skuname
] = copy
.deepcopy(PcdObj
.SkuInfoList
[nextskuid
])
2506 PcdObj
.SkuInfoList
[skuname
].SkuId
= skuid
2507 PcdObj
.SkuInfoList
[skuname
].SkuIdName
= skuname
2508 if PcdType
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
2509 PcdObj
.DefaultValue
= PcdObj
.SkuInfoList
.values()[0].HiiDefaultValue
if self
.SkuIdMgr
.SkuUsageType
== self
.SkuIdMgr
.SINGLE
else PcdObj
.SkuInfoList
[TAB_DEFAULT
].HiiDefaultValue
2510 Pcds
[PcdCName
, TokenSpaceGuid
]= PcdObj
2512 ## Retrieve dynamic HII PCD settings
2514 # @param Type PCD type
2516 # @retval a dict object contains settings of given PCD type
2518 def _GetDynamicHiiPcd(self
, Type
):
2522 Pcds
= OrderedDict()
2523 UserDefinedDefaultStores
= []
2525 # tdict is a special dict kind of type, used for selecting correct
2526 # PCD settings for certain ARCH and SKU
2528 PcdDict
= tdict(True, 5)
2530 RecordList
= self
._RawData
[Type
, self
._Arch
]
2531 # Find out all possible PCD candidates for self._Arch
2532 AvailableSkuIdSet
= copy
.copy(self
.SkuIds
)
2533 DefaultStoresDefine
= self
._GetDefaultStores
()
2535 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, SkuName
, DefaultStore
, Dummy4
, Dummy5
in RecordList
:
2536 SkuName
= SkuName
.upper()
2537 SkuName
= TAB_DEFAULT
if SkuName
== TAB_COMMON
else SkuName
2538 DefaultStore
= DefaultStore
.upper()
2539 if DefaultStore
== TAB_COMMON
:
2540 DefaultStore
= TAB_DEFAULT_STORES_DEFAULT
2542 #The end user define [DefaultStores] and [SKUID_IDENTIFIER.Menufacturing] in DSC
2543 UserDefinedDefaultStores
.append((PcdCName
, TokenSpaceGuid
))
2544 if SkuName
not in AvailableSkuIdSet
:
2545 EdkLogger
.error('build', PARAMETER_INVALID
, 'Sku %s is not defined in [SkuIds] section' % SkuName
,
2546 File
=self
.MetaFile
, Line
=Dummy5
)
2547 if DefaultStore
not in DefaultStoresDefine
:
2548 EdkLogger
.error('build', PARAMETER_INVALID
, 'DefaultStores %s is not defined in [DefaultStores] section' % DefaultStore
,
2549 File
=self
.MetaFile
, Line
=Dummy5
)
2550 if "." not in TokenSpaceGuid
:
2551 PcdSet
.add((PcdCName
, TokenSpaceGuid
, SkuName
, DefaultStore
, Dummy5
))
2552 PcdDict
[Arch
, SkuName
, PcdCName
, TokenSpaceGuid
, DefaultStore
] = Setting
2555 # Remove redundant PCD candidates, per the ARCH and SKU
2556 for PcdCName
, TokenSpaceGuid
, SkuName
, DefaultStore
, Dummy4
in PcdSet
:
2558 Setting
= PcdDict
[self
._Arch
, SkuName
, PcdCName
, TokenSpaceGuid
, DefaultStore
]
2561 VariableName
, VariableGuid
, VariableOffset
, DefaultValue
, VarAttribute
= self
._ValidatePcd
(PcdCName
, TokenSpaceGuid
, Setting
, Type
, Dummy4
)
2563 rt
, Msg
= VariableAttributes
.ValidateVarAttributes(VarAttribute
)
2565 EdkLogger
.error("build", PCD_VARIABLE_ATTRIBUTES_ERROR
, "Variable attributes settings for %s is incorrect.\n %s" % (".".join((TokenSpaceGuid
, PcdCName
)), Msg
),
2566 ExtraData
="[%s]" % VarAttribute
)
2568 FormatCorrect
= True
2569 if VariableOffset
.isdigit():
2570 if int(VariableOffset
, 10) > 0xFFFF:
2572 elif variablePattern
.match(VariableOffset
):
2573 if int(VariableOffset
, 16) > 0xFFFF:
2575 # For Offset written in "A.B"
2576 elif VariableOffset
.find('.') > -1:
2577 VariableOffsetList
= VariableOffset
.split(".")
2578 if not (len(VariableOffsetList
) == 2
2579 and IsValidWord(VariableOffsetList
[0])
2580 and IsValidWord(VariableOffsetList
[1])):
2581 FormatCorrect
= False
2583 FormatCorrect
= False
2584 if not FormatCorrect
:
2585 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid syntax or format of the variable offset value is incorrect for %s." % ".".join((TokenSpaceGuid
, PcdCName
)))
2588 EdkLogger
.error('Build', OPTION_VALUE_INVALID
, "The variable offset value must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join((TokenSpaceGuid
, PcdCName
)))
2589 if (VariableName
, VariableGuid
) not in VariableAttrs
:
2590 VariableAttrs
[(VariableName
, VariableGuid
)] = VarAttribute
2592 if not DscBuildData
.CompareVarAttr(VariableAttrs
[(VariableName
, VariableGuid
)], VarAttribute
):
2593 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
)]))
2595 pcdDecObject
= self
._DecPcds
[PcdCName
, TokenSpaceGuid
]
2596 if (PcdCName
, TokenSpaceGuid
) in Pcds
:
2597 pcdObject
= Pcds
[PcdCName
, TokenSpaceGuid
]
2598 if SkuName
in pcdObject
.SkuInfoList
:
2599 Skuitem
= pcdObject
.SkuInfoList
[SkuName
]
2600 Skuitem
.DefaultStoreDict
.update({DefaultStore
:DefaultValue
})
2602 SkuInfo
= SkuInfoClass(SkuName
, self
.SkuIds
[SkuName
][0], VariableName
, VariableGuid
, VariableOffset
, DefaultValue
, VariableAttribute
=VarAttribute
, DefaultStore
={DefaultStore
:DefaultValue
})
2603 pcdObject
.SkuInfoList
[SkuName
] = SkuInfo
2605 SkuInfo
= SkuInfoClass(SkuName
, self
.SkuIds
[SkuName
][0], VariableName
, VariableGuid
, VariableOffset
, DefaultValue
, VariableAttribute
=VarAttribute
, DefaultStore
={DefaultStore
:DefaultValue
})
2606 PcdClassObj
= PcdClassObject(
2609 self
._PCD
_TYPE
_STRING
_[Type
],
2614 {SkuName
: SkuInfo
},
2617 pcdDecObject
.validateranges
,
2618 pcdDecObject
.validlists
,
2619 pcdDecObject
.expressions
,
2621 if (PcdCName
, TokenSpaceGuid
) in UserDefinedDefaultStores
:
2622 PcdClassObj
.UserDefinedDefaultStoresFlag
= True
2623 Pcds
[PcdCName
, TokenSpaceGuid
] = PcdClassObj
2625 if SkuName
not in Pcds
[PcdCName
, TokenSpaceGuid
].DscRawValue
:
2626 Pcds
[PcdCName
, TokenSpaceGuid
].DscRawValue
[SkuName
] = {}
2627 Pcds
[PcdCName
, TokenSpaceGuid
].DscRawValue
[SkuName
][DefaultStore
] = DefaultValue
2628 for pcd
in Pcds
.values():
2629 SkuInfoObj
= pcd
.SkuInfoList
.values()[0]
2630 pcdDecObject
= self
._DecPcds
[pcd
.TokenCName
, pcd
.TokenSpaceGuidCName
]
2631 pcd
.DatumType
= pcdDecObject
.DatumType
2632 # Only fix the value while no value provided in DSC file.
2633 for sku
in pcd
.SkuInfoList
.values():
2634 if (sku
.HiiDefaultValue
== "" or sku
.HiiDefaultValue
is None):
2635 sku
.HiiDefaultValue
= pcdDecObject
.DefaultValue
2636 for default_store
in sku
.DefaultStoreDict
:
2637 sku
.DefaultStoreDict
[default_store
]=pcdDecObject
.DefaultValue
2638 pcd
.DefaultValue
= pcdDecObject
.DefaultValue
2639 if TAB_DEFAULT
not in pcd
.SkuInfoList
and TAB_COMMON
not in pcd
.SkuInfoList
:
2640 valuefromDec
= pcdDecObject
.DefaultValue
2641 SkuInfo
= SkuInfoClass(TAB_DEFAULT
, '0', SkuInfoObj
.VariableName
, SkuInfoObj
.VariableGuid
, SkuInfoObj
.VariableOffset
, valuefromDec
, VariableAttribute
=SkuInfoObj
.VariableAttribute
, DefaultStore
={DefaultStore
:valuefromDec
})
2642 pcd
.SkuInfoList
[TAB_DEFAULT
] = SkuInfo
2643 elif TAB_DEFAULT
not in pcd
.SkuInfoList
and TAB_COMMON
in pcd
.SkuInfoList
:
2644 pcd
.SkuInfoList
[TAB_DEFAULT
] = pcd
.SkuInfoList
[TAB_COMMON
]
2645 del pcd
.SkuInfoList
[TAB_COMMON
]
2646 elif TAB_DEFAULT
in pcd
.SkuInfoList
and TAB_COMMON
in pcd
.SkuInfoList
:
2647 del pcd
.SkuInfoList
[TAB_COMMON
]
2649 if pcd
.MaxDatumSize
.strip():
2650 MaxSize
= int(pcd
.MaxDatumSize
, 0)
2653 if pcd
.DatumType
not in TAB_PCD_NUMERIC_TYPES
:
2654 for (_
, skuobj
) in pcd
.SkuInfoList
.items():
2656 skuobj
.HiiDefaultValue
= StringToArray(skuobj
.HiiDefaultValue
)
2657 datalen
= len(skuobj
.HiiDefaultValue
.split(","))
2658 if datalen
> MaxSize
:
2660 for defaultst
in skuobj
.DefaultStoreDict
:
2661 skuobj
.DefaultStoreDict
[defaultst
] = StringToArray(skuobj
.DefaultStoreDict
[defaultst
])
2662 pcd
.DefaultValue
= StringToArray(pcd
.DefaultValue
)
2663 pcd
.MaxDatumSize
= str(MaxSize
)
2664 rt
, invalidhii
= DscBuildData
.CheckVariableNameAssignment(Pcds
)
2666 invalidpcd
= ",".join(invalidhii
)
2667 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
)
2669 map(self
.FilterSkuSettings
, Pcds
.values())
2674 def CheckVariableNameAssignment(Pcds
):
2676 for pcdname
in Pcds
:
2678 varnameset
= set(sku
.VariableName
for (skuid
, sku
) in pcd
.SkuInfoList
.items())
2679 if len(varnameset
) > 1:
2680 invalidhii
.append(".".join((pcdname
[1], pcdname
[0])))
2682 return False, invalidhii
2685 ## Retrieve dynamic VPD PCD settings
2687 # @param Type PCD type
2689 # @retval a dict object contains settings of given PCD type
2691 def _GetDynamicVpdPcd(self
, Type
):
2694 Pcds
= OrderedDict()
2696 # tdict is a special dict kind of type, used for selecting correct
2697 # PCD settings for certain ARCH and SKU
2699 PcdDict
= tdict(True, 4)
2702 # Find out all possible PCD candidates for self._Arch
2703 RecordList
= self
._RawData
[Type
, self
._Arch
]
2704 AvailableSkuIdSet
= copy
.copy(self
.SkuIds
)
2706 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, SkuName
, Dummy3
, Dummy4
, Dummy5
in RecordList
:
2707 SkuName
= SkuName
.upper()
2708 SkuName
= TAB_DEFAULT
if SkuName
== TAB_COMMON
else SkuName
2709 if SkuName
not in AvailableSkuIdSet
:
2710 EdkLogger
.error('build', PARAMETER_INVALID
, 'Sku %s is not defined in [SkuIds] section' % SkuName
,
2711 File
=self
.MetaFile
, Line
=Dummy5
)
2712 if "." not in TokenSpaceGuid
:
2713 PcdList
.append((PcdCName
, TokenSpaceGuid
, SkuName
, Dummy5
))
2714 PcdDict
[Arch
, SkuName
, PcdCName
, TokenSpaceGuid
] = Setting
2716 # Remove redundant PCD candidates, per the ARCH and SKU
2717 for PcdCName
, TokenSpaceGuid
, SkuName
, Dummy4
in PcdList
:
2718 Setting
= PcdDict
[self
._Arch
, SkuName
, PcdCName
, TokenSpaceGuid
]
2722 # For the VOID* type, it can have optional data of MaxDatumSize and InitialValue
2723 # For the Integer & Boolean type, the optional data can only be InitialValue.
2724 # At this point, we put all the data into the PcdClssObject for we don't know the PCD's datumtype
2725 # until the DEC parser has been called.
2727 VpdOffset
, MaxDatumSize
, InitialValue
= self
._ValidatePcd
(PcdCName
, TokenSpaceGuid
, Setting
, Type
, Dummy4
)
2729 if int(MaxDatumSize
, 0) > 0xFFFF:
2730 EdkLogger
.error('build', FORMAT_INVALID
, "The size value must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join((TokenSpaceGuid
, PcdCName
)),
2731 File
=self
.MetaFile
, Line
=Dummy4
)
2732 if int(MaxDatumSize
, 0) < 0:
2733 EdkLogger
.error('build', FORMAT_INVALID
, "The size value can't be set to negative value for %s." % ".".join((TokenSpaceGuid
, PcdCName
)),
2734 File
=self
.MetaFile
, Line
=Dummy4
)
2735 SkuInfo
= SkuInfoClass(SkuName
, self
.SkuIds
[SkuName
][0], '', '', '', '', VpdOffset
, InitialValue
)
2736 if (PcdCName
, TokenSpaceGuid
) in Pcds
:
2737 pcdObject
= Pcds
[PcdCName
, TokenSpaceGuid
]
2738 pcdObject
.SkuInfoList
[SkuName
] = SkuInfo
2739 if MaxDatumSize
.strip():
2740 CurrentMaxSize
= int(MaxDatumSize
.strip(), 0)
2743 if pcdObject
.MaxDatumSize
:
2744 PcdMaxSize
= int(pcdObject
.MaxDatumSize
, 0)
2747 if CurrentMaxSize
> PcdMaxSize
:
2748 pcdObject
.MaxDatumSize
= str(CurrentMaxSize
)
2750 Pcds
[PcdCName
, TokenSpaceGuid
] = PcdClassObject(
2753 self
._PCD
_TYPE
_STRING
_[Type
],
2758 {SkuName
: SkuInfo
},
2763 if SkuName
not in Pcds
[PcdCName
, TokenSpaceGuid
].DscRawValue
:
2764 Pcds
[PcdCName
, TokenSpaceGuid
].DscRawValue
[SkuName
] = {}
2765 Pcds
[PcdCName
, TokenSpaceGuid
].DscRawValue
[SkuName
][TAB_DEFAULT_STORES_DEFAULT
] = InitialValue
2766 for pcd
in Pcds
.values():
2767 SkuInfoObj
= pcd
.SkuInfoList
.values()[0]
2768 pcdDecObject
= self
._DecPcds
[pcd
.TokenCName
, pcd
.TokenSpaceGuidCName
]
2769 pcd
.DatumType
= pcdDecObject
.DatumType
2770 # Only fix the value while no value provided in DSC file.
2771 for sku
in pcd
.SkuInfoList
.values():
2772 if not sku
.DefaultValue
:
2773 sku
.DefaultValue
= pcdDecObject
.DefaultValue
2774 if TAB_DEFAULT
not in pcd
.SkuInfoList
and TAB_COMMON
not in pcd
.SkuInfoList
:
2775 valuefromDec
= pcdDecObject
.DefaultValue
2776 SkuInfo
= SkuInfoClass(TAB_DEFAULT
, '0', '', '', '', '', SkuInfoObj
.VpdOffset
, valuefromDec
)
2777 pcd
.SkuInfoList
[TAB_DEFAULT
] = SkuInfo
2778 elif TAB_DEFAULT
not in pcd
.SkuInfoList
and TAB_COMMON
in pcd
.SkuInfoList
:
2779 pcd
.SkuInfoList
[TAB_DEFAULT
] = pcd
.SkuInfoList
[TAB_COMMON
]
2780 del pcd
.SkuInfoList
[TAB_COMMON
]
2781 elif TAB_DEFAULT
in pcd
.SkuInfoList
and TAB_COMMON
in pcd
.SkuInfoList
:
2782 del pcd
.SkuInfoList
[TAB_COMMON
]
2785 map(self
.FilterSkuSettings
, Pcds
.values())
2788 ## Add external modules
2790 # The external modules are mostly those listed in FDF file, which don't
2793 # @param FilePath The path of module description file
2795 def AddModule(self
, FilePath
):
2796 FilePath
= NormPath(FilePath
)
2797 if FilePath
not in self
.Modules
:
2798 Module
= ModuleBuildClassObject()
2799 Module
.MetaFile
= FilePath
2800 self
.Modules
.append(Module
)
2802 def _GetToolChainFamily(self
):
2803 self
._ToolChainFamily
= TAB_COMPILER_MSFT
2804 BuildConfigurationFile
= os
.path
.normpath(os
.path
.join(GlobalData
.gConfDirectory
, "target.txt"))
2805 if os
.path
.isfile(BuildConfigurationFile
) == True:
2806 TargetTxt
= TargetTxtClassObject()
2807 TargetTxt
.LoadTargetTxtFile(BuildConfigurationFile
)
2808 ToolDefinitionFile
= TargetTxt
.TargetTxtDictionary
[DataType
.TAB_TAT_DEFINES_TOOL_CHAIN_CONF
]
2809 if ToolDefinitionFile
== '':
2810 ToolDefinitionFile
= "tools_def.txt"
2811 ToolDefinitionFile
= os
.path
.normpath(mws
.join(self
.WorkspaceDir
, 'Conf', ToolDefinitionFile
))
2812 if os
.path
.isfile(ToolDefinitionFile
) == True:
2813 ToolDef
= ToolDefClassObject()
2814 ToolDef
.LoadToolDefFile(ToolDefinitionFile
)
2815 ToolDefinition
= ToolDef
.ToolsDefTxtDatabase
2816 if TAB_TOD_DEFINES_FAMILY
not in ToolDefinition \
2817 or self
._Toolchain
not in ToolDefinition
[TAB_TOD_DEFINES_FAMILY
] \
2818 or not ToolDefinition
[TAB_TOD_DEFINES_FAMILY
][self
._Toolchain
]:
2819 self
._ToolChainFamily
= TAB_COMPILER_MSFT
2821 self
._ToolChainFamily
= ToolDefinition
[TAB_TOD_DEFINES_FAMILY
][self
._Toolchain
]
2822 return self
._ToolChainFamily
2824 ## Add external PCDs
2826 # The external PCDs are mostly those listed in FDF file to specify address
2827 # or offset information.
2829 # @param Name Name of the PCD
2830 # @param Guid Token space guid of the PCD
2831 # @param Value Value of the PCD
2833 def AddPcd(self
, Name
, Guid
, Value
):
2834 if (Name
, Guid
) not in self
.Pcds
:
2835 self
.Pcds
[Name
, Guid
] = PcdClassObject(Name
, Guid
, '', '', '', '', '', {}, False, None)
2836 self
.Pcds
[Name
, Guid
].DefaultValue
= Value
2839 if self
._DecPcds
is None:
2841 if GlobalData
.gFdfParser
:
2842 FdfInfList
= GlobalData
.gFdfParser
.Profile
.InfList
2844 for Inf
in FdfInfList
:
2845 ModuleFile
= PathClass(NormPath(Inf
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
2846 if ModuleFile
in self
._Modules
:
2848 ModuleData
= self
._Bdb
[ModuleFile
, self
._Arch
, self
._Target
, self
._Toolchain
]
2849 PkgSet
.update(ModuleData
.Packages
)
2850 self
._DecPcds
, self
._GuidDict
= GetDeclaredPcd(self
, self
._Bdb
, self
._Arch
, self
._Target
, self
._Toolchain
, PkgSet
)
2851 return self
._DecPcds
2852 _Macros
= property(_GetMacros
)
2853 Arch
= property(_GetArch
)
2854 Platform
= property(_GetPlatformName
)
2855 PlatformName
= property(_GetPlatformName
)
2856 Guid
= property(_GetFileGuid
)
2857 Version
= property(_GetVersion
)
2858 DscSpecification
= property(_GetDscSpec
)
2859 OutputDirectory
= property(_GetOutpuDir
)
2860 SupArchList
= property(_GetSupArch
)
2861 BuildTargets
= property(_GetBuildTarget
)
2862 SkuName
= property(_GetSkuName
, _SetSkuName
)
2863 PcdInfoFlag
= property(_GetPcdInfoFlag
)
2864 VarCheckFlag
= property(_GetVarCheckFlag
)
2865 FlashDefinition
= property(_GetFdfFile
)
2866 Prebuild
= property(_GetPrebuild
)
2867 Postbuild
= property(_GetPostbuild
)
2868 BuildNumber
= property(_GetBuildNumber
)
2869 MakefileName
= property(_GetMakefileName
)
2870 BsBaseAddress
= property(_GetBsBaseAddress
)
2871 RtBaseAddress
= property(_GetRtBaseAddress
)
2872 LoadFixAddress
= property(_GetLoadFixAddress
)
2873 RFCLanguages
= property(_GetRFCLanguages
)
2874 ISOLanguages
= property(_GetISOLanguages
)
2875 VpdToolGuid
= property(_GetVpdToolGuid
)
2876 SkuIds
= property(_GetSkuIds
)
2877 Modules
= property(_GetModules
)
2878 LibraryInstances
= property(_GetLibraryInstances
)
2879 LibraryClasses
= property(_GetLibraryClasses
)
2880 Pcds
= property(_GetPcds
)
2881 BuildOptions
= property(_GetBuildOptions
)
2882 ToolChainFamily
= property(_GetToolChainFamily
)