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]+$')
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
)
313 # Changing the default ARCH to another may affect all other information
314 # because all information in a platform may be ARCH-related. That's
315 # why we need to clear all internal used members, in order to cause all
316 # information to be re-retrieved.
318 # @param Value The value of ARCH
320 def _SetArch(self
, Value
):
321 if self
._Arch
== Value
:
326 ## Retrieve all information in [Defines] section
328 # (Retriving all [Defines] information in one-shot is just to save time.)
330 def _GetHeaderInfo(self
):
331 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER
, self
._Arch
]
332 for Record
in RecordList
:
334 # items defined _PROPERTY_ don't need additional processing
336 # some special items in [Defines] section need special treatment
337 if Name
== TAB_DSC_DEFINES_OUTPUT_DIRECTORY
:
338 self
._OutputDirectory
= NormPath(Record
[2], self
._Macros
)
339 if ' ' in self
._OutputDirectory
:
340 EdkLogger
.error("build", FORMAT_NOT_SUPPORTED
, "No space is allowed in OUTPUT_DIRECTORY",
341 File
=self
.MetaFile
, Line
=Record
[-1],
342 ExtraData
=self
._OutputDirectory
)
343 elif Name
== TAB_DSC_DEFINES_FLASH_DEFINITION
:
344 self
._FlashDefinition
= PathClass(NormPath(Record
[2], self
._Macros
), GlobalData
.gWorkspace
)
345 ErrorCode
, ErrorInfo
= self
._FlashDefinition
.Validate('.fdf')
347 EdkLogger
.error('build', ErrorCode
, File
=self
.MetaFile
, Line
=Record
[-1],
349 elif Name
== TAB_DSC_PREBUILD
:
350 PrebuildValue
= Record
[2]
351 if Record
[2][0] == '"':
352 if Record
[2][-1] != '"':
353 EdkLogger
.error('build', FORMAT_INVALID
, 'Missing double quotes in the end of %s statement.' % TAB_DSC_PREBUILD
,
354 File
=self
.MetaFile
, Line
=Record
[-1])
355 PrebuildValue
= Record
[2][1:-1]
356 self
._Prebuild
= PrebuildValue
357 elif Name
== TAB_DSC_POSTBUILD
:
358 PostbuildValue
= Record
[2]
359 if Record
[2][0] == '"':
360 if Record
[2][-1] != '"':
361 EdkLogger
.error('build', FORMAT_INVALID
, 'Missing double quotes in the end of %s statement.' % TAB_DSC_POSTBUILD
,
362 File
=self
.MetaFile
, Line
=Record
[-1])
363 PostbuildValue
= Record
[2][1:-1]
364 self
._Postbuild
= PostbuildValue
365 elif Name
== TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES
:
366 self
._SupArchList
= GetSplitValueList(Record
[2], TAB_VALUE_SPLIT
)
367 elif Name
== TAB_DSC_DEFINES_BUILD_TARGETS
:
368 self
._BuildTargets
= GetSplitValueList(Record
[2])
369 elif Name
== TAB_DSC_DEFINES_SKUID_IDENTIFIER
:
370 if self
._SkuName
is None:
371 self
._SkuName
= Record
[2]
372 if GlobalData
.gSKUID_CMD
:
373 self
._SkuName
= GlobalData
.gSKUID_CMD
374 elif Name
== TAB_DSC_DEFINES_PCD_INFO_GENERATION
:
375 self
._PcdInfoFlag
= Record
[2]
376 elif Name
== TAB_DSC_DEFINES_PCD_VAR_CHECK_GENERATION
:
377 self
._VarCheckFlag
= Record
[2]
378 elif Name
== TAB_FIX_LOAD_TOP_MEMORY_ADDRESS
:
380 self
._LoadFixAddress
= int (Record
[2], 0)
382 EdkLogger
.error("build", PARAMETER_INVALID
, "FIX_LOAD_TOP_MEMORY_ADDRESS %s is not valid dec or hex string" % (Record
[2]))
383 elif Name
== TAB_DSC_DEFINES_RFC_LANGUAGES
:
384 if not Record
[2] or Record
[2][0] != '"' or Record
[2][-1] != '"' or len(Record
[2]) == 1:
385 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"',
386 File
=self
.MetaFile
, Line
=Record
[-1])
387 LanguageCodes
= Record
[2][1:-1]
388 if not LanguageCodes
:
389 EdkLogger
.error('build', FORMAT_NOT_SUPPORTED
, 'one or more RFC4646 format language code must be provided for RFC_LANGUAGES statement',
390 File
=self
.MetaFile
, Line
=Record
[-1])
391 LanguageList
= GetSplitValueList(LanguageCodes
, TAB_SEMI_COLON_SPLIT
)
392 # check whether there is empty entries in the list
393 if None in LanguageList
:
394 EdkLogger
.error('build', FORMAT_NOT_SUPPORTED
, 'one or more empty language code is in RFC_LANGUAGES statement',
395 File
=self
.MetaFile
, Line
=Record
[-1])
396 self
._RFCLanguages
= LanguageList
397 elif Name
== TAB_DSC_DEFINES_ISO_LANGUAGES
:
398 if not Record
[2] or Record
[2][0] != '"' or Record
[2][-1] != '"' or len(Record
[2]) == 1:
399 EdkLogger
.error('build', FORMAT_NOT_SUPPORTED
, 'language code for ISO_LANGUAGES must have double quotes around it, for example: ISO_LANGUAGES = "engchn"',
400 File
=self
.MetaFile
, Line
=Record
[-1])
401 LanguageCodes
= Record
[2][1:-1]
402 if not LanguageCodes
:
403 EdkLogger
.error('build', FORMAT_NOT_SUPPORTED
, 'one or more ISO639-2 format language code must be provided for ISO_LANGUAGES statement',
404 File
=self
.MetaFile
, Line
=Record
[-1])
405 if len(LanguageCodes
) % 3:
406 EdkLogger
.error('build', FORMAT_NOT_SUPPORTED
, 'bad ISO639-2 format for ISO_LANGUAGES',
407 File
=self
.MetaFile
, Line
=Record
[-1])
409 for i
in range(0, len(LanguageCodes
), 3):
410 LanguageList
.append(LanguageCodes
[i
:i
+ 3])
411 self
._ISOLanguages
= LanguageList
412 elif Name
== TAB_DSC_DEFINES_VPD_TOOL_GUID
:
414 # try to convert GUID to a real UUID value to see whether the GUID is format
415 # for VPD_TOOL_GUID is correct.
420 EdkLogger
.error("build", FORMAT_INVALID
, "Invalid GUID format for VPD_TOOL_GUID", File
=self
.MetaFile
)
421 self
._VpdToolGuid
= Record
[2]
423 self
[Name
] = Record
[2]
424 # set _Header to non-None in order to avoid database re-querying
425 self
._Header
= 'DUMMY'
427 ## Retrieve platform name
428 def _GetPlatformName(self
):
429 if self
._PlatformName
is None:
430 if self
._Header
is None:
431 self
._GetHeaderInfo
()
432 if self
._PlatformName
is None:
433 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No PLATFORM_NAME", File
=self
.MetaFile
)
434 return self
._PlatformName
436 ## Retrieve file guid
437 def _GetFileGuid(self
):
438 if self
._Guid
is None:
439 if self
._Header
is None:
440 self
._GetHeaderInfo
()
441 if self
._Guid
is None:
442 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No PLATFORM_GUID", File
=self
.MetaFile
)
445 ## Retrieve platform version
446 def _GetVersion(self
):
447 if self
._Version
is None:
448 if self
._Header
is None:
449 self
._GetHeaderInfo
()
450 if self
._Version
is None:
451 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No PLATFORM_VERSION", File
=self
.MetaFile
)
454 ## Retrieve platform description file version
455 def _GetDscSpec(self
):
456 if self
._DscSpecification
is None:
457 if self
._Header
is None:
458 self
._GetHeaderInfo
()
459 if self
._DscSpecification
is None:
460 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No DSC_SPECIFICATION", File
=self
.MetaFile
)
461 return self
._DscSpecification
463 ## Retrieve OUTPUT_DIRECTORY
464 def _GetOutpuDir(self
):
465 if self
._OutputDirectory
is None:
466 if self
._Header
is None:
467 self
._GetHeaderInfo
()
468 if self
._OutputDirectory
is None:
469 self
._OutputDirectory
= os
.path
.join("Build", self
._PlatformName
)
470 return self
._OutputDirectory
472 ## Retrieve SUPPORTED_ARCHITECTURES
473 def _GetSupArch(self
):
474 if self
._SupArchList
is None:
475 if self
._Header
is None:
476 self
._GetHeaderInfo
()
477 if self
._SupArchList
is None:
478 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No SUPPORTED_ARCHITECTURES", File
=self
.MetaFile
)
479 return self
._SupArchList
481 ## Retrieve BUILD_TARGETS
482 def _GetBuildTarget(self
):
483 if self
._BuildTargets
is None:
484 if self
._Header
is None:
485 self
._GetHeaderInfo
()
486 if self
._BuildTargets
is None:
487 EdkLogger
.error('build', ATTRIBUTE_NOT_AVAILABLE
, "No BUILD_TARGETS", File
=self
.MetaFile
)
488 return self
._BuildTargets
490 def _GetPcdInfoFlag(self
):
491 if self
._PcdInfoFlag
is None or self
._PcdInfoFlag
.upper() == 'FALSE':
493 elif self
._PcdInfoFlag
.upper() == 'TRUE':
497 def _GetVarCheckFlag(self
):
498 if self
._VarCheckFlag
is None or self
._VarCheckFlag
.upper() == 'FALSE':
500 elif self
._VarCheckFlag
.upper() == 'TRUE':
505 # # Retrieve SKUID_IDENTIFIER
506 def _GetSkuName(self
):
507 if self
._SkuName
is None:
508 if self
._Header
is None:
509 self
._GetHeaderInfo
()
510 if self
._SkuName
is None:
511 self
._SkuName
= TAB_DEFAULT
514 ## Override SKUID_IDENTIFIER
515 def _SetSkuName(self
, Value
):
516 self
._SkuName
= Value
518 def _GetFdfFile(self
):
519 if self
._FlashDefinition
is None:
520 if self
._Header
is None:
521 self
._GetHeaderInfo
()
522 if self
._FlashDefinition
is None:
523 self
._FlashDefinition
= ''
524 return self
._FlashDefinition
526 def _GetPrebuild(self
):
527 if self
._Prebuild
is None:
528 if self
._Header
is None:
529 self
._GetHeaderInfo
()
530 if self
._Prebuild
is None:
532 return self
._Prebuild
534 def _GetPostbuild(self
):
535 if self
._Postbuild
is None:
536 if self
._Header
is None:
537 self
._GetHeaderInfo
()
538 if self
._Postbuild
is None:
540 return self
._Postbuild
542 ## Retrieve FLASH_DEFINITION
543 def _GetBuildNumber(self
):
544 if self
._BuildNumber
is None:
545 if self
._Header
is None:
546 self
._GetHeaderInfo
()
547 if self
._BuildNumber
is None:
548 self
._BuildNumber
= ''
549 return self
._BuildNumber
551 ## Retrieve MAKEFILE_NAME
552 def _GetMakefileName(self
):
553 if self
._MakefileName
is None:
554 if self
._Header
is None:
555 self
._GetHeaderInfo
()
556 if self
._MakefileName
is None:
557 self
._MakefileName
= ''
558 return self
._MakefileName
560 ## Retrieve BsBaseAddress
561 def _GetBsBaseAddress(self
):
562 if self
._BsBaseAddress
is None:
563 if self
._Header
is None:
564 self
._GetHeaderInfo
()
565 if self
._BsBaseAddress
is None:
566 self
._BsBaseAddress
= ''
567 return self
._BsBaseAddress
569 ## Retrieve RtBaseAddress
570 def _GetRtBaseAddress(self
):
571 if self
._RtBaseAddress
is None:
572 if self
._Header
is None:
573 self
._GetHeaderInfo
()
574 if self
._RtBaseAddress
is None:
575 self
._RtBaseAddress
= ''
576 return self
._RtBaseAddress
578 ## Retrieve the top address for the load fix address
579 def _GetLoadFixAddress(self
):
580 if self
._LoadFixAddress
is None:
581 if self
._Header
is None:
582 self
._GetHeaderInfo
()
584 if self
._LoadFixAddress
is None:
585 self
._LoadFixAddress
= self
._Macros
.get(TAB_FIX_LOAD_TOP_MEMORY_ADDRESS
, '0')
588 self
._LoadFixAddress
= int (self
._LoadFixAddress
, 0)
590 EdkLogger
.error("build", PARAMETER_INVALID
, "FIX_LOAD_TOP_MEMORY_ADDRESS %s is not valid dec or hex string" % (self
._LoadFixAddress
))
593 # If command line defined, should override the value in DSC file.
595 if 'FIX_LOAD_TOP_MEMORY_ADDRESS' in GlobalData
.gCommandLineDefines
:
597 self
._LoadFixAddress
= int(GlobalData
.gCommandLineDefines
['FIX_LOAD_TOP_MEMORY_ADDRESS'], 0)
599 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']))
601 if self
._LoadFixAddress
< 0:
602 EdkLogger
.error("build", PARAMETER_INVALID
, "FIX_LOAD_TOP_MEMORY_ADDRESS is set to the invalid negative value 0x%x" % (self
._LoadFixAddress
))
603 if self
._LoadFixAddress
!= 0xFFFFFFFFFFFFFFFF and self
._LoadFixAddress
% 0x1000 != 0:
604 EdkLogger
.error("build", PARAMETER_INVALID
, "FIX_LOAD_TOP_MEMORY_ADDRESS is set to the invalid unaligned 4K value 0x%x" % (self
._LoadFixAddress
))
606 return self
._LoadFixAddress
608 ## Retrieve RFCLanguage filter
609 def _GetRFCLanguages(self
):
610 if self
._RFCLanguages
is None:
611 if self
._Header
is None:
612 self
._GetHeaderInfo
()
613 if self
._RFCLanguages
is None:
614 self
._RFCLanguages
= []
615 return self
._RFCLanguages
617 ## Retrieve ISOLanguage filter
618 def _GetISOLanguages(self
):
619 if self
._ISOLanguages
is None:
620 if self
._Header
is None:
621 self
._GetHeaderInfo
()
622 if self
._ISOLanguages
is None:
623 self
._ISOLanguages
= []
624 return self
._ISOLanguages
625 ## Retrieve the GUID string for VPD tool
626 def _GetVpdToolGuid(self
):
627 if self
._VpdToolGuid
is None:
628 if self
._Header
is None:
629 self
._GetHeaderInfo
()
630 if self
._VpdToolGuid
is None:
631 self
._VpdToolGuid
= ''
632 return self
._VpdToolGuid
634 ## Retrieve [SkuIds] section information
635 def _GetSkuIds(self
):
636 if self
._SkuIds
is None:
637 self
._SkuIds
= OrderedDict()
638 RecordList
= self
._RawData
[MODEL_EFI_SKU_ID
, self
._Arch
]
639 for Record
in RecordList
:
641 EdkLogger
.error('build', FORMAT_INVALID
, 'No Sku ID number',
642 File
=self
.MetaFile
, Line
=Record
[-1])
644 EdkLogger
.error('build', FORMAT_INVALID
, 'No Sku ID name',
645 File
=self
.MetaFile
, Line
=Record
[-1])
646 if not Pattern
.match(Record
[0]) and not HexPattern
.match(Record
[0]):
647 EdkLogger
.error('build', FORMAT_INVALID
, "The format of the Sku ID number is invalid. It only support Integer and HexNumber",
648 File
=self
.MetaFile
, Line
=Record
[-1])
649 if not IsValidWord(Record
[1]):
650 EdkLogger
.error('build', FORMAT_INVALID
, "The format of the Sku ID name is invalid. The correct format is '(a-zA-Z0-9_)(a-zA-Z0-9_-.)*'",
651 File
=self
.MetaFile
, Line
=Record
[-1])
652 self
._SkuIds
[Record
[1].upper()] = (str(DscBuildData
.ToInt(Record
[0])), Record
[1].upper(), Record
[2].upper())
653 if TAB_DEFAULT
not in self
._SkuIds
:
654 self
._SkuIds
[TAB_DEFAULT
] = ("0", TAB_DEFAULT
, TAB_DEFAULT
)
655 if TAB_COMMON
not in self
._SkuIds
:
656 self
._SkuIds
[TAB_COMMON
] = ("0", TAB_DEFAULT
, TAB_DEFAULT
)
661 return int(intstr
, 16) if intstr
.upper().startswith("0X") else int(intstr
)
663 def _GetDefaultStores(self
):
664 if self
.DefaultStores
is None:
665 self
.DefaultStores
= OrderedDict()
666 RecordList
= self
._RawData
[MODEL_EFI_DEFAULT_STORES
, self
._Arch
]
667 for Record
in RecordList
:
669 EdkLogger
.error('build', FORMAT_INVALID
, 'No DefaultStores ID number',
670 File
=self
.MetaFile
, Line
=Record
[-1])
672 EdkLogger
.error('build', FORMAT_INVALID
, 'No DefaultStores ID name',
673 File
=self
.MetaFile
, Line
=Record
[-1])
674 if not Pattern
.match(Record
[0]) and not HexPattern
.match(Record
[0]):
675 EdkLogger
.error('build', FORMAT_INVALID
, "The format of the DefaultStores ID number is invalid. It only support Integer and HexNumber",
676 File
=self
.MetaFile
, Line
=Record
[-1])
677 if not IsValidWord(Record
[1]):
678 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_-.)*'",
679 File
=self
.MetaFile
, Line
=Record
[-1])
680 self
.DefaultStores
[Record
[1].upper()] = (DscBuildData
.ToInt(Record
[0]), Record
[1].upper())
681 if TAB_DEFAULT_STORES_DEFAULT
not in self
.DefaultStores
:
682 self
.DefaultStores
[TAB_DEFAULT_STORES_DEFAULT
] = (0, TAB_DEFAULT_STORES_DEFAULT
)
683 GlobalData
.gDefaultStores
= sorted(self
.DefaultStores
.keys())
684 return self
.DefaultStores
686 ## Retrieve [Components] section information
687 def _GetModules(self
):
688 if self
._Modules
is not None:
691 self
._Modules
= OrderedDict()
692 RecordList
= self
._RawData
[MODEL_META_DATA_COMPONENT
, self
._Arch
]
693 Macros
= self
._Macros
694 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
695 for Record
in RecordList
:
696 DuplicatedFile
= False
698 ModuleFile
= PathClass(NormPath(Record
[0], Macros
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
702 # check the file validation
703 ErrorCode
, ErrorInfo
= ModuleFile
.Validate('.inf')
705 EdkLogger
.error('build', ErrorCode
, File
=self
.MetaFile
, Line
=LineNo
,
708 # If arch is COMMON, no duplicate module is checked since all modules in all component sections are selected
709 if self
._Arch
!= TAB_ARCH_COMMON
and ModuleFile
in self
._Modules
:
710 DuplicatedFile
= True
712 Module
= ModuleBuildClassObject()
713 Module
.MetaFile
= ModuleFile
715 # get module private library instance
716 RecordList
= self
._RawData
[MODEL_EFI_LIBRARY_CLASS
, self
._Arch
, None, ModuleId
]
717 for Record
in RecordList
:
718 LibraryClass
= Record
[0]
719 LibraryPath
= PathClass(NormPath(Record
[1], Macros
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
722 # check the file validation
723 ErrorCode
, ErrorInfo
= LibraryPath
.Validate('.inf')
725 EdkLogger
.error('build', ErrorCode
, File
=self
.MetaFile
, Line
=LineNo
,
728 if LibraryClass
== '' or LibraryClass
== 'NULL':
729 self
._NullLibraryNumber
+= 1
730 LibraryClass
= 'NULL%d' % self
._NullLibraryNumber
731 EdkLogger
.verbose("Found forced library for %s\n\t%s [%s]" % (ModuleFile
, LibraryPath
, LibraryClass
))
732 Module
.LibraryClasses
[LibraryClass
] = LibraryPath
733 if LibraryPath
not in self
.LibraryInstances
:
734 self
.LibraryInstances
.append(LibraryPath
)
736 # get module private PCD setting
737 for Type
in [MODEL_PCD_FIXED_AT_BUILD
, MODEL_PCD_PATCHABLE_IN_MODULE
, \
738 MODEL_PCD_FEATURE_FLAG
, MODEL_PCD_DYNAMIC
, MODEL_PCD_DYNAMIC_EX
]:
739 RecordList
= self
._RawData
[Type
, self
._Arch
, None, ModuleId
]
740 for TokenSpaceGuid
, PcdCName
, Setting
, Dummy1
, Dummy2
, Dummy3
, Dummy4
, Dummy5
in RecordList
:
741 TokenList
= GetSplitValueList(Setting
)
742 DefaultValue
= TokenList
[0]
743 # the format is PcdName| Value | VOID* | MaxDatumSize
744 if len(TokenList
) > 2:
745 MaxDatumSize
= TokenList
[2]
748 TypeString
= self
._PCD
_TYPE
_STRING
_[Type
]
749 Pcd
= PcdClassObject(
761 Module
.Pcds
[PcdCName
, TokenSpaceGuid
] = Pcd
763 # get module private build options
764 RecordList
= self
._RawData
[MODEL_META_DATA_BUILD_OPTION
, self
._Arch
, None, ModuleId
]
765 for ToolChainFamily
, ToolChain
, Option
, Dummy1
, Dummy2
, Dummy3
, Dummy4
, Dummy5
in RecordList
:
766 if (ToolChainFamily
, ToolChain
) not in Module
.BuildOptions
:
767 Module
.BuildOptions
[ToolChainFamily
, ToolChain
] = Option
769 OptionString
= Module
.BuildOptions
[ToolChainFamily
, ToolChain
]
770 Module
.BuildOptions
[ToolChainFamily
, ToolChain
] = OptionString
+ " " + Option
772 RecordList
= self
._RawData
[MODEL_META_DATA_HEADER
, self
._Arch
, None, ModuleId
]
773 if DuplicatedFile
and not RecordList
:
774 EdkLogger
.error('build', FILE_DUPLICATED
, File
=self
.MetaFile
, ExtraData
=str(ModuleFile
), Line
=LineNo
)
776 if len(RecordList
) != 1:
777 EdkLogger
.error('build', OPTION_UNKNOWN
, 'Only FILE_GUID can be listed in <Defines> section.',
778 File
=self
.MetaFile
, ExtraData
=str(ModuleFile
), Line
=LineNo
)
779 ModuleFile
= ProcessDuplicatedInf(ModuleFile
, RecordList
[0][2], GlobalData
.gWorkspace
)
780 ModuleFile
.Arch
= self
._Arch
782 self
._Modules
[ModuleFile
] = Module
785 ## Retrieve all possible library instances used in this platform
786 def _GetLibraryInstances(self
):
787 if self
._LibraryInstances
is None:
788 self
._GetLibraryClasses
()
789 return self
._LibraryInstances
791 ## Retrieve [LibraryClasses] information
792 def _GetLibraryClasses(self
):
793 if self
._LibraryClasses
is None:
794 self
._LibraryInstances
= []
796 # tdict is a special dict kind of type, used for selecting correct
797 # library instance for given library class and module type
799 LibraryClassDict
= tdict(True, 3)
800 # track all library class names
801 LibraryClassSet
= set()
802 RecordList
= self
._RawData
[MODEL_EFI_LIBRARY_CLASS
, self
._Arch
, None, -1]
803 Macros
= self
._Macros
804 for Record
in RecordList
:
805 LibraryClass
, LibraryInstance
, Dummy
, Arch
, ModuleType
, Dummy
, Dummy
, LineNo
= Record
806 if LibraryClass
== '' or LibraryClass
== 'NULL':
807 self
._NullLibraryNumber
+= 1
808 LibraryClass
= 'NULL%d' % self
._NullLibraryNumber
809 EdkLogger
.verbose("Found forced library for arch=%s\n\t%s [%s]" % (Arch
, LibraryInstance
, LibraryClass
))
810 LibraryClassSet
.add(LibraryClass
)
811 LibraryInstance
= PathClass(NormPath(LibraryInstance
, Macros
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
812 # check the file validation
813 ErrorCode
, ErrorInfo
= LibraryInstance
.Validate('.inf')
815 EdkLogger
.error('build', ErrorCode
, File
=self
.MetaFile
, Line
=LineNo
,
818 if ModuleType
!= TAB_COMMON
and ModuleType
not in SUP_MODULE_LIST
:
819 EdkLogger
.error('build', OPTION_UNKNOWN
, "Unknown module type [%s]" % ModuleType
,
820 File
=self
.MetaFile
, ExtraData
=LibraryInstance
, Line
=LineNo
)
821 LibraryClassDict
[Arch
, ModuleType
, LibraryClass
] = LibraryInstance
822 if LibraryInstance
not in self
._LibraryInstances
:
823 self
._LibraryInstances
.append(LibraryInstance
)
825 # resolve the specific library instance for each class and each module type
826 self
._LibraryClasses
= tdict(True)
827 for LibraryClass
in LibraryClassSet
:
828 # try all possible module types
829 for ModuleType
in SUP_MODULE_LIST
:
830 LibraryInstance
= LibraryClassDict
[self
._Arch
, ModuleType
, LibraryClass
]
831 if LibraryInstance
is None:
833 self
._LibraryClasses
[LibraryClass
, ModuleType
] = LibraryInstance
835 # for Edk style library instances, which are listed in different section
836 Macros
["EDK_SOURCE"] = GlobalData
.gEcpSource
837 RecordList
= self
._RawData
[MODEL_EFI_LIBRARY_INSTANCE
, self
._Arch
]
838 for Record
in RecordList
:
839 File
= PathClass(NormPath(Record
[0], Macros
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
841 # check the file validation
842 ErrorCode
, ErrorInfo
= File
.Validate('.inf')
844 EdkLogger
.error('build', ErrorCode
, File
=self
.MetaFile
, Line
=LineNo
,
846 if File
not in self
._LibraryInstances
:
847 self
._LibraryInstances
.append(File
)
849 # we need the module name as the library class name, so we have
850 # to parse it here. (self._Bdb[] will trigger a file parse if it
851 # hasn't been parsed)
853 Library
= self
._Bdb
[File
, self
._Arch
, self
._Target
, self
._Toolchain
]
854 self
._LibraryClasses
[Library
.BaseName
, ':dummy:'] = Library
855 return self
._LibraryClasses
857 def _ValidatePcd(self
, PcdCName
, TokenSpaceGuid
, Setting
, PcdType
, LineNo
):
858 if self
._DecPcds
is None:
861 if GlobalData
.gFdfParser
:
862 FdfInfList
= GlobalData
.gFdfParser
.Profile
.InfList
865 for Inf
in FdfInfList
:
866 ModuleFile
= PathClass(NormPath(Inf
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
867 if ModuleFile
in self
._Modules
:
869 ModuleData
= self
._Bdb
[ModuleFile
, self
._Arch
, self
._Target
, self
._Toolchain
]
870 PkgSet
.update(ModuleData
.Packages
)
872 self
._DecPcds
, self
._GuidDict
= GetDeclaredPcd(self
, self
._Bdb
, self
._Arch
, self
._Target
, self
._Toolchain
, PkgSet
)
873 self
._GuidDict
.update(GlobalData
.gPlatformPcds
)
875 if (PcdCName
, TokenSpaceGuid
) not in self
._DecPcds
:
876 EdkLogger
.error('build', PARSER_ERROR
,
877 "Pcd (%s.%s) defined in DSC is not declared in DEC files. Arch: ['%s']" % (TokenSpaceGuid
, PcdCName
, self
._Arch
),
878 File
=self
.MetaFile
, Line
=LineNo
)
879 ValueList
, IsValid
, Index
= AnalyzeDscPcd(Setting
, PcdType
, self
._DecPcds
[PcdCName
, TokenSpaceGuid
].DatumType
)
881 if PcdType
not in [MODEL_PCD_FEATURE_FLAG
, MODEL_PCD_FIXED_AT_BUILD
]:
882 EdkLogger
.error('build', FORMAT_INVALID
, "Pcd format incorrect.", File
=self
.MetaFile
, Line
=LineNo
,
883 ExtraData
="%s.%s|%s" % (TokenSpaceGuid
, PcdCName
, Setting
))
885 if ValueList
[2] == '-1':
886 EdkLogger
.error('build', FORMAT_INVALID
, "Pcd format incorrect.", File
=self
.MetaFile
, Line
=LineNo
,
887 ExtraData
="%s.%s|%s" % (TokenSpaceGuid
, PcdCName
, Setting
))
889 DatumType
= self
._DecPcds
[PcdCName
, TokenSpaceGuid
].DatumType
891 ValueList
[Index
] = ValueExpressionEx(ValueList
[Index
], DatumType
, self
._GuidDict
)(True)
892 except BadExpression
as Value
:
893 EdkLogger
.error('Parser', FORMAT_INVALID
, Value
, File
=self
.MetaFile
, Line
=LineNo
,
894 ExtraData
="PCD [%s.%s] Value \"%s\" " % (
895 TokenSpaceGuid
, PcdCName
, ValueList
[Index
]))
896 except EvaluationException
as Excpt
:
897 if hasattr(Excpt
, 'Pcd'):
898 if Excpt
.Pcd
in GlobalData
.gPlatformOtherPcds
:
899 EdkLogger
.error('Parser', FORMAT_INVALID
, "Cannot use this PCD (%s) in an expression as"
900 " it must be defined in a [PcdsFixedAtBuild] or [PcdsFeatureFlag] section"
901 " of the DSC file" % Excpt
.Pcd
,
902 File
=self
.MetaFile
, Line
=LineNo
)
904 EdkLogger
.error('Parser', FORMAT_INVALID
, "PCD (%s) is not defined in DSC file" % Excpt
.Pcd
,
905 File
=self
.MetaFile
, Line
=LineNo
)
907 EdkLogger
.error('Parser', FORMAT_INVALID
, "Invalid expression: %s" % str(Excpt
),
908 File
=self
.MetaFile
, Line
=LineNo
)
911 Valid
, ErrStr
= CheckPcdDatum(self
._DecPcds
[PcdCName
, TokenSpaceGuid
].DatumType
, ValueList
[Index
])
913 EdkLogger
.error('build', FORMAT_INVALID
, ErrStr
, File
=self
.MetaFile
, Line
=LineNo
,
914 ExtraData
="%s.%s" % (TokenSpaceGuid
, PcdCName
))
915 if PcdType
in (MODEL_PCD_DYNAMIC_DEFAULT
, MODEL_PCD_DYNAMIC_EX_DEFAULT
):
916 if self
._DecPcds
[PcdCName
, TokenSpaceGuid
].DatumType
.strip() != ValueList
[1].strip():
917 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
,
918 ExtraData
="%s.%s|%s" % (TokenSpaceGuid
, PcdCName
, Setting
))
919 if (TokenSpaceGuid
+ '.' + PcdCName
) in GlobalData
.gPlatformPcds
:
920 if GlobalData
.gPlatformPcds
[TokenSpaceGuid
+ '.' + PcdCName
] != ValueList
[Index
]:
921 GlobalData
.gPlatformPcds
[TokenSpaceGuid
+ '.' + PcdCName
] = ValueList
[Index
]
924 def _FilterPcdBySkuUsage(self
, Pcds
):
925 available_sku
= self
.SkuIdMgr
.AvailableSkuIdSet
926 sku_usage
= self
.SkuIdMgr
.SkuUsageType
927 if sku_usage
== SkuClass
.SINGLE
:
930 Pcds
[pcdname
].SkuInfoList
= {TAB_DEFAULT
:pcd
.SkuInfoList
[skuid
] for skuid
in pcd
.SkuInfoList
if skuid
in available_sku
}
931 if isinstance(pcd
, StructurePcd
) and pcd
.SkuOverrideValues
:
932 Pcds
[pcdname
].SkuOverrideValues
= {TAB_DEFAULT
:pcd
.SkuOverrideValues
[skuid
] for skuid
in pcd
.SkuOverrideValues
if skuid
in available_sku
}
936 Pcds
[pcdname
].SkuInfoList
= {skuid
:pcd
.SkuInfoList
[skuid
] for skuid
in pcd
.SkuInfoList
if skuid
in available_sku
}
937 if isinstance(pcd
, StructurePcd
) and pcd
.SkuOverrideValues
:
938 Pcds
[pcdname
].SkuOverrideValues
= {skuid
:pcd
.SkuOverrideValues
[skuid
] for skuid
in pcd
.SkuOverrideValues
if skuid
in available_sku
}
940 def CompleteHiiPcdsDefaultStores(self
, Pcds
):
941 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
]]]
942 DefaultStoreMgr
= DefaultStore(self
.DefaultStores
)
944 for skuid
in pcd
.SkuInfoList
:
945 skuobj
= pcd
.SkuInfoList
.get(skuid
)
946 if TAB_DEFAULT_STORES_DEFAULT
not in skuobj
.DefaultStoreDict
:
947 PcdDefaultStoreSet
= set(defaultstorename
for defaultstorename
in skuobj
.DefaultStoreDict
)
948 mindefaultstorename
= DefaultStoreMgr
.GetMin(PcdDefaultStoreSet
)
949 skuobj
.DefaultStoreDict
[TAB_DEFAULT_STORES_DEFAULT
] = copy
.deepcopy(skuobj
.DefaultStoreDict
[mindefaultstorename
])
952 def RecoverCommandLinePcd(self
):
953 def UpdateCommandLineValue(pcd
):
954 if pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FIXED_AT_BUILD
],
955 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_PATCHABLE_IN_MODULE
]]:
956 pcd
.PcdValueFromComm
= pcd
.DefaultValue
957 elif pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
958 pcd
.PcdValueFromComm
= pcd
.SkuInfoList
.get(TAB_DEFAULT
).HiiDefaultValue
960 pcd
.PcdValueFromComm
= pcd
.SkuInfoList
.get(TAB_DEFAULT
).DefaultValue
961 for pcd
in self
._Pcds
:
962 if isinstance(self
._Pcds
[pcd
], StructurePcd
) and (self
._Pcds
[pcd
].PcdValueFromComm
or self
._Pcds
[pcd
].PcdFieldValueFromComm
):
963 UpdateCommandLineValue(self
._Pcds
[pcd
])
965 def __ParsePcdFromCommandLine(self
):
966 if GlobalData
.BuildOptionPcd
:
967 for i
, pcd
in enumerate(GlobalData
.BuildOptionPcd
):
968 if isinstance(pcd
, tuple):
970 (pcdname
, pcdvalue
) = pcd
.split('=')
972 EdkLogger
.error('build', AUTOGEN_ERROR
, "No Value specified for the PCD %s." % (pcdname
))
974 (Name1
, Name2
) = pcdname
.split('.', 1)
976 (Name3
, FieldName
) = Name2
.split(".", 1)
977 if ((Name3
, Name1
)) in self
.DecPcds
:
980 TokenSpaceGuidCName
= Name1
984 TokenSpaceGuidCName
= ''
985 HasTokenSpace
= False
987 if ((Name2
, Name1
)) in self
.DecPcds
:
990 TokenSpaceGuidCName
= Name1
995 TokenSpaceGuidCName
= ''
996 HasTokenSpace
= False
1000 TokenSpaceGuidCName
= ''
1001 HasTokenSpace
= False
1002 TokenSpaceGuidCNameList
= []
1005 DisplayName
= TokenCName
1007 DisplayName
= TokenCName
+ '.' + FieldName
1008 if not HasTokenSpace
:
1009 for key
in self
.DecPcds
:
1010 PcdItem
= self
.DecPcds
[key
]
1011 if TokenCName
== PcdItem
.TokenCName
:
1012 if not PcdItem
.TokenSpaceGuidCName
in TokenSpaceGuidCNameList
:
1013 if len (TokenSpaceGuidCNameList
) < 1:
1014 TokenSpaceGuidCNameList
.append(PcdItem
.TokenSpaceGuidCName
)
1015 TokenSpaceGuidCName
= PcdItem
.TokenSpaceGuidCName
1016 PcdDatumType
= PcdItem
.DatumType
1022 "The Pcd %s is found under multiple different TokenSpaceGuid: %s and %s." % (DisplayName
, PcdItem
.TokenSpaceGuidCName
, TokenSpaceGuidCNameList
[0])
1025 if (TokenCName
, TokenSpaceGuidCName
) in self
.DecPcds
:
1026 PcdDatumType
= self
.DecPcds
[(TokenCName
, TokenSpaceGuidCName
)].DatumType
1030 EdkLogger
.error('build', AUTOGEN_ERROR
, "The Pcd %s.%s is not found in the DEC file." % (TokenSpaceGuidCName
, DisplayName
))
1032 EdkLogger
.error('build', AUTOGEN_ERROR
, "The Pcd %s is not found in the DEC file." % (DisplayName
))
1033 pcdvalue
= pcdvalue
.replace("\\\\\\'", '\\\\\\"').replace('\\\'', '\'').replace('\\\\\\"', "\\'")
1035 pcdvalue
= DscBuildData
.HandleFlexiblePcd(TokenSpaceGuidCName
, TokenCName
, pcdvalue
, PcdDatumType
, self
._GuidDict
, FieldName
)
1037 pcdvalue
= DscBuildData
.HandleFlexiblePcd(TokenSpaceGuidCName
, TokenCName
, pcdvalue
, PcdDatumType
, self
._GuidDict
)
1038 IsValid
, Cause
= CheckPcdDatum(PcdDatumType
, pcdvalue
)
1040 EdkLogger
.error("build", FORMAT_INVALID
, Cause
, ExtraData
="%s.%s" % (TokenSpaceGuidCName
, TokenCName
))
1041 GlobalData
.BuildOptionPcd
[i
] = (TokenSpaceGuidCName
, TokenCName
, FieldName
, pcdvalue
, ("build command options", 1))
1043 for BuildData
in self
._Bdb
._CACHE
_.values():
1044 if BuildData
.MetaFile
.Ext
== '.dec' or BuildData
.MetaFile
.Ext
== '.dsc':
1046 for key
in BuildData
.Pcds
:
1047 PcdItem
= BuildData
.Pcds
[key
]
1048 if (TokenSpaceGuidCName
, TokenCName
) == (PcdItem
.TokenSpaceGuidCName
, PcdItem
.TokenCName
) and FieldName
=="":
1049 PcdItem
.DefaultValue
= pcdvalue
1052 def HandleFlexiblePcd(TokenSpaceGuidCName
, TokenCName
, PcdValue
, PcdDatumType
, GuidDict
, FieldName
=''):
1055 TokenCName
+= '.' + FieldName
1056 if PcdValue
.startswith('H'):
1057 if FieldName
and IsFieldValueAnArray(PcdValue
[1:]):
1058 PcdDatumType
= TAB_VOID
1060 if FieldName
and not IsArray
:
1063 PcdValue
= ValueExpressionEx(PcdValue
[1:], PcdDatumType
, GuidDict
)(True)
1064 except BadExpression
as Value
:
1065 EdkLogger
.error('Parser', FORMAT_INVALID
, 'PCD [%s.%s] Value "%s", %s' %
1066 (TokenSpaceGuidCName
, TokenCName
, PcdValue
, Value
))
1067 elif PcdValue
.startswith("L'") or PcdValue
.startswith("'"):
1068 if FieldName
and IsFieldValueAnArray(PcdValue
):
1069 PcdDatumType
= TAB_VOID
1071 if FieldName
and not IsArray
:
1074 PcdValue
= ValueExpressionEx(PcdValue
, PcdDatumType
, GuidDict
)(True)
1075 except BadExpression
as Value
:
1076 EdkLogger
.error('Parser', FORMAT_INVALID
, 'PCD [%s.%s] Value "%s", %s' %
1077 (TokenSpaceGuidCName
, TokenCName
, PcdValue
, Value
))
1078 elif PcdValue
.startswith('L'):
1079 PcdValue
= 'L"' + PcdValue
[1:] + '"'
1080 if FieldName
and IsFieldValueAnArray(PcdValue
):
1081 PcdDatumType
= TAB_VOID
1083 if FieldName
and not IsArray
:
1086 PcdValue
= ValueExpressionEx(PcdValue
, PcdDatumType
, GuidDict
)(True)
1087 except BadExpression
as Value
:
1088 EdkLogger
.error('Parser', FORMAT_INVALID
, 'PCD [%s.%s] Value "%s", %s' %
1089 (TokenSpaceGuidCName
, TokenCName
, PcdValue
, Value
))
1091 if PcdValue
.upper() == 'FALSE':
1093 if PcdValue
.upper() == 'TRUE':
1096 if PcdDatumType
not in TAB_PCD_NUMERIC_TYPES
:
1097 PcdValue
= '"' + PcdValue
+ '"'
1101 if PcdValue
.upper().startswith('0X'):
1104 Num
= int(PcdValue
, Base
)
1106 PcdValue
= '"' + PcdValue
+ '"'
1107 if IsFieldValueAnArray(PcdValue
):
1108 PcdDatumType
= TAB_VOID
1113 PcdValue
= ValueExpressionEx(PcdValue
, PcdDatumType
, GuidDict
)(True)
1114 except BadExpression
as Value
:
1115 EdkLogger
.error('Parser', FORMAT_INVALID
, 'PCD [%s.%s] Value "%s", %s' %
1116 (TokenSpaceGuidCName
, TokenCName
, PcdValue
, Value
))
1119 ## Retrieve all PCD settings in platform
1121 if self
._Pcds
is None:
1122 self
._Pcds
= OrderedDict()
1123 self
.__ParsePcdFromCommandLine
()
1124 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_FIXED_AT_BUILD
))
1125 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_PATCHABLE_IN_MODULE
))
1126 self
._Pcds
.update(self
._GetPcd
(MODEL_PCD_FEATURE_FLAG
))
1127 self
._Pcds
.update(self
._GetDynamicPcd
(MODEL_PCD_DYNAMIC_DEFAULT
))
1128 self
._Pcds
.update(self
._GetDynamicHiiPcd
(MODEL_PCD_DYNAMIC_HII
))
1129 self
._Pcds
.update(self
._GetDynamicVpdPcd
(MODEL_PCD_DYNAMIC_VPD
))
1130 self
._Pcds
.update(self
._GetDynamicPcd
(MODEL_PCD_DYNAMIC_EX_DEFAULT
))
1131 self
._Pcds
.update(self
._GetDynamicHiiPcd
(MODEL_PCD_DYNAMIC_EX_HII
))
1132 self
._Pcds
.update(self
._GetDynamicVpdPcd
(MODEL_PCD_DYNAMIC_EX_VPD
))
1134 self
._Pcds
= self
.CompletePcdValues(self
._Pcds
)
1135 self
._Pcds
= self
.OverrideByFdfOverAll(self
._Pcds
)
1136 self
._Pcds
= self
.OverrideByCommOverAll(self
._Pcds
)
1137 self
._Pcds
= self
.UpdateStructuredPcds(MODEL_PCD_TYPE_LIST
, self
._Pcds
)
1138 self
._Pcds
= self
.CompleteHiiPcdsDefaultStores(self
._Pcds
)
1139 self
._Pcds
= self
._FilterPcdBySkuUsage
(self
._Pcds
)
1141 self
.RecoverCommandLinePcd()
1144 ## Retrieve [BuildOptions]
1145 def _GetBuildOptions(self
):
1146 if self
._BuildOptions
is None:
1147 self
._BuildOptions
= OrderedDict()
1149 # Retrieve build option for EDKII and EDK style module
1151 for CodeBase
in (EDKII_NAME
, EDK_NAME
):
1152 RecordList
= self
._RawData
[MODEL_META_DATA_BUILD_OPTION
, self
._Arch
, CodeBase
]
1153 for ToolChainFamily
, ToolChain
, Option
, Dummy1
, Dummy2
, Dummy3
, Dummy4
, Dummy5
in RecordList
:
1154 if Dummy3
.upper() != TAB_COMMON
:
1156 CurKey
= (ToolChainFamily
, ToolChain
, CodeBase
)
1158 # Only flags can be appended
1160 if CurKey
not in self
._BuildOptions
or not ToolChain
.endswith('_FLAGS') or Option
.startswith('='):
1161 self
._BuildOptions
[CurKey
] = Option
1163 if ' ' + Option
not in self
._BuildOptions
[CurKey
]:
1164 self
._BuildOptions
[CurKey
] += ' ' + Option
1165 return self
._BuildOptions
1167 def GetBuildOptionsByModuleType(self
, Edk
, ModuleType
):
1168 if self
._ModuleTypeOptions
is None:
1169 self
._ModuleTypeOptions
= OrderedDict()
1170 if (Edk
, ModuleType
) not in self
._ModuleTypeOptions
:
1171 options
= OrderedDict()
1172 self
._ModuleTypeOptions
[Edk
, ModuleType
] = options
1173 DriverType
= '%s.%s' % (Edk
, ModuleType
)
1174 CommonDriverType
= '%s.%s' % (TAB_COMMON
, ModuleType
)
1175 RecordList
= self
._RawData
[MODEL_META_DATA_BUILD_OPTION
, self
._Arch
]
1176 for ToolChainFamily
, ToolChain
, Option
, Dummy1
, Dummy2
, Dummy3
, Dummy4
, Dummy5
in RecordList
:
1177 Type
= Dummy2
+ '.' + Dummy3
1178 if Type
.upper() == DriverType
.upper() or Type
.upper() == CommonDriverType
.upper():
1179 Key
= (ToolChainFamily
, ToolChain
, Edk
)
1180 if Key
not in options
or not ToolChain
.endswith('_FLAGS') or Option
.startswith('='):
1181 options
[Key
] = Option
1183 if ' ' + Option
not in options
[Key
]:
1184 options
[Key
] += ' ' + Option
1185 return self
._ModuleTypeOptions
[Edk
, ModuleType
]
1188 def GetStructurePcdInfo(PcdSet
):
1189 structure_pcd_data
= defaultdict(list)
1191 structure_pcd_data
[(item
[0], item
[1])].append(item
)
1193 return structure_pcd_data
1196 def OverrideByFdf(StruPcds
,workspace
):
1197 if GlobalData
.gFdfParser
is None:
1199 StructurePcdInFdf
= OrderedDict()
1200 fdfpcd
= GlobalData
.gFdfParser
.Profile
.PcdDict
1201 fdfpcdlocation
= GlobalData
.gFdfParser
.Profile
.PcdLocalDict
1202 for item
in fdfpcd
:
1203 if len(item
[2]) and (item
[0],item
[1]) in StruPcds
:
1204 StructurePcdInFdf
[(item
[1],item
[0],item
[2] )] = fdfpcd
[item
]
1205 GlobalPcds
= {(item
[0],item
[1]) for item
in StructurePcdInFdf
}
1206 for Pcd
in StruPcds
.values():
1207 if (Pcd
.TokenSpaceGuidCName
,Pcd
.TokenCName
) not in GlobalPcds
:
1209 FieldValues
= OrderedDict()
1210 for item
in StructurePcdInFdf
:
1211 if (Pcd
.TokenSpaceGuidCName
,Pcd
.TokenCName
) == (item
[0],item
[1]) and item
[2]:
1212 FieldValues
[item
[2]] = StructurePcdInFdf
[item
]
1213 for field
in FieldValues
:
1214 if field
not in Pcd
.PcdFieldValueFromFdf
:
1215 Pcd
.PcdFieldValueFromFdf
[field
] = ["","",""]
1216 Pcd
.PcdFieldValueFromFdf
[field
][0] = FieldValues
[field
]
1217 Pcd
.PcdFieldValueFromFdf
[field
][1] = os
.path
.relpath(fdfpcdlocation
[(Pcd
.TokenCName
,Pcd
.TokenSpaceGuidCName
,field
)][0],workspace
)
1218 Pcd
.PcdFieldValueFromFdf
[field
][2] = fdfpcdlocation
[(Pcd
.TokenCName
,Pcd
.TokenSpaceGuidCName
,field
)][1]
1223 def OverrideByComm(StruPcds
):
1224 StructurePcdInCom
= OrderedDict()
1225 for item
in GlobalData
.BuildOptionPcd
:
1226 if len(item
) == 5 and (item
[1], item
[0]) in StruPcds
:
1227 StructurePcdInCom
[(item
[0], item
[1], item
[2] )] = (item
[3], item
[4])
1228 GlobalPcds
= {(item
[0], item
[1]) for item
in StructurePcdInCom
}
1229 for Pcd
in StruPcds
.values():
1230 if (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
) not in GlobalPcds
:
1232 FieldValues
= OrderedDict()
1233 for item
in StructurePcdInCom
:
1234 if (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
) == (item
[0], item
[1]) and item
[2]:
1235 FieldValues
[item
[2]] = StructurePcdInCom
[item
]
1236 for field
in FieldValues
:
1237 if field
not in Pcd
.PcdFieldValueFromComm
:
1238 Pcd
.PcdFieldValueFromComm
[field
] = ["", "", ""]
1239 Pcd
.PcdFieldValueFromComm
[field
][0] = FieldValues
[field
][0]
1240 Pcd
.PcdFieldValueFromComm
[field
][1] = FieldValues
[field
][1][0]
1241 Pcd
.PcdFieldValueFromComm
[field
][2] = FieldValues
[field
][1][1]
1245 def OverrideByCommOverAll(self
,AllPcds
):
1246 def CheckStructureInComm(commpcds
):
1249 if len(commpcds
[0]) == 5:
1253 if CheckStructureInComm(GlobalData
.BuildOptionPcd
):
1254 StructurePcdInCom
= {(item
[0], item
[1], item
[2] ):(item
[3], item
[4]) for item
in GlobalData
.BuildOptionPcd
} if GlobalData
.BuildOptionPcd
else {}
1255 NoFiledValues
= {(item
[0], item
[1]):StructurePcdInCom
[item
] for item
in StructurePcdInCom
if not item
[2]}
1257 NoFiledValues
= {(item
[0], item
[1]):[item
[2]] for item
in GlobalData
.BuildOptionPcd
}
1258 for Guid
, Name
in NoFiledValues
:
1259 if (Name
, Guid
) in AllPcds
:
1260 Pcd
= AllPcds
.get((Name
, Guid
))
1261 if isinstance(self
._DecPcds
.get((Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
), None), StructurePcd
):
1262 self
._DecPcds
.get((Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
)).PcdValueFromComm
= NoFiledValues
[(Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)][0]
1264 Pcd
.PcdValueFromComm
= NoFiledValues
[(Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)][0]
1265 Pcd
.DefaultValue
= NoFiledValues
[(Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)][0]
1266 for sku
in Pcd
.SkuInfoList
:
1267 SkuInfo
= Pcd
.SkuInfoList
[sku
]
1268 if SkuInfo
.DefaultValue
:
1269 SkuInfo
.DefaultValue
= NoFiledValues
[(Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)][0]
1271 SkuInfo
.HiiDefaultValue
= NoFiledValues
[(Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)][0]
1272 for defaultstore
in SkuInfo
.DefaultStoreDict
:
1273 SkuInfo
.DefaultStoreDict
[defaultstore
] = NoFiledValues
[(Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)][0]
1274 if Pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
]]:
1275 if Pcd
.DatumType
== TAB_VOID
:
1276 if not Pcd
.MaxDatumSize
:
1277 Pcd
.MaxDatumSize
= '0'
1278 CurrentSize
= int(Pcd
.MaxDatumSize
, 16) if Pcd
.MaxDatumSize
.upper().startswith("0X") else int(Pcd
.MaxDatumSize
)
1279 OptionSize
= len((StringToArray(Pcd
.PcdValueFromComm
)).split(","))
1280 MaxSize
= max(CurrentSize
, OptionSize
)
1281 Pcd
.MaxDatumSize
= str(MaxSize
)
1283 PcdInDec
= self
.DecPcds
.get((Name
, Guid
))
1285 PcdInDec
.PcdValueFromComm
= NoFiledValues
[(Guid
, Name
)][0]
1286 if PcdInDec
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FIXED_AT_BUILD
],
1287 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_PATCHABLE_IN_MODULE
],
1288 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FEATURE_FLAG
]]:
1289 self
.Pcds
[Name
, Guid
] = copy
.deepcopy(PcdInDec
)
1290 self
.Pcds
[Name
, Guid
].DefaultValue
= NoFiledValues
[( Guid
, Name
)][0]
1293 def OverrideByFdfOverAll(self
,AllPcds
):
1295 if GlobalData
.gFdfParser
is None:
1297 NoFiledValues
= GlobalData
.gFdfParser
.Profile
.PcdDict
1298 for Name
,Guid
,Field
in NoFiledValues
:
1301 Value
= NoFiledValues
[(Name
,Guid
,Field
)]
1302 if (Name
,Guid
) in AllPcds
:
1303 Pcd
= AllPcds
.get((Name
,Guid
))
1304 if isinstance(self
._DecPcds
.get((Pcd
.TokenCName
,Pcd
.TokenSpaceGuidCName
), None),StructurePcd
):
1305 self
._DecPcds
.get((Pcd
.TokenCName
,Pcd
.TokenSpaceGuidCName
)).PcdValueFromComm
= Value
1307 Pcd
.PcdValueFromComm
= Value
1308 Pcd
.DefaultValue
= Value
1309 for sku
in Pcd
.SkuInfoList
:
1310 SkuInfo
= Pcd
.SkuInfoList
[sku
]
1311 if SkuInfo
.DefaultValue
:
1312 SkuInfo
.DefaultValue
= Value
1314 SkuInfo
.HiiDefaultValue
= Value
1315 for defaultstore
in SkuInfo
.DefaultStoreDict
:
1316 SkuInfo
.DefaultStoreDict
[defaultstore
] = Value
1317 if Pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
]]:
1318 if Pcd
.DatumType
== TAB_VOID
:
1319 if not Pcd
.MaxDatumSize
:
1320 Pcd
.MaxDatumSize
= '0'
1321 CurrentSize
= int(Pcd
.MaxDatumSize
,16) if Pcd
.MaxDatumSize
.upper().startswith("0X") else int(Pcd
.MaxDatumSize
)
1322 OptionSize
= len((StringToArray(Pcd
.PcdValueFromComm
)).split(","))
1323 MaxSize
= max(CurrentSize
, OptionSize
)
1324 Pcd
.MaxDatumSize
= str(MaxSize
)
1326 PcdInDec
= self
.DecPcds
.get((Name
,Guid
))
1328 PcdInDec
.PcdValueFromFdf
= Value
1329 if PcdInDec
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FIXED_AT_BUILD
],
1330 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_PATCHABLE_IN_MODULE
],
1331 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FEATURE_FLAG
]]:
1332 self
.Pcds
[Name
, Guid
] = copy
.deepcopy(PcdInDec
)
1333 self
.Pcds
[Name
, Guid
].DefaultValue
= Value
1336 def UpdateStructuredPcds(self
, TypeList
, AllPcds
):
1338 DynamicPcdType
= [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_DEFAULT
],
1339 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
],
1340 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_VPD
],
1341 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_DEFAULT
],
1342 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
],
1343 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_VPD
]]
1346 DefaultStoreMgr
= DefaultStore(self
.DefaultStores
)
1347 SkuIds
= self
.SkuIdMgr
.AvailableSkuIdSet
1348 SkuIds
.update({TAB_DEFAULT
:0})
1349 DefaultStores
= {storename
for pcdobj
in AllPcds
.values() for skuobj
in pcdobj
.SkuInfoList
.values() for storename
in skuobj
.DefaultStoreDict
}
1352 # Find out all possible PCD candidates for self._Arch
1355 for Type
in TypeList
:
1356 RecordList
.extend(self
._RawData
[Type
, self
._Arch
])
1358 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, SkuName
, default_store
, Dummy4
, Dummy5
in RecordList
:
1359 SkuName
= SkuName
.upper()
1360 default_store
= default_store
.upper()
1361 SkuName
= TAB_DEFAULT
if SkuName
== TAB_COMMON
else SkuName
1362 if SkuName
not in SkuIds
:
1365 if SkuName
in SkuIds
and "." in TokenSpaceGuid
:
1366 S_PcdSet
.append([ TokenSpaceGuid
.split(".")[0], TokenSpaceGuid
.split(".")[1], PcdCName
, SkuName
, default_store
, Dummy5
, AnalyzePcdExpression(Setting
)[0]])
1368 # handle pcd value override
1369 StrPcdSet
= DscBuildData
.GetStructurePcdInfo(S_PcdSet
)
1370 S_pcd_set
= OrderedDict()
1371 for str_pcd
in StrPcdSet
:
1372 str_pcd_obj
= Pcds
.get((str_pcd
[1], str_pcd
[0]), None)
1373 str_pcd_dec
= self
._DecPcds
.get((str_pcd
[1], str_pcd
[0]), None)
1374 if not isinstance (str_pcd_dec
, StructurePcd
):
1375 EdkLogger
.error('build', PARSER_ERROR
,
1376 "Pcd (%s.%s) is not declared as Structure PCD in DEC files. Arch: ['%s']" % (str_pcd
[0], str_pcd
[1], self
._Arch
),
1377 File
=self
.MetaFile
, Line
= StrPcdSet
[str_pcd
][0][5])
1379 str_pcd_obj_str
= StructurePcd()
1380 str_pcd_obj_str
.copy(str_pcd_dec
)
1382 str_pcd_obj_str
.copy(str_pcd_obj
)
1383 if str_pcd_obj
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
1384 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
}
1386 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
}
1387 for str_pcd_data
in StrPcdSet
[str_pcd
]:
1388 if str_pcd_data
[3] in SkuIds
:
1389 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])
1390 S_pcd_set
[str_pcd
[1], str_pcd
[0]] = str_pcd_obj_str
1392 EdkLogger
.error('build', PARSER_ERROR
,
1393 "Pcd (%s.%s) defined in DSC is not declared in DEC files. Arch: ['%s']" % (str_pcd
[0], str_pcd
[1], self
._Arch
),
1394 File
=self
.MetaFile
, Line
= StrPcdSet
[str_pcd
][0][5])
1395 # Add the Structure PCD that only defined in DEC, don't have override in DSC file
1396 for Pcd
in self
.DecPcds
:
1397 if isinstance(self
._DecPcds
[Pcd
], StructurePcd
):
1398 if Pcd
not in S_pcd_set
:
1399 str_pcd_obj_str
= StructurePcd()
1400 str_pcd_obj_str
.copy(self
._DecPcds
[Pcd
])
1401 str_pcd_obj
= Pcds
.get(Pcd
, None)
1403 str_pcd_obj_str
.copy(str_pcd_obj
)
1404 if str_pcd_obj
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
1405 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
}
1407 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
}
1408 S_pcd_set
[Pcd
] = str_pcd_obj_str
1410 GlobalData
.gStructurePcd
[self
.Arch
] = S_pcd_set
1411 for stru_pcd
in S_pcd_set
.values():
1412 for skuid
in SkuIds
:
1413 if skuid
in stru_pcd
.SkuOverrideValues
:
1415 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(skuid
)
1417 if skuid
not in stru_pcd
.SkuOverrideValues
:
1418 while nextskuid
not in stru_pcd
.SkuOverrideValues
:
1419 if nextskuid
== TAB_DEFAULT
:
1422 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(nextskuid
)
1423 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
})
1425 stru_pcd
.ValueChain
.add((skuid
, ''))
1426 if stru_pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
1427 for skuid
in SkuIds
:
1430 if skuid
not in stru_pcd
.SkuOverrideValues
:
1431 while nextskuid
not in stru_pcd
.SkuOverrideValues
:
1432 if nextskuid
== TAB_DEFAULT
:
1435 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(nextskuid
)
1438 PcdDefaultStoreSet
= set(defaultstorename
for defaultstorename
in stru_pcd
.SkuOverrideValues
[nextskuid
])
1439 mindefaultstorename
= DefaultStoreMgr
.GetMin(PcdDefaultStoreSet
)
1441 for defaultstoreid
in DefaultStores
:
1442 if defaultstoreid
not in stru_pcd
.SkuOverrideValues
[skuid
]:
1443 stru_pcd
.SkuOverrideValues
[skuid
][defaultstoreid
] = copy
.deepcopy(stru_pcd
.SkuOverrideValues
[nextskuid
][mindefaultstorename
])
1444 stru_pcd
.ValueChain
.add((skuid
, defaultstoreid
))
1445 S_pcd_set
= DscBuildData
.OverrideByFdf(S_pcd_set
,self
.WorkspaceDir
)
1446 S_pcd_set
= DscBuildData
.OverrideByComm(S_pcd_set
)
1447 Str_Pcd_Values
= self
.GenerateByteArrayValue(S_pcd_set
)
1449 for (skuname
, StoreName
, PcdGuid
, PcdName
, PcdValue
) in Str_Pcd_Values
:
1450 str_pcd_obj
= S_pcd_set
.get((PcdName
, PcdGuid
))
1451 if str_pcd_obj
is None:
1452 print(PcdName
, PcdGuid
)
1454 if str_pcd_obj
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
],
1455 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
1456 if skuname
not in str_pcd_obj
.SkuInfoList
:
1457 str_pcd_obj
.SkuInfoList
[skuname
] = SkuInfoClass(SkuIdName
=skuname
, SkuId
=self
.SkuIds
[skuname
][0], HiiDefaultValue
=PcdValue
, DefaultStore
= {StoreName
:PcdValue
})
1459 str_pcd_obj
.SkuInfoList
[skuname
].HiiDefaultValue
= PcdValue
1460 str_pcd_obj
.SkuInfoList
[skuname
].DefaultStoreDict
.update({StoreName
:PcdValue
})
1461 elif str_pcd_obj
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FIXED_AT_BUILD
],
1462 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_PATCHABLE_IN_MODULE
]]:
1463 if skuname
in (self
.SkuIdMgr
.SystemSkuId
, TAB_DEFAULT
, TAB_COMMON
):
1464 str_pcd_obj
.DefaultValue
= PcdValue
1466 if skuname
not in str_pcd_obj
.SkuInfoList
:
1467 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(skuname
)
1469 while nextskuid
not in str_pcd_obj
.SkuInfoList
:
1470 if nextskuid
== TAB_DEFAULT
:
1473 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(nextskuid
)
1474 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
)
1475 str_pcd_obj
.SkuInfoList
[skuname
].SkuId
= self
.SkuIds
[skuname
][0]
1476 str_pcd_obj
.SkuInfoList
[skuname
].SkuIdName
= skuname
1478 str_pcd_obj
.SkuInfoList
[skuname
].DefaultValue
= PcdValue
1479 for str_pcd_obj
in S_pcd_set
.values():
1480 if str_pcd_obj
.Type
not in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
],
1481 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
1483 PcdDefaultStoreSet
= set(defaultstorename
for skuobj
in str_pcd_obj
.SkuInfoList
.values() for defaultstorename
in skuobj
.DefaultStoreDict
)
1484 DefaultStoreObj
= DefaultStore(self
._GetDefaultStores
())
1485 mindefaultstorename
= DefaultStoreObj
.GetMin(PcdDefaultStoreSet
)
1486 str_pcd_obj
.SkuInfoList
[self
.SkuIdMgr
.SystemSkuId
].HiiDefaultValue
= str_pcd_obj
.SkuInfoList
[self
.SkuIdMgr
.SystemSkuId
].DefaultStoreDict
[mindefaultstorename
]
1488 for str_pcd_obj
in S_pcd_set
.values():
1490 str_pcd_obj
.MaxDatumSize
= self
.GetStructurePcdMaxSize(str_pcd_obj
)
1491 Pcds
[str_pcd_obj
.TokenCName
, str_pcd_obj
.TokenSpaceGuidCName
] = str_pcd_obj
1495 if TAB_DEFAULT
not in pcd
.SkuInfoList
and TAB_COMMON
in pcd
.SkuInfoList
:
1496 pcd
.SkuInfoList
[TAB_DEFAULT
] = pcd
.SkuInfoList
[TAB_COMMON
]
1497 del pcd
.SkuInfoList
[TAB_COMMON
]
1498 elif TAB_DEFAULT
in pcd
.SkuInfoList
and TAB_COMMON
in pcd
.SkuInfoList
:
1499 del pcd
.SkuInfoList
[TAB_COMMON
]
1501 map(self
.FilterSkuSettings
, [Pcds
[pcdkey
] for pcdkey
in Pcds
if Pcds
[pcdkey
].Type
in DynamicPcdType
])
1504 ## Retrieve non-dynamic PCD settings
1506 # @param Type PCD type
1508 # @retval a dict object contains settings of given PCD type
1510 def _GetPcd(self
, Type
):
1511 Pcds
= OrderedDict()
1513 # tdict is a special dict kind of type, used for selecting correct
1514 # PCD settings for certain ARCH
1516 AvailableSkuIdSet
= copy
.copy(self
.SkuIds
)
1518 PcdDict
= tdict(True, 3)
1520 # Find out all possible PCD candidates for self._Arch
1521 RecordList
= self
._RawData
[Type
, self
._Arch
]
1522 PcdValueDict
= OrderedDict()
1523 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, SkuName
, Dummy3
, Dummy4
, Dummy5
in RecordList
:
1524 SkuName
= SkuName
.upper()
1525 SkuName
= TAB_DEFAULT
if SkuName
== TAB_COMMON
else SkuName
1526 if SkuName
not in AvailableSkuIdSet
:
1527 EdkLogger
.error('build ', PARAMETER_INVALID
, 'Sku %s is not defined in [SkuIds] section' % SkuName
,
1528 File
=self
.MetaFile
, Line
=Dummy5
)
1529 if SkuName
in (self
.SkuIdMgr
.SystemSkuId
, TAB_DEFAULT
, TAB_COMMON
):
1530 if "." not in TokenSpaceGuid
:
1531 PcdSet
.add((PcdCName
, TokenSpaceGuid
, SkuName
, Dummy5
))
1532 PcdDict
[Arch
, PcdCName
, TokenSpaceGuid
, SkuName
] = Setting
1534 for PcdCName
, TokenSpaceGuid
, SkuName
, Dummy4
in PcdSet
:
1535 Setting
= PcdDict
[self
._Arch
, PcdCName
, TokenSpaceGuid
, SkuName
]
1538 PcdValue
, DatumType
, MaxDatumSize
= self
._ValidatePcd
(PcdCName
, TokenSpaceGuid
, Setting
, Type
, Dummy4
)
1540 if int(MaxDatumSize
, 0) > 0xFFFF:
1541 EdkLogger
.error('build', FORMAT_INVALID
, "The size value must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join((TokenSpaceGuid
, PcdCName
)),
1542 File
=self
.MetaFile
, Line
=Dummy4
)
1543 if int(MaxDatumSize
, 0) < 0:
1544 EdkLogger
.error('build', FORMAT_INVALID
, "The size value can't be set to negative value for %s." % ".".join((TokenSpaceGuid
, PcdCName
)),
1545 File
=self
.MetaFile
, Line
=Dummy4
)
1546 if (PcdCName
, TokenSpaceGuid
) in PcdValueDict
:
1547 PcdValueDict
[PcdCName
, TokenSpaceGuid
][SkuName
] = (PcdValue
, DatumType
, MaxDatumSize
)
1549 PcdValueDict
[PcdCName
, TokenSpaceGuid
] = {SkuName
:(PcdValue
, DatumType
, MaxDatumSize
)}
1551 for ((PcdCName
, TokenSpaceGuid
), PcdSetting
) in PcdValueDict
.iteritems():
1555 if TAB_COMMON
in PcdSetting
:
1556 PcdValue
, DatumType
, MaxDatumSize
= PcdSetting
[TAB_COMMON
]
1557 if TAB_DEFAULT
in PcdSetting
:
1558 PcdValue
, DatumType
, MaxDatumSize
= PcdSetting
[TAB_DEFAULT
]
1559 if self
.SkuIdMgr
.SystemSkuId
in PcdSetting
:
1560 PcdValue
, DatumType
, MaxDatumSize
= PcdSetting
[self
.SkuIdMgr
.SystemSkuId
]
1562 Pcds
[PcdCName
, TokenSpaceGuid
] = PcdClassObject(
1565 self
._PCD
_TYPE
_STRING
_[Type
],
1578 def GetStructurePcdMaxSize(self
, str_pcd
):
1579 pcd_default_value
= str_pcd
.DefaultValue
1580 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()]
1581 sku_values
.append(pcd_default_value
)
1583 def get_length(value
):
1584 Value
= value
.strip()
1586 if Value
.startswith(TAB_GUID
) and Value
.endswith(')'):
1588 if Value
.startswith('L"') and Value
.endswith('"'):
1589 return len(Value
[2:-1])
1590 if Value
[0] == '"' and Value
[-1] == '"':
1591 return len(Value
) - 2
1592 if Value
[0] == '{' and Value
[-1] == '}':
1593 return len(Value
.split(","))
1594 if Value
.startswith("L'") and Value
.endswith("'") and len(list(Value
[2:-1])) > 1:
1595 return len(list(Value
[2:-1]))
1596 if Value
[0] == "'" and Value
[-1] == "'" and len(list(Value
[1:-1])) > 1:
1597 return len(Value
) - 2
1600 return str(max(get_length(item
) for item
in sku_values
))
1603 def ExecuteCommand (Command
):
1605 Process
= subprocess
.Popen(Command
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
, shell
=True)
1607 EdkLogger
.error('Build', COMMAND_FAILURE
, 'Can not execute command: %s' % Command
)
1608 Result
= Process
.communicate()
1609 return Process
.returncode
, Result
[0], Result
[1]
1612 def IntToCString(Value
, ValueSize
):
1614 if not isinstance (Value
, str):
1615 for Index
in range(0, ValueSize
):
1616 Result
= Result
+ '\\x%02x' % (Value
& 0xff)
1618 Result
= Result
+ '"'
1621 def GenerateSizeFunction(self
, Pcd
):
1622 CApp
= "// Default Value in Dec \n"
1623 CApp
= CApp
+ "void Cal_%s_%s_Size(UINT32 *Size){\n" % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
1624 for FieldList
in [Pcd
.DefaultValues
]:
1627 for FieldName
in FieldList
:
1628 FieldName
= "." + FieldName
1629 IsArray
= IsFieldValueAnArray(FieldList
[FieldName
.strip(".")][0])
1630 if IsArray
and not (FieldList
[FieldName
.strip(".")][0].startswith('{GUID') and FieldList
[FieldName
.strip(".")][0].endswith('}')):
1632 Value
= ValueExpressionEx(FieldList
[FieldName
.strip(".")][0], TAB_VOID
, self
._GuidDict
)(True)
1633 except BadExpression
:
1634 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid value format for %s. From %s Line %d " %
1635 (".".join((Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldName
.strip('.'))), FieldList
[FieldName
.strip(".")][1], FieldList
[FieldName
.strip(".")][2]))
1636 Value
, ValueSize
= ParseFieldValue(Value
)
1637 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]);
1640 FieldName_ori
= FieldName
.strip('.')
1641 while '[' in FieldName
:
1642 NewFieldName
= NewFieldName
+ FieldName
.split('[', 1)[0] + '[0]'
1643 ArrayIndex
= int(FieldName
.split('[', 1)[1].split(']', 1)[0])
1644 FieldName
= FieldName
.split(']', 1)[1]
1645 FieldName
= NewFieldName
+ FieldName
1646 while '[' in FieldName
:
1647 FieldName
= FieldName
.rsplit('[', 1)[0]
1648 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])
1649 for skuname
in Pcd
.SkuOverrideValues
:
1650 if skuname
== TAB_COMMON
:
1652 for defaultstorenameitem
in Pcd
.SkuOverrideValues
[skuname
]:
1653 CApp
= CApp
+ "// SkuName: %s, DefaultStoreName: %s \n" % (skuname
, defaultstorenameitem
)
1654 for FieldList
in [Pcd
.SkuOverrideValues
[skuname
].get(defaultstorenameitem
)]:
1657 for FieldName
in FieldList
:
1658 FieldName
= "." + FieldName
1659 IsArray
= IsFieldValueAnArray(FieldList
[FieldName
.strip(".")][0])
1660 if IsArray
and not (FieldList
[FieldName
.strip(".")][0].startswith('{GUID') and FieldList
[FieldName
.strip(".")][0].endswith('}')):
1662 Value
= ValueExpressionEx(FieldList
[FieldName
.strip(".")][0], TAB_VOID
, self
._GuidDict
)(True)
1663 except BadExpression
:
1664 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid value format for %s. From %s Line %d " %
1665 (".".join((Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldName
.strip('.'))), FieldList
[FieldName
.strip(".")][1], FieldList
[FieldName
.strip(".")][2]))
1666 Value
, ValueSize
= ParseFieldValue(Value
)
1667 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]);
1670 FieldName_ori
= FieldName
.strip('.')
1671 while '[' in FieldName
:
1672 NewFieldName
= NewFieldName
+ FieldName
.split('[', 1)[0] + '[0]'
1673 ArrayIndex
= int(FieldName
.split('[', 1)[1].split(']', 1)[0])
1674 FieldName
= FieldName
.split(']', 1)[1]
1675 FieldName
= NewFieldName
+ FieldName
1676 while '[' in FieldName
:
1677 FieldName
= FieldName
.rsplit('[', 1)[0]
1678 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])
1679 if Pcd
.PcdFieldValueFromFdf
:
1680 CApp
= CApp
+ "// From fdf \n"
1681 for FieldName
in Pcd
.PcdFieldValueFromFdf
:
1682 FieldName
= "." + FieldName
1683 IsArray
= IsFieldValueAnArray(Pcd
.PcdFieldValueFromFdf
[FieldName
.strip(".")][0])
1684 if IsArray
and not (Pcd
.PcdFieldValueFromFdf
[FieldName
.strip(".")][0].startswith('{GUID') and Pcd
.PcdFieldValueFromFdf
[FieldName
.strip(".")][0].endswith('}')):
1686 Value
= ValueExpressionEx(Pcd
.PcdFieldValueFromFdf
[FieldName
.strip(".")][0], TAB_VOID
, self
._GuidDict
)(True)
1687 except BadExpression
:
1688 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid value format for %s. From %s Line %d " %
1689 (".".join((Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldName
.strip('.'))), Pcd
.PcdFieldValueFromFdf
[FieldName
.strip(".")][1], Pcd
.PcdFieldValueFromFdf
[FieldName
.strip(".")][2]))
1690 Value
, ValueSize
= ParseFieldValue(Value
)
1691 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]);
1694 FieldName_ori
= FieldName
.strip('.')
1695 while '[' in FieldName
:
1696 NewFieldName
= NewFieldName
+ FieldName
.split('[', 1)[0] + '[0]'
1697 ArrayIndex
= int(FieldName
.split('[', 1)[1].split(']', 1)[0])
1698 FieldName
= FieldName
.split(']', 1)[1]
1699 FieldName
= NewFieldName
+ FieldName
1700 while '[' in FieldName
:
1701 FieldName
= FieldName
.rsplit('[', 1)[0]
1702 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])
1703 if Pcd
.PcdFieldValueFromComm
:
1704 CApp
= CApp
+ "// From Command Line \n"
1705 for FieldName
in Pcd
.PcdFieldValueFromComm
:
1706 FieldName
= "." + FieldName
1707 IsArray
= IsFieldValueAnArray(Pcd
.PcdFieldValueFromComm
[FieldName
.strip(".")][0])
1708 if IsArray
and not (Pcd
.PcdFieldValueFromComm
[FieldName
.strip(".")][0].startswith('{GUID') and Pcd
.PcdFieldValueFromComm
[FieldName
.strip(".")][0].endswith('}')):
1710 Value
= ValueExpressionEx(Pcd
.PcdFieldValueFromComm
[FieldName
.strip(".")][0], TAB_VOID
, self
._GuidDict
)(True)
1711 except BadExpression
:
1712 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid value format for %s. From %s Line %d " %
1713 (".".join((Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldName
.strip('.'))), Pcd
.PcdFieldValueFromComm
[FieldName
.strip(".")][1], Pcd
.PcdFieldValueFromComm
[FieldName
.strip(".")][2]))
1714 Value
, ValueSize
= ParseFieldValue(Value
)
1715 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]);
1718 FieldName_ori
= FieldName
.strip('.')
1719 while '[' in FieldName
:
1720 NewFieldName
= NewFieldName
+ FieldName
.split('[', 1)[0] + '[0]'
1721 ArrayIndex
= int(FieldName
.split('[', 1)[1].split(']', 1)[0])
1722 FieldName
= FieldName
.split(']', 1)[1]
1723 FieldName
= NewFieldName
+ FieldName
1724 while '[' in FieldName
:
1725 FieldName
= FieldName
.rsplit('[', 1)[0]
1726 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])
1727 CApp
= CApp
+ " *Size = (%d > *Size ? %d : *Size); // The Pcd maxsize is %d \n" % (Pcd
.GetPcdMaxSize(), Pcd
.GetPcdMaxSize(), Pcd
.GetPcdMaxSize())
1732 def GenerateSizeStatments(Pcd
):
1733 CApp
= ' Size = sizeof(%s);\n' % (Pcd
.DatumType
)
1734 CApp
= CApp
+ ' Cal_%s_%s_Size(&Size);\n' % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
1737 def GenerateDefaultValueAssignFunction(self
, Pcd
):
1738 CApp
= "// Default value in Dec \n"
1739 CApp
= CApp
+ "void Assign_%s_%s_Default_Value(%s *Pcd){\n" % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, Pcd
.DatumType
)
1740 CApp
= CApp
+ ' UINT32 FieldSize;\n'
1741 CApp
= CApp
+ ' CHAR8 *Value;\n'
1742 DefaultValueFromDec
= Pcd
.DefaultValueFromDec
1743 IsArray
= IsFieldValueAnArray(Pcd
.DefaultValueFromDec
)
1746 DefaultValueFromDec
= ValueExpressionEx(Pcd
.DefaultValueFromDec
, TAB_VOID
)(True)
1747 except BadExpression
:
1748 EdkLogger
.error("Build", FORMAT_INVALID
, "Invalid value format for %s.%s, from DEC: %s" %
1749 (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, DefaultValueFromDec
))
1750 DefaultValueFromDec
= StringToArray(DefaultValueFromDec
)
1751 Value
, ValueSize
= ParseFieldValue (DefaultValueFromDec
)
1752 if isinstance(Value
, str):
1753 CApp
= CApp
+ ' Pcd = %s; // From DEC Default Value %s\n' % (Value
, Pcd
.DefaultValueFromDec
)
1756 # Use memcpy() to copy value into field
1758 CApp
= CApp
+ ' Value = %s; // From DEC Default Value %s\n' % (DscBuildData
.IntToCString(Value
, ValueSize
), Pcd
.DefaultValueFromDec
)
1759 CApp
= CApp
+ ' memcpy (Pcd, Value, %d);\n' % (ValueSize
)
1760 for FieldList
in [Pcd
.DefaultValues
]:
1763 for FieldName
in FieldList
:
1764 IsArray
= IsFieldValueAnArray(FieldList
[FieldName
][0])
1767 FieldList
[FieldName
][0] = ValueExpressionEx(FieldList
[FieldName
][0], TAB_VOID
, self
._GuidDict
)(True)
1768 except BadExpression
:
1769 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid value format for %s. From %s Line %d " %
1770 (".".join((Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldName
)), FieldList
[FieldName
][1], FieldList
[FieldName
][2]))
1773 Value
, ValueSize
= ParseFieldValue (FieldList
[FieldName
][0])
1775 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]))
1776 if isinstance(Value
, str):
1777 CApp
= CApp
+ ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1780 # Use memcpy() to copy value into field
1782 CApp
= CApp
+ ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd
.DatumType
, FieldName
)
1783 CApp
= CApp
+ ' Value = %s; // From %s Line %d Value %s\n' % (DscBuildData
.IntToCString(Value
, ValueSize
), FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1784 CApp
= CApp
+ ' memcpy (&Pcd->%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName
, ValueSize
, ValueSize
)
1787 CApp
= CApp
+ ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1789 CApp
= CApp
+ ' Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1794 def GenerateDefaultValueAssignStatement(Pcd
):
1795 CApp
= ' Assign_%s_%s_Default_Value(Pcd);\n' % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
1798 def GenerateInitValueFunction(self
, Pcd
, SkuName
, DefaultStoreName
):
1799 CApp
= "// Value in Dsc for Sku: %s, DefaultStore %s\n" % (SkuName
, DefaultStoreName
)
1800 CApp
= CApp
+ "void Assign_%s_%s_%s_%s_Value(%s *Pcd){\n" % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, SkuName
, DefaultStoreName
, Pcd
.DatumType
)
1801 CApp
= CApp
+ ' UINT32 FieldSize;\n'
1802 CApp
= CApp
+ ' CHAR8 *Value;\n'
1804 CApp
= CApp
+ "// SkuName: %s, DefaultStoreName: %s \n" % (TAB_DEFAULT
, TAB_DEFAULT_STORES_DEFAULT
)
1805 inherit_OverrideValues
= Pcd
.SkuOverrideValues
[SkuName
]
1806 if (SkuName
, DefaultStoreName
) == (TAB_DEFAULT
, TAB_DEFAULT_STORES_DEFAULT
):
1807 pcddefaultvalue
= Pcd
.DefaultFromDSC
.get(TAB_DEFAULT
, {}).get(TAB_DEFAULT_STORES_DEFAULT
, Pcd
.DefaultValue
) if Pcd
.DefaultFromDSC
else Pcd
.DefaultValue
1809 if not Pcd
.DscRawValue
:
1810 # handle the case that structure pcd is not appear in DSC
1811 self
.CopyDscRawValue(Pcd
)
1812 pcddefaultvalue
= Pcd
.DscRawValue
.get(SkuName
, {}).get(DefaultStoreName
)
1813 for FieldList
in [pcddefaultvalue
, inherit_OverrideValues
.get(DefaultStoreName
)]:
1816 if pcddefaultvalue
and FieldList
== pcddefaultvalue
:
1817 IsArray
= IsFieldValueAnArray(FieldList
)
1820 FieldList
= ValueExpressionEx(FieldList
, TAB_VOID
)(True)
1821 except BadExpression
:
1822 EdkLogger
.error("Build", FORMAT_INVALID
, "Invalid value format for %s.%s, from DSC: %s" %
1823 (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldList
))
1824 Value
, ValueSize
= ParseFieldValue (FieldList
)
1826 if (SkuName
, DefaultStoreName
) == (TAB_DEFAULT
, TAB_DEFAULT_STORES_DEFAULT
):
1827 if isinstance(Value
, str):
1828 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
)
1831 # Use memcpy() to copy value into field
1833 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
)
1834 CApp
= CApp
+ ' memcpy (Pcd, Value, %d);\n' % (ValueSize
)
1836 if isinstance(Value
, str):
1837 CApp
= CApp
+ ' Pcd = %s; // From DSC Default Value %s\n' % (Value
, Pcd
.DscRawValue
.get(SkuName
, {}).get(DefaultStoreName
))
1840 # Use memcpy() to copy value into field
1842 CApp
= CApp
+ ' Value = %s; // From DSC Default Value %s\n' % (DscBuildData
.IntToCString(Value
, ValueSize
), Pcd
.DscRawValue
.get(SkuName
, {}).get(DefaultStoreName
))
1843 CApp
= CApp
+ ' memcpy (Pcd, Value, %d);\n' % (ValueSize
)
1845 if (SkuName
, DefaultStoreName
) == (TAB_DEFAULT
, TAB_DEFAULT_STORES_DEFAULT
) or (( (SkuName
, '') not in Pcd
.ValueChain
) and ( (SkuName
, DefaultStoreName
) not in Pcd
.ValueChain
)):
1846 for FieldName
in FieldList
:
1847 IsArray
= IsFieldValueAnArray(FieldList
[FieldName
][0])
1850 FieldList
[FieldName
][0] = ValueExpressionEx(FieldList
[FieldName
][0], TAB_VOID
, self
._GuidDict
)(True)
1851 except BadExpression
:
1852 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid value format for %s. From %s Line %d " %
1853 (".".join((Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldName
)), FieldList
[FieldName
][1], FieldList
[FieldName
][2]))
1855 Value
, ValueSize
= ParseFieldValue (FieldList
[FieldName
][0])
1857 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]))
1858 if isinstance(Value
, str):
1859 CApp
= CApp
+ ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1862 # Use memcpy() to copy value into field
1864 CApp
= CApp
+ ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd
.DatumType
, FieldName
)
1865 CApp
= CApp
+ ' Value = %s; // From %s Line %d Value %s\n' % (DscBuildData
.IntToCString(Value
, ValueSize
), FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1866 CApp
= CApp
+ ' memcpy (&Pcd->%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName
, ValueSize
, ValueSize
)
1869 CApp
= CApp
+ ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1871 CApp
= CApp
+ ' Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1876 def GenerateInitValueStatement(Pcd
, SkuName
, DefaultStoreName
):
1877 CApp
= ' Assign_%s_%s_%s_%s_Value(Pcd);\n' % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, SkuName
, DefaultStoreName
)
1880 def GenerateCommandLineValue(self
, Pcd
):
1881 CApp
= "// Value in CommandLine\n"
1882 CApp
= CApp
+ "void Assign_%s_%s_CommandLine_Value(%s *Pcd){\n" % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, Pcd
.DatumType
)
1883 CApp
= CApp
+ ' UINT32 FieldSize;\n'
1884 CApp
= CApp
+ ' CHAR8 *Value;\n'
1886 pcddefaultvalue
= Pcd
.PcdValueFromComm
1887 for FieldList
in [pcddefaultvalue
, Pcd
.PcdFieldValueFromComm
]:
1890 if pcddefaultvalue
and FieldList
== pcddefaultvalue
:
1891 IsArray
= IsFieldValueAnArray(FieldList
)
1894 FieldList
= ValueExpressionEx(FieldList
, TAB_VOID
)(True)
1895 except BadExpression
:
1896 EdkLogger
.error("Build", FORMAT_INVALID
, "Invalid value format for %s.%s, from Command: %s" %
1897 (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldList
))
1898 Value
, ValueSize
= ParseFieldValue (FieldList
)
1900 if isinstance(Value
, str):
1901 CApp
= CApp
+ ' Pcd = %s; // From Command Line \n' % (Value
)
1904 # Use memcpy() to copy value into field
1906 CApp
= CApp
+ ' Value = %s; // From Command Line.\n' % (DscBuildData
.IntToCString(Value
, ValueSize
))
1907 CApp
= CApp
+ ' memcpy (Pcd, Value, %d);\n' % (ValueSize
)
1909 for FieldName
in FieldList
:
1910 IsArray
= IsFieldValueAnArray(FieldList
[FieldName
][0])
1913 FieldList
[FieldName
][0] = ValueExpressionEx(FieldList
[FieldName
][0], TAB_VOID
, self
._GuidDict
)(True)
1914 except BadExpression
:
1915 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid value format for %s. From %s Line %d " %
1916 (".".join((Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldName
)), FieldList
[FieldName
][1], FieldList
[FieldName
][2]))
1920 Value
, ValueSize
= ParseFieldValue (FieldList
[FieldName
][0])
1922 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]))
1923 if isinstance(Value
, str):
1924 CApp
= CApp
+ ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1927 # Use memcpy() to copy value into field
1929 CApp
= CApp
+ ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd
.DatumType
, FieldName
)
1930 CApp
= CApp
+ ' Value = %s; // From %s Line %d Value %s\n' % (DscBuildData
.IntToCString(Value
, ValueSize
), FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1931 CApp
= CApp
+ ' memcpy (&Pcd->%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName
, ValueSize
, ValueSize
)
1934 CApp
= CApp
+ ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1936 CApp
= CApp
+ ' Pcd->%s = %d; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1941 def GenerateCommandLineValueStatement(Pcd
):
1942 CApp
= ' Assign_%s_%s_CommandLine_Value(Pcd);\n' % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
1944 def GenerateFdfValue(self
,Pcd
):
1945 CApp
= "// Value in Fdf\n"
1946 CApp
= CApp
+ "void Assign_%s_%s_Fdf_Value(%s *Pcd){\n" % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
,Pcd
.DatumType
)
1947 CApp
= CApp
+ ' UINT32 FieldSize;\n'
1948 CApp
= CApp
+ ' CHAR8 *Value;\n'
1950 pcddefaultvalue
= Pcd
.PcdValueFromFdf
1951 for FieldList
in [pcddefaultvalue
,Pcd
.PcdFieldValueFromFdf
]:
1954 if pcddefaultvalue
and FieldList
== pcddefaultvalue
:
1955 IsArray
= IsFieldValueAnArray(FieldList
)
1958 FieldList
= ValueExpressionEx(FieldList
, TAB_VOID
)(True)
1959 except BadExpression
:
1960 EdkLogger
.error("Build", FORMAT_INVALID
, "Invalid value format for %s.%s, from Fdf: %s" %
1961 (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldList
))
1962 Value
, ValueSize
= ParseFieldValue (FieldList
)
1964 if isinstance(Value
, str):
1965 CApp
= CApp
+ ' Pcd = %s; // From Fdf \n' % (Value
)
1968 # Use memcpy() to copy value into field
1970 CApp
= CApp
+ ' Value = %s; // From Fdf .\n' % (DscBuildData
.IntToCString(Value
, ValueSize
))
1971 CApp
= CApp
+ ' memcpy (Pcd, Value, %d);\n' % (ValueSize
)
1973 for FieldName
in FieldList
:
1974 IsArray
= IsFieldValueAnArray(FieldList
[FieldName
][0])
1977 FieldList
[FieldName
][0] = ValueExpressionEx(FieldList
[FieldName
][0], TAB_VOID
, self
._GuidDict
)(True)
1978 except BadExpression
:
1979 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid value format for %s. From %s Line %d " %
1980 (".".join((Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, FieldName
)), FieldList
[FieldName
][1], FieldList
[FieldName
][2]))
1984 Value
, ValueSize
= ParseFieldValue (FieldList
[FieldName
][0])
1986 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]))
1987 if isinstance(Value
, str):
1988 CApp
= CApp
+ ' Pcd->%s = %s; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1991 # Use memcpy() to copy value into field
1993 CApp
= CApp
+ ' FieldSize = __FIELD_SIZE(%s, %s);\n' % (Pcd
.DatumType
, FieldName
)
1994 CApp
= CApp
+ ' Value = %s; // From %s Line %d Value %s\n' % (DscBuildData
.IntToCString(Value
, ValueSize
), FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
1995 CApp
= CApp
+ ' memcpy (&Pcd->%s, Value, (FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName
, ValueSize
, ValueSize
)
1998 CApp
= CApp
+ ' Pcd->%s = %dULL; // From %s Line %d Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
2000 CApp
= CApp
+ ' Pcd->%s = %d; // From %s Line %s Value %s\n' % (FieldName
, Value
, FieldList
[FieldName
][1], FieldList
[FieldName
][2], FieldList
[FieldName
][0])
2005 def GenerateFdfValueStatement(Pcd
):
2006 CApp
= ' Assign_%s_%s_Fdf_Value(Pcd);\n' % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
2009 def GenerateInitializeFunc(self
, SkuName
, DefaultStore
, Pcd
, InitByteValue
, CApp
):
2010 OverrideValues
= {DefaultStore
:""}
2011 if Pcd
.SkuOverrideValues
:
2012 OverrideValues
= Pcd
.SkuOverrideValues
[SkuName
]
2013 for DefaultStoreName
in OverrideValues
:
2014 CApp
= CApp
+ 'void\n'
2015 CApp
= CApp
+ 'Initialize_%s_%s_%s_%s(\n' % (SkuName
, DefaultStoreName
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
2016 CApp
= CApp
+ ' void\n'
2017 CApp
= CApp
+ ' )\n'
2019 CApp
= CApp
+ ' UINT32 Size;\n'
2020 CApp
= CApp
+ ' UINT32 FieldSize;\n'
2021 CApp
= CApp
+ ' CHAR8 *Value;\n'
2022 CApp
= CApp
+ ' UINT32 OriginalSize;\n'
2023 CApp
= CApp
+ ' VOID *OriginalPcd;\n'
2024 CApp
= CApp
+ ' %s *Pcd; // From %s Line %d \n' % (Pcd
.DatumType
, Pcd
.PkgPath
, Pcd
.PcdDefineLineNo
)
2027 if SkuName
in Pcd
.SkuInfoList
:
2028 DefaultValue
= Pcd
.SkuInfoList
[SkuName
].DefaultStoreDict
.get(DefaultStoreName
, Pcd
.SkuInfoList
[SkuName
].HiiDefaultValue
if Pcd
.SkuInfoList
[SkuName
].HiiDefaultValue
else Pcd
.SkuInfoList
[SkuName
].DefaultValue
)
2030 DefaultValue
= Pcd
.DefaultValue
2031 PcdDefaultValue
= StringToArray(DefaultValue
.strip())
2033 InitByteValue
+= '%s.%s.%s.%s|%s|%s\n' % (SkuName
, DefaultStoreName
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, Pcd
.DatumType
, PcdDefaultValue
)
2036 # Get current PCD value and size
2038 CApp
= CApp
+ ' OriginalPcd = PcdGetPtr (%s, %s, %s, %s, &OriginalSize);\n' % (SkuName
, DefaultStoreName
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
2041 # Determine the size of the PCD. For simple structures, sizeof(TYPE) provides
2042 # the correct value. For structures with a flexible array member, the flexible
2043 # array member is detected, and the size is based on the highest index used with
2044 # the flexible array member. The flexible array member must be the last field
2045 # in a structure. The size formula for this case is:
2046 # OFFSET_OF(FlexbleArrayField) + sizeof(FlexibleArray[0]) * (HighestIndex + 1)
2048 CApp
= CApp
+ DscBuildData
.GenerateSizeStatments(Pcd
)
2051 # Allocate and zero buffer for the PCD
2052 # Must handle cases where current value is smaller, larger, or same size
2053 # Always keep that larger one as the current size
2055 CApp
= CApp
+ ' Size = (OriginalSize > Size ? OriginalSize : Size);\n'
2056 CApp
= CApp
+ ' Pcd = (%s *)malloc (Size);\n' % (Pcd
.DatumType
)
2057 CApp
= CApp
+ ' memset (Pcd, 0, Size);\n'
2060 # Copy current PCD value into allocated buffer.
2062 CApp
= CApp
+ ' memcpy (Pcd, OriginalPcd, OriginalSize);\n'
2065 # Assign field values in PCD
2067 CApp
= CApp
+ DscBuildData
.GenerateDefaultValueAssignStatement(Pcd
)
2068 if Pcd
.Type
not in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FIXED_AT_BUILD
],
2069 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_PATCHABLE_IN_MODULE
]]:
2070 for skuname
in self
.SkuIdMgr
.GetSkuChain(SkuName
):
2071 storeset
= [DefaultStoreName
] if DefaultStoreName
== TAB_DEFAULT_STORES_DEFAULT
else [TAB_DEFAULT_STORES_DEFAULT
, DefaultStoreName
]
2072 for defaultstorenameitem
in storeset
:
2073 CApp
= CApp
+ "// SkuName: %s, DefaultStoreName: %s \n" % (skuname
, defaultstorenameitem
)
2074 CApp
= CApp
+ DscBuildData
.GenerateInitValueStatement(Pcd
, skuname
, defaultstorenameitem
)
2075 if skuname
== SkuName
:
2078 CApp
= CApp
+ "// SkuName: %s, DefaultStoreName: STANDARD \n" % self
.SkuIdMgr
.SystemSkuId
2079 CApp
= CApp
+ DscBuildData
.GenerateInitValueStatement(Pcd
, self
.SkuIdMgr
.SystemSkuId
, TAB_DEFAULT_STORES_DEFAULT
)
2080 CApp
= CApp
+ DscBuildData
.GenerateFdfValueStatement(Pcd
)
2081 CApp
= CApp
+ DscBuildData
.GenerateCommandLineValueStatement(Pcd
)
2083 # Set new PCD value and size
2085 CApp
= CApp
+ ' PcdSetPtr (%s, %s, %s, %s, Size, (UINT8 *)Pcd);\n' % (SkuName
, DefaultStoreName
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
2090 CApp
= CApp
+ ' free (Pcd);\n'
2093 return InitByteValue
, CApp
2095 def GenerateByteArrayValue (self
, StructuredPcds
):
2097 # Generate/Compile/Run C application to determine if there are any flexible array members
2099 if not StructuredPcds
:
2103 CApp
= PcdMainCHeader
2105 IncludeFiles
= set()
2106 for PcdName
in StructuredPcds
:
2107 Pcd
= StructuredPcds
[PcdName
]
2108 for IncludeFile
in Pcd
.StructuredPcdIncludeFile
:
2109 if IncludeFile
not in IncludeFiles
:
2110 IncludeFiles
.add(IncludeFile
)
2111 CApp
= CApp
+ '#include <%s>\n' % (IncludeFile
)
2113 for PcdName
in StructuredPcds
:
2114 Pcd
= StructuredPcds
[PcdName
]
2115 CApp
= CApp
+ self
.GenerateSizeFunction(Pcd
)
2116 CApp
= CApp
+ self
.GenerateDefaultValueAssignFunction(Pcd
)
2117 CApp
= CApp
+ self
.GenerateFdfValue(Pcd
)
2118 CApp
= CApp
+ self
.GenerateCommandLineValue(Pcd
)
2119 if not Pcd
.SkuOverrideValues
or Pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FIXED_AT_BUILD
],
2120 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_PATCHABLE_IN_MODULE
]]:
2121 CApp
= CApp
+ self
.GenerateInitValueFunction(Pcd
, self
.SkuIdMgr
.SystemSkuId
, TAB_DEFAULT_STORES_DEFAULT
)
2123 for SkuName
in self
.SkuIdMgr
.SkuOverrideOrder():
2124 if SkuName
not in Pcd
.SkuOverrideValues
:
2126 for DefaultStoreName
in Pcd
.SkuOverrideValues
[SkuName
]:
2127 CApp
= CApp
+ self
.GenerateInitValueFunction(Pcd
, SkuName
, DefaultStoreName
)
2128 if not Pcd
.SkuOverrideValues
or Pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FIXED_AT_BUILD
],
2129 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_PATCHABLE_IN_MODULE
]]:
2130 InitByteValue
, CApp
= self
.GenerateInitializeFunc(self
.SkuIdMgr
.SystemSkuId
, TAB_DEFAULT_STORES_DEFAULT
, Pcd
, InitByteValue
, CApp
)
2132 for SkuName
in self
.SkuIdMgr
.SkuOverrideOrder():
2133 if SkuName
not in Pcd
.SkuOverrideValues
:
2135 for DefaultStoreName
in Pcd
.DefaultStoreName
:
2136 Pcd
= StructuredPcds
[PcdName
]
2137 InitByteValue
, CApp
= self
.GenerateInitializeFunc(SkuName
, DefaultStoreName
, Pcd
, InitByteValue
, CApp
)
2139 CApp
= CApp
+ 'VOID\n'
2140 CApp
= CApp
+ 'PcdEntryPoint(\n'
2141 CApp
= CApp
+ ' VOID\n'
2142 CApp
= CApp
+ ' )\n'
2144 for Pcd
in StructuredPcds
.values():
2145 if not Pcd
.SkuOverrideValues
or Pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FIXED_AT_BUILD
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_PATCHABLE_IN_MODULE
]]:
2146 CApp
= CApp
+ ' Initialize_%s_%s_%s_%s();\n' % (self
.SkuIdMgr
.SystemSkuId
, TAB_DEFAULT_STORES_DEFAULT
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
2148 for SkuName
in self
.SkuIdMgr
.SkuOverrideOrder():
2149 if SkuName
not in Pcd
.SkuOverrideValues
:
2151 for DefaultStoreName
in Pcd
.SkuOverrideValues
[SkuName
]:
2152 CApp
= CApp
+ ' Initialize_%s_%s_%s_%s();\n' % (SkuName
, DefaultStoreName
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
2155 CApp
= CApp
+ PcdMainCEntry
+ '\n'
2157 if not os
.path
.exists(self
.OutputPath
):
2158 os
.makedirs(self
.OutputPath
)
2159 CAppBaseFileName
= os
.path
.join(self
.OutputPath
, PcdValueInitName
)
2160 SaveFileOnChange(CAppBaseFileName
+ '.c', CApp
, False)
2162 MakeApp
= PcdMakefileHeader
2163 if sys
.platform
== "win32":
2164 MakeApp
= MakeApp
+ 'APPNAME = %s\n' % (PcdValueInitName
) + 'OBJECTS = %s\%s.obj\n' % (self
.OutputPath
, PcdValueInitName
) + 'INC = '
2166 MakeApp
= MakeApp
+ PcdGccMakefile
2167 MakeApp
= MakeApp
+ 'APPNAME = %s\n' % (PcdValueInitName
) + 'OBJECTS = %s/%s.o\n' % (self
.OutputPath
, PcdValueInitName
) + \
2168 'include $(MAKEROOT)/Makefiles/app.makefile\n' + 'INCLUDE +='
2172 for Cache
in self
._Bdb
._CACHE
_.values():
2173 if Cache
.MetaFile
.Ext
.lower() != '.dec':
2176 if str(Cache
.MetaFile
.Path
) not in PlatformInc
:
2177 PlatformInc
[str(Cache
.MetaFile
.Path
)] = []
2178 PlatformInc
[str(Cache
.MetaFile
.Path
)].append (os
.path
.dirname(Cache
.MetaFile
.Path
))
2179 PlatformInc
[str(Cache
.MetaFile
.Path
)].extend (Cache
.CommonIncludes
)
2182 for Pcd
in StructuredPcds
.values():
2183 for PackageDec
in Pcd
.PackageDecs
:
2184 Package
= os
.path
.normpath(mws
.join(GlobalData
.gWorkspace
, PackageDec
))
2185 if not os
.path
.exists(Package
):
2186 EdkLogger
.error('Build', RESOURCE_NOT_AVAILABLE
, "The dependent Package %s of PCD %s.%s is not exist." % (PackageDec
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
))
2187 if Package
not in PcdDependDEC
:
2188 PcdDependDEC
.append(Package
)
2190 if PlatformInc
and PcdDependDEC
:
2191 for pkg
in PcdDependDEC
:
2192 if pkg
in PlatformInc
:
2193 for inc
in PlatformInc
[pkg
]:
2194 MakeApp
+= '-I' + str(inc
) + ' '
2195 IncSearchList
.append(inc
)
2196 MakeApp
= MakeApp
+ '\n'
2198 CC_FLAGS
= LinuxCFLAGS
2199 if sys
.platform
== "win32":
2200 CC_FLAGS
= WindowsCFLAGS
2202 for Options
in self
.BuildOptions
:
2203 if Options
[2] != EDKII_NAME
:
2206 if Family
and Family
!= self
.ToolChainFamily
:
2208 Target
, Tag
, Arch
, Tool
, Attr
= Options
[1].split("_")
2212 if Target
== "*" or Target
== self
._Target
:
2213 if Tag
== "*" or Tag
== self
._Toolchain
:
2214 if Arch
== "*" or Arch
== self
.Arch
:
2215 if Tool
not in BuildOptions
:
2216 BuildOptions
[Tool
] = {}
2217 if Attr
!= "FLAGS" or Attr
not in BuildOptions
[Tool
] or self
.BuildOptions
[Options
].startswith('='):
2218 BuildOptions
[Tool
][Attr
] = self
.BuildOptions
[Options
]
2220 # append options for the same tool except PATH
2222 BuildOptions
[Tool
][Attr
] += " " + self
.BuildOptions
[Options
]
2224 BuildOptions
[Tool
][Attr
] = self
.BuildOptions
[Options
]
2226 for Tool
in BuildOptions
:
2227 for Attr
in BuildOptions
[Tool
]:
2229 Value
= BuildOptions
[Tool
][Attr
]
2230 ValueList
= Value
.split()
2232 for Id
, Item
in enumerate(ValueList
):
2233 if Item
in ['-D', '/D', '-U', '/U']:
2234 CC_FLAGS
+= ' ' + Item
2235 if Id
+ 1 < len(ValueList
):
2236 CC_FLAGS
+= ' ' + ValueList
[Id
+ 1]
2237 elif Item
.startswith(('-D', '/D', '-U', '/U')):
2238 CC_FLAGS
+= ' ' + Item
2241 if sys
.platform
== "win32":
2242 MakeApp
= MakeApp
+ PcdMakefileEnd
2243 MakeApp
= MakeApp
+ '\n'
2244 IncludeFileFullPaths
= []
2245 for includefile
in IncludeFiles
:
2246 for includepath
in IncSearchList
:
2247 includefullpath
= os
.path
.join(str(includepath
), includefile
)
2248 if os
.path
.exists(includefullpath
):
2249 IncludeFileFullPaths
.append(os
.path
.normpath(includefullpath
))
2252 SearchPathList
.append(os
.path
.normpath(mws
.join(GlobalData
.gWorkspace
, "BaseTools/Source/C/Include")))
2253 SearchPathList
.append(os
.path
.normpath(mws
.join(GlobalData
.gWorkspace
, "BaseTools/Source/C/Common")))
2254 SearchPathList
.extend(str(item
) for item
in IncSearchList
)
2255 IncFileList
= GetDependencyList(IncludeFileFullPaths
, SearchPathList
)
2256 for include_file
in IncFileList
:
2257 MakeApp
+= "$(OBJECTS) : %s\n" % include_file
2258 MakeFileName
= os
.path
.join(self
.OutputPath
, 'Makefile')
2259 MakeApp
+= "$(OBJECTS) : %s\n" % MakeFileName
2260 SaveFileOnChange(MakeFileName
, MakeApp
, False)
2262 InputValueFile
= os
.path
.join(self
.OutputPath
, 'Input.txt')
2263 OutputValueFile
= os
.path
.join(self
.OutputPath
, 'Output.txt')
2264 SaveFileOnChange(InputValueFile
, InitByteValue
, False)
2266 PcdValueInitExe
= PcdValueInitName
2267 if not sys
.platform
== "win32":
2268 PcdValueInitExe
= os
.path
.join(os
.getenv("EDK_TOOLS_PATH"), 'Source', 'C', 'bin', PcdValueInitName
)
2270 PcdValueInitExe
= os
.path
.join(os
.getenv("EDK_TOOLS_PATH"), 'Bin', 'Win32', PcdValueInitName
) +".exe"
2273 if sys
.platform
== "win32":
2274 MakeCommand
= 'nmake -f %s' % (MakeFileName
)
2275 returncode
, StdOut
, StdErr
= DscBuildData
.ExecuteCommand (MakeCommand
)
2278 MakeCommand
= 'make -f %s' % (MakeFileName
)
2279 returncode
, StdOut
, StdErr
= DscBuildData
.ExecuteCommand (MakeCommand
)
2281 Messages
= Messages
.split('\n')
2284 CAppBaseFileName
= os
.path
.join(self
.OutputPath
, PcdValueInitName
)
2285 File
= open (CAppBaseFileName
+ '.c', 'r')
2286 FileData
= File
.readlines()
2288 for Message
in Messages
:
2289 if " error" in Message
or "warning" in Message
:
2290 FileInfo
= Message
.strip().split('(')
2291 if len (FileInfo
) > 1:
2292 FileName
= FileInfo
[0]
2293 FileLine
= FileInfo
[1].split (')')[0]
2295 FileInfo
= Message
.strip().split(':')
2296 FileName
= FileInfo
[0]
2297 FileLine
= FileInfo
[1]
2298 if FileLine
.isdigit():
2299 error_line
= FileData
[int (FileLine
) - 1]
2300 if r
"//" in error_line
:
2301 c_line
, dsc_line
= error_line
.split(r
"//")
2303 dsc_line
= error_line
2304 message_itmes
= Message
.split(":")
2306 if "PcdValueInit.c" not in Message
:
2307 if not MessageGroup
:
2308 MessageGroup
.append(Message
)
2311 for item
in message_itmes
:
2312 if "PcdValueInit.c" in item
:
2313 Index
= message_itmes
.index(item
)
2314 message_itmes
[Index
] = dsc_line
.strip()
2316 MessageGroup
.append(":".join(message_itmes
[Index
:]).strip())
2319 MessageGroup
.append(Message
)
2321 EdkLogger
.error("build", PCD_STRUCTURE_PCD_ERROR
, "\n".join(MessageGroup
) )
2323 EdkLogger
.error('Build', COMMAND_FAILURE
, 'Can not execute command: %s' % MakeCommand
)
2325 if DscBuildData
.NeedUpdateOutput(OutputValueFile
, PcdValueInitExe
, InputValueFile
):
2326 Command
= PcdValueInitExe
+ ' -i %s -o %s' % (InputValueFile
, OutputValueFile
)
2327 returncode
, StdOut
, StdErr
= DscBuildData
.ExecuteCommand (Command
)
2329 EdkLogger
.warn('Build', COMMAND_FAILURE
, 'Can not collect output from command: %s' % Command
)
2331 File
= open (OutputValueFile
, 'r')
2332 FileBuffer
= File
.readlines()
2335 StructurePcdSet
= []
2336 for Pcd
in FileBuffer
:
2337 PcdValue
= Pcd
.split ('|')
2338 PcdInfo
= PcdValue
[0].split ('.')
2339 StructurePcdSet
.append((PcdInfo
[0], PcdInfo
[1], PcdInfo
[2], PcdInfo
[3], PcdValue
[2].strip()))
2340 return StructurePcdSet
2343 def NeedUpdateOutput(OutputFile
, ValueCFile
, StructureInput
):
2344 if not os
.path
.exists(OutputFile
):
2346 if os
.stat(OutputFile
).st_mtime
<= os
.stat(ValueCFile
).st_mtime
:
2348 if os
.stat(OutputFile
).st_mtime
<= os
.stat(StructureInput
).st_mtime
:
2352 ## Retrieve dynamic PCD settings
2354 # @param Type PCD type
2356 # @retval a dict object contains settings of given PCD type
2358 def _GetDynamicPcd(self
, Type
):
2361 Pcds
= OrderedDict()
2363 # tdict is a special dict kind of type, used for selecting correct
2364 # PCD settings for certain ARCH and SKU
2366 PcdDict
= tdict(True, 4)
2368 # Find out all possible PCD candidates for self._Arch
2369 RecordList
= self
._RawData
[Type
, self
._Arch
]
2370 AvailableSkuIdSet
= copy
.copy(self
.SkuIds
)
2373 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, SkuName
, Dummy3
, Dummy4
, Dummy5
in RecordList
:
2374 SkuName
= SkuName
.upper()
2375 SkuName
= TAB_DEFAULT
if SkuName
== TAB_COMMON
else SkuName
2376 if SkuName
not in AvailableSkuIdSet
:
2377 EdkLogger
.error('build', PARAMETER_INVALID
, 'Sku %s is not defined in [SkuIds] section' % SkuName
,
2378 File
=self
.MetaFile
, Line
=Dummy5
)
2379 if "." not in TokenSpaceGuid
:
2380 PcdList
.append((PcdCName
, TokenSpaceGuid
, SkuName
, Dummy5
))
2381 PcdDict
[Arch
, SkuName
, PcdCName
, TokenSpaceGuid
] = Setting
2383 # Remove redundant PCD candidates, per the ARCH and SKU
2384 for PcdCName
, TokenSpaceGuid
, SkuName
, Dummy4
in PcdList
:
2386 Setting
= PcdDict
[self
._Arch
, SkuName
, PcdCName
, TokenSpaceGuid
]
2390 PcdValue
, DatumType
, MaxDatumSize
= self
._ValidatePcd
(PcdCName
, TokenSpaceGuid
, Setting
, Type
, Dummy4
)
2392 if int(MaxDatumSize
, 0) > 0xFFFF:
2393 EdkLogger
.error('build', FORMAT_INVALID
, "The size value must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join((TokenSpaceGuid
, PcdCName
)),
2394 File
=self
.MetaFile
, Line
=Dummy4
)
2395 if int(MaxDatumSize
, 0) < 0:
2396 EdkLogger
.error('build', FORMAT_INVALID
, "The size value can't be set to negative value for %s." % ".".join((TokenSpaceGuid
, PcdCName
)),
2397 File
=self
.MetaFile
, Line
=Dummy4
)
2398 SkuInfo
= SkuInfoClass(SkuName
, self
.SkuIds
[SkuName
][0], '', '', '', '', '', PcdValue
)
2399 if (PcdCName
, TokenSpaceGuid
) in Pcds
:
2400 pcdObject
= Pcds
[PcdCName
, TokenSpaceGuid
]
2401 pcdObject
.SkuInfoList
[SkuName
] = SkuInfo
2402 if MaxDatumSize
.strip():
2403 CurrentMaxSize
= int(MaxDatumSize
.strip(), 0)
2406 if pcdObject
.MaxDatumSize
:
2407 PcdMaxSize
= int(pcdObject
.MaxDatumSize
, 0)
2410 if CurrentMaxSize
> PcdMaxSize
:
2411 pcdObject
.MaxDatumSize
= str(CurrentMaxSize
)
2413 Pcds
[PcdCName
, TokenSpaceGuid
] = PcdClassObject(
2416 self
._PCD
_TYPE
_STRING
_[Type
],
2421 {SkuName
: SkuInfo
},
2426 for pcd
in Pcds
.values():
2427 pcdDecObject
= self
._DecPcds
[pcd
.TokenCName
, pcd
.TokenSpaceGuidCName
]
2428 # Only fix the value while no value provided in DSC file.
2429 for sku
in pcd
.SkuInfoList
.values():
2430 if not sku
.DefaultValue
:
2431 sku
.DefaultValue
= pcdDecObject
.DefaultValue
2432 if TAB_DEFAULT
not in pcd
.SkuInfoList
and TAB_COMMON
not in pcd
.SkuInfoList
:
2433 valuefromDec
= pcdDecObject
.DefaultValue
2434 SkuInfo
= SkuInfoClass(TAB_DEFAULT
, '0', '', '', '', '', '', valuefromDec
)
2435 pcd
.SkuInfoList
[TAB_DEFAULT
] = SkuInfo
2436 elif TAB_DEFAULT
not in pcd
.SkuInfoList
and TAB_COMMON
in pcd
.SkuInfoList
:
2437 pcd
.SkuInfoList
[TAB_DEFAULT
] = pcd
.SkuInfoList
[TAB_COMMON
]
2438 del pcd
.SkuInfoList
[TAB_COMMON
]
2439 elif TAB_DEFAULT
in pcd
.SkuInfoList
and TAB_COMMON
in pcd
.SkuInfoList
:
2440 del pcd
.SkuInfoList
[TAB_COMMON
]
2442 map(self
.FilterSkuSettings
, Pcds
.values())
2446 def FilterSkuSettings(self
, PcdObj
):
2448 if self
.SkuIdMgr
.SkuUsageType
== self
.SkuIdMgr
.SINGLE
:
2449 if TAB_DEFAULT
in PcdObj
.SkuInfoList
and self
.SkuIdMgr
.SystemSkuId
not in PcdObj
.SkuInfoList
:
2450 PcdObj
.SkuInfoList
[self
.SkuIdMgr
.SystemSkuId
] = PcdObj
.SkuInfoList
[TAB_DEFAULT
]
2451 PcdObj
.SkuInfoList
= {TAB_DEFAULT
:PcdObj
.SkuInfoList
[self
.SkuIdMgr
.SystemSkuId
]}
2452 PcdObj
.SkuInfoList
[TAB_DEFAULT
].SkuIdName
= TAB_DEFAULT
2453 PcdObj
.SkuInfoList
[TAB_DEFAULT
].SkuId
= '0'
2455 elif self
.SkuIdMgr
.SkuUsageType
== self
.SkuIdMgr
.DEFAULT
:
2456 PcdObj
.SkuInfoList
= {TAB_DEFAULT
:PcdObj
.SkuInfoList
[TAB_DEFAULT
]}
2461 def CompareVarAttr(Attr1
, Attr2
):
2462 if not Attr1
or not Attr2
: # for empty string
2464 Attr1s
= [attr
.strip() for attr
in Attr1
.split(",")]
2465 Attr1Set
= set(Attr1s
)
2466 Attr2s
= [attr
.strip() for attr
in Attr2
.split(",")]
2467 Attr2Set
= set(Attr2s
)
2468 if Attr2Set
== Attr1Set
:
2473 def CopyDscRawValue(self
, Pcd
):
2474 if Pcd
.DscRawValue
is None:
2475 Pcd
.DscRawValue
= dict()
2476 if Pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_FIXED_AT_BUILD
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_PATCHABLE_IN_MODULE
]]:
2477 if self
.SkuIdMgr
.SystemSkuId
not in Pcd
.DscRawValue
:
2478 Pcd
.DscRawValue
[self
.SkuIdMgr
.SystemSkuId
] = {}
2479 Pcd
.DscRawValue
[self
.SkuIdMgr
.SystemSkuId
][TAB_DEFAULT_STORES_DEFAULT
] = Pcd
.DefaultValue
2480 for skuname
in Pcd
.SkuInfoList
:
2481 Pcd
.DscRawValue
[skuname
] = {}
2482 if Pcd
.Type
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
2483 for defaultstore
in Pcd
.SkuInfoList
[skuname
].DefaultStoreDict
:
2484 Pcd
.DscRawValue
[skuname
][defaultstore
] = Pcd
.SkuInfoList
[skuname
].DefaultStoreDict
[defaultstore
]
2486 Pcd
.DscRawValue
[skuname
][TAB_DEFAULT_STORES_DEFAULT
] = Pcd
.SkuInfoList
[skuname
].DefaultValue
2487 def CompletePcdValues(self
, PcdSet
):
2489 DefaultStoreObj
= DefaultStore(self
._GetDefaultStores
())
2490 SkuIds
= {skuname
:skuid
for skuname
, skuid
in self
.SkuIdMgr
.AvailableSkuIdSet
.items() if skuname
!= TAB_COMMON
}
2491 DefaultStores
= set(storename
for pcdobj
in PcdSet
.values() for skuobj
in pcdobj
.SkuInfoList
.values() for storename
in skuobj
.DefaultStoreDict
)
2492 for PcdCName
, TokenSpaceGuid
in PcdSet
:
2493 PcdObj
= PcdSet
[(PcdCName
, TokenSpaceGuid
)]
2494 self
.CopyDscRawValue(PcdObj
)
2495 if PcdObj
.Type
not in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_DEFAULT
],
2496 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
],
2497 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_VPD
],
2498 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_DEFAULT
],
2499 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
],
2500 self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_VPD
]]:
2501 Pcds
[PcdCName
, TokenSpaceGuid
]= PcdObj
2503 PcdType
= PcdObj
.Type
2504 if PcdType
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
2505 for skuid
in PcdObj
.SkuInfoList
:
2506 skuobj
= PcdObj
.SkuInfoList
[skuid
]
2507 mindefaultstorename
= DefaultStoreObj
.GetMin(set(defaultstorename
for defaultstorename
in skuobj
.DefaultStoreDict
))
2508 for defaultstorename
in DefaultStores
:
2509 if defaultstorename
not in skuobj
.DefaultStoreDict
:
2510 skuobj
.DefaultStoreDict
[defaultstorename
] = copy
.deepcopy(skuobj
.DefaultStoreDict
[mindefaultstorename
])
2511 skuobj
.HiiDefaultValue
= skuobj
.DefaultStoreDict
[mindefaultstorename
]
2512 for skuname
, skuid
in SkuIds
.items():
2513 if skuname
not in PcdObj
.SkuInfoList
:
2514 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(skuname
)
2515 while nextskuid
not in PcdObj
.SkuInfoList
:
2516 nextskuid
= self
.SkuIdMgr
.GetNextSkuId(nextskuid
)
2517 PcdObj
.SkuInfoList
[skuname
] = copy
.deepcopy(PcdObj
.SkuInfoList
[nextskuid
])
2518 PcdObj
.SkuInfoList
[skuname
].SkuId
= skuid
2519 PcdObj
.SkuInfoList
[skuname
].SkuIdName
= skuname
2520 if PcdType
in [self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_HII
], self
._PCD
_TYPE
_STRING
_[MODEL_PCD_DYNAMIC_EX_HII
]]:
2521 PcdObj
.DefaultValue
= PcdObj
.SkuInfoList
.values()[0].HiiDefaultValue
if self
.SkuIdMgr
.SkuUsageType
== self
.SkuIdMgr
.SINGLE
else PcdObj
.SkuInfoList
[TAB_DEFAULT
].HiiDefaultValue
2522 Pcds
[PcdCName
, TokenSpaceGuid
]= PcdObj
2524 ## Retrieve dynamic HII PCD settings
2526 # @param Type PCD type
2528 # @retval a dict object contains settings of given PCD type
2530 def _GetDynamicHiiPcd(self
, Type
):
2534 Pcds
= OrderedDict()
2536 # tdict is a special dict kind of type, used for selecting correct
2537 # PCD settings for certain ARCH and SKU
2539 PcdDict
= tdict(True, 5)
2541 RecordList
= self
._RawData
[Type
, self
._Arch
]
2542 # Find out all possible PCD candidates for self._Arch
2543 AvailableSkuIdSet
= copy
.copy(self
.SkuIds
)
2544 DefaultStoresDefine
= self
._GetDefaultStores
()
2546 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, SkuName
, DefaultStore
, Dummy4
, Dummy5
in RecordList
:
2547 SkuName
= SkuName
.upper()
2548 SkuName
= TAB_DEFAULT
if SkuName
== TAB_COMMON
else SkuName
2549 DefaultStore
= DefaultStore
.upper()
2550 if DefaultStore
== TAB_COMMON
:
2551 DefaultStore
= TAB_DEFAULT_STORES_DEFAULT
2552 if SkuName
not in AvailableSkuIdSet
:
2553 EdkLogger
.error('build', PARAMETER_INVALID
, 'Sku %s is not defined in [SkuIds] section' % SkuName
,
2554 File
=self
.MetaFile
, Line
=Dummy5
)
2555 if DefaultStore
not in DefaultStoresDefine
:
2556 EdkLogger
.error('build', PARAMETER_INVALID
, 'DefaultStores %s is not defined in [DefaultStores] section' % DefaultStore
,
2557 File
=self
.MetaFile
, Line
=Dummy5
)
2558 if "." not in TokenSpaceGuid
:
2559 PcdSet
.add((PcdCName
, TokenSpaceGuid
, SkuName
, DefaultStore
, Dummy5
))
2560 PcdDict
[Arch
, SkuName
, PcdCName
, TokenSpaceGuid
, DefaultStore
] = Setting
2563 # Remove redundant PCD candidates, per the ARCH and SKU
2564 for PcdCName
, TokenSpaceGuid
, SkuName
, DefaultStore
, Dummy4
in PcdSet
:
2566 Setting
= PcdDict
[self
._Arch
, SkuName
, PcdCName
, TokenSpaceGuid
, DefaultStore
]
2569 VariableName
, VariableGuid
, VariableOffset
, DefaultValue
, VarAttribute
= self
._ValidatePcd
(PcdCName
, TokenSpaceGuid
, Setting
, Type
, Dummy4
)
2571 rt
, Msg
= VariableAttributes
.ValidateVarAttributes(VarAttribute
)
2573 EdkLogger
.error("build", PCD_VARIABLE_ATTRIBUTES_ERROR
, "Variable attributes settings for %s is incorrect.\n %s" % (".".join((TokenSpaceGuid
, PcdCName
)), Msg
),
2574 ExtraData
="[%s]" % VarAttribute
)
2576 FormatCorrect
= True
2577 if VariableOffset
.isdigit():
2578 if int(VariableOffset
, 10) > 0xFFFF:
2580 elif variablePattern
.match(VariableOffset
):
2581 if int(VariableOffset
, 16) > 0xFFFF:
2583 # For Offset written in "A.B"
2584 elif VariableOffset
.find('.') > -1:
2585 VariableOffsetList
= VariableOffset
.split(".")
2586 if not (len(VariableOffsetList
) == 2
2587 and IsValidWord(VariableOffsetList
[0])
2588 and IsValidWord(VariableOffsetList
[1])):
2589 FormatCorrect
= False
2591 FormatCorrect
= False
2592 if not FormatCorrect
:
2593 EdkLogger
.error('Build', FORMAT_INVALID
, "Invalid syntax or format of the variable offset value is incorrect for %s." % ".".join((TokenSpaceGuid
, PcdCName
)))
2596 EdkLogger
.error('Build', OPTION_VALUE_INVALID
, "The variable offset value must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join((TokenSpaceGuid
, PcdCName
)))
2597 if (VariableName
, VariableGuid
) not in VariableAttrs
:
2598 VariableAttrs
[(VariableName
, VariableGuid
)] = VarAttribute
2600 if not DscBuildData
.CompareVarAttr(VariableAttrs
[(VariableName
, VariableGuid
)], VarAttribute
):
2601 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
)]))
2603 pcdDecObject
= self
._DecPcds
[PcdCName
, TokenSpaceGuid
]
2604 if (PcdCName
, TokenSpaceGuid
) in Pcds
:
2605 pcdObject
= Pcds
[PcdCName
, TokenSpaceGuid
]
2606 if SkuName
in pcdObject
.SkuInfoList
:
2607 Skuitem
= pcdObject
.SkuInfoList
[SkuName
]
2608 Skuitem
.DefaultStoreDict
.update({DefaultStore
:DefaultValue
})
2610 SkuInfo
= SkuInfoClass(SkuName
, self
.SkuIds
[SkuName
][0], VariableName
, VariableGuid
, VariableOffset
, DefaultValue
, VariableAttribute
=VarAttribute
, DefaultStore
={DefaultStore
:DefaultValue
})
2611 pcdObject
.SkuInfoList
[SkuName
] = SkuInfo
2613 SkuInfo
= SkuInfoClass(SkuName
, self
.SkuIds
[SkuName
][0], VariableName
, VariableGuid
, VariableOffset
, DefaultValue
, VariableAttribute
=VarAttribute
, DefaultStore
={DefaultStore
:DefaultValue
})
2614 Pcds
[PcdCName
, TokenSpaceGuid
] = PcdClassObject(
2617 self
._PCD
_TYPE
_STRING
_[Type
],
2622 {SkuName
: SkuInfo
},
2625 pcdDecObject
.validateranges
,
2626 pcdDecObject
.validlists
,
2627 pcdDecObject
.expressions
,
2631 for pcd
in Pcds
.values():
2632 SkuInfoObj
= pcd
.SkuInfoList
.values()[0]
2633 pcdDecObject
= self
._DecPcds
[pcd
.TokenCName
, pcd
.TokenSpaceGuidCName
]
2634 pcd
.DatumType
= pcdDecObject
.DatumType
2635 # Only fix the value while no value provided in DSC file.
2636 for sku
in pcd
.SkuInfoList
.values():
2637 if (sku
.HiiDefaultValue
== "" or sku
.HiiDefaultValue
is None):
2638 sku
.HiiDefaultValue
= pcdDecObject
.DefaultValue
2639 for default_store
in sku
.DefaultStoreDict
:
2640 sku
.DefaultStoreDict
[default_store
]=pcdDecObject
.DefaultValue
2641 pcd
.DefaultValue
= pcdDecObject
.DefaultValue
2642 if TAB_DEFAULT
not in pcd
.SkuInfoList
and TAB_COMMON
not in pcd
.SkuInfoList
:
2643 valuefromDec
= pcdDecObject
.DefaultValue
2644 SkuInfo
= SkuInfoClass(TAB_DEFAULT
, '0', SkuInfoObj
.VariableName
, SkuInfoObj
.VariableGuid
, SkuInfoObj
.VariableOffset
, valuefromDec
, VariableAttribute
=SkuInfoObj
.VariableAttribute
, DefaultStore
={DefaultStore
:valuefromDec
})
2645 pcd
.SkuInfoList
[TAB_DEFAULT
] = SkuInfo
2646 elif TAB_DEFAULT
not in pcd
.SkuInfoList
and TAB_COMMON
in pcd
.SkuInfoList
:
2647 pcd
.SkuInfoList
[TAB_DEFAULT
] = pcd
.SkuInfoList
[TAB_COMMON
]
2648 del pcd
.SkuInfoList
[TAB_COMMON
]
2649 elif TAB_DEFAULT
in pcd
.SkuInfoList
and TAB_COMMON
in pcd
.SkuInfoList
:
2650 del pcd
.SkuInfoList
[TAB_COMMON
]
2652 if pcd
.MaxDatumSize
.strip():
2653 MaxSize
= int(pcd
.MaxDatumSize
, 0)
2656 if pcd
.DatumType
not in TAB_PCD_NUMERIC_TYPES
:
2657 for (_
, skuobj
) in pcd
.SkuInfoList
.items():
2659 skuobj
.HiiDefaultValue
= StringToArray(skuobj
.HiiDefaultValue
)
2660 datalen
= len(skuobj
.HiiDefaultValue
.split(","))
2661 if datalen
> MaxSize
:
2663 for defaultst
in skuobj
.DefaultStoreDict
:
2664 skuobj
.DefaultStoreDict
[defaultst
] = StringToArray(skuobj
.DefaultStoreDict
[defaultst
])
2665 pcd
.DefaultValue
= StringToArray(pcd
.DefaultValue
)
2666 pcd
.MaxDatumSize
= str(MaxSize
)
2667 rt
, invalidhii
= DscBuildData
.CheckVariableNameAssignment(Pcds
)
2669 invalidpcd
= ",".join(invalidhii
)
2670 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
)
2672 map(self
.FilterSkuSettings
, Pcds
.values())
2677 def CheckVariableNameAssignment(Pcds
):
2679 for pcdname
in Pcds
:
2681 varnameset
= set(sku
.VariableName
for (skuid
, sku
) in pcd
.SkuInfoList
.items())
2682 if len(varnameset
) > 1:
2683 invalidhii
.append(".".join((pcdname
[1], pcdname
[0])))
2685 return False, invalidhii
2688 ## Retrieve dynamic VPD PCD settings
2690 # @param Type PCD type
2692 # @retval a dict object contains settings of given PCD type
2694 def _GetDynamicVpdPcd(self
, Type
):
2697 Pcds
= OrderedDict()
2699 # tdict is a special dict kind of type, used for selecting correct
2700 # PCD settings for certain ARCH and SKU
2702 PcdDict
= tdict(True, 4)
2705 # Find out all possible PCD candidates for self._Arch
2706 RecordList
= self
._RawData
[Type
, self
._Arch
]
2707 AvailableSkuIdSet
= copy
.copy(self
.SkuIds
)
2709 for TokenSpaceGuid
, PcdCName
, Setting
, Arch
, SkuName
, Dummy3
, Dummy4
, Dummy5
in RecordList
:
2710 SkuName
= SkuName
.upper()
2711 SkuName
= TAB_DEFAULT
if SkuName
== TAB_COMMON
else SkuName
2712 if SkuName
not in AvailableSkuIdSet
:
2713 EdkLogger
.error('build', PARAMETER_INVALID
, 'Sku %s is not defined in [SkuIds] section' % SkuName
,
2714 File
=self
.MetaFile
, Line
=Dummy5
)
2715 if "." not in TokenSpaceGuid
:
2716 PcdList
.append((PcdCName
, TokenSpaceGuid
, SkuName
, Dummy5
))
2717 PcdDict
[Arch
, SkuName
, PcdCName
, TokenSpaceGuid
] = Setting
2719 # Remove redundant PCD candidates, per the ARCH and SKU
2720 for PcdCName
, TokenSpaceGuid
, SkuName
, Dummy4
in PcdList
:
2721 Setting
= PcdDict
[self
._Arch
, SkuName
, PcdCName
, TokenSpaceGuid
]
2725 # For the VOID* type, it can have optional data of MaxDatumSize and InitialValue
2726 # For the Integer & Boolean type, the optional data can only be InitialValue.
2727 # At this point, we put all the data into the PcdClssObject for we don't know the PCD's datumtype
2728 # until the DEC parser has been called.
2730 VpdOffset
, MaxDatumSize
, InitialValue
= self
._ValidatePcd
(PcdCName
, TokenSpaceGuid
, Setting
, Type
, Dummy4
)
2732 if int(MaxDatumSize
, 0) > 0xFFFF:
2733 EdkLogger
.error('build', FORMAT_INVALID
, "The size value must not exceed the maximum value of 0xFFFF (UINT16) for %s." % ".".join((TokenSpaceGuid
, PcdCName
)),
2734 File
=self
.MetaFile
, Line
=Dummy4
)
2735 if int(MaxDatumSize
, 0) < 0:
2736 EdkLogger
.error('build', FORMAT_INVALID
, "The size value can't be set to negative value for %s." % ".".join((TokenSpaceGuid
, PcdCName
)),
2737 File
=self
.MetaFile
, Line
=Dummy4
)
2738 SkuInfo
= SkuInfoClass(SkuName
, self
.SkuIds
[SkuName
][0], '', '', '', '', VpdOffset
, InitialValue
)
2739 if (PcdCName
, TokenSpaceGuid
) in Pcds
:
2740 pcdObject
= Pcds
[PcdCName
, TokenSpaceGuid
]
2741 pcdObject
.SkuInfoList
[SkuName
] = SkuInfo
2742 if MaxDatumSize
.strip():
2743 CurrentMaxSize
= int(MaxDatumSize
.strip(), 0)
2746 if pcdObject
.MaxDatumSize
:
2747 PcdMaxSize
= int(pcdObject
.MaxDatumSize
, 0)
2750 if CurrentMaxSize
> PcdMaxSize
:
2751 pcdObject
.MaxDatumSize
= str(CurrentMaxSize
)
2753 Pcds
[PcdCName
, TokenSpaceGuid
] = PcdClassObject(
2756 self
._PCD
_TYPE
_STRING
_[Type
],
2761 {SkuName
: SkuInfo
},
2765 for pcd
in Pcds
.values():
2766 SkuInfoObj
= pcd
.SkuInfoList
.values()[0]
2767 pcdDecObject
= self
._DecPcds
[pcd
.TokenCName
, pcd
.TokenSpaceGuidCName
]
2768 pcd
.DatumType
= pcdDecObject
.DatumType
2769 # Only fix the value while no value provided in DSC file.
2770 for sku
in pcd
.SkuInfoList
.values():
2771 if not sku
.DefaultValue
:
2772 sku
.DefaultValue
= pcdDecObject
.DefaultValue
2773 if TAB_DEFAULT
not in pcd
.SkuInfoList
and TAB_COMMON
not in pcd
.SkuInfoList
:
2774 valuefromDec
= pcdDecObject
.DefaultValue
2775 SkuInfo
= SkuInfoClass(TAB_DEFAULT
, '0', '', '', '', '', SkuInfoObj
.VpdOffset
, valuefromDec
)
2776 pcd
.SkuInfoList
[TAB_DEFAULT
] = SkuInfo
2777 elif TAB_DEFAULT
not in pcd
.SkuInfoList
and TAB_COMMON
in pcd
.SkuInfoList
:
2778 pcd
.SkuInfoList
[TAB_DEFAULT
] = pcd
.SkuInfoList
[TAB_COMMON
]
2779 del pcd
.SkuInfoList
[TAB_COMMON
]
2780 elif TAB_DEFAULT
in pcd
.SkuInfoList
and TAB_COMMON
in pcd
.SkuInfoList
:
2781 del pcd
.SkuInfoList
[TAB_COMMON
]
2784 map(self
.FilterSkuSettings
, Pcds
.values())
2787 ## Add external modules
2789 # The external modules are mostly those listed in FDF file, which don't
2792 # @param FilePath The path of module description file
2794 def AddModule(self
, FilePath
):
2795 FilePath
= NormPath(FilePath
)
2796 if FilePath
not in self
.Modules
:
2797 Module
= ModuleBuildClassObject()
2798 Module
.MetaFile
= FilePath
2799 self
.Modules
.append(Module
)
2801 def _GetToolChainFamily(self
):
2802 self
._ToolChainFamily
= "MSFT"
2803 BuildConfigurationFile
= os
.path
.normpath(os
.path
.join(GlobalData
.gConfDirectory
, "target.txt"))
2804 if os
.path
.isfile(BuildConfigurationFile
) == True:
2805 TargetTxt
= TargetTxtClassObject()
2806 TargetTxt
.LoadTargetTxtFile(BuildConfigurationFile
)
2807 ToolDefinitionFile
= TargetTxt
.TargetTxtDictionary
[DataType
.TAB_TAT_DEFINES_TOOL_CHAIN_CONF
]
2808 if ToolDefinitionFile
== '':
2809 ToolDefinitionFile
= "tools_def.txt"
2810 ToolDefinitionFile
= os
.path
.normpath(mws
.join(self
.WorkspaceDir
, 'Conf', ToolDefinitionFile
))
2811 if os
.path
.isfile(ToolDefinitionFile
) == True:
2812 ToolDef
= ToolDefClassObject()
2813 ToolDef
.LoadToolDefFile(ToolDefinitionFile
)
2814 ToolDefinition
= ToolDef
.ToolsDefTxtDatabase
2815 if TAB_TOD_DEFINES_FAMILY
not in ToolDefinition \
2816 or self
._Toolchain
not in ToolDefinition
[TAB_TOD_DEFINES_FAMILY
] \
2817 or not ToolDefinition
[TAB_TOD_DEFINES_FAMILY
][self
._Toolchain
]:
2818 self
._ToolChainFamily
= "MSFT"
2820 self
._ToolChainFamily
= ToolDefinition
[TAB_TOD_DEFINES_FAMILY
][self
._Toolchain
]
2821 return self
._ToolChainFamily
2823 ## Add external PCDs
2825 # The external PCDs are mostly those listed in FDF file to specify address
2826 # or offset information.
2828 # @param Name Name of the PCD
2829 # @param Guid Token space guid of the PCD
2830 # @param Value Value of the PCD
2832 def AddPcd(self
, Name
, Guid
, Value
):
2833 if (Name
, Guid
) not in self
.Pcds
:
2834 self
.Pcds
[Name
, Guid
] = PcdClassObject(Name
, Guid
, '', '', '', '', '', {}, False, None)
2835 self
.Pcds
[Name
, Guid
].DefaultValue
= Value
2838 if self
._DecPcds
is None:
2840 if GlobalData
.gFdfParser
:
2841 FdfInfList
= GlobalData
.gFdfParser
.Profile
.InfList
2843 for Inf
in FdfInfList
:
2844 ModuleFile
= PathClass(NormPath(Inf
), GlobalData
.gWorkspace
, Arch
=self
._Arch
)
2845 if ModuleFile
in self
._Modules
:
2847 ModuleData
= self
._Bdb
[ModuleFile
, self
._Arch
, self
._Target
, self
._Toolchain
]
2848 PkgSet
.update(ModuleData
.Packages
)
2849 self
._DecPcds
, self
._GuidDict
= GetDeclaredPcd(self
, self
._Bdb
, self
._Arch
, self
._Target
, self
._Toolchain
, PkgSet
)
2850 return self
._DecPcds
2851 _Macros
= property(_GetMacros
)
2852 Arch
= property(_GetArch
, _SetArch
)
2853 Platform
= property(_GetPlatformName
)
2854 PlatformName
= property(_GetPlatformName
)
2855 Guid
= property(_GetFileGuid
)
2856 Version
= property(_GetVersion
)
2857 DscSpecification
= property(_GetDscSpec
)
2858 OutputDirectory
= property(_GetOutpuDir
)
2859 SupArchList
= property(_GetSupArch
)
2860 BuildTargets
= property(_GetBuildTarget
)
2861 SkuName
= property(_GetSkuName
, _SetSkuName
)
2862 PcdInfoFlag
= property(_GetPcdInfoFlag
)
2863 VarCheckFlag
= property(_GetVarCheckFlag
)
2864 FlashDefinition
= property(_GetFdfFile
)
2865 Prebuild
= property(_GetPrebuild
)
2866 Postbuild
= property(_GetPostbuild
)
2867 BuildNumber
= property(_GetBuildNumber
)
2868 MakefileName
= property(_GetMakefileName
)
2869 BsBaseAddress
= property(_GetBsBaseAddress
)
2870 RtBaseAddress
= property(_GetRtBaseAddress
)
2871 LoadFixAddress
= property(_GetLoadFixAddress
)
2872 RFCLanguages
= property(_GetRFCLanguages
)
2873 ISOLanguages
= property(_GetISOLanguages
)
2874 VpdToolGuid
= property(_GetVpdToolGuid
)
2875 SkuIds
= property(_GetSkuIds
)
2876 Modules
= property(_GetModules
)
2877 LibraryInstances
= property(_GetLibraryInstances
)
2878 LibraryClasses
= property(_GetLibraryClasses
)
2879 Pcds
= property(_GetPcds
)
2880 BuildOptions
= property(_GetBuildOptions
)
2881 ToolChainFamily
= property(_GetToolChainFamily
)