2 # Generate AutoGen.h, AutoGen.c and *.depex files
4 # Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
5 # This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 import Common
.LongFilePathOs
as os
18 import os
.path
as path
25 from StringIO
import StringIO
27 from StrGather
import *
28 from BuildEngine
import BuildRule
30 from Common
.LongFilePathSupport
import CopyLongFilePath
31 from Common
.BuildToolError
import *
32 from Common
.DataType
import *
33 from Common
.Misc
import *
34 from Common
.String
import *
35 import Common
.GlobalData
as GlobalData
36 from GenFds
.FdfParser
import *
37 from CommonDataClass
.CommonClass
import SkuInfoClass
38 from Workspace
.BuildClassObject
import *
39 from GenPatchPcdTable
.GenPatchPcdTable
import parsePcdInfoFromMapFile
40 import Common
.VpdInfoFile
as VpdInfoFile
41 from GenPcdDb
import CreatePcdDatabaseCode
42 from Workspace
.MetaFileCommentParser
import UsageList
43 from Common
.MultipleWorkspace
import MultipleWorkspace
as mws
44 import InfSectionParser
46 ## Regular expression for splitting Dependency Expression string into tokens
47 gDepexTokenPattern
= re
.compile("(\(|\)|\w+| \S+\.inf)")
50 # Match name = variable
52 gEfiVarStoreNamePattern
= re
.compile("\s*name\s*=\s*(\w+)")
54 # The format of guid in efivarstore statement likes following and must be correct:
55 # guid = {0xA04A27f4, 0xDF00, 0x4D42, {0xB5, 0x52, 0x39, 0x51, 0x13, 0x02, 0x11, 0x3D}}
57 gEfiVarStoreGuidPattern
= re
.compile("\s*guid\s*=\s*({.*?{.*?}\s*})")
59 ## Mapping Makefile type
60 gMakeTypeMap
= {"MSFT":"nmake", "GCC":"gmake"}
63 ## Build rule configuration file
64 gDefaultBuildRuleFile
= 'Conf/build_rule.txt'
66 ## Build rule default version
67 AutoGenReqBuildRuleVerNum
= "0.1"
69 ## default file name for AutoGen
70 gAutoGenCodeFileName
= "AutoGen.c"
71 gAutoGenHeaderFileName
= "AutoGen.h"
72 gAutoGenStringFileName
= "%(module_name)sStrDefs.h"
73 gAutoGenStringFormFileName
= "%(module_name)sStrDefs.hpk"
74 gAutoGenDepexFileName
= "%(module_name)s.depex"
76 gInfSpecVersion
= "0x00010017"
79 # Template string to generic AsBuilt INF
81 gAsBuiltInfHeaderString
= TemplateString("""${header_comments}
87 INF_VERSION = ${module_inf_version}
88 BASE_NAME = ${module_name}
89 FILE_GUID = ${module_guid}
90 MODULE_TYPE = ${module_module_type}${BEGIN}
91 VERSION_STRING = ${module_version_string}${END}${BEGIN}
92 PCD_IS_DRIVER = ${pcd_is_driver_string}${END}${BEGIN}
93 UEFI_SPECIFICATION_VERSION = ${module_uefi_specification_version}${END}${BEGIN}
94 PI_SPECIFICATION_VERSION = ${module_pi_specification_version}${END}${BEGIN}
95 ENTRY_POINT = ${module_entry_point}${END}${BEGIN}
96 UNLOAD_IMAGE = ${module_unload_image}${END}${BEGIN}
97 CONSTRUCTOR = ${module_constructor}${END}${BEGIN}
98 DESTRUCTOR = ${module_destructor}${END}${BEGIN}
99 SHADOW = ${module_shadow}${END}${BEGIN}
100 PCI_VENDOR_ID = ${module_pci_vendor_id}${END}${BEGIN}
101 PCI_DEVICE_ID = ${module_pci_device_id}${END}${BEGIN}
102 PCI_CLASS_CODE = ${module_pci_class_code}${END}${BEGIN}
103 PCI_REVISION = ${module_pci_revision}${END}${BEGIN}
104 BUILD_NUMBER = ${module_build_number}${END}${BEGIN}
105 SPEC = ${module_spec}${END}${BEGIN}
106 UEFI_HII_RESOURCE_SECTION = ${module_uefi_hii_resource_section}${END}${BEGIN}
107 MODULE_UNI_FILE = ${module_uni_file}${END}
109 [Packages.${module_arch}]${BEGIN}
110 ${package_item}${END}
112 [Binaries.${module_arch}]${BEGIN}
115 [PatchPcd.${module_arch}]${BEGIN}
119 [Protocols.${module_arch}]${BEGIN}
123 [Ppis.${module_arch}]${BEGIN}
127 [Guids.${module_arch}]${BEGIN}
131 [PcdEx.${module_arch}]${BEGIN}
135 [LibraryClasses.${module_arch}]
136 ## @LIB_INSTANCES${BEGIN}
137 # ${libraryclasses_item}${END}
143 [BuildOptions.${module_arch}]
145 ## ${flags_item}${END}
148 ## Base class for AutoGen
150 # This class just implements the cache mechanism of AutoGen objects.
152 class AutoGen(object):
153 # database to maintain the objects of xxxAutoGen
154 _CACHE_
= {} # (BuildTarget, ToolChain) : {ARCH : {platform file: AutoGen object}}}
158 # @param Class class object of real AutoGen class
159 # (WorkspaceAutoGen, ModuleAutoGen or PlatformAutoGen)
160 # @param Workspace Workspace directory or WorkspaceAutoGen object
161 # @param MetaFile The path of meta file
162 # @param Target Build target
163 # @param Toolchain Tool chain name
164 # @param Arch Target arch
165 # @param *args The specific class related parameters
166 # @param **kwargs The specific class related dict parameters
168 def __new__(Class
, Workspace
, MetaFile
, Target
, Toolchain
, Arch
, *args
, **kwargs
):
169 # check if the object has been created
170 Key
= (Target
, Toolchain
)
171 if Key
not in Class
._CACHE
_ or Arch
not in Class
._CACHE
_[Key
] \
172 or MetaFile
not in Class
._CACHE
_[Key
][Arch
]:
173 AutoGenObject
= super(AutoGen
, Class
).__new
__(Class
)
174 # call real constructor
175 if not AutoGenObject
._Init
(Workspace
, MetaFile
, Target
, Toolchain
, Arch
, *args
, **kwargs
):
177 if Key
not in Class
._CACHE
_:
178 Class
._CACHE
_[Key
] = {}
179 if Arch
not in Class
._CACHE
_[Key
]:
180 Class
._CACHE
_[Key
][Arch
] = {}
181 Class
._CACHE
_[Key
][Arch
][MetaFile
] = AutoGenObject
183 AutoGenObject
= Class
._CACHE
_[Key
][Arch
][MetaFile
]
189 # The file path of platform file will be used to represent hash value of this object
191 # @retval int Hash value of the file path of platform file
194 return hash(self
.MetaFile
)
198 # The file path of platform file will be used to represent this object
200 # @retval string String of platform file path
203 return str(self
.MetaFile
)
206 def __eq__(self
, Other
):
207 return Other
and self
.MetaFile
== Other
209 ## Workspace AutoGen class
211 # This class is used mainly to control the whole platform build for different
212 # architecture. This class will generate top level makefile.
214 class WorkspaceAutoGen(AutoGen
):
215 ## Real constructor of WorkspaceAutoGen
217 # This method behaves the same as __init__ except that it needs explicit invoke
218 # (in super class's __new__ method)
220 # @param WorkspaceDir Root directory of workspace
221 # @param ActivePlatform Meta-file of active platform
222 # @param Target Build target
223 # @param Toolchain Tool chain name
224 # @param ArchList List of architecture of current build
225 # @param MetaFileDb Database containing meta-files
226 # @param BuildConfig Configuration of build
227 # @param ToolDefinition Tool chain definitions
228 # @param FlashDefinitionFile File of flash definition
229 # @param Fds FD list to be generated
230 # @param Fvs FV list to be generated
231 # @param Caps Capsule list to be generated
232 # @param SkuId SKU id from command line
234 def _Init(self
, WorkspaceDir
, ActivePlatform
, Target
, Toolchain
, ArchList
, MetaFileDb
,
235 BuildConfig
, ToolDefinition
, FlashDefinitionFile
='', Fds
=None, Fvs
=None, Caps
=None, SkuId
='', UniFlag
=None,
236 Progress
=None, BuildModule
=None):
243 self
.BuildDatabase
= MetaFileDb
244 self
.MetaFile
= ActivePlatform
245 self
.WorkspaceDir
= WorkspaceDir
246 self
.Platform
= self
.BuildDatabase
[self
.MetaFile
, 'COMMON', Target
, Toolchain
]
247 GlobalData
.gActivePlatform
= self
.Platform
248 self
.BuildTarget
= Target
249 self
.ToolChain
= Toolchain
250 self
.ArchList
= ArchList
252 self
.UniFlag
= UniFlag
254 self
.TargetTxt
= BuildConfig
255 self
.ToolDef
= ToolDefinition
256 self
.FdfFile
= FlashDefinitionFile
257 self
.FdTargetList
= Fds
258 self
.FvTargetList
= Fvs
259 self
.CapTargetList
= Caps
260 self
.AutoGenObjectList
= []
262 # there's many relative directory operations, so ...
263 os
.chdir(self
.WorkspaceDir
)
268 if not self
.ArchList
:
269 ArchList
= set(self
.Platform
.SupArchList
)
271 ArchList
= set(self
.ArchList
) & set(self
.Platform
.SupArchList
)
273 EdkLogger
.error("build", PARAMETER_INVALID
,
274 ExtraData
= "Invalid ARCH specified. [Valid ARCH: %s]" % (" ".join(self
.Platform
.SupArchList
)))
275 elif self
.ArchList
and len(ArchList
) != len(self
.ArchList
):
276 SkippedArchList
= set(self
.ArchList
).symmetric_difference(set(self
.Platform
.SupArchList
))
277 EdkLogger
.verbose("\nArch [%s] is ignored because the platform supports [%s] only!"
278 % (" ".join(SkippedArchList
), " ".join(self
.Platform
.SupArchList
)))
279 self
.ArchList
= tuple(ArchList
)
281 # Validate build target
282 if self
.BuildTarget
not in self
.Platform
.BuildTargets
:
283 EdkLogger
.error("build", PARAMETER_INVALID
,
284 ExtraData
="Build target [%s] is not supported by the platform. [Valid target: %s]"
285 % (self
.BuildTarget
, " ".join(self
.Platform
.BuildTargets
)))
288 # parse FDF file to get PCDs in it, if any
290 self
.FdfFile
= self
.Platform
.FlashDefinition
294 EdkLogger
.info('%-16s = %s' % ("Architecture(s)", ' '.join(self
.ArchList
)))
295 EdkLogger
.info('%-16s = %s' % ("Build target", self
.BuildTarget
))
296 EdkLogger
.info('%-16s = %s' % ("Toolchain", self
.ToolChain
))
298 EdkLogger
.info('\n%-24s = %s' % ("Active Platform", self
.Platform
))
300 EdkLogger
.info('%-24s = %s' % ("Active Module", BuildModule
))
303 EdkLogger
.info('%-24s = %s' % ("Flash Image Definition", self
.FdfFile
))
305 EdkLogger
.verbose("\nFLASH_DEFINITION = %s" % self
.FdfFile
)
308 Progress
.Start("\nProcessing meta-data")
312 # Mark now build in AutoGen Phase
314 GlobalData
.gAutoGenPhase
= True
315 Fdf
= FdfParser(self
.FdfFile
.Path
)
317 GlobalData
.gFdfParser
= Fdf
318 GlobalData
.gAutoGenPhase
= False
319 PcdSet
= Fdf
.Profile
.PcdDict
320 if Fdf
.CurrentFdName
and Fdf
.CurrentFdName
in Fdf
.Profile
.FdDict
:
321 FdDict
= Fdf
.Profile
.FdDict
[Fdf
.CurrentFdName
]
322 for FdRegion
in FdDict
.RegionList
:
323 if str(FdRegion
.RegionType
) is 'FILE' and self
.Platform
.VpdToolGuid
in str(FdRegion
.RegionDataList
):
324 if int(FdRegion
.Offset
) % 8 != 0:
325 EdkLogger
.error("build", FORMAT_INVALID
, 'The VPD Base Address %s must be 8-byte aligned.' % (FdRegion
.Offset
))
326 ModuleList
= Fdf
.Profile
.InfList
327 self
.FdfProfile
= Fdf
.Profile
328 for fvname
in self
.FvTargetList
:
329 if fvname
.upper() not in self
.FdfProfile
.FvDict
:
330 EdkLogger
.error("build", OPTION_VALUE_INVALID
,
331 "No such an FV in FDF file: %s" % fvname
)
335 self
.FdfProfile
= None
336 if self
.FdTargetList
:
337 EdkLogger
.info("No flash definition file found. FD [%s] will be ignored." % " ".join(self
.FdTargetList
))
338 self
.FdTargetList
= []
339 if self
.FvTargetList
:
340 EdkLogger
.info("No flash definition file found. FV [%s] will be ignored." % " ".join(self
.FvTargetList
))
341 self
.FvTargetList
= []
342 if self
.CapTargetList
:
343 EdkLogger
.info("No flash definition file found. Capsule [%s] will be ignored." % " ".join(self
.CapTargetList
))
344 self
.CapTargetList
= []
346 # apply SKU and inject PCDs from Flash Definition file
347 for Arch
in self
.ArchList
:
348 Platform
= self
.BuildDatabase
[self
.MetaFile
, Arch
, Target
, Toolchain
]
352 PGen
= PlatformAutoGen(self
, self
.MetaFile
, Target
, Toolchain
, Arch
)
353 #Collect package set information from INF of FDF
355 for Inf
in ModuleList
:
356 ModuleFile
= PathClass(NormPath(Inf
), GlobalData
.gWorkspace
, Arch
)
357 if ModuleFile
in Platform
.Modules
:
359 ModuleData
= self
.BuildDatabase
[ModuleFile
, Arch
, Target
, Toolchain
]
360 PkgSet
.update(ModuleData
.Packages
)
361 Pkgs
= list(PkgSet
) + list(PGen
.PackageList
)
364 DecPcds
[Pcd
[0], Pcd
[1]] = Pkg
.Pcds
[Pcd
]
365 DecPcdsKey
.add((Pcd
[0], Pcd
[1], Pcd
[2]))
367 Platform
.SkuName
= self
.SkuId
368 for Name
, Guid
in PcdSet
:
369 if (Name
, Guid
) not in DecPcds
:
373 "PCD (%s.%s) used in FDF is not declared in DEC files." % (Guid
, Name
),
374 File
= self
.FdfProfile
.PcdFileLineDict
[Name
, Guid
][0],
375 Line
= self
.FdfProfile
.PcdFileLineDict
[Name
, Guid
][1]
378 # Check whether Dynamic or DynamicEx PCD used in FDF file. If used, build break and give a error message.
379 if (Name
, Guid
, TAB_PCDS_FIXED_AT_BUILD
) in DecPcdsKey \
380 or (Name
, Guid
, TAB_PCDS_PATCHABLE_IN_MODULE
) in DecPcdsKey \
381 or (Name
, Guid
, TAB_PCDS_FEATURE_FLAG
) in DecPcdsKey
:
382 Platform
.AddPcd(Name
, Guid
, PcdSet
[Name
, Guid
])
384 elif (Name
, Guid
, TAB_PCDS_DYNAMIC
) in DecPcdsKey
or (Name
, Guid
, TAB_PCDS_DYNAMIC_EX
) in DecPcdsKey
:
388 "Using Dynamic or DynamicEx type of PCD [%s.%s] in FDF file is not allowed." % (Guid
, Name
),
389 File
= self
.FdfProfile
.PcdFileLineDict
[Name
, Guid
][0],
390 Line
= self
.FdfProfile
.PcdFileLineDict
[Name
, Guid
][1]
393 Pa
= PlatformAutoGen(self
, self
.MetaFile
, Target
, Toolchain
, Arch
)
395 # Explicitly collect platform's dynamic PCDs
397 Pa
.CollectPlatformDynamicPcds()
398 Pa
.CollectFixedAtBuildPcds()
399 self
.AutoGenObjectList
.append(Pa
)
402 # Check PCDs token value conflict in each DEC file.
404 self
._CheckAllPcdsTokenValueConflict
()
407 # Check PCD type and definition between DSC and DEC
409 self
._CheckPcdDefineAndType
()
412 # self._CheckDuplicateInFV(Fdf)
414 self
._BuildDir
= None
416 self
._MakeFileDir
= None
417 self
._BuildCommand
= None
421 ## _CheckDuplicateInFV() method
423 # Check whether there is duplicate modules/files exist in FV section.
424 # The check base on the file GUID;
426 def _CheckDuplicateInFV(self
, Fdf
):
427 for Fv
in Fdf
.Profile
.FvDict
:
429 for FfsFile
in Fdf
.Profile
.FvDict
[Fv
].FfsList
:
430 if FfsFile
.InfFileName
and FfsFile
.NameGuid
== None:
435 for Pa
in self
.AutoGenObjectList
:
438 for Module
in Pa
.ModuleAutoGenList
:
439 if path
.normpath(Module
.MetaFile
.File
) == path
.normpath(FfsFile
.InfFileName
):
441 if not Module
.Guid
.upper() in _GuidDict
.keys():
442 _GuidDict
[Module
.Guid
.upper()] = FfsFile
445 EdkLogger
.error("build",
447 "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile
.CurrentLineNum
,
448 FfsFile
.CurrentLineContent
,
449 _GuidDict
[Module
.Guid
.upper()].CurrentLineNum
,
450 _GuidDict
[Module
.Guid
.upper()].CurrentLineContent
,
451 Module
.Guid
.upper()),
452 ExtraData
=self
.FdfFile
)
454 # Some INF files not have entity in DSC file.
457 if FfsFile
.InfFileName
.find('$') == -1:
458 InfPath
= NormPath(FfsFile
.InfFileName
)
459 if not os
.path
.exists(InfPath
):
460 EdkLogger
.error('build', GENFDS_ERROR
, "Non-existant Module %s !" % (FfsFile
.InfFileName
))
462 PathClassObj
= PathClass(FfsFile
.InfFileName
, self
.WorkspaceDir
)
464 # Here we just need to get FILE_GUID from INF file, use 'COMMON' as ARCH attribute. and use
465 # BuildObject from one of AutoGenObjectList is enough.
467 InfObj
= self
.AutoGenObjectList
[0].BuildDatabase
.WorkspaceDb
.BuildObject
[PathClassObj
, 'COMMON', self
.BuildTarget
, self
.ToolChain
]
468 if not InfObj
.Guid
.upper() in _GuidDict
.keys():
469 _GuidDict
[InfObj
.Guid
.upper()] = FfsFile
471 EdkLogger
.error("build",
473 "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile
.CurrentLineNum
,
474 FfsFile
.CurrentLineContent
,
475 _GuidDict
[InfObj
.Guid
.upper()].CurrentLineNum
,
476 _GuidDict
[InfObj
.Guid
.upper()].CurrentLineContent
,
477 InfObj
.Guid
.upper()),
478 ExtraData
=self
.FdfFile
)
481 if FfsFile
.NameGuid
!= None:
482 _CheckPCDAsGuidPattern
= re
.compile("^PCD\(.+\..+\)$")
485 # If the NameGuid reference a PCD name.
486 # The style must match: PCD(xxxx.yyy)
488 if _CheckPCDAsGuidPattern
.match(FfsFile
.NameGuid
):
490 # Replace the PCD value.
492 _PcdName
= FfsFile
.NameGuid
.lstrip("PCD(").rstrip(")")
494 for Pa
in self
.AutoGenObjectList
:
496 for PcdItem
in Pa
.AllPcdList
:
497 if (PcdItem
.TokenSpaceGuidCName
+ "." + PcdItem
.TokenCName
) == _PcdName
:
499 # First convert from CFormatGuid to GUID string
501 _PcdGuidString
= GuidStructureStringToGuidString(PcdItem
.DefaultValue
)
503 if not _PcdGuidString
:
505 # Then try Byte array.
507 _PcdGuidString
= GuidStructureByteArrayToGuidString(PcdItem
.DefaultValue
)
509 if not _PcdGuidString
:
511 # Not Byte array or CFormat GUID, raise error.
513 EdkLogger
.error("build",
515 "The format of PCD value is incorrect. PCD: %s , Value: %s\n" % (_PcdName
, PcdItem
.DefaultValue
),
516 ExtraData
=self
.FdfFile
)
518 if not _PcdGuidString
.upper() in _GuidDict
.keys():
519 _GuidDict
[_PcdGuidString
.upper()] = FfsFile
523 EdkLogger
.error("build",
525 "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile
.CurrentLineNum
,
526 FfsFile
.CurrentLineContent
,
527 _GuidDict
[_PcdGuidString
.upper()].CurrentLineNum
,
528 _GuidDict
[_PcdGuidString
.upper()].CurrentLineContent
,
529 FfsFile
.NameGuid
.upper()),
530 ExtraData
=self
.FdfFile
)
532 if not FfsFile
.NameGuid
.upper() in _GuidDict
.keys():
533 _GuidDict
[FfsFile
.NameGuid
.upper()] = FfsFile
536 # Two raw file GUID conflict.
538 EdkLogger
.error("build",
540 "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile
.CurrentLineNum
,
541 FfsFile
.CurrentLineContent
,
542 _GuidDict
[FfsFile
.NameGuid
.upper()].CurrentLineNum
,
543 _GuidDict
[FfsFile
.NameGuid
.upper()].CurrentLineContent
,
544 FfsFile
.NameGuid
.upper()),
545 ExtraData
=self
.FdfFile
)
548 def _CheckPcdDefineAndType(self
):
550 "FixedAtBuild", "PatchableInModule", "FeatureFlag",
551 "Dynamic", #"DynamicHii", "DynamicVpd",
552 "DynamicEx", # "DynamicExHii", "DynamicExVpd"
555 # This dict store PCDs which are not used by any modules with specified arches
557 for Pa
in self
.AutoGenObjectList
:
558 # Key of DSC's Pcds dictionary is PcdCName, TokenSpaceGuid
559 for Pcd
in Pa
.Platform
.Pcds
:
560 PcdType
= Pa
.Platform
.Pcds
[Pcd
].Type
562 # If no PCD type, this PCD comes from FDF
566 # Try to remove Hii and Vpd suffix
567 if PcdType
.startswith("DynamicEx"):
568 PcdType
= "DynamicEx"
569 elif PcdType
.startswith("Dynamic"):
572 for Package
in Pa
.PackageList
:
573 # Key of DEC's Pcds dictionary is PcdCName, TokenSpaceGuid, PcdType
574 if (Pcd
[0], Pcd
[1], PcdType
) in Package
.Pcds
:
576 for Type
in PcdTypeList
:
577 if (Pcd
[0], Pcd
[1], Type
) in Package
.Pcds
:
581 "Type [%s] of PCD [%s.%s] in DSC file doesn't match the type [%s] defined in DEC file." \
582 % (Pa
.Platform
.Pcds
[Pcd
].Type
, Pcd
[1], Pcd
[0], Type
),
587 UnusedPcd
.setdefault(Pcd
, []).append(Pa
.Arch
)
589 for Pcd
in UnusedPcd
:
592 "The PCD was not specified by any INF module in the platform for the given architecture.\n"
593 "\tPCD: [%s.%s]\n\tPlatform: [%s]\n\tArch: %s"
594 % (Pcd
[1], Pcd
[0], os
.path
.basename(str(self
.MetaFile
)), str(UnusedPcd
[Pcd
])),
599 return "%s [%s]" % (self
.MetaFile
, ", ".join(self
.ArchList
))
601 ## Return the directory to store FV files
603 if self
._FvDir
== None:
604 self
._FvDir
= path
.join(self
.BuildDir
, 'FV')
607 ## Return the directory to store all intermediate and final files built
608 def _GetBuildDir(self
):
609 return self
.AutoGenObjectList
[0].BuildDir
611 ## Return the build output directory platform specifies
612 def _GetOutputDir(self
):
613 return self
.Platform
.OutputDirectory
615 ## Return platform name
617 return self
.Platform
.PlatformName
619 ## Return meta-file GUID
621 return self
.Platform
.Guid
623 ## Return platform version
624 def _GetVersion(self
):
625 return self
.Platform
.Version
627 ## Return paths of tools
628 def _GetToolDefinition(self
):
629 return self
.AutoGenObjectList
[0].ToolDefinition
631 ## Return directory of platform makefile
633 # @retval string Makefile directory
635 def _GetMakeFileDir(self
):
636 if self
._MakeFileDir
== None:
637 self
._MakeFileDir
= self
.BuildDir
638 return self
._MakeFileDir
640 ## Return build command string
642 # @retval string Build command string
644 def _GetBuildCommand(self
):
645 if self
._BuildCommand
== None:
646 # BuildCommand should be all the same. So just get one from platform AutoGen
647 self
._BuildCommand
= self
.AutoGenObjectList
[0].BuildCommand
648 return self
._BuildCommand
650 ## Check the PCDs token value conflict in each DEC file.
652 # Will cause build break and raise error message while two PCDs conflict.
656 def _CheckAllPcdsTokenValueConflict(self
):
657 for Pa
in self
.AutoGenObjectList
:
658 for Package
in Pa
.PackageList
:
659 PcdList
= Package
.Pcds
.values()
660 PcdList
.sort(lambda x
, y
: cmp(int(x
.TokenValue
, 0), int(y
.TokenValue
, 0)))
662 while (Count
< len(PcdList
) - 1) :
663 Item
= PcdList
[Count
]
664 ItemNext
= PcdList
[Count
+ 1]
666 # Make sure in the same token space the TokenValue should be unique
668 if (int(Item
.TokenValue
, 0) == int(ItemNext
.TokenValue
, 0)):
669 SameTokenValuePcdList
= []
670 SameTokenValuePcdList
.append(Item
)
671 SameTokenValuePcdList
.append(ItemNext
)
672 RemainPcdListLength
= len(PcdList
) - Count
- 2
673 for ValueSameCount
in range(RemainPcdListLength
):
674 if int(PcdList
[len(PcdList
) - RemainPcdListLength
+ ValueSameCount
].TokenValue
, 0) == int(Item
.TokenValue
, 0):
675 SameTokenValuePcdList
.append(PcdList
[len(PcdList
) - RemainPcdListLength
+ ValueSameCount
])
679 # Sort same token value PCD list with TokenGuid and TokenCName
681 SameTokenValuePcdList
.sort(lambda x
, y
: cmp("%s.%s" % (x
.TokenSpaceGuidCName
, x
.TokenCName
), "%s.%s" % (y
.TokenSpaceGuidCName
, y
.TokenCName
)))
682 SameTokenValuePcdListCount
= 0
683 while (SameTokenValuePcdListCount
< len(SameTokenValuePcdList
) - 1):
684 TemListItem
= SameTokenValuePcdList
[SameTokenValuePcdListCount
]
685 TemListItemNext
= SameTokenValuePcdList
[SameTokenValuePcdListCount
+ 1]
687 if (TemListItem
.TokenSpaceGuidCName
== TemListItemNext
.TokenSpaceGuidCName
) and (TemListItem
.TokenCName
!= TemListItemNext
.TokenCName
):
691 "The TokenValue [%s] of PCD [%s.%s] is conflict with: [%s.%s] in %s"\
692 % (TemListItem
.TokenValue
, TemListItem
.TokenSpaceGuidCName
, TemListItem
.TokenCName
, TemListItemNext
.TokenSpaceGuidCName
, TemListItemNext
.TokenCName
, Package
),
695 SameTokenValuePcdListCount
+= 1
696 Count
+= SameTokenValuePcdListCount
699 PcdList
= Package
.Pcds
.values()
700 PcdList
.sort(lambda x
, y
: cmp("%s.%s" % (x
.TokenSpaceGuidCName
, x
.TokenCName
), "%s.%s" % (y
.TokenSpaceGuidCName
, y
.TokenCName
)))
702 while (Count
< len(PcdList
) - 1) :
703 Item
= PcdList
[Count
]
704 ItemNext
= PcdList
[Count
+ 1]
706 # Check PCDs with same TokenSpaceGuidCName.TokenCName have same token value as well.
708 if (Item
.TokenSpaceGuidCName
== ItemNext
.TokenSpaceGuidCName
) and (Item
.TokenCName
== ItemNext
.TokenCName
) and (int(Item
.TokenValue
, 0) != int(ItemNext
.TokenValue
, 0)):
712 "The TokenValue [%s] of PCD [%s.%s] in %s defined in two places should be same as well."\
713 % (Item
.TokenValue
, Item
.TokenSpaceGuidCName
, Item
.TokenCName
, Package
),
717 ## Generate fds command
718 def _GenFdsCommand(self
):
719 return (GenMake
.TopLevelMakefile(self
)._TEMPLATE
_.Replace(GenMake
.TopLevelMakefile(self
)._TemplateDict
)).strip()
721 ## Create makefile for the platform and modules in it
723 # @param CreateDepsMakeFile Flag indicating if the makefile for
724 # modules will be created as well
726 def CreateMakeFile(self
, CreateDepsMakeFile
=False):
727 if CreateDepsMakeFile
:
728 for Pa
in self
.AutoGenObjectList
:
729 Pa
.CreateMakeFile(CreateDepsMakeFile
)
731 ## Create autogen code for platform and modules
733 # Since there's no autogen code for platform, this method will do nothing
734 # if CreateModuleCodeFile is set to False.
736 # @param CreateDepsCodeFile Flag indicating if creating module's
737 # autogen code file or not
739 def CreateCodeFile(self
, CreateDepsCodeFile
=False):
740 if not CreateDepsCodeFile
:
742 for Pa
in self
.AutoGenObjectList
:
743 Pa
.CreateCodeFile(CreateDepsCodeFile
)
745 ## Create AsBuilt INF file the platform
747 def CreateAsBuiltInf(self
):
750 Name
= property(_GetName
)
751 Guid
= property(_GetGuid
)
752 Version
= property(_GetVersion
)
753 OutputDir
= property(_GetOutputDir
)
755 ToolDefinition
= property(_GetToolDefinition
) # toolcode : tool path
757 BuildDir
= property(_GetBuildDir
)
758 FvDir
= property(_GetFvDir
)
759 MakeFileDir
= property(_GetMakeFileDir
)
760 BuildCommand
= property(_GetBuildCommand
)
761 GenFdsCommand
= property(_GenFdsCommand
)
763 ## AutoGen class for platform
765 # PlatformAutoGen class will process the original information in platform
766 # file in order to generate makefile for platform.
768 class PlatformAutoGen(AutoGen
):
770 # Used to store all PCDs for both PEI and DXE phase, in order to generate
771 # correct PCD database
774 _NonDynaPcdList_
= []
777 # The priority list while override build option
779 PrioList
= {"0x11111" : 16, # TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE (Highest)
780 "0x01111" : 15, # ******_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE
781 "0x10111" : 14, # TARGET_*********_ARCH_COMMANDTYPE_ATTRIBUTE
782 "0x00111" : 13, # ******_*********_ARCH_COMMANDTYPE_ATTRIBUTE
783 "0x11011" : 12, # TARGET_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE
784 "0x01011" : 11, # ******_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE
785 "0x10011" : 10, # TARGET_*********_****_COMMANDTYPE_ATTRIBUTE
786 "0x00011" : 9, # ******_*********_****_COMMANDTYPE_ATTRIBUTE
787 "0x11101" : 8, # TARGET_TOOLCHAIN_ARCH_***********_ATTRIBUTE
788 "0x01101" : 7, # ******_TOOLCHAIN_ARCH_***********_ATTRIBUTE
789 "0x10101" : 6, # TARGET_*********_ARCH_***********_ATTRIBUTE
790 "0x00101" : 5, # ******_*********_ARCH_***********_ATTRIBUTE
791 "0x11001" : 4, # TARGET_TOOLCHAIN_****_***********_ATTRIBUTE
792 "0x01001" : 3, # ******_TOOLCHAIN_****_***********_ATTRIBUTE
793 "0x10001" : 2, # TARGET_*********_****_***********_ATTRIBUTE
794 "0x00001" : 1} # ******_*********_****_***********_ATTRIBUTE (Lowest)
796 ## The real constructor of PlatformAutoGen
798 # This method is not supposed to be called by users of PlatformAutoGen. It's
799 # only used by factory method __new__() to do real initialization work for an
800 # object of PlatformAutoGen
802 # @param Workspace WorkspaceAutoGen object
803 # @param PlatformFile Platform file (DSC file)
804 # @param Target Build target (DEBUG, RELEASE)
805 # @param Toolchain Name of tool chain
806 # @param Arch arch of the platform supports
808 def _Init(self
, Workspace
, PlatformFile
, Target
, Toolchain
, Arch
):
809 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "AutoGen platform [%s] [%s]" % (PlatformFile
, Arch
))
810 GlobalData
.gProcessingFile
= "%s [%s, %s, %s]" % (PlatformFile
, Arch
, Toolchain
, Target
)
812 self
.MetaFile
= PlatformFile
813 self
.Workspace
= Workspace
814 self
.WorkspaceDir
= Workspace
.WorkspaceDir
815 self
.ToolChain
= Toolchain
816 self
.BuildTarget
= Target
818 self
.SourceDir
= PlatformFile
.SubDir
819 self
.SourceOverrideDir
= None
820 self
.FdTargetList
= self
.Workspace
.FdTargetList
821 self
.FvTargetList
= self
.Workspace
.FvTargetList
823 # get the original module/package/platform objects
824 self
.BuildDatabase
= Workspace
.BuildDatabase
826 # flag indicating if the makefile/C-code file has been created or not
827 self
.IsMakeFileCreated
= False
828 self
.IsCodeFileCreated
= False
830 self
._Platform
= None
835 self
._BuildRule
= None
836 self
._SourceDir
= None
837 self
._BuildDir
= None
838 self
._OutputDir
= None
840 self
._MakeFileDir
= None
843 self
._PcdTokenNumber
= None # (TokenCName, TokenSpaceGuidCName) : GeneratedTokenNumber
844 self
._DynamicPcdList
= None # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]
845 self
._NonDynamicPcdList
= None # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]
846 self
._NonDynamicPcdDict
= {}
848 self
._ToolDefinitions
= None
849 self
._ToolDefFile
= None # toolcode : tool path
850 self
._ToolChainFamily
= None
851 self
._BuildRuleFamily
= None
852 self
._BuildOption
= None # toolcode : option
853 self
._EdkBuildOption
= None # edktoolcode : option
854 self
._EdkIIBuildOption
= None # edkiitoolcode : option
855 self
._PackageList
= None
856 self
._ModuleAutoGenList
= None
857 self
._LibraryAutoGenList
= None
858 self
._BuildCommand
= None
859 self
._AsBuildInfList
= []
860 self
._AsBuildModuleList
= []
861 if GlobalData
.gFdfParser
!= None:
862 self
._AsBuildInfList
= GlobalData
.gFdfParser
.Profile
.InfList
863 for Inf
in self
._AsBuildInfList
:
864 InfClass
= PathClass(NormPath(Inf
), GlobalData
.gWorkspace
, self
.Arch
)
865 M
= self
.BuildDatabase
[InfClass
, self
.Arch
, self
.BuildTarget
, self
.ToolChain
]
866 if not M
.IsSupportedArch
:
868 self
._AsBuildModuleList
.append(InfClass
)
869 # get library/modules for build
870 self
.LibraryBuildDirectoryList
= []
871 self
.ModuleBuildDirectoryList
= []
875 return "%s [%s]" % (self
.MetaFile
, self
.Arch
)
877 ## Create autogen code for platform and modules
879 # Since there's no autogen code for platform, this method will do nothing
880 # if CreateModuleCodeFile is set to False.
882 # @param CreateModuleCodeFile Flag indicating if creating module's
883 # autogen code file or not
885 def CreateCodeFile(self
, CreateModuleCodeFile
=False):
886 # only module has code to be greated, so do nothing if CreateModuleCodeFile is False
887 if self
.IsCodeFileCreated
or not CreateModuleCodeFile
:
890 for Ma
in self
.ModuleAutoGenList
:
891 Ma
.CreateCodeFile(True)
893 # don't do this twice
894 self
.IsCodeFileCreated
= True
896 ## Generate Fds Command
897 def _GenFdsCommand(self
):
898 return self
.Workspace
.GenFdsCommand
900 ## Create makefile for the platform and mdoules in it
902 # @param CreateModuleMakeFile Flag indicating if the makefile for
903 # modules will be created as well
905 def CreateMakeFile(self
, CreateModuleMakeFile
=False):
906 if CreateModuleMakeFile
:
907 for ModuleFile
in self
.Platform
.Modules
:
908 Ma
= ModuleAutoGen(self
.Workspace
, ModuleFile
, self
.BuildTarget
,
909 self
.ToolChain
, self
.Arch
, self
.MetaFile
)
910 Ma
.CreateMakeFile(True)
911 #Ma.CreateAsBuiltInf()
913 # no need to create makefile for the platform more than once
914 if self
.IsMakeFileCreated
:
917 # create library/module build dirs for platform
918 Makefile
= GenMake
.PlatformMakefile(self
)
919 self
.LibraryBuildDirectoryList
= Makefile
.GetLibraryBuildDirectoryList()
920 self
.ModuleBuildDirectoryList
= Makefile
.GetModuleBuildDirectoryList()
922 self
.IsMakeFileCreated
= True
924 ## Deal with Shared FixedAtBuild Pcds
926 def CollectFixedAtBuildPcds(self
):
927 for LibAuto
in self
.LibraryAutoGenList
:
928 FixedAtBuildPcds
= {}
929 ShareFixedAtBuildPcdsSameValue
= {}
930 for Module
in LibAuto
._ReferenceModules
:
931 for Pcd
in Module
.FixedAtBuildPcds
+ LibAuto
.FixedAtBuildPcds
:
932 key
= ".".join((Pcd
.TokenSpaceGuidCName
,Pcd
.TokenCName
))
933 if key
not in FixedAtBuildPcds
:
934 ShareFixedAtBuildPcdsSameValue
[key
] = True
935 FixedAtBuildPcds
[key
] = Pcd
.DefaultValue
937 if FixedAtBuildPcds
[key
] != Pcd
.DefaultValue
:
938 ShareFixedAtBuildPcdsSameValue
[key
] = False
939 for Pcd
in LibAuto
.FixedAtBuildPcds
:
940 key
= ".".join((Pcd
.TokenSpaceGuidCName
,Pcd
.TokenCName
))
941 if (Pcd
.TokenCName
,Pcd
.TokenSpaceGuidCName
) not in self
.NonDynamicPcdDict
:
944 DscPcd
= self
.NonDynamicPcdDict
[(Pcd
.TokenCName
,Pcd
.TokenSpaceGuidCName
)]
945 if DscPcd
.Type
!= "FixedAtBuild":
947 if key
in ShareFixedAtBuildPcdsSameValue
and ShareFixedAtBuildPcdsSameValue
[key
]:
948 LibAuto
.ConstPcd
[key
] = Pcd
.DefaultValue
950 ## Collect dynamic PCDs
952 # Gather dynamic PCDs list from each module and their settings from platform
953 # This interface should be invoked explicitly when platform action is created.
955 def CollectPlatformDynamicPcds(self
):
956 # for gathering error information
957 NoDatumTypePcdList
= set()
961 for InfName
in self
._AsBuildInfList
:
962 InfName
= mws
.join(self
.WorkspaceDir
, InfName
)
963 FdfModuleList
.append(os
.path
.normpath(InfName
))
964 for F
in self
.Platform
.Modules
.keys():
965 M
= ModuleAutoGen(self
.Workspace
, F
, self
.BuildTarget
, self
.ToolChain
, self
.Arch
, self
.MetaFile
)
966 #GuidValue.update(M.Guids)
968 self
.Platform
.Modules
[F
].M
= M
970 for PcdFromModule
in M
.ModulePcdList
+ M
.LibraryPcdList
:
971 # make sure that the "VOID*" kind of datum has MaxDatumSize set
972 if PcdFromModule
.DatumType
== "VOID*" and PcdFromModule
.MaxDatumSize
in [None, '']:
973 NoDatumTypePcdList
.add("%s.%s [%s]" % (PcdFromModule
.TokenSpaceGuidCName
, PcdFromModule
.TokenCName
, F
))
975 # Check the PCD from Binary INF or Source INF
976 if M
.IsBinaryModule
== True:
977 PcdFromModule
.IsFromBinaryInf
= True
979 # Check the PCD from DSC or not
980 if (PcdFromModule
.TokenCName
, PcdFromModule
.TokenSpaceGuidCName
) in self
.Platform
.Pcds
.keys():
981 PcdFromModule
.IsFromDsc
= True
983 PcdFromModule
.IsFromDsc
= False
984 if PcdFromModule
.Type
in GenC
.gDynamicPcd
or PcdFromModule
.Type
in GenC
.gDynamicExPcd
:
985 if F
.Path
not in FdfModuleList
:
986 # If one of the Source built modules listed in the DSC is not listed
987 # in FDF modules, and the INF lists a PCD can only use the PcdsDynamic
988 # access method (it is only listed in the DEC file that declares the
989 # PCD as PcdsDynamic), then build tool will report warning message
990 # notify the PI that they are attempting to build a module that must
991 # be included in a flash image in order to be functional. These Dynamic
992 # PCD will not be added into the Database unless it is used by other
993 # modules that are included in the FDF file.
994 if PcdFromModule
.Type
in GenC
.gDynamicPcd
and \
995 PcdFromModule
.IsFromBinaryInf
== False:
996 # Print warning message to let the developer make a determine.
997 if PcdFromModule
not in PcdNotInDb
:
998 PcdNotInDb
.append(PcdFromModule
)
1000 # If one of the Source built modules listed in the DSC is not listed in
1001 # FDF modules, and the INF lists a PCD can only use the PcdsDynamicEx
1002 # access method (it is only listed in the DEC file that declares the
1003 # PCD as PcdsDynamicEx), then DO NOT break the build; DO NOT add the
1004 # PCD to the Platform's PCD Database.
1005 if PcdFromModule
.Type
in GenC
.gDynamicExPcd
:
1006 if PcdFromModule
not in PcdNotInDb
:
1007 PcdNotInDb
.append(PcdFromModule
)
1010 # If a dynamic PCD used by a PEM module/PEI module & DXE module,
1011 # it should be stored in Pcd PEI database, If a dynamic only
1012 # used by DXE module, it should be stored in DXE PCD database.
1013 # The default Phase is DXE
1015 if M
.ModuleType
in ["PEIM", "PEI_CORE"]:
1016 PcdFromModule
.Phase
= "PEI"
1017 if PcdFromModule
not in self
._DynaPcdList
_:
1018 self
._DynaPcdList
_.append(PcdFromModule
)
1019 elif PcdFromModule
.Phase
== 'PEI':
1020 # overwrite any the same PCD existing, if Phase is PEI
1021 Index
= self
._DynaPcdList
_.index(PcdFromModule
)
1022 self
._DynaPcdList
_[Index
] = PcdFromModule
1023 elif PcdFromModule
not in self
._NonDynaPcdList
_:
1024 self
._NonDynaPcdList
_.append(PcdFromModule
)
1025 elif PcdFromModule
in self
._NonDynaPcdList
_ and PcdFromModule
.IsFromBinaryInf
== True:
1026 Index
= self
._NonDynaPcdList
_.index(PcdFromModule
)
1027 if self
._NonDynaPcdList
_[Index
].IsFromBinaryInf
== False:
1028 #The PCD from Binary INF will override the same one from source INF
1029 self
._NonDynaPcdList
_.remove (self
._NonDynaPcdList
_[Index
])
1030 PcdFromModule
.Pending
= False
1031 self
._NonDynaPcdList
_.append (PcdFromModule
)
1032 # Parse the DynamicEx PCD from the AsBuild INF module list of FDF.
1034 for ModuleInf
in self
.Platform
.Modules
.keys():
1035 DscModuleList
.append (os
.path
.normpath(ModuleInf
.Path
))
1036 # add the PCD from modules that listed in FDF but not in DSC to Database
1037 for InfName
in FdfModuleList
:
1038 if InfName
not in DscModuleList
:
1039 InfClass
= PathClass(InfName
)
1040 M
= self
.BuildDatabase
[InfClass
, self
.Arch
, self
.BuildTarget
, self
.ToolChain
]
1041 # If a module INF in FDF but not in current arch's DSC module list, it must be module (either binary or source)
1042 # for different Arch. PCDs in source module for different Arch is already added before, so skip the source module here.
1043 # For binary module, if in current arch, we need to list the PCDs into database.
1044 if not M
.IsSupportedArch
:
1046 # Override the module PCD setting by platform setting
1047 ModulePcdList
= self
.ApplyPcdSetting(M
, M
.Pcds
)
1048 for PcdFromModule
in ModulePcdList
:
1049 PcdFromModule
.IsFromBinaryInf
= True
1050 PcdFromModule
.IsFromDsc
= False
1051 # Only allow the DynamicEx and Patchable PCD in AsBuild INF
1052 if PcdFromModule
.Type
not in GenC
.gDynamicExPcd
and PcdFromModule
.Type
not in TAB_PCDS_PATCHABLE_IN_MODULE
:
1053 EdkLogger
.error("build", AUTOGEN_ERROR
, "PCD setting error",
1055 ExtraData
="\n\tExisted %s PCD %s in:\n\t\t%s\n"
1056 % (PcdFromModule
.Type
, PcdFromModule
.TokenCName
, InfName
))
1057 # make sure that the "VOID*" kind of datum has MaxDatumSize set
1058 if PcdFromModule
.DatumType
== "VOID*" and PcdFromModule
.MaxDatumSize
in [None, '']:
1059 NoDatumTypePcdList
.add("%s.%s [%s]" % (PcdFromModule
.TokenSpaceGuidCName
, PcdFromModule
.TokenCName
, InfName
))
1060 if M
.ModuleType
in ["PEIM", "PEI_CORE"]:
1061 PcdFromModule
.Phase
= "PEI"
1062 if PcdFromModule
not in self
._DynaPcdList
_ and PcdFromModule
.Type
in GenC
.gDynamicExPcd
:
1063 self
._DynaPcdList
_.append(PcdFromModule
)
1064 elif PcdFromModule
not in self
._NonDynaPcdList
_ and PcdFromModule
.Type
in TAB_PCDS_PATCHABLE_IN_MODULE
:
1065 self
._NonDynaPcdList
_.append(PcdFromModule
)
1066 if PcdFromModule
in self
._DynaPcdList
_ and PcdFromModule
.Phase
== 'PEI' and PcdFromModule
.Type
in GenC
.gDynamicExPcd
:
1067 # Overwrite the phase of any the same PCD existing, if Phase is PEI.
1068 # It is to solve the case that a dynamic PCD used by a PEM module/PEI
1069 # module & DXE module at a same time.
1070 # Overwrite the type of the PCDs in source INF by the type of AsBuild
1071 # INF file as DynamicEx.
1072 Index
= self
._DynaPcdList
_.index(PcdFromModule
)
1073 self
._DynaPcdList
_[Index
].Phase
= PcdFromModule
.Phase
1074 self
._DynaPcdList
_[Index
].Type
= PcdFromModule
.Type
1075 for PcdFromModule
in self
._NonDynaPcdList
_:
1076 # If a PCD is not listed in the DSC file, but binary INF files used by
1077 # this platform all (that use this PCD) list the PCD in a [PatchPcds]
1078 # section, AND all source INF files used by this platform the build
1079 # that use the PCD list the PCD in either a [Pcds] or [PatchPcds]
1080 # section, then the tools must NOT add the PCD to the Platform's PCD
1081 # Database; the build must assign the access method for this PCD as
1082 # PcdsPatchableInModule.
1083 if PcdFromModule
not in self
._DynaPcdList
_:
1085 Index
= self
._DynaPcdList
_.index(PcdFromModule
)
1086 if PcdFromModule
.IsFromDsc
== False and \
1087 PcdFromModule
.Type
in TAB_PCDS_PATCHABLE_IN_MODULE
and \
1088 PcdFromModule
.IsFromBinaryInf
== True and \
1089 self
._DynaPcdList
_[Index
].IsFromBinaryInf
== False:
1090 Index
= self
._DynaPcdList
_.index(PcdFromModule
)
1091 self
._DynaPcdList
_.remove (self
._DynaPcdList
_[Index
])
1093 # print out error information and break the build, if error found
1094 if len(NoDatumTypePcdList
) > 0:
1095 NoDatumTypePcdListString
= "\n\t\t".join(NoDatumTypePcdList
)
1096 EdkLogger
.error("build", AUTOGEN_ERROR
, "PCD setting error",
1098 ExtraData
="\n\tPCD(s) without MaxDatumSize:\n\t\t%s\n"
1099 % NoDatumTypePcdListString
)
1100 self
._NonDynamicPcdList
= self
._NonDynaPcdList
_
1101 self
._DynamicPcdList
= self
._DynaPcdList
_
1103 # Sort dynamic PCD list to:
1104 # 1) If PCD's datum type is VOID* and value is unicode string which starts with L, the PCD item should
1105 # try to be put header of dynamicd List
1106 # 2) If PCD is HII type, the PCD item should be put after unicode type PCD
1108 # The reason of sorting is make sure the unicode string is in double-byte alignment in string table.
1110 UnicodePcdArray
= []
1114 VpdFile
= VpdInfoFile
.VpdInfoFile()
1115 NeedProcessVpdMapFile
= False
1117 if (self
.Workspace
.ArchList
[-1] == self
.Arch
):
1118 for Pcd
in self
._DynamicPcdList
:
1119 # just pick the a value to determine whether is unicode string type
1120 Sku
= Pcd
.SkuInfoList
[Pcd
.SkuInfoList
.keys()[0]]
1121 Sku
.VpdOffset
= Sku
.VpdOffset
.strip()
1123 PcdValue
= Sku
.DefaultValue
1124 if Pcd
.DatumType
== 'VOID*' and PcdValue
.startswith("L"):
1125 # if found PCD which datum value is unicode string the insert to left size of UnicodeIndex
1126 UnicodePcdArray
.append(Pcd
)
1127 elif len(Sku
.VariableName
) > 0:
1128 # if found HII type PCD then insert to right of UnicodeIndex
1129 HiiPcdArray
.append(Pcd
)
1131 OtherPcdArray
.append(Pcd
)
1132 if Pcd
.Type
in [TAB_PCDS_DYNAMIC_VPD
, TAB_PCDS_DYNAMIC_EX_VPD
]:
1133 VpdPcdDict
[(Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
)] = Pcd
1135 PlatformPcds
= self
.Platform
.Pcds
.keys()
1138 # Add VPD type PCD into VpdFile and determine whether the VPD PCD need to be fixed up.
1140 for PcdKey
in PlatformPcds
:
1141 Pcd
= self
.Platform
.Pcds
[PcdKey
]
1142 if Pcd
.Type
in [TAB_PCDS_DYNAMIC_VPD
, TAB_PCDS_DYNAMIC_EX_VPD
] and \
1143 PcdKey
in VpdPcdDict
:
1144 Pcd
= VpdPcdDict
[PcdKey
]
1145 for (SkuName
,Sku
) in Pcd
.SkuInfoList
.items():
1146 Sku
.VpdOffset
= Sku
.VpdOffset
.strip()
1147 PcdValue
= Sku
.DefaultValue
1149 PcdValue
= Pcd
.DefaultValue
1150 if Sku
.VpdOffset
!= '*':
1151 if PcdValue
.startswith("{"):
1153 elif PcdValue
.startswith("L"):
1157 if int(Sku
.VpdOffset
) % Alignment
!= 0:
1158 EdkLogger
.error("build", FORMAT_INVALID
, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, Alignment
))
1159 VpdFile
.Add(Pcd
, Sku
.VpdOffset
)
1160 # if the offset of a VPD is *, then it need to be fixed up by third party tool.
1161 if not NeedProcessVpdMapFile
and Sku
.VpdOffset
== "*":
1162 NeedProcessVpdMapFile
= True
1163 if self
.Platform
.VpdToolGuid
== None or self
.Platform
.VpdToolGuid
== '':
1164 EdkLogger
.error("Build", FILE_NOT_FOUND
, \
1165 "Fail to find third-party BPDG tool to process VPD PCDs. BPDG Guid tool need to be defined in tools_def.txt and VPD_TOOL_GUID need to be provided in DSC file.")
1169 # Fix the PCDs define in VPD PCD section that never referenced by module.
1170 # An example is PCD for signature usage.
1172 for DscPcd
in PlatformPcds
:
1173 DscPcdEntry
= self
.Platform
.Pcds
[DscPcd
]
1174 if DscPcdEntry
.Type
in [TAB_PCDS_DYNAMIC_VPD
, TAB_PCDS_DYNAMIC_EX_VPD
]:
1175 if not (self
.Platform
.VpdToolGuid
== None or self
.Platform
.VpdToolGuid
== ''):
1177 for VpdPcd
in VpdFile
._VpdArray
.keys():
1178 # This PCD has been referenced by module
1179 if (VpdPcd
.TokenSpaceGuidCName
== DscPcdEntry
.TokenSpaceGuidCName
) and \
1180 (VpdPcd
.TokenCName
== DscPcdEntry
.TokenCName
):
1183 # Not found, it should be signature
1185 # just pick the a value to determine whether is unicode string type
1186 for (SkuName
,Sku
) in DscPcdEntry
.SkuInfoList
.items():
1187 Sku
.VpdOffset
= Sku
.VpdOffset
.strip()
1189 # Need to iterate DEC pcd information to get the value & datumtype
1190 for eachDec
in self
.PackageList
:
1191 for DecPcd
in eachDec
.Pcds
:
1192 DecPcdEntry
= eachDec
.Pcds
[DecPcd
]
1193 if (DecPcdEntry
.TokenSpaceGuidCName
== DscPcdEntry
.TokenSpaceGuidCName
) and \
1194 (DecPcdEntry
.TokenCName
== DscPcdEntry
.TokenCName
):
1195 # Print warning message to let the developer make a determine.
1196 EdkLogger
.warn("build", "Unreferenced vpd pcd used!",
1197 File
=self
.MetaFile
, \
1198 ExtraData
= "PCD: %s.%s used in the DSC file %s is unreferenced." \
1199 %(DscPcdEntry
.TokenSpaceGuidCName
, DscPcdEntry
.TokenCName
, self
.Platform
.MetaFile
.Path
))
1201 DscPcdEntry
.DatumType
= DecPcdEntry
.DatumType
1202 DscPcdEntry
.DefaultValue
= DecPcdEntry
.DefaultValue
1203 DscPcdEntry
.TokenValue
= DecPcdEntry
.TokenValue
1204 DscPcdEntry
.TokenSpaceGuidValue
= eachDec
.Guids
[DecPcdEntry
.TokenSpaceGuidCName
]
1205 # Only fix the value while no value provided in DSC file.
1206 if (Sku
.DefaultValue
== "" or Sku
.DefaultValue
==None):
1207 DscPcdEntry
.SkuInfoList
[DscPcdEntry
.SkuInfoList
.keys()[0]].DefaultValue
= DecPcdEntry
.DefaultValue
1209 if DscPcdEntry
not in self
._DynamicPcdList
:
1210 self
._DynamicPcdList
.append(DscPcdEntry
)
1211 # Sku = DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]]
1212 Sku
.VpdOffset
= Sku
.VpdOffset
.strip()
1213 PcdValue
= Sku
.DefaultValue
1215 PcdValue
= DscPcdEntry
.DefaultValue
1216 if Sku
.VpdOffset
!= '*':
1217 if PcdValue
.startswith("{"):
1219 elif PcdValue
.startswith("L"):
1223 if int(Sku
.VpdOffset
) % Alignment
!= 0:
1224 EdkLogger
.error("build", FORMAT_INVALID
, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (DscPcdEntry
.TokenSpaceGuidCName
, DscPcdEntry
.TokenCName
, Alignment
))
1225 VpdFile
.Add(DscPcdEntry
, Sku
.VpdOffset
)
1226 if not NeedProcessVpdMapFile
and Sku
.VpdOffset
== "*":
1227 NeedProcessVpdMapFile
= True
1228 if DscPcdEntry
.DatumType
== 'VOID*' and PcdValue
.startswith("L"):
1229 UnicodePcdArray
.append(DscPcdEntry
)
1230 elif len(Sku
.VariableName
) > 0:
1231 HiiPcdArray
.append(DscPcdEntry
)
1233 OtherPcdArray
.append(DscPcdEntry
)
1235 # if the offset of a VPD is *, then it need to be fixed up by third party tool.
1239 if (self
.Platform
.FlashDefinition
== None or self
.Platform
.FlashDefinition
== '') and \
1240 VpdFile
.GetCount() != 0:
1241 EdkLogger
.error("build", ATTRIBUTE_NOT_AVAILABLE
,
1242 "Fail to get FLASH_DEFINITION definition in DSC file %s which is required when DSC contains VPD PCD." % str(self
.Platform
.MetaFile
))
1244 if VpdFile
.GetCount() != 0:
1245 DscTimeStamp
= self
.Platform
.MetaFile
.TimeStamp
1246 FvPath
= os
.path
.join(self
.BuildDir
, "FV")
1247 if not os
.path
.exists(FvPath
):
1251 EdkLogger
.error("build", FILE_WRITE_FAILURE
, "Fail to create FV folder under %s" % self
.BuildDir
)
1254 VpdFilePath
= os
.path
.join(FvPath
, "%s.txt" % self
.Platform
.VpdToolGuid
)
1257 if not os
.path
.exists(VpdFilePath
) or os
.path
.getmtime(VpdFilePath
) < DscTimeStamp
:
1258 VpdFile
.Write(VpdFilePath
)
1260 # retrieve BPDG tool's path from tool_def.txt according to VPD_TOOL_GUID defined in DSC file.
1262 for ToolDef
in self
.ToolDefinition
.values():
1263 if ToolDef
.has_key("GUID") and ToolDef
["GUID"] == self
.Platform
.VpdToolGuid
:
1264 if not ToolDef
.has_key("PATH"):
1265 EdkLogger
.error("build", ATTRIBUTE_NOT_AVAILABLE
, "PATH attribute was not provided for BPDG guid tool %s in tools_def.txt" % self
.Platform
.VpdToolGuid
)
1266 BPDGToolName
= ToolDef
["PATH"]
1268 # Call third party GUID BPDG tool.
1269 if BPDGToolName
!= None:
1270 VpdInfoFile
.CallExtenalBPDGTool(BPDGToolName
, VpdFilePath
)
1272 EdkLogger
.error("Build", FILE_NOT_FOUND
, "Fail to find third-party BPDG tool to process VPD PCDs. BPDG Guid tool need to be defined in tools_def.txt and VPD_TOOL_GUID need to be provided in DSC file.")
1274 # Process VPD map file generated by third party BPDG tool
1275 if NeedProcessVpdMapFile
:
1276 VpdMapFilePath
= os
.path
.join(self
.BuildDir
, "FV", "%s.map" % self
.Platform
.VpdToolGuid
)
1277 if os
.path
.exists(VpdMapFilePath
):
1278 VpdFile
.Read(VpdMapFilePath
)
1281 for Pcd
in self
._DynamicPcdList
:
1282 # just pick the a value to determine whether is unicode string type
1284 for (SkuName
,Sku
) in Pcd
.SkuInfoList
.items():
1285 if Sku
.VpdOffset
== "*":
1286 Sku
.VpdOffset
= VpdFile
.GetOffset(Pcd
)[i
].strip()
1289 EdkLogger
.error("build", FILE_READ_FAILURE
, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath
)
1291 # Delete the DynamicPcdList At the last time enter into this function
1292 del self
._DynamicPcdList
[:]
1293 self
._DynamicPcdList
.extend(UnicodePcdArray
)
1294 self
._DynamicPcdList
.extend(HiiPcdArray
)
1295 self
._DynamicPcdList
.extend(OtherPcdArray
)
1296 self
.AllPcdList
= self
._NonDynamicPcdList
+ self
._DynamicPcdList
1298 ## Return the platform build data object
1299 def _GetPlatform(self
):
1300 if self
._Platform
== None:
1301 self
._Platform
= self
.BuildDatabase
[self
.MetaFile
, self
.Arch
, self
.BuildTarget
, self
.ToolChain
]
1302 return self
._Platform
1304 ## Return platform name
1306 return self
.Platform
.PlatformName
1308 ## Return the meta file GUID
1310 return self
.Platform
.Guid
1312 ## Return the platform version
1313 def _GetVersion(self
):
1314 return self
.Platform
.Version
1316 ## Return the FDF file name
1317 def _GetFdfFile(self
):
1318 if self
._FdfFile
== None:
1319 if self
.Workspace
.FdfFile
!= "":
1320 self
._FdfFile
= mws
.join(self
.WorkspaceDir
, self
.Workspace
.FdfFile
)
1323 return self
._FdfFile
1325 ## Return the build output directory platform specifies
1326 def _GetOutputDir(self
):
1327 return self
.Platform
.OutputDirectory
1329 ## Return the directory to store all intermediate and final files built
1330 def _GetBuildDir(self
):
1331 if self
._BuildDir
== None:
1332 if os
.path
.isabs(self
.OutputDir
):
1333 self
._BuildDir
= path
.join(
1334 path
.abspath(self
.OutputDir
),
1335 self
.BuildTarget
+ "_" + self
.ToolChain
,
1338 self
._BuildDir
= path
.join(
1341 self
.BuildTarget
+ "_" + self
.ToolChain
,
1343 return self
._BuildDir
1345 ## Return directory of platform makefile
1347 # @retval string Makefile directory
1349 def _GetMakeFileDir(self
):
1350 if self
._MakeFileDir
== None:
1351 self
._MakeFileDir
= path
.join(self
.BuildDir
, self
.Arch
)
1352 return self
._MakeFileDir
1354 ## Return build command string
1356 # @retval string Build command string
1358 def _GetBuildCommand(self
):
1359 if self
._BuildCommand
== None:
1360 self
._BuildCommand
= []
1361 if "MAKE" in self
.ToolDefinition
and "PATH" in self
.ToolDefinition
["MAKE"]:
1362 self
._BuildCommand
+= SplitOption(self
.ToolDefinition
["MAKE"]["PATH"])
1363 if "FLAGS" in self
.ToolDefinition
["MAKE"]:
1364 NewOption
= self
.ToolDefinition
["MAKE"]["FLAGS"].strip()
1366 self
._BuildCommand
+= SplitOption(NewOption
)
1367 return self
._BuildCommand
1369 ## Get tool chain definition
1371 # Get each tool defition for given tool chain from tools_def.txt and platform
1373 def _GetToolDefinition(self
):
1374 if self
._ToolDefinitions
== None:
1375 ToolDefinition
= self
.Workspace
.ToolDef
.ToolsDefTxtDictionary
1376 if TAB_TOD_DEFINES_COMMAND_TYPE
not in self
.Workspace
.ToolDef
.ToolsDefTxtDatabase
:
1377 EdkLogger
.error('build', RESOURCE_NOT_AVAILABLE
, "No tools found in configuration",
1378 ExtraData
="[%s]" % self
.MetaFile
)
1379 self
._ToolDefinitions
= {}
1381 for Def
in ToolDefinition
:
1382 Target
, Tag
, Arch
, Tool
, Attr
= Def
.split("_")
1383 if Target
!= self
.BuildTarget
or Tag
!= self
.ToolChain
or Arch
!= self
.Arch
:
1386 Value
= ToolDefinition
[Def
]
1387 # don't record the DLL
1389 DllPathList
.add(Value
)
1392 if Tool
not in self
._ToolDefinitions
:
1393 self
._ToolDefinitions
[Tool
] = {}
1394 self
._ToolDefinitions
[Tool
][Attr
] = Value
1398 if GlobalData
.gOptions
.SilentMode
and "MAKE" in self
._ToolDefinitions
:
1399 if "FLAGS" not in self
._ToolDefinitions
["MAKE"]:
1400 self
._ToolDefinitions
["MAKE"]["FLAGS"] = ""
1401 self
._ToolDefinitions
["MAKE"]["FLAGS"] += " -s"
1403 for Tool
in self
._ToolDefinitions
:
1404 for Attr
in self
._ToolDefinitions
[Tool
]:
1405 Value
= self
._ToolDefinitions
[Tool
][Attr
]
1406 if Tool
in self
.BuildOption
and Attr
in self
.BuildOption
[Tool
]:
1407 # check if override is indicated
1408 if self
.BuildOption
[Tool
][Attr
].startswith('='):
1409 Value
= self
.BuildOption
[Tool
][Attr
][1:]
1411 Value
+= " " + self
.BuildOption
[Tool
][Attr
]
1414 # Don't put MAKE definition in the file
1418 ToolsDef
+= "%s = %s\n" % (Tool
, Value
)
1420 # Don't put MAKE definition in the file
1425 ToolsDef
+= "%s_%s = %s\n" % (Tool
, Attr
, Value
)
1428 SaveFileOnChange(self
.ToolDefinitionFile
, ToolsDef
)
1429 for DllPath
in DllPathList
:
1430 os
.environ
["PATH"] = DllPath
+ os
.pathsep
+ os
.environ
["PATH"]
1431 os
.environ
["MAKE_FLAGS"] = MakeFlags
1433 return self
._ToolDefinitions
1435 ## Return the paths of tools
1436 def _GetToolDefFile(self
):
1437 if self
._ToolDefFile
== None:
1438 self
._ToolDefFile
= os
.path
.join(self
.MakeFileDir
, "TOOLS_DEF." + self
.Arch
)
1439 return self
._ToolDefFile
1441 ## Retrieve the toolchain family of given toolchain tag. Default to 'MSFT'.
1442 def _GetToolChainFamily(self
):
1443 if self
._ToolChainFamily
== None:
1444 ToolDefinition
= self
.Workspace
.ToolDef
.ToolsDefTxtDatabase
1445 if TAB_TOD_DEFINES_FAMILY
not in ToolDefinition \
1446 or self
.ToolChain
not in ToolDefinition
[TAB_TOD_DEFINES_FAMILY
] \
1447 or not ToolDefinition
[TAB_TOD_DEFINES_FAMILY
][self
.ToolChain
]:
1448 EdkLogger
.verbose("No tool chain family found in configuration for %s. Default to MSFT." \
1450 self
._ToolChainFamily
= "MSFT"
1452 self
._ToolChainFamily
= ToolDefinition
[TAB_TOD_DEFINES_FAMILY
][self
.ToolChain
]
1453 return self
._ToolChainFamily
1455 def _GetBuildRuleFamily(self
):
1456 if self
._BuildRuleFamily
== None:
1457 ToolDefinition
= self
.Workspace
.ToolDef
.ToolsDefTxtDatabase
1458 if TAB_TOD_DEFINES_BUILDRULEFAMILY
not in ToolDefinition \
1459 or self
.ToolChain
not in ToolDefinition
[TAB_TOD_DEFINES_BUILDRULEFAMILY
] \
1460 or not ToolDefinition
[TAB_TOD_DEFINES_BUILDRULEFAMILY
][self
.ToolChain
]:
1461 EdkLogger
.verbose("No tool chain family found in configuration for %s. Default to MSFT." \
1463 self
._BuildRuleFamily
= "MSFT"
1465 self
._BuildRuleFamily
= ToolDefinition
[TAB_TOD_DEFINES_BUILDRULEFAMILY
][self
.ToolChain
]
1466 return self
._BuildRuleFamily
1468 ## Return the build options specific for all modules in this platform
1469 def _GetBuildOptions(self
):
1470 if self
._BuildOption
== None:
1471 self
._BuildOption
= self
._ExpandBuildOption
(self
.Platform
.BuildOptions
)
1472 return self
._BuildOption
1474 ## Return the build options specific for EDK modules in this platform
1475 def _GetEdkBuildOptions(self
):
1476 if self
._EdkBuildOption
== None:
1477 self
._EdkBuildOption
= self
._ExpandBuildOption
(self
.Platform
.BuildOptions
, EDK_NAME
)
1478 return self
._EdkBuildOption
1480 ## Return the build options specific for EDKII modules in this platform
1481 def _GetEdkIIBuildOptions(self
):
1482 if self
._EdkIIBuildOption
== None:
1483 self
._EdkIIBuildOption
= self
._ExpandBuildOption
(self
.Platform
.BuildOptions
, EDKII_NAME
)
1484 return self
._EdkIIBuildOption
1486 ## Parse build_rule.txt in Conf Directory.
1488 # @retval BuildRule object
1490 def _GetBuildRule(self
):
1491 if self
._BuildRule
== None:
1492 BuildRuleFile
= None
1493 if TAB_TAT_DEFINES_BUILD_RULE_CONF
in self
.Workspace
.TargetTxt
.TargetTxtDictionary
:
1494 BuildRuleFile
= self
.Workspace
.TargetTxt
.TargetTxtDictionary
[TAB_TAT_DEFINES_BUILD_RULE_CONF
]
1495 if BuildRuleFile
in [None, '']:
1496 BuildRuleFile
= gDefaultBuildRuleFile
1497 self
._BuildRule
= BuildRule(BuildRuleFile
)
1498 if self
._BuildRule
._FileVersion
== "":
1499 self
._BuildRule
._FileVersion
= AutoGenReqBuildRuleVerNum
1501 if self
._BuildRule
._FileVersion
< AutoGenReqBuildRuleVerNum
:
1502 # If Build Rule's version is less than the version number required by the tools, halting the build.
1503 EdkLogger
.error("build", AUTOGEN_ERROR
,
1504 ExtraData
="The version number [%s] of build_rule.txt is less than the version number required by the AutoGen.(the minimum required version number is [%s])"\
1505 % (self
._BuildRule
._FileVersion
, AutoGenReqBuildRuleVerNum
))
1507 return self
._BuildRule
1509 ## Summarize the packages used by modules in this platform
1510 def _GetPackageList(self
):
1511 if self
._PackageList
== None:
1512 self
._PackageList
= set()
1513 for La
in self
.LibraryAutoGenList
:
1514 self
._PackageList
.update(La
.DependentPackageList
)
1515 for Ma
in self
.ModuleAutoGenList
:
1516 self
._PackageList
.update(Ma
.DependentPackageList
)
1517 #Collect package set information from INF of FDF
1519 for ModuleFile
in self
._AsBuildModuleList
:
1520 if ModuleFile
in self
.Platform
.Modules
:
1522 ModuleData
= self
.BuildDatabase
[ModuleFile
, self
.Arch
, self
.BuildTarget
, self
.ToolChain
]
1523 PkgSet
.update(ModuleData
.Packages
)
1524 self
._PackageList
= list(self
._PackageList
) + list (PkgSet
)
1525 return self
._PackageList
1527 def _GetNonDynamicPcdDict(self
):
1528 if self
._NonDynamicPcdDict
:
1529 return self
._NonDynamicPcdDict
1530 for Pcd
in self
.NonDynamicPcdList
:
1531 self
._NonDynamicPcdDict
[(Pcd
.TokenCName
,Pcd
.TokenSpaceGuidCName
)] = Pcd
1532 return self
._NonDynamicPcdDict
1534 ## Get list of non-dynamic PCDs
1535 def _GetNonDynamicPcdList(self
):
1536 if self
._NonDynamicPcdList
== None:
1537 self
.CollectPlatformDynamicPcds()
1538 return self
._NonDynamicPcdList
1540 ## Get list of dynamic PCDs
1541 def _GetDynamicPcdList(self
):
1542 if self
._DynamicPcdList
== None:
1543 self
.CollectPlatformDynamicPcds()
1544 return self
._DynamicPcdList
1546 ## Generate Token Number for all PCD
1547 def _GetPcdTokenNumbers(self
):
1548 if self
._PcdTokenNumber
== None:
1549 self
._PcdTokenNumber
= sdict()
1552 # Make the Dynamic and DynamicEx PCD use within different TokenNumber area.
1556 # TokenNumber 0 ~ 10
1558 # TokeNumber 11 ~ 20
1560 for Pcd
in self
.DynamicPcdList
:
1561 if Pcd
.Phase
== "PEI":
1562 if Pcd
.Type
in ["Dynamic", "DynamicDefault", "DynamicVpd", "DynamicHii"]:
1563 EdkLogger
.debug(EdkLogger
.DEBUG_5
, "%s %s (%s) -> %d" % (Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
, Pcd
.Phase
, TokenNumber
))
1564 self
._PcdTokenNumber
[Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
] = TokenNumber
1567 for Pcd
in self
.DynamicPcdList
:
1568 if Pcd
.Phase
== "PEI":
1569 if Pcd
.Type
in ["DynamicEx", "DynamicExDefault", "DynamicExVpd", "DynamicExHii"]:
1570 EdkLogger
.debug(EdkLogger
.DEBUG_5
, "%s %s (%s) -> %d" % (Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
, Pcd
.Phase
, TokenNumber
))
1571 self
._PcdTokenNumber
[Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
] = TokenNumber
1574 for Pcd
in self
.DynamicPcdList
:
1575 if Pcd
.Phase
== "DXE":
1576 if Pcd
.Type
in ["Dynamic", "DynamicDefault", "DynamicVpd", "DynamicHii"]:
1577 EdkLogger
.debug(EdkLogger
.DEBUG_5
, "%s %s (%s) -> %d" % (Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
, Pcd
.Phase
, TokenNumber
))
1578 self
._PcdTokenNumber
[Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
] = TokenNumber
1581 for Pcd
in self
.DynamicPcdList
:
1582 if Pcd
.Phase
== "DXE":
1583 if Pcd
.Type
in ["DynamicEx", "DynamicExDefault", "DynamicExVpd", "DynamicExHii"]:
1584 EdkLogger
.debug(EdkLogger
.DEBUG_5
, "%s %s (%s) -> %d" % (Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
, Pcd
.Phase
, TokenNumber
))
1585 self
._PcdTokenNumber
[Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
] = TokenNumber
1588 for Pcd
in self
.NonDynamicPcdList
:
1589 self
._PcdTokenNumber
[Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
] = TokenNumber
1591 return self
._PcdTokenNumber
1593 ## Summarize ModuleAutoGen objects of all modules/libraries to be built for this platform
1594 def _GetAutoGenObjectList(self
):
1595 self
._ModuleAutoGenList
= []
1596 self
._LibraryAutoGenList
= []
1597 for ModuleFile
in self
.Platform
.Modules
:
1606 if Ma
not in self
._ModuleAutoGenList
:
1607 self
._ModuleAutoGenList
.append(Ma
)
1608 for La
in Ma
.LibraryAutoGenList
:
1609 if La
not in self
._LibraryAutoGenList
:
1610 self
._LibraryAutoGenList
.append(La
)
1611 if Ma
not in La
._ReferenceModules
:
1612 La
._ReferenceModules
.append(Ma
)
1614 ## Summarize ModuleAutoGen objects of all modules to be built for this platform
1615 def _GetModuleAutoGenList(self
):
1616 if self
._ModuleAutoGenList
== None:
1617 self
._GetAutoGenObjectList
()
1618 return self
._ModuleAutoGenList
1620 ## Summarize ModuleAutoGen objects of all libraries to be built for this platform
1621 def _GetLibraryAutoGenList(self
):
1622 if self
._LibraryAutoGenList
== None:
1623 self
._GetAutoGenObjectList
()
1624 return self
._LibraryAutoGenList
1626 ## Test if a module is supported by the platform
1628 # An error will be raised directly if the module or its arch is not supported
1629 # by the platform or current configuration
1631 def ValidModule(self
, Module
):
1632 return Module
in self
.Platform
.Modules
or Module
in self
.Platform
.LibraryInstances \
1633 or Module
in self
._AsBuildModuleList
1635 ## Resolve the library classes in a module to library instances
1637 # This method will not only resolve library classes but also sort the library
1638 # instances according to the dependency-ship.
1640 # @param Module The module from which the library classes will be resolved
1642 # @retval library_list List of library instances sorted
1644 def ApplyLibraryInstance(self
, Module
):
1645 ModuleType
= Module
.ModuleType
1647 # for overridding library instances with module specific setting
1648 PlatformModule
= self
.Platform
.Modules
[str(Module
)]
1650 # add forced library instances (specified under LibraryClasses sections)
1652 # If a module has a MODULE_TYPE of USER_DEFINED,
1653 # do not link in NULL library class instances from the global [LibraryClasses.*] sections.
1655 if Module
.ModuleType
!= SUP_MODULE_USER_DEFINED
:
1656 for LibraryClass
in self
.Platform
.LibraryClasses
.GetKeys():
1657 if LibraryClass
.startswith("NULL") and self
.Platform
.LibraryClasses
[LibraryClass
, Module
.ModuleType
]:
1658 Module
.LibraryClasses
[LibraryClass
] = self
.Platform
.LibraryClasses
[LibraryClass
, Module
.ModuleType
]
1660 # add forced library instances (specified in module overrides)
1661 for LibraryClass
in PlatformModule
.LibraryClasses
:
1662 if LibraryClass
.startswith("NULL"):
1663 Module
.LibraryClasses
[LibraryClass
] = PlatformModule
.LibraryClasses
[LibraryClass
]
1666 LibraryConsumerList
= [Module
]
1668 ConsumedByList
= sdict()
1669 LibraryInstance
= sdict()
1671 EdkLogger
.verbose("")
1672 EdkLogger
.verbose("Library instances of module [%s] [%s]:" % (str(Module
), self
.Arch
))
1673 while len(LibraryConsumerList
) > 0:
1674 M
= LibraryConsumerList
.pop()
1675 for LibraryClassName
in M
.LibraryClasses
:
1676 if LibraryClassName
not in LibraryInstance
:
1677 # override library instance for this module
1678 if LibraryClassName
in PlatformModule
.LibraryClasses
:
1679 LibraryPath
= PlatformModule
.LibraryClasses
[LibraryClassName
]
1681 LibraryPath
= self
.Platform
.LibraryClasses
[LibraryClassName
, ModuleType
]
1682 if LibraryPath
== None or LibraryPath
== "":
1683 LibraryPath
= M
.LibraryClasses
[LibraryClassName
]
1684 if LibraryPath
== None or LibraryPath
== "":
1685 EdkLogger
.error("build", RESOURCE_NOT_AVAILABLE
,
1686 "Instance of library class [%s] is not found" % LibraryClassName
,
1688 ExtraData
="in [%s] [%s]\n\tconsumed by module [%s]" % (str(M
), self
.Arch
, str(Module
)))
1690 LibraryModule
= self
.BuildDatabase
[LibraryPath
, self
.Arch
, self
.BuildTarget
, self
.ToolChain
]
1691 # for those forced library instance (NULL library), add a fake library class
1692 if LibraryClassName
.startswith("NULL"):
1693 LibraryModule
.LibraryClass
.append(LibraryClassObject(LibraryClassName
, [ModuleType
]))
1694 elif LibraryModule
.LibraryClass
== None \
1695 or len(LibraryModule
.LibraryClass
) == 0 \
1696 or (ModuleType
!= 'USER_DEFINED'
1697 and ModuleType
not in LibraryModule
.LibraryClass
[0].SupModList
):
1698 # only USER_DEFINED can link against any library instance despite of its SupModList
1699 EdkLogger
.error("build", OPTION_MISSING
,
1700 "Module type [%s] is not supported by library instance [%s]" \
1701 % (ModuleType
, LibraryPath
), File
=self
.MetaFile
,
1702 ExtraData
="consumed by [%s]" % str(Module
))
1704 LibraryInstance
[LibraryClassName
] = LibraryModule
1705 LibraryConsumerList
.append(LibraryModule
)
1706 EdkLogger
.verbose("\t" + str(LibraryClassName
) + " : " + str(LibraryModule
))
1708 LibraryModule
= LibraryInstance
[LibraryClassName
]
1710 if LibraryModule
== None:
1713 if LibraryModule
.ConstructorList
!= [] and LibraryModule
not in Constructor
:
1714 Constructor
.append(LibraryModule
)
1716 if LibraryModule
not in ConsumedByList
:
1717 ConsumedByList
[LibraryModule
] = []
1718 # don't add current module itself to consumer list
1720 if M
in ConsumedByList
[LibraryModule
]:
1722 ConsumedByList
[LibraryModule
].append(M
)
1724 # Initialize the sorted output list to the empty set
1726 SortedLibraryList
= []
1728 # Q <- Set of all nodes with no incoming edges
1730 LibraryList
= [] #LibraryInstance.values()
1732 for LibraryClassName
in LibraryInstance
:
1733 M
= LibraryInstance
[LibraryClassName
]
1734 LibraryList
.append(M
)
1735 if ConsumedByList
[M
] == []:
1739 # start the DAG algorithm
1743 while Q
== [] and EdgeRemoved
:
1745 # for each node Item with a Constructor
1746 for Item
in LibraryList
:
1747 if Item
not in Constructor
:
1749 # for each Node without a constructor with an edge e from Item to Node
1750 for Node
in ConsumedByList
[Item
]:
1751 if Node
in Constructor
:
1753 # remove edge e from the graph if Node has no constructor
1754 ConsumedByList
[Item
].remove(Node
)
1756 if ConsumedByList
[Item
] == []:
1757 # insert Item into Q
1762 # DAG is done if there's no more incoming edge for all nodes
1766 # remove node from Q
1769 SortedLibraryList
.append(Node
)
1771 # for each node Item with an edge e from Node to Item do
1772 for Item
in LibraryList
:
1773 if Node
not in ConsumedByList
[Item
]:
1775 # remove edge e from the graph
1776 ConsumedByList
[Item
].remove(Node
)
1778 if ConsumedByList
[Item
] != []:
1780 # insert Item into Q, if Item has no other incoming edges
1784 # if any remaining node Item in the graph has a constructor and an incoming edge, then the graph has a cycle
1786 for Item
in LibraryList
:
1787 if ConsumedByList
[Item
] != [] and Item
in Constructor
and len(Constructor
) > 1:
1788 ErrorMessage
= "\tconsumed by " + "\n\tconsumed by ".join([str(L
) for L
in ConsumedByList
[Item
]])
1789 EdkLogger
.error("build", BUILD_ERROR
, 'Library [%s] with constructors has a cycle' % str(Item
),
1790 ExtraData
=ErrorMessage
, File
=self
.MetaFile
)
1791 if Item
not in SortedLibraryList
:
1792 SortedLibraryList
.append(Item
)
1795 # Build the list of constructor and destructir names
1796 # The DAG Topo sort produces the destructor order, so the list of constructors must generated in the reverse order
1798 SortedLibraryList
.reverse()
1799 return SortedLibraryList
1802 ## Override PCD setting (type, value, ...)
1804 # @param ToPcd The PCD to be overrided
1805 # @param FromPcd The PCD overrideing from
1807 def _OverridePcd(self
, ToPcd
, FromPcd
, Module
=""):
1809 # in case there's PCDs coming from FDF file, which have no type given.
1810 # at this point, ToPcd.Type has the type found from dependent
1814 if ToPcd
.Pending
and FromPcd
.Type
not in [None, '']:
1815 ToPcd
.Type
= FromPcd
.Type
1816 elif (ToPcd
.Type
not in [None, '']) and (FromPcd
.Type
not in [None, ''])\
1817 and (ToPcd
.Type
!= FromPcd
.Type
) and (ToPcd
.Type
in FromPcd
.Type
):
1818 if ToPcd
.Type
.strip() == "DynamicEx":
1819 ToPcd
.Type
= FromPcd
.Type
1820 elif ToPcd
.Type
not in [None, ''] and FromPcd
.Type
not in [None, ''] \
1821 and ToPcd
.Type
!= FromPcd
.Type
:
1822 EdkLogger
.error("build", OPTION_CONFLICT
, "Mismatched PCD type",
1823 ExtraData
="%s.%s is defined as [%s] in module %s, but as [%s] in platform."\
1824 % (ToPcd
.TokenSpaceGuidCName
, ToPcd
.TokenCName
,
1825 ToPcd
.Type
, Module
, FromPcd
.Type
),
1828 if FromPcd
.MaxDatumSize
not in [None, '']:
1829 ToPcd
.MaxDatumSize
= FromPcd
.MaxDatumSize
1830 if FromPcd
.DefaultValue
not in [None, '']:
1831 ToPcd
.DefaultValue
= FromPcd
.DefaultValue
1832 if FromPcd
.TokenValue
not in [None, '']:
1833 ToPcd
.TokenValue
= FromPcd
.TokenValue
1834 if FromPcd
.MaxDatumSize
not in [None, '']:
1835 ToPcd
.MaxDatumSize
= FromPcd
.MaxDatumSize
1836 if FromPcd
.DatumType
not in [None, '']:
1837 ToPcd
.DatumType
= FromPcd
.DatumType
1838 if FromPcd
.SkuInfoList
not in [None, '', []]:
1839 ToPcd
.SkuInfoList
= FromPcd
.SkuInfoList
1841 # check the validation of datum
1842 IsValid
, Cause
= CheckPcdDatum(ToPcd
.DatumType
, ToPcd
.DefaultValue
)
1844 EdkLogger
.error('build', FORMAT_INVALID
, Cause
, File
=self
.MetaFile
,
1845 ExtraData
="%s.%s" % (ToPcd
.TokenSpaceGuidCName
, ToPcd
.TokenCName
))
1846 ToPcd
.validateranges
= FromPcd
.validateranges
1847 ToPcd
.validlists
= FromPcd
.validlists
1848 ToPcd
.expressions
= FromPcd
.expressions
1850 if ToPcd
.DatumType
== "VOID*" and ToPcd
.MaxDatumSize
in ['', None]:
1851 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "No MaxDatumSize specified for PCD %s.%s" \
1852 % (ToPcd
.TokenSpaceGuidCName
, ToPcd
.TokenCName
))
1853 Value
= ToPcd
.DefaultValue
1854 if Value
in [None, '']:
1855 ToPcd
.MaxDatumSize
= '1'
1856 elif Value
[0] == 'L':
1857 ToPcd
.MaxDatumSize
= str((len(Value
) - 2) * 2)
1858 elif Value
[0] == '{':
1859 ToPcd
.MaxDatumSize
= str(len(Value
.split(',')))
1861 ToPcd
.MaxDatumSize
= str(len(Value
) - 1)
1863 # apply default SKU for dynamic PCDS if specified one is not available
1864 if (ToPcd
.Type
in PCD_DYNAMIC_TYPE_LIST
or ToPcd
.Type
in PCD_DYNAMIC_EX_TYPE_LIST
) \
1865 and ToPcd
.SkuInfoList
in [None, {}, '']:
1866 if self
.Platform
.SkuName
in self
.Platform
.SkuIds
:
1867 SkuName
= self
.Platform
.SkuName
1870 ToPcd
.SkuInfoList
= {
1871 SkuName
: SkuInfoClass(SkuName
, self
.Platform
.SkuIds
[SkuName
], '', '', '', '', '', ToPcd
.DefaultValue
)
1874 ## Apply PCD setting defined platform to a module
1876 # @param Module The module from which the PCD setting will be overrided
1878 # @retval PCD_list The list PCDs with settings from platform
1880 def ApplyPcdSetting(self
, Module
, Pcds
):
1881 # for each PCD in module
1882 for Name
, Guid
in Pcds
:
1883 PcdInModule
= Pcds
[Name
, Guid
]
1884 # find out the PCD setting in platform
1885 if (Name
, Guid
) in self
.Platform
.Pcds
:
1886 PcdInPlatform
= self
.Platform
.Pcds
[Name
, Guid
]
1888 PcdInPlatform
= None
1889 # then override the settings if any
1890 self
._OverridePcd
(PcdInModule
, PcdInPlatform
, Module
)
1891 # resolve the VariableGuid value
1892 for SkuId
in PcdInModule
.SkuInfoList
:
1893 Sku
= PcdInModule
.SkuInfoList
[SkuId
]
1894 if Sku
.VariableGuid
== '': continue
1895 Sku
.VariableGuidValue
= GuidValue(Sku
.VariableGuid
, self
.PackageList
)
1896 if Sku
.VariableGuidValue
== None:
1897 PackageList
= "\n\t".join([str(P
) for P
in self
.PackageList
])
1900 RESOURCE_NOT_AVAILABLE
,
1901 "Value of GUID [%s] is not found in" % Sku
.VariableGuid
,
1902 ExtraData
=PackageList
+ "\n\t(used with %s.%s from module %s)" \
1903 % (Guid
, Name
, str(Module
)),
1907 # override PCD settings with module specific setting
1908 if Module
in self
.Platform
.Modules
:
1909 PlatformModule
= self
.Platform
.Modules
[str(Module
)]
1910 for Key
in PlatformModule
.Pcds
:
1912 self
._OverridePcd
(Pcds
[Key
], PlatformModule
.Pcds
[Key
], Module
)
1913 return Pcds
.values()
1915 ## Resolve library names to library modules
1917 # (for Edk.x modules)
1919 # @param Module The module from which the library names will be resolved
1921 # @retval library_list The list of library modules
1923 def ResolveLibraryReference(self
, Module
):
1924 EdkLogger
.verbose("")
1925 EdkLogger
.verbose("Library instances of module [%s] [%s]:" % (str(Module
), self
.Arch
))
1926 LibraryConsumerList
= [Module
]
1928 # "CompilerStub" is a must for Edk modules
1929 if Module
.Libraries
:
1930 Module
.Libraries
.append("CompilerStub")
1932 while len(LibraryConsumerList
) > 0:
1933 M
= LibraryConsumerList
.pop()
1934 for LibraryName
in M
.Libraries
:
1935 Library
= self
.Platform
.LibraryClasses
[LibraryName
, ':dummy:']
1937 for Key
in self
.Platform
.LibraryClasses
.data
.keys():
1938 if LibraryName
.upper() == Key
.upper():
1939 Library
= self
.Platform
.LibraryClasses
[Key
, ':dummy:']
1942 EdkLogger
.warn("build", "Library [%s] is not found" % LibraryName
, File
=str(M
),
1943 ExtraData
="\t%s [%s]" % (str(Module
), self
.Arch
))
1946 if Library
not in LibraryList
:
1947 LibraryList
.append(Library
)
1948 LibraryConsumerList
.append(Library
)
1949 EdkLogger
.verbose("\t" + LibraryName
+ " : " + str(Library
) + ' ' + str(type(Library
)))
1952 ## Calculate the priority value of the build option
1954 # @param Key Build option definition contain: TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE
1956 # @retval Value Priority value based on the priority list.
1958 def CalculatePriorityValue(self
, Key
):
1959 Target
, ToolChain
, Arch
, CommandType
, Attr
= Key
.split('_')
1960 PriorityValue
= 0x11111
1962 PriorityValue
&= 0x01111
1963 if ToolChain
== "*":
1964 PriorityValue
&= 0x10111
1966 PriorityValue
&= 0x11011
1967 if CommandType
== "*":
1968 PriorityValue
&= 0x11101
1970 PriorityValue
&= 0x11110
1972 return self
.PrioList
["0x%0.5x" % PriorityValue
]
1975 ## Expand * in build option key
1977 # @param Options Options to be expanded
1979 # @retval options Options expanded
1981 def _ExpandBuildOption(self
, Options
, ModuleStyle
=None):
1988 # Construct a list contain the build options which need override.
1992 # Key[0] -- tool family
1993 # Key[1] -- TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE
1995 if (Key
[0] == self
.BuildRuleFamily
and
1996 (ModuleStyle
== None or len(Key
) < 3 or (len(Key
) > 2 and Key
[2] == ModuleStyle
))):
1997 Target
, ToolChain
, Arch
, CommandType
, Attr
= Key
[1].split('_')
1998 if Target
== self
.BuildTarget
or Target
== "*":
1999 if ToolChain
== self
.ToolChain
or ToolChain
== "*":
2000 if Arch
== self
.Arch
or Arch
== "*":
2001 if Options
[Key
].startswith("="):
2002 if OverrideList
.get(Key
[1]) != None:
2003 OverrideList
.pop(Key
[1])
2004 OverrideList
[Key
[1]] = Options
[Key
]
2007 # Use the highest priority value.
2009 if (len(OverrideList
) >= 2):
2010 KeyList
= OverrideList
.keys()
2011 for Index
in range(len(KeyList
)):
2012 NowKey
= KeyList
[Index
]
2013 Target1
, ToolChain1
, Arch1
, CommandType1
, Attr1
= NowKey
.split("_")
2014 for Index1
in range(len(KeyList
) - Index
- 1):
2015 NextKey
= KeyList
[Index1
+ Index
+ 1]
2017 # Compare two Key, if one is included by another, choose the higher priority one
2019 Target2
, ToolChain2
, Arch2
, CommandType2
, Attr2
= NextKey
.split("_")
2020 if Target1
== Target2
or Target1
== "*" or Target2
== "*":
2021 if ToolChain1
== ToolChain2
or ToolChain1
== "*" or ToolChain2
== "*":
2022 if Arch1
== Arch2
or Arch1
== "*" or Arch2
== "*":
2023 if CommandType1
== CommandType2
or CommandType1
== "*" or CommandType2
== "*":
2024 if Attr1
== Attr2
or Attr1
== "*" or Attr2
== "*":
2025 if self
.CalculatePriorityValue(NowKey
) > self
.CalculatePriorityValue(NextKey
):
2026 if Options
.get((self
.BuildRuleFamily
, NextKey
)) != None:
2027 Options
.pop((self
.BuildRuleFamily
, NextKey
))
2029 if Options
.get((self
.BuildRuleFamily
, NowKey
)) != None:
2030 Options
.pop((self
.BuildRuleFamily
, NowKey
))
2033 if ModuleStyle
!= None and len (Key
) > 2:
2034 # Check Module style is EDK or EDKII.
2035 # Only append build option for the matched style module.
2036 if ModuleStyle
== EDK_NAME
and Key
[2] != EDK_NAME
:
2038 elif ModuleStyle
== EDKII_NAME
and Key
[2] != EDKII_NAME
:
2041 Target
, Tag
, Arch
, Tool
, Attr
= Key
[1].split("_")
2042 # if tool chain family doesn't match, skip it
2043 if Tool
in self
.ToolDefinition
and Family
!= "":
2044 FamilyIsNull
= False
2045 if self
.ToolDefinition
[Tool
].get(TAB_TOD_DEFINES_BUILDRULEFAMILY
, "") != "":
2046 if Family
!= self
.ToolDefinition
[Tool
][TAB_TOD_DEFINES_BUILDRULEFAMILY
]:
2048 elif Family
!= self
.ToolDefinition
[Tool
][TAB_TOD_DEFINES_FAMILY
]:
2051 # expand any wildcard
2052 if Target
== "*" or Target
== self
.BuildTarget
:
2053 if Tag
== "*" or Tag
== self
.ToolChain
:
2054 if Arch
== "*" or Arch
== self
.Arch
:
2055 if Tool
not in BuildOptions
:
2056 BuildOptions
[Tool
] = {}
2057 if Attr
!= "FLAGS" or Attr
not in BuildOptions
[Tool
] or Options
[Key
].startswith('='):
2058 BuildOptions
[Tool
][Attr
] = Options
[Key
]
2060 # append options for the same tool
2061 BuildOptions
[Tool
][Attr
] += " " + Options
[Key
]
2062 # Build Option Family has been checked, which need't to be checked again for family.
2063 if FamilyMatch
or FamilyIsNull
:
2067 if ModuleStyle
!= None and len (Key
) > 2:
2068 # Check Module style is EDK or EDKII.
2069 # Only append build option for the matched style module.
2070 if ModuleStyle
== EDK_NAME
and Key
[2] != EDK_NAME
:
2072 elif ModuleStyle
== EDKII_NAME
and Key
[2] != EDKII_NAME
:
2075 Target
, Tag
, Arch
, Tool
, Attr
= Key
[1].split("_")
2076 # if tool chain family doesn't match, skip it
2077 if Tool
not in self
.ToolDefinition
or Family
== "":
2079 # option has been added before
2080 if Family
!= self
.ToolDefinition
[Tool
][TAB_TOD_DEFINES_FAMILY
]:
2083 # expand any wildcard
2084 if Target
== "*" or Target
== self
.BuildTarget
:
2085 if Tag
== "*" or Tag
== self
.ToolChain
:
2086 if Arch
== "*" or Arch
== self
.Arch
:
2087 if Tool
not in BuildOptions
:
2088 BuildOptions
[Tool
] = {}
2089 if Attr
!= "FLAGS" or Attr
not in BuildOptions
[Tool
] or Options
[Key
].startswith('='):
2090 BuildOptions
[Tool
][Attr
] = Options
[Key
]
2092 # append options for the same tool
2093 BuildOptions
[Tool
][Attr
] += " " + Options
[Key
]
2096 ## Append build options in platform to a module
2098 # @param Module The module to which the build options will be appened
2100 # @retval options The options appended with build options in platform
2102 def ApplyBuildOption(self
, Module
):
2103 # Get the different options for the different style module
2104 if Module
.AutoGenVersion
< 0x00010005:
2105 PlatformOptions
= self
.EdkBuildOption
2106 ModuleTypeOptions
= self
.Platform
.GetBuildOptionsByModuleType(EDK_NAME
, Module
.ModuleType
)
2108 PlatformOptions
= self
.EdkIIBuildOption
2109 ModuleTypeOptions
= self
.Platform
.GetBuildOptionsByModuleType(EDKII_NAME
, Module
.ModuleType
)
2110 ModuleTypeOptions
= self
._ExpandBuildOption
(ModuleTypeOptions
)
2111 ModuleOptions
= self
._ExpandBuildOption
(Module
.BuildOptions
)
2112 if Module
in self
.Platform
.Modules
:
2113 PlatformModule
= self
.Platform
.Modules
[str(Module
)]
2114 PlatformModuleOptions
= self
._ExpandBuildOption
(PlatformModule
.BuildOptions
)
2116 PlatformModuleOptions
= {}
2118 BuildRuleOrder
= None
2119 for Options
in [self
.ToolDefinition
, ModuleOptions
, PlatformOptions
, ModuleTypeOptions
, PlatformModuleOptions
]:
2120 for Tool
in Options
:
2121 for Attr
in Options
[Tool
]:
2122 if Attr
== TAB_TOD_DEFINES_BUILDRULEORDER
:
2123 BuildRuleOrder
= Options
[Tool
][Attr
]
2125 AllTools
= set(ModuleOptions
.keys() + PlatformOptions
.keys() +
2126 PlatformModuleOptions
.keys() + ModuleTypeOptions
.keys() +
2127 self
.ToolDefinition
.keys())
2129 for Tool
in AllTools
:
2130 if Tool
not in BuildOptions
:
2131 BuildOptions
[Tool
] = {}
2133 for Options
in [self
.ToolDefinition
, ModuleOptions
, PlatformOptions
, ModuleTypeOptions
, PlatformModuleOptions
]:
2134 if Tool
not in Options
:
2136 for Attr
in Options
[Tool
]:
2137 Value
= Options
[Tool
][Attr
]
2139 # Do not generate it in Makefile
2141 if Attr
== TAB_TOD_DEFINES_BUILDRULEORDER
:
2143 if Attr
not in BuildOptions
[Tool
]:
2144 BuildOptions
[Tool
][Attr
] = ""
2145 # check if override is indicated
2146 if Value
.startswith('='):
2147 ToolPath
= Value
[1:]
2148 ToolPath
= mws
.handleWsMacro(ToolPath
)
2149 BuildOptions
[Tool
][Attr
] = ToolPath
2151 Value
= mws
.handleWsMacro(Value
)
2152 BuildOptions
[Tool
][Attr
] += " " + Value
2153 if Module
.AutoGenVersion
< 0x00010005 and self
.Workspace
.UniFlag
!= None:
2155 # Override UNI flag only for EDK module.
2157 if 'BUILD' not in BuildOptions
:
2158 BuildOptions
['BUILD'] = {}
2159 BuildOptions
['BUILD']['FLAGS'] = self
.Workspace
.UniFlag
2160 return BuildOptions
, BuildRuleOrder
2162 Platform
= property(_GetPlatform
)
2163 Name
= property(_GetName
)
2164 Guid
= property(_GetGuid
)
2165 Version
= property(_GetVersion
)
2167 OutputDir
= property(_GetOutputDir
)
2168 BuildDir
= property(_GetBuildDir
)
2169 MakeFileDir
= property(_GetMakeFileDir
)
2170 FdfFile
= property(_GetFdfFile
)
2172 PcdTokenNumber
= property(_GetPcdTokenNumbers
) # (TokenCName, TokenSpaceGuidCName) : GeneratedTokenNumber
2173 DynamicPcdList
= property(_GetDynamicPcdList
) # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]
2174 NonDynamicPcdList
= property(_GetNonDynamicPcdList
) # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]
2175 NonDynamicPcdDict
= property(_GetNonDynamicPcdDict
)
2176 PackageList
= property(_GetPackageList
)
2178 ToolDefinition
= property(_GetToolDefinition
) # toolcode : tool path
2179 ToolDefinitionFile
= property(_GetToolDefFile
) # toolcode : lib path
2180 ToolChainFamily
= property(_GetToolChainFamily
)
2181 BuildRuleFamily
= property(_GetBuildRuleFamily
)
2182 BuildOption
= property(_GetBuildOptions
) # toolcode : option
2183 EdkBuildOption
= property(_GetEdkBuildOptions
) # edktoolcode : option
2184 EdkIIBuildOption
= property(_GetEdkIIBuildOptions
) # edkiitoolcode : option
2186 BuildCommand
= property(_GetBuildCommand
)
2187 BuildRule
= property(_GetBuildRule
)
2188 ModuleAutoGenList
= property(_GetModuleAutoGenList
)
2189 LibraryAutoGenList
= property(_GetLibraryAutoGenList
)
2190 GenFdsCommand
= property(_GenFdsCommand
)
2192 ## ModuleAutoGen class
2194 # This class encapsules the AutoGen behaviors for the build tools. In addition to
2195 # the generation of AutoGen.h and AutoGen.c, it will generate *.depex file according
2196 # to the [depex] section in module's inf file.
2198 class ModuleAutoGen(AutoGen
):
2199 ## The real constructor of ModuleAutoGen
2201 # This method is not supposed to be called by users of ModuleAutoGen. It's
2202 # only used by factory method __new__() to do real initialization work for an
2203 # object of ModuleAutoGen
2205 # @param Workspace EdkIIWorkspaceBuild object
2206 # @param ModuleFile The path of module file
2207 # @param Target Build target (DEBUG, RELEASE)
2208 # @param Toolchain Name of tool chain
2209 # @param Arch The arch the module supports
2210 # @param PlatformFile Platform meta-file
2212 def _Init(self
, Workspace
, ModuleFile
, Target
, Toolchain
, Arch
, PlatformFile
):
2213 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "AutoGen module [%s] [%s]" % (ModuleFile
, Arch
))
2214 GlobalData
.gProcessingFile
= "%s [%s, %s, %s]" % (ModuleFile
, Arch
, Toolchain
, Target
)
2216 self
.Workspace
= Workspace
2217 self
.WorkspaceDir
= Workspace
.WorkspaceDir
2219 self
.MetaFile
= ModuleFile
2220 self
.PlatformInfo
= PlatformAutoGen(Workspace
, PlatformFile
, Target
, Toolchain
, Arch
)
2221 # check if this module is employed by active platform
2222 if not self
.PlatformInfo
.ValidModule(self
.MetaFile
):
2223 EdkLogger
.verbose("Module [%s] for [%s] is not employed by active platform\n" \
2224 % (self
.MetaFile
, Arch
))
2227 self
.SourceDir
= self
.MetaFile
.SubDir
2228 self
.SourceDir
= mws
.relpath(self
.SourceDir
, self
.WorkspaceDir
)
2230 self
.SourceOverrideDir
= None
2231 # use overrided path defined in DSC file
2232 if self
.MetaFile
.Key
in GlobalData
.gOverrideDir
:
2233 self
.SourceOverrideDir
= GlobalData
.gOverrideDir
[self
.MetaFile
.Key
]
2235 self
.ToolChain
= Toolchain
2236 self
.BuildTarget
= Target
2238 self
.ToolChainFamily
= self
.PlatformInfo
.ToolChainFamily
2239 self
.BuildRuleFamily
= self
.PlatformInfo
.BuildRuleFamily
2241 self
.IsMakeFileCreated
= False
2242 self
.IsCodeFileCreated
= False
2243 self
.IsAsBuiltInfCreated
= False
2244 self
.DepexGenerated
= False
2246 self
.BuildDatabase
= self
.Workspace
.BuildDatabase
2247 self
.BuildRuleOrder
= None
2252 self
._Version
= None
2253 self
._ModuleType
= None
2254 self
._ComponentType
= None
2255 self
._PcdIsDriver
= None
2256 self
._AutoGenVersion
= None
2257 self
._LibraryFlag
= None
2258 self
._CustomMakefile
= None
2261 self
._BuildDir
= None
2262 self
._OutputDir
= None
2263 self
._DebugDir
= None
2264 self
._MakeFileDir
= None
2266 self
._IncludePathList
= None
2267 self
._AutoGenFileList
= None
2268 self
._UnicodeFileList
= None
2269 self
._SourceFileList
= None
2270 self
._ObjectFileList
= None
2271 self
._BinaryFileList
= None
2273 self
._DependentPackageList
= None
2274 self
._DependentLibraryList
= None
2275 self
._LibraryAutoGenList
= None
2276 self
._DerivedPackageList
= None
2277 self
._ModulePcdList
= None
2278 self
._LibraryPcdList
= None
2279 self
._PcdComments
= sdict()
2280 self
._GuidList
= None
2281 self
._GuidsUsedByPcd
= None
2282 self
._GuidComments
= sdict()
2283 self
._ProtocolList
= None
2284 self
._ProtocolComments
= sdict()
2285 self
._PpiList
= None
2286 self
._PpiComments
= sdict()
2287 self
._DepexList
= None
2288 self
._DepexExpressionList
= None
2289 self
._BuildOption
= None
2290 self
._BuildOptionIncPathList
= None
2291 self
._BuildTargets
= None
2292 self
._IntroBuildTargetList
= None
2293 self
._FinalBuildTargetList
= None
2294 self
._FileTypes
= None
2295 self
._BuildRules
= None
2297 ## The Modules referenced to this Library
2298 # Only Library has this attribute
2299 self
._ReferenceModules
= []
2301 ## Store the FixedAtBuild Pcds
2303 self
._FixedAtBuildPcds
= []
2308 return "%s [%s]" % (self
.MetaFile
, self
.Arch
)
2310 # Get FixedAtBuild Pcds of this Module
2311 def _GetFixedAtBuildPcds(self
):
2312 if self
._FixedAtBuildPcds
:
2313 return self
._FixedAtBuildPcds
2314 for Pcd
in self
.ModulePcdList
:
2316 if not (Pcd
.Pending
== False and Pcd
.Type
== "FixedAtBuild"):
2318 elif Pcd
.Type
!= "FixedAtBuild":
2320 if Pcd
not in self
._FixedAtBuildPcds
:
2321 self
._FixedAtBuildPcds
.append(Pcd
)
2323 return self
._FixedAtBuildPcds
2325 def _GetUniqueBaseName(self
):
2326 BaseName
= self
.Name
2327 for Module
in self
.PlatformInfo
.ModuleAutoGenList
:
2328 if Module
.MetaFile
== self
.MetaFile
:
2330 if Module
.Name
== self
.Name
:
2331 if uuid
.UUID(Module
.Guid
) == uuid
.UUID(self
.Guid
):
2332 EdkLogger
.error("build", FILE_DUPLICATED
, 'Modules have same BaseName and FILE_GUID:\n'
2333 ' %s\n %s' % (Module
.MetaFile
, self
.MetaFile
))
2334 BaseName
= '%s_%s' % (self
.Name
, self
.Guid
)
2337 # Macros could be used in build_rule.txt (also Makefile)
2338 def _GetMacros(self
):
2339 if self
._Macro
== None:
2340 self
._Macro
= sdict()
2341 self
._Macro
["WORKSPACE" ] = self
.WorkspaceDir
2342 self
._Macro
["MODULE_NAME" ] = self
.Name
2343 self
._Macro
["MODULE_NAME_GUID" ] = self
._GetUniqueBaseName
()
2344 self
._Macro
["MODULE_GUID" ] = self
.Guid
2345 self
._Macro
["MODULE_VERSION" ] = self
.Version
2346 self
._Macro
["MODULE_TYPE" ] = self
.ModuleType
2347 self
._Macro
["MODULE_FILE" ] = str(self
.MetaFile
)
2348 self
._Macro
["MODULE_FILE_BASE_NAME" ] = self
.MetaFile
.BaseName
2349 self
._Macro
["MODULE_RELATIVE_DIR" ] = self
.SourceDir
2350 self
._Macro
["MODULE_DIR" ] = self
.SourceDir
2352 self
._Macro
["BASE_NAME" ] = self
.Name
2354 self
._Macro
["ARCH" ] = self
.Arch
2355 self
._Macro
["TOOLCHAIN" ] = self
.ToolChain
2356 self
._Macro
["TOOLCHAIN_TAG" ] = self
.ToolChain
2357 self
._Macro
["TOOL_CHAIN_TAG" ] = self
.ToolChain
2358 self
._Macro
["TARGET" ] = self
.BuildTarget
2360 self
._Macro
["BUILD_DIR" ] = self
.PlatformInfo
.BuildDir
2361 self
._Macro
["BIN_DIR" ] = os
.path
.join(self
.PlatformInfo
.BuildDir
, self
.Arch
)
2362 self
._Macro
["LIB_DIR" ] = os
.path
.join(self
.PlatformInfo
.BuildDir
, self
.Arch
)
2363 self
._Macro
["MODULE_BUILD_DIR" ] = self
.BuildDir
2364 self
._Macro
["OUTPUT_DIR" ] = self
.OutputDir
2365 self
._Macro
["DEBUG_DIR" ] = self
.DebugDir
2368 ## Return the module build data object
2369 def _GetModule(self
):
2370 if self
._Module
== None:
2371 self
._Module
= self
.Workspace
.BuildDatabase
[self
.MetaFile
, self
.Arch
, self
.BuildTarget
, self
.ToolChain
]
2374 ## Return the module name
2375 def _GetBaseName(self
):
2376 return self
.Module
.BaseName
2378 ## Return the module DxsFile if exist
2379 def _GetDxsFile(self
):
2380 return self
.Module
.DxsFile
2382 ## Return the module SourceOverridePath
2383 def _GetSourceOverridePath(self
):
2384 return self
.Module
.SourceOverridePath
2386 ## Return the module meta-file GUID
2389 # To build same module more than once, the module path with FILE_GUID overridden has
2390 # the file name FILE_GUIDmodule.inf, but the relative path (self.MetaFile.File) is the realy path
2391 # in DSC. The overridden GUID can be retrieved from file name
2393 if os
.path
.basename(self
.MetaFile
.File
) != os
.path
.basename(self
.MetaFile
.Path
):
2395 # Length of GUID is 36
2397 return os
.path
.basename(self
.MetaFile
.Path
)[:36]
2398 return self
.Module
.Guid
2400 ## Return the module version
2401 def _GetVersion(self
):
2402 return self
.Module
.Version
2404 ## Return the module type
2405 def _GetModuleType(self
):
2406 return self
.Module
.ModuleType
2408 ## Return the component type (for Edk.x style of module)
2409 def _GetComponentType(self
):
2410 return self
.Module
.ComponentType
2412 ## Return the build type
2413 def _GetBuildType(self
):
2414 return self
.Module
.BuildType
2416 ## Return the PCD_IS_DRIVER setting
2417 def _GetPcdIsDriver(self
):
2418 return self
.Module
.PcdIsDriver
2420 ## Return the autogen version, i.e. module meta-file version
2421 def _GetAutoGenVersion(self
):
2422 return self
.Module
.AutoGenVersion
2424 ## Check if the module is library or not
2425 def _IsLibrary(self
):
2426 if self
._LibraryFlag
== None:
2427 if self
.Module
.LibraryClass
!= None and self
.Module
.LibraryClass
!= []:
2428 self
._LibraryFlag
= True
2430 self
._LibraryFlag
= False
2431 return self
._LibraryFlag
2433 ## Check if the module is binary module or not
2434 def _IsBinaryModule(self
):
2435 return self
.Module
.IsBinaryModule
2437 ## Return the directory to store intermediate files of the module
2438 def _GetBuildDir(self
):
2439 if self
._BuildDir
== None:
2440 self
._BuildDir
= path
.join(
2441 self
.PlatformInfo
.BuildDir
,
2444 self
.MetaFile
.BaseName
2446 CreateDirectory(self
._BuildDir
)
2447 return self
._BuildDir
2449 ## Return the directory to store the intermediate object files of the mdoule
2450 def _GetOutputDir(self
):
2451 if self
._OutputDir
== None:
2452 self
._OutputDir
= path
.join(self
.BuildDir
, "OUTPUT")
2453 CreateDirectory(self
._OutputDir
)
2454 return self
._OutputDir
2456 ## Return the directory to store auto-gened source files of the mdoule
2457 def _GetDebugDir(self
):
2458 if self
._DebugDir
== None:
2459 self
._DebugDir
= path
.join(self
.BuildDir
, "DEBUG")
2460 CreateDirectory(self
._DebugDir
)
2461 return self
._DebugDir
2463 ## Return the path of custom file
2464 def _GetCustomMakefile(self
):
2465 if self
._CustomMakefile
== None:
2466 self
._CustomMakefile
= {}
2467 for Type
in self
.Module
.CustomMakefile
:
2468 if Type
in gMakeTypeMap
:
2469 MakeType
= gMakeTypeMap
[Type
]
2472 if self
.SourceOverrideDir
!= None:
2473 File
= os
.path
.join(self
.SourceOverrideDir
, self
.Module
.CustomMakefile
[Type
])
2474 if not os
.path
.exists(File
):
2475 File
= os
.path
.join(self
.SourceDir
, self
.Module
.CustomMakefile
[Type
])
2477 File
= os
.path
.join(self
.SourceDir
, self
.Module
.CustomMakefile
[Type
])
2478 self
._CustomMakefile
[MakeType
] = File
2479 return self
._CustomMakefile
2481 ## Return the directory of the makefile
2483 # @retval string The directory string of module's makefile
2485 def _GetMakeFileDir(self
):
2486 return self
.BuildDir
2488 ## Return build command string
2490 # @retval string Build command string
2492 def _GetBuildCommand(self
):
2493 return self
.PlatformInfo
.BuildCommand
2495 ## Get object list of all packages the module and its dependent libraries belong to
2497 # @retval list The list of package object
2499 def _GetDerivedPackageList(self
):
2501 for M
in [self
.Module
] + self
.DependentLibraryList
:
2502 for Package
in M
.Packages
:
2503 if Package
in PackageList
:
2505 PackageList
.append(Package
)
2508 ## Get the depex string
2510 # @return : a string contain all depex expresion.
2511 def _GetDepexExpresionString(self
):
2514 ## DPX_SOURCE IN Define section.
2515 if self
.Module
.DxsFile
:
2517 for M
in [self
.Module
] + self
.DependentLibraryList
:
2518 Filename
= M
.MetaFile
.Path
2519 InfObj
= InfSectionParser
.InfSectionParser(Filename
)
2520 DepexExpresionList
= InfObj
.GetDepexExpresionList()
2521 for DepexExpresion
in DepexExpresionList
:
2522 for key
in DepexExpresion
.keys():
2523 Arch
, ModuleType
= key
2524 # the type of build module is USER_DEFINED.
2525 # All different DEPEX section tags would be copied into the As Built INF file
2526 # and there would be separate DEPEX section tags
2527 if self
.ModuleType
.upper() == SUP_MODULE_USER_DEFINED
:
2528 if (Arch
.upper() == self
.Arch
.upper()) and (ModuleType
.upper() != TAB_ARCH_COMMON
):
2529 DepexList
.append({(Arch
, ModuleType
): DepexExpresion
[key
][:]})
2531 if Arch
.upper() == TAB_ARCH_COMMON
or \
2532 (Arch
.upper() == self
.Arch
.upper() and \
2533 ModuleType
.upper() in [TAB_ARCH_COMMON
, self
.ModuleType
.upper()]):
2534 DepexList
.append({(Arch
, ModuleType
): DepexExpresion
[key
][:]})
2536 #the type of build module is USER_DEFINED.
2537 if self
.ModuleType
.upper() == SUP_MODULE_USER_DEFINED
:
2538 for Depex
in DepexList
:
2539 for key
in Depex
.keys():
2540 DepexStr
+= '[Depex.%s.%s]\n' % key
2541 DepexStr
+= '\n'.join(['# '+ val
for val
in Depex
[key
]])
2544 return '[Depex.%s]\n' % self
.Arch
2547 #the type of build module not is USER_DEFINED.
2549 for Depex
in DepexList
:
2554 for D
in Depex
.values():
2555 DepexStr
+= ' '.join([val
for val
in D
])
2556 Index
= DepexStr
.find('END')
2557 if Index
> -1 and Index
== len(DepexStr
) - 3:
2558 DepexStr
= DepexStr
[:-3]
2559 DepexStr
= DepexStr
.strip()
2562 DepexStr
= DepexStr
.lstrip('(').rstrip(')').strip()
2564 return '[Depex.%s]\n' % self
.Arch
2565 return '[Depex.%s]\n# ' % self
.Arch
+ DepexStr
2567 ## Merge dependency expression
2569 # @retval list The token list of the dependency expression after parsed
2571 def _GetDepexTokenList(self
):
2572 if self
._DepexList
== None:
2573 self
._DepexList
= {}
2574 if self
.DxsFile
or self
.IsLibrary
or TAB_DEPENDENCY_EXPRESSION_FILE
in self
.FileTypes
:
2575 return self
._DepexList
2577 self
._DepexList
[self
.ModuleType
] = []
2579 for ModuleType
in self
._DepexList
:
2580 DepexList
= self
._DepexList
[ModuleType
]
2582 # Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion
2584 for M
in [self
.Module
] + self
.DependentLibraryList
:
2586 for D
in M
.Depex
[self
.Arch
, ModuleType
]:
2588 DepexList
.append('AND')
2589 DepexList
.append('(')
2591 if DepexList
[-1] == 'END': # no need of a END at this time
2593 DepexList
.append(')')
2596 EdkLogger
.verbose("DEPEX[%s] (+%s) = %s" % (self
.Name
, M
.BaseName
, DepexList
))
2597 if 'BEFORE' in DepexList
or 'AFTER' in DepexList
:
2599 if len(DepexList
) > 0:
2600 EdkLogger
.verbose('')
2601 return self
._DepexList
2603 ## Merge dependency expression
2605 # @retval list The token list of the dependency expression after parsed
2607 def _GetDepexExpressionTokenList(self
):
2608 if self
._DepexExpressionList
== None:
2609 self
._DepexExpressionList
= {}
2610 if self
.DxsFile
or self
.IsLibrary
or TAB_DEPENDENCY_EXPRESSION_FILE
in self
.FileTypes
:
2611 return self
._DepexExpressionList
2613 self
._DepexExpressionList
[self
.ModuleType
] = ''
2615 for ModuleType
in self
._DepexExpressionList
:
2616 DepexExpressionList
= self
._DepexExpressionList
[ModuleType
]
2618 # Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion
2620 for M
in [self
.Module
] + self
.DependentLibraryList
:
2622 for D
in M
.DepexExpression
[self
.Arch
, ModuleType
]:
2623 if DepexExpressionList
!= '':
2624 DepexExpressionList
+= ' AND '
2625 DepexExpressionList
+= '('
2626 DepexExpressionList
+= D
2627 DepexExpressionList
= DepexExpressionList
.rstrip('END').strip()
2628 DepexExpressionList
+= ')'
2631 EdkLogger
.verbose("DEPEX[%s] (+%s) = %s" % (self
.Name
, M
.BaseName
, DepexExpressionList
))
2632 if 'BEFORE' in DepexExpressionList
or 'AFTER' in DepexExpressionList
:
2634 if len(DepexExpressionList
) > 0:
2635 EdkLogger
.verbose('')
2636 self
._DepexExpressionList
[ModuleType
] = DepexExpressionList
2637 return self
._DepexExpressionList
2639 ## Return the list of specification version required for the module
2641 # @retval list The list of specification defined in module file
2643 def _GetSpecification(self
):
2644 return self
.Module
.Specification
2646 ## Tool option for the module build
2648 # @param PlatformInfo The object of PlatformBuildInfo
2649 # @retval dict The dict containing valid options
2651 def _GetModuleBuildOption(self
):
2652 if self
._BuildOption
== None:
2653 self
._BuildOption
, self
.BuildRuleOrder
= self
.PlatformInfo
.ApplyBuildOption(self
.Module
)
2654 if self
.BuildRuleOrder
:
2655 self
.BuildRuleOrder
= ['.%s' % Ext
for Ext
in self
.BuildRuleOrder
.split()]
2656 return self
._BuildOption
2658 ## Get include path list from tool option for the module build
2660 # @retval list The include path list
2662 def _GetBuildOptionIncPathList(self
):
2663 if self
._BuildOptionIncPathList
== None:
2665 # Regular expression for finding Include Directories, the difference between MSFT and INTEL/GCC/RVCT
2666 # is the former use /I , the Latter used -I to specify include directories
2668 if self
.PlatformInfo
.ToolChainFamily
in ('MSFT'):
2669 gBuildOptIncludePattern
= re
.compile(r
"(?:.*?)/I[ \t]*([^ ]*)", re
.MULTILINE | re
.DOTALL
)
2670 elif self
.PlatformInfo
.ToolChainFamily
in ('INTEL', 'GCC', 'RVCT'):
2671 gBuildOptIncludePattern
= re
.compile(r
"(?:.*?)-I[ \t]*([^ ]*)", re
.MULTILINE | re
.DOTALL
)
2674 # New ToolChainFamily, don't known whether there is option to specify include directories
2676 self
._BuildOptionIncPathList
= []
2677 return self
._BuildOptionIncPathList
2679 BuildOptionIncPathList
= []
2680 for Tool
in ('CC', 'PP', 'VFRPP', 'ASLPP', 'ASLCC', 'APP', 'ASM'):
2683 FlagOption
= self
.BuildOption
[Tool
][Attr
]
2687 if self
.PlatformInfo
.ToolChainFamily
!= 'RVCT':
2688 IncPathList
= [NormPath(Path
, self
.Macros
) for Path
in gBuildOptIncludePattern
.findall(FlagOption
)]
2691 # RVCT may specify a list of directory seperated by commas
2694 for Path
in gBuildOptIncludePattern
.findall(FlagOption
):
2695 PathList
= GetSplitList(Path
, TAB_COMMA_SPLIT
)
2696 IncPathList
+= [NormPath(PathEntry
, self
.Macros
) for PathEntry
in PathList
]
2699 # EDK II modules must not reference header files outside of the packages they depend on or
2700 # within the module's directory tree. Report error if violation.
2702 if self
.AutoGenVersion
>= 0x00010005 and len(IncPathList
) > 0:
2703 for Path
in IncPathList
:
2704 if (Path
not in self
.IncludePathList
) and (CommonPath([Path
, self
.MetaFile
.Dir
]) != self
.MetaFile
.Dir
):
2705 ErrMsg
= "The include directory for the EDK II module in this line is invalid %s specified in %s FLAGS '%s'" % (Path
, Tool
, FlagOption
)
2706 EdkLogger
.error("build",
2709 File
=str(self
.MetaFile
))
2712 BuildOptionIncPathList
+= IncPathList
2714 self
._BuildOptionIncPathList
= BuildOptionIncPathList
2716 return self
._BuildOptionIncPathList
2718 ## Return a list of files which can be built from source
2720 # What kind of files can be built is determined by build rules in
2721 # $(CONF_DIRECTORY)/build_rule.txt and toolchain family.
2723 def _GetSourceFileList(self
):
2724 if self
._SourceFileList
== None:
2725 self
._SourceFileList
= []
2726 for F
in self
.Module
.Sources
:
2728 if F
.TagName
not in ("", "*", self
.ToolChain
):
2729 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "The toolchain [%s] for processing file [%s] is found, "
2730 "but [%s] is needed" % (F
.TagName
, str(F
), self
.ToolChain
))
2732 # match tool chain family
2733 if F
.ToolChainFamily
not in ("", "*", self
.ToolChainFamily
):
2736 "The file [%s] must be built by tools of [%s], " \
2737 "but current toolchain family is [%s]" \
2738 % (str(F
), F
.ToolChainFamily
, self
.ToolChainFamily
))
2741 # add the file path into search path list for file including
2742 if F
.Dir
not in self
.IncludePathList
and self
.AutoGenVersion
>= 0x00010005:
2743 self
.IncludePathList
.insert(0, F
.Dir
)
2744 self
._SourceFileList
.append(F
)
2746 self
._MatchBuildRuleOrder
(self
._SourceFileList
)
2748 for F
in self
._SourceFileList
:
2749 self
._ApplyBuildRule
(F
, TAB_UNKNOWN_FILE
)
2750 return self
._SourceFileList
2752 def _MatchBuildRuleOrder(self
, FileList
):
2754 self
._GetModuleBuildOption
()
2755 for SingleFile
in FileList
:
2756 if self
.BuildRuleOrder
and SingleFile
.Ext
in self
.BuildRuleOrder
and SingleFile
.Ext
in self
.BuildRules
:
2757 key
= SingleFile
.Path
.split(SingleFile
.Ext
)[0]
2758 if key
in Order_Dict
:
2759 Order_Dict
[key
].append(SingleFile
.Ext
)
2761 Order_Dict
[key
] = [SingleFile
.Ext
]
2764 for F
in Order_Dict
:
2765 if len(Order_Dict
[F
]) > 1:
2766 Order_Dict
[F
].sort(key
=lambda i
: self
.BuildRuleOrder
.index(i
))
2767 for Ext
in Order_Dict
[F
][1:]:
2768 RemoveList
.append(F
+ Ext
)
2770 for item
in RemoveList
:
2771 FileList
.remove(item
)
2775 ## Return the list of unicode files
2776 def _GetUnicodeFileList(self
):
2777 if self
._UnicodeFileList
== None:
2778 if TAB_UNICODE_FILE
in self
.FileTypes
:
2779 self
._UnicodeFileList
= self
.FileTypes
[TAB_UNICODE_FILE
]
2781 self
._UnicodeFileList
= []
2782 return self
._UnicodeFileList
2784 ## Return a list of files which can be built from binary
2786 # "Build" binary files are just to copy them to build directory.
2788 # @retval list The list of files which can be built later
2790 def _GetBinaryFiles(self
):
2791 if self
._BinaryFileList
== None:
2792 self
._BinaryFileList
= []
2793 for F
in self
.Module
.Binaries
:
2794 if F
.Target
not in ['COMMON', '*'] and F
.Target
!= self
.BuildTarget
:
2796 self
._BinaryFileList
.append(F
)
2797 self
._ApplyBuildRule
(F
, F
.Type
)
2798 return self
._BinaryFileList
2800 def _GetBuildRules(self
):
2801 if self
._BuildRules
== None:
2803 BuildRuleDatabase
= self
.PlatformInfo
.BuildRule
2804 for Type
in BuildRuleDatabase
.FileTypeList
:
2805 #first try getting build rule by BuildRuleFamily
2806 RuleObject
= BuildRuleDatabase
[Type
, self
.BuildType
, self
.Arch
, self
.BuildRuleFamily
]
2808 # build type is always module type, but ...
2809 if self
.ModuleType
!= self
.BuildType
:
2810 RuleObject
= BuildRuleDatabase
[Type
, self
.ModuleType
, self
.Arch
, self
.BuildRuleFamily
]
2811 #second try getting build rule by ToolChainFamily
2813 RuleObject
= BuildRuleDatabase
[Type
, self
.BuildType
, self
.Arch
, self
.ToolChainFamily
]
2815 # build type is always module type, but ...
2816 if self
.ModuleType
!= self
.BuildType
:
2817 RuleObject
= BuildRuleDatabase
[Type
, self
.ModuleType
, self
.Arch
, self
.ToolChainFamily
]
2820 RuleObject
= RuleObject
.Instantiate(self
.Macros
)
2821 BuildRules
[Type
] = RuleObject
2822 for Ext
in RuleObject
.SourceFileExtList
:
2823 BuildRules
[Ext
] = RuleObject
2824 self
._BuildRules
= BuildRules
2825 return self
._BuildRules
2827 def _ApplyBuildRule(self
, File
, FileType
):
2828 if self
._BuildTargets
== None:
2829 self
._IntroBuildTargetList
= set()
2830 self
._FinalBuildTargetList
= set()
2831 self
._BuildTargets
= {}
2832 self
._FileTypes
= {}
2834 SubDirectory
= os
.path
.join(self
.OutputDir
, File
.SubDir
)
2835 if not os
.path
.exists(SubDirectory
):
2836 CreateDirectory(SubDirectory
)
2842 # Make sure to get build rule order value
2844 self
._GetModuleBuildOption
()
2846 while Index
< len(SourceList
):
2847 Source
= SourceList
[Index
]
2851 CreateDirectory(Source
.Dir
)
2853 if File
.IsBinary
and File
== Source
and self
._BinaryFileList
!= None and File
in self
._BinaryFileList
:
2854 # Skip all files that are not binary libraries
2855 if not self
.IsLibrary
:
2857 RuleObject
= self
.BuildRules
[TAB_DEFAULT_BINARY_FILE
]
2858 elif FileType
in self
.BuildRules
:
2859 RuleObject
= self
.BuildRules
[FileType
]
2860 elif Source
.Ext
in self
.BuildRules
:
2861 RuleObject
= self
.BuildRules
[Source
.Ext
]
2863 # stop at no more rules
2865 self
._FinalBuildTargetList
.add(LastTarget
)
2868 FileType
= RuleObject
.SourceFileType
2869 if FileType
not in self
._FileTypes
:
2870 self
._FileTypes
[FileType
] = set()
2871 self
._FileTypes
[FileType
].add(Source
)
2873 # stop at STATIC_LIBRARY for library
2874 if self
.IsLibrary
and FileType
== TAB_STATIC_LIBRARY
:
2876 self
._FinalBuildTargetList
.add(LastTarget
)
2879 Target
= RuleObject
.Apply(Source
, self
.BuildRuleOrder
)
2882 self
._FinalBuildTargetList
.add(LastTarget
)
2884 elif not Target
.Outputs
:
2885 # Only do build for target with outputs
2886 self
._FinalBuildTargetList
.add(Target
)
2888 if FileType
not in self
._BuildTargets
:
2889 self
._BuildTargets
[FileType
] = set()
2890 self
._BuildTargets
[FileType
].add(Target
)
2892 if not Source
.IsBinary
and Source
== File
:
2893 self
._IntroBuildTargetList
.add(Target
)
2895 # to avoid cyclic rule
2896 if FileType
in RuleChain
:
2899 RuleChain
.append(FileType
)
2900 SourceList
.extend(Target
.Outputs
)
2902 FileType
= TAB_UNKNOWN_FILE
2904 def _GetTargets(self
):
2905 if self
._BuildTargets
== None:
2906 self
._IntroBuildTargetList
= set()
2907 self
._FinalBuildTargetList
= set()
2908 self
._BuildTargets
= {}
2909 self
._FileTypes
= {}
2911 #TRICK: call _GetSourceFileList to apply build rule for source files
2912 if self
.SourceFileList
:
2915 #TRICK: call _GetBinaryFileList to apply build rule for binary files
2916 if self
.BinaryFileList
:
2919 return self
._BuildTargets
2921 def _GetIntroTargetList(self
):
2923 return self
._IntroBuildTargetList
2925 def _GetFinalTargetList(self
):
2927 return self
._FinalBuildTargetList
2929 def _GetFileTypes(self
):
2931 return self
._FileTypes
2933 ## Get the list of package object the module depends on
2935 # @retval list The package object list
2937 def _GetDependentPackageList(self
):
2938 return self
.Module
.Packages
2940 ## Return the list of auto-generated code file
2942 # @retval list The list of auto-generated file
2944 def _GetAutoGenFileList(self
):
2945 UniStringAutoGenC
= True
2946 UniStringBinBuffer
= StringIO()
2947 if self
.BuildType
== 'UEFI_HII':
2948 UniStringAutoGenC
= False
2949 if self
._AutoGenFileList
== None:
2950 self
._AutoGenFileList
= {}
2951 AutoGenC
= TemplateString()
2952 AutoGenH
= TemplateString()
2953 StringH
= TemplateString()
2954 GenC
.CreateCode(self
, AutoGenC
, AutoGenH
, StringH
, UniStringAutoGenC
, UniStringBinBuffer
)
2956 # AutoGen.c is generated if there are library classes in inf, or there are object files
2958 if str(AutoGenC
) != "" and (len(self
.Module
.LibraryClasses
) > 0
2959 or TAB_OBJECT_FILE
in self
.FileTypes
):
2960 AutoFile
= PathClass(gAutoGenCodeFileName
, self
.DebugDir
)
2961 self
._AutoGenFileList
[AutoFile
] = str(AutoGenC
)
2962 self
._ApplyBuildRule
(AutoFile
, TAB_UNKNOWN_FILE
)
2963 if str(AutoGenH
) != "":
2964 AutoFile
= PathClass(gAutoGenHeaderFileName
, self
.DebugDir
)
2965 self
._AutoGenFileList
[AutoFile
] = str(AutoGenH
)
2966 self
._ApplyBuildRule
(AutoFile
, TAB_UNKNOWN_FILE
)
2967 if str(StringH
) != "":
2968 AutoFile
= PathClass(gAutoGenStringFileName
% {"module_name":self
.Name
}, self
.DebugDir
)
2969 self
._AutoGenFileList
[AutoFile
] = str(StringH
)
2970 self
._ApplyBuildRule
(AutoFile
, TAB_UNKNOWN_FILE
)
2971 if UniStringBinBuffer
!= None and UniStringBinBuffer
.getvalue() != "":
2972 AutoFile
= PathClass(gAutoGenStringFormFileName
% {"module_name":self
.Name
}, self
.OutputDir
)
2973 self
._AutoGenFileList
[AutoFile
] = UniStringBinBuffer
.getvalue()
2974 AutoFile
.IsBinary
= True
2975 self
._ApplyBuildRule
(AutoFile
, TAB_UNKNOWN_FILE
)
2976 if UniStringBinBuffer
!= None:
2977 UniStringBinBuffer
.close()
2978 return self
._AutoGenFileList
2980 ## Return the list of library modules explicitly or implicityly used by this module
2981 def _GetLibraryList(self
):
2982 if self
._DependentLibraryList
== None:
2983 # only merge library classes and PCD for non-library module
2985 self
._DependentLibraryList
= []
2987 if self
.AutoGenVersion
< 0x00010005:
2988 self
._DependentLibraryList
= self
.PlatformInfo
.ResolveLibraryReference(self
.Module
)
2990 self
._DependentLibraryList
= self
.PlatformInfo
.ApplyLibraryInstance(self
.Module
)
2991 return self
._DependentLibraryList
2994 def UpdateComments(Recver
, Src
):
2996 if Key
not in Recver
:
2998 Recver
[Key
].extend(Src
[Key
])
2999 ## Get the list of PCDs from current module
3001 # @retval list The list of PCD
3003 def _GetModulePcdList(self
):
3004 if self
._ModulePcdList
== None:
3005 # apply PCD settings from platform
3006 self
._ModulePcdList
= self
.PlatformInfo
.ApplyPcdSetting(self
.Module
, self
.Module
.Pcds
)
3007 self
.UpdateComments(self
._PcdComments
, self
.Module
.PcdComments
)
3008 return self
._ModulePcdList
3010 ## Get the list of PCDs from dependent libraries
3012 # @retval list The list of PCD
3014 def _GetLibraryPcdList(self
):
3015 if self
._LibraryPcdList
== None:
3017 if not self
.IsLibrary
:
3018 # get PCDs from dependent libraries
3019 for Library
in self
.DependentLibraryList
:
3020 self
.UpdateComments(self
._PcdComments
, Library
.PcdComments
)
3021 for Key
in Library
.Pcds
:
3022 # skip duplicated PCDs
3023 if Key
in self
.Module
.Pcds
or Key
in Pcds
:
3025 Pcds
[Key
] = copy
.copy(Library
.Pcds
[Key
])
3026 # apply PCD settings from platform
3027 self
._LibraryPcdList
= self
.PlatformInfo
.ApplyPcdSetting(self
.Module
, Pcds
)
3029 self
._LibraryPcdList
= []
3030 return self
._LibraryPcdList
3032 ## Get the GUID value mapping
3034 # @retval dict The mapping between GUID cname and its value
3036 def _GetGuidList(self
):
3037 if self
._GuidList
== None:
3038 self
._GuidList
= sdict()
3039 self
._GuidList
.update(self
.Module
.Guids
)
3040 for Library
in self
.DependentLibraryList
:
3041 self
._GuidList
.update(Library
.Guids
)
3042 self
.UpdateComments(self
._GuidComments
, Library
.GuidComments
)
3043 self
.UpdateComments(self
._GuidComments
, self
.Module
.GuidComments
)
3044 return self
._GuidList
3046 def GetGuidsUsedByPcd(self
):
3047 if self
._GuidsUsedByPcd
== None:
3048 self
._GuidsUsedByPcd
= sdict()
3049 self
._GuidsUsedByPcd
.update(self
.Module
.GetGuidsUsedByPcd())
3050 for Library
in self
.DependentLibraryList
:
3051 self
._GuidsUsedByPcd
.update(Library
.GetGuidsUsedByPcd())
3052 return self
._GuidsUsedByPcd
3053 ## Get the protocol value mapping
3055 # @retval dict The mapping between protocol cname and its value
3057 def _GetProtocolList(self
):
3058 if self
._ProtocolList
== None:
3059 self
._ProtocolList
= sdict()
3060 self
._ProtocolList
.update(self
.Module
.Protocols
)
3061 for Library
in self
.DependentLibraryList
:
3062 self
._ProtocolList
.update(Library
.Protocols
)
3063 self
.UpdateComments(self
._ProtocolComments
, Library
.ProtocolComments
)
3064 self
.UpdateComments(self
._ProtocolComments
, self
.Module
.ProtocolComments
)
3065 return self
._ProtocolList
3067 ## Get the PPI value mapping
3069 # @retval dict The mapping between PPI cname and its value
3071 def _GetPpiList(self
):
3072 if self
._PpiList
== None:
3073 self
._PpiList
= sdict()
3074 self
._PpiList
.update(self
.Module
.Ppis
)
3075 for Library
in self
.DependentLibraryList
:
3076 self
._PpiList
.update(Library
.Ppis
)
3077 self
.UpdateComments(self
._PpiComments
, Library
.PpiComments
)
3078 self
.UpdateComments(self
._PpiComments
, self
.Module
.PpiComments
)
3079 return self
._PpiList
3081 ## Get the list of include search path
3083 # @retval list The list path
3085 def _GetIncludePathList(self
):
3086 if self
._IncludePathList
== None:
3087 self
._IncludePathList
= []
3088 if self
.AutoGenVersion
< 0x00010005:
3089 for Inc
in self
.Module
.Includes
:
3090 if Inc
not in self
._IncludePathList
:
3091 self
._IncludePathList
.append(Inc
)
3093 Inc
= path
.join(Inc
, self
.Arch
.capitalize())
3094 if os
.path
.exists(Inc
) and Inc
not in self
._IncludePathList
:
3095 self
._IncludePathList
.append(Inc
)
3096 # Edk module needs to put DEBUG_DIR at the end of search path and not to use SOURCE_DIR all the time
3097 self
._IncludePathList
.append(self
.DebugDir
)
3099 self
._IncludePathList
.append(self
.MetaFile
.Dir
)
3100 self
._IncludePathList
.append(self
.DebugDir
)
3102 for Package
in self
.Module
.Packages
:
3103 PackageDir
= mws
.join(self
.WorkspaceDir
, Package
.MetaFile
.Dir
)
3104 if PackageDir
not in self
._IncludePathList
:
3105 self
._IncludePathList
.append(PackageDir
)
3106 for Inc
in Package
.Includes
:
3107 if Inc
not in self
._IncludePathList
:
3108 self
._IncludePathList
.append(str(Inc
))
3109 return self
._IncludePathList
3111 ## Get HII EX PCDs which maybe used by VFR
3113 # efivarstore used by VFR may relate with HII EX PCDs
3114 # Get the variable name and GUID from efivarstore and HII EX PCD
3115 # List the HII EX PCDs in As Built INF if both name and GUID match.
3117 # @retval list HII EX PCDs
3119 def _GetPcdsMaybeUsedByVfr(self
):
3120 if not self
.SourceFileList
:
3124 for SrcFile
in self
.SourceFileList
:
3125 if SrcFile
.Ext
.lower() != '.vfr':
3127 Vfri
= os
.path
.join(self
.OutputDir
, SrcFile
.BaseName
+ '.i')
3128 if not os
.path
.exists(Vfri
):
3130 VfriFile
= open(Vfri
, 'r')
3131 Content
= VfriFile
.read()
3133 Pos
= Content
.find('efivarstore')
3136 # Make sure 'efivarstore' is the start of efivarstore statement
3137 # In case of the value of 'name' (name = efivarstore) is equal to 'efivarstore'
3140 while Index
>= 0 and Content
[Index
] in ' \t\r\n':
3142 if Index
>= 0 and Content
[Index
] != ';':
3143 Pos
= Content
.find('efivarstore', Pos
+ len('efivarstore'))
3146 # 'efivarstore' must be followed by name and guid
3148 Name
= gEfiVarStoreNamePattern
.search(Content
, Pos
)
3151 Guid
= gEfiVarStoreGuidPattern
.search(Content
, Pos
)
3154 NameArray
= ConvertStringToByteArray('L"' + Name
.group(1) + '"')
3155 NameGuids
.append((NameArray
, GuidStructureStringToGuidString(Guid
.group(1))))
3156 Pos
= Content
.find('efivarstore', Name
.end())
3160 for Pcd
in self
.PlatformInfo
.Platform
.Pcds
.values():
3161 if Pcd
.Type
!= TAB_PCDS_DYNAMIC_EX_HII
:
3163 for SkuName
in Pcd
.SkuInfoList
:
3164 SkuInfo
= Pcd
.SkuInfoList
[SkuName
]
3165 Name
= ConvertStringToByteArray(SkuInfo
.VariableName
)
3166 Value
= GuidValue(SkuInfo
.VariableGuid
, self
.PlatformInfo
.PackageList
)
3169 Guid
= GuidStructureStringToGuidString(Value
)
3170 if (Name
, Guid
) in NameGuids
and Pcd
not in HiiExPcds
:
3171 HiiExPcds
.append(Pcd
)
3176 def _GenOffsetBin(self
):
3178 for SourceFile
in self
.Module
.Sources
:
3179 if SourceFile
.Type
.upper() == ".VFR" :
3181 # search the .map file to find the offset of vfr binary in the PE32+/TE file.
3183 VfrUniBaseName
[SourceFile
.BaseName
] = (SourceFile
.BaseName
+ "Bin")
3184 if SourceFile
.Type
.upper() == ".UNI" :
3186 # search the .map file to find the offset of Uni strings binary in the PE32+/TE file.
3188 VfrUniBaseName
["UniOffsetName"] = (self
.Name
+ "Strings")
3190 if len(VfrUniBaseName
) == 0:
3192 MapFileName
= os
.path
.join(self
.OutputDir
, self
.Name
+ ".map")
3193 EfiFileName
= os
.path
.join(self
.OutputDir
, self
.Name
+ ".efi")
3194 VfrUniOffsetList
= GetVariableOffset(MapFileName
, EfiFileName
, VfrUniBaseName
.values())
3195 if not VfrUniOffsetList
:
3198 OutputName
= '%sOffset.bin' % self
.Name
3199 UniVfrOffsetFileName
= os
.path
.join( self
.OutputDir
, OutputName
)
3202 fInputfile
= open(UniVfrOffsetFileName
, "wb+", 0)
3204 EdkLogger
.error("build", FILE_OPEN_FAILURE
, "File open failed for %s" % UniVfrOffsetFileName
,None)
3206 # Use a instance of StringIO to cache data
3207 fStringIO
= StringIO('')
3209 for Item
in VfrUniOffsetList
:
3210 if (Item
[0].find("Strings") != -1):
3212 # UNI offset in image.
3214 # { 0x8913c5e0, 0x33f6, 0x4d86, { 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66 } }
3216 UniGuid
= [0xe0, 0xc5, 0x13, 0x89, 0xf6, 0x33, 0x86, 0x4d, 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66]
3217 UniGuid
= [chr(ItemGuid
) for ItemGuid
in UniGuid
]
3218 fStringIO
.write(''.join(UniGuid
))
3219 UniValue
= pack ('Q', int (Item
[1], 16))
3220 fStringIO
.write (UniValue
)
3223 # VFR binary offset in image.
3225 # { 0xd0bc7cb4, 0x6a47, 0x495f, { 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2 } };
3227 VfrGuid
= [0xb4, 0x7c, 0xbc, 0xd0, 0x47, 0x6a, 0x5f, 0x49, 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2]
3228 VfrGuid
= [chr(ItemGuid
) for ItemGuid
in VfrGuid
]
3229 fStringIO
.write(''.join(VfrGuid
))
3231 VfrValue
= pack ('Q', int (Item
[1], 16))
3232 fStringIO
.write (VfrValue
)
3234 # write data into file.
3237 fInputfile
.write (fStringIO
.getvalue())
3239 EdkLogger
.error("build", FILE_WRITE_FAILURE
, "Write data to file %s failed, please check whether the "
3240 "file been locked or using by other applications." %UniVfrOffsetFileName
,None)
3246 ## Create AsBuilt INF file the module
3248 def CreateAsBuiltInf(self
):
3249 if self
.IsAsBuiltInfCreated
:
3252 # Skip the following code for EDK I inf
3253 if self
.AutoGenVersion
< 0x00010005:
3256 # Skip the following code for libraries
3260 # Skip the following code for modules with no source files
3261 if self
.SourceFileList
== None or self
.SourceFileList
== []:
3264 # Skip the following code for modules without any binary files
3265 if self
.BinaryFileList
<> None and self
.BinaryFileList
<> []:
3268 ### TODO: How to handles mixed source and binary modules
3270 # Find all DynamicEx and PatchableInModule PCDs used by this module and dependent libraries
3271 # Also find all packages that the DynamicEx PCDs depend on
3276 PcdTokenSpaceList
= []
3277 for Pcd
in self
.ModulePcdList
+ self
.LibraryPcdList
:
3278 if Pcd
.Type
== TAB_PCDS_PATCHABLE_IN_MODULE
:
3279 PatchablePcds
[Pcd
.TokenCName
] = Pcd
3280 PcdCheckList
.append((Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
, 'PatchableInModule'))
3281 elif Pcd
.Type
in GenC
.gDynamicExPcd
:
3284 PcdCheckList
.append((Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
, 'DynamicEx'))
3285 PcdCheckList
.append((Pcd
.TokenCName
, Pcd
.TokenSpaceGuidCName
, 'Dynamic'))
3286 PcdTokenSpaceList
.append(Pcd
.TokenSpaceGuidCName
)
3288 GuidList
.update(self
.GuidList
)
3289 for TokenSpace
in self
.GetGuidsUsedByPcd():
3290 # If token space is not referred by patch PCD or Ex PCD, remove the GUID from GUID list
3291 # The GUIDs in GUIDs section should really be the GUIDs in source INF or referred by Ex an patch PCDs
3292 if TokenSpace
not in PcdTokenSpaceList
and TokenSpace
in GuidList
:
3293 GuidList
.pop(TokenSpace
)
3294 CheckList
= (GuidList
, self
.PpiList
, self
.ProtocolList
, PcdCheckList
)
3295 for Package
in self
.DerivedPackageList
:
3296 if Package
in Packages
:
3298 BeChecked
= (Package
.Guids
, Package
.Ppis
, Package
.Protocols
, Package
.Pcds
)
3300 for Index
in range(len(BeChecked
)):
3301 for Item
in CheckList
[Index
]:
3302 if Item
in BeChecked
[Index
]:
3303 Packages
+= [Package
]
3308 VfrPcds
= self
._GetPcdsMaybeUsedByVfr
()
3309 for Pkg
in self
.PlatformInfo
.PackageList
:
3312 for VfrPcd
in VfrPcds
:
3313 if ((VfrPcd
.TokenCName
, VfrPcd
.TokenSpaceGuidCName
, 'DynamicEx') in Pkg
.Pcds
or
3314 (VfrPcd
.TokenCName
, VfrPcd
.TokenSpaceGuidCName
, 'Dynamic') in Pkg
.Pcds
):
3318 ModuleType
= self
.ModuleType
3319 if ModuleType
== 'UEFI_DRIVER' and self
.DepexGenerated
:
3320 ModuleType
= 'DXE_DRIVER'
3323 if self
.PcdIsDriver
!= '':
3324 DriverType
= self
.PcdIsDriver
3327 MDefs
= self
.Module
.Defines
3330 'module_name' : self
.Name
,
3331 'module_guid' : Guid
,
3332 'module_module_type' : ModuleType
,
3333 'module_version_string' : [MDefs
['VERSION_STRING']] if 'VERSION_STRING' in MDefs
else [],
3334 'pcd_is_driver_string' : [],
3335 'module_uefi_specification_version' : [],
3336 'module_pi_specification_version' : [],
3337 'module_entry_point' : self
.Module
.ModuleEntryPointList
,
3338 'module_unload_image' : self
.Module
.ModuleUnloadImageList
,
3339 'module_constructor' : self
.Module
.ConstructorList
,
3340 'module_destructor' : self
.Module
.DestructorList
,
3341 'module_shadow' : [MDefs
['SHADOW']] if 'SHADOW' in MDefs
else [],
3342 'module_pci_vendor_id' : [MDefs
['PCI_VENDOR_ID']] if 'PCI_VENDOR_ID' in MDefs
else [],
3343 'module_pci_device_id' : [MDefs
['PCI_DEVICE_ID']] if 'PCI_DEVICE_ID' in MDefs
else [],
3344 'module_pci_class_code' : [MDefs
['PCI_CLASS_CODE']] if 'PCI_CLASS_CODE' in MDefs
else [],
3345 'module_pci_revision' : [MDefs
['PCI_REVISION']] if 'PCI_REVISION' in MDefs
else [],
3346 'module_build_number' : [MDefs
['BUILD_NUMBER']] if 'BUILD_NUMBER' in MDefs
else [],
3347 'module_spec' : [MDefs
['SPEC']] if 'SPEC' in MDefs
else [],
3348 'module_uefi_hii_resource_section' : [MDefs
['UEFI_HII_RESOURCE_SECTION']] if 'UEFI_HII_RESOURCE_SECTION' in MDefs
else [],
3349 'module_uni_file' : [MDefs
['MODULE_UNI_FILE']] if 'MODULE_UNI_FILE' in MDefs
else [],
3350 'module_arch' : self
.Arch
,
3351 'package_item' : ['%s' % (Package
.MetaFile
.File
.replace('\\', '/')) for Package
in Packages
],
3353 'patchablepcd_item' : [],
3355 'protocol_item' : [],
3359 'libraryclasses_item' : []
3362 if self
.AutoGenVersion
> int(gInfSpecVersion
, 0):
3363 AsBuiltInfDict
['module_inf_version'] = '0x%08x' % self
.AutoGenVersion
3365 AsBuiltInfDict
['module_inf_version'] = gInfSpecVersion
3368 AsBuiltInfDict
['pcd_is_driver_string'] += [DriverType
]
3370 if 'UEFI_SPECIFICATION_VERSION' in self
.Specification
:
3371 AsBuiltInfDict
['module_uefi_specification_version'] += [self
.Specification
['UEFI_SPECIFICATION_VERSION']]
3372 if 'PI_SPECIFICATION_VERSION' in self
.Specification
:
3373 AsBuiltInfDict
['module_pi_specification_version'] += [self
.Specification
['PI_SPECIFICATION_VERSION']]
3375 OutputDir
= self
.OutputDir
.replace('\\', '/').strip('/')
3376 if self
.ModuleType
in ['BASE', 'USER_DEFINED']:
3377 for Item
in self
.CodaTargetList
:
3378 File
= Item
.Target
.Path
.replace('\\', '/').strip('/').replace(OutputDir
, '').strip('/')
3379 if Item
.Target
.Ext
.lower() == '.aml':
3380 AsBuiltInfDict
['binary_item'] += ['ASL|' + File
]
3381 elif Item
.Target
.Ext
.lower() == '.acpi':
3382 AsBuiltInfDict
['binary_item'] += ['ACPI|' + File
]
3384 AsBuiltInfDict
['binary_item'] += ['BIN|' + File
]
3386 for Item
in self
.CodaTargetList
:
3387 File
= Item
.Target
.Path
.replace('\\', '/').strip('/').replace(OutputDir
, '').strip('/')
3388 if Item
.Target
.Ext
.lower() == '.efi':
3389 AsBuiltInfDict
['binary_item'] += ['PE32|' + self
.Name
+ '.efi']
3391 AsBuiltInfDict
['binary_item'] += ['BIN|' + File
]
3392 if self
.DepexGenerated
:
3393 if self
.ModuleType
in ['PEIM']:
3394 AsBuiltInfDict
['binary_item'] += ['PEI_DEPEX|' + self
.Name
+ '.depex']
3395 if self
.ModuleType
in ['DXE_DRIVER', 'DXE_RUNTIME_DRIVER', 'DXE_SAL_DRIVER', 'UEFI_DRIVER']:
3396 AsBuiltInfDict
['binary_item'] += ['DXE_DEPEX|' + self
.Name
+ '.depex']
3397 if self
.ModuleType
in ['DXE_SMM_DRIVER']:
3398 AsBuiltInfDict
['binary_item'] += ['SMM_DEPEX|' + self
.Name
+ '.depex']
3400 Bin
= self
._GenOffsetBin
()
3402 AsBuiltInfDict
['binary_item'] += ['BIN|%s' % Bin
]
3404 for Root
, Dirs
, Files
in os
.walk(OutputDir
):
3406 if File
.lower().endswith('.pdb'):
3407 AsBuiltInfDict
['binary_item'] += ['DISPOSABLE|' + File
]
3408 HeaderComments
= self
.Module
.HeaderComments
3410 for Index
in range(len(HeaderComments
)):
3411 if HeaderComments
[Index
].find('@BinaryHeader') != -1:
3412 HeaderComments
[Index
] = HeaderComments
[Index
].replace('@BinaryHeader', '@file')
3415 AsBuiltInfDict
['header_comments'] = '\n'.join(HeaderComments
[StartPos
:]).replace(':#', '://')
3416 AsBuiltInfDict
['tail_comments'] = '\n'.join(self
.Module
.TailComments
)
3419 (self
.ProtocolList
, self
._ProtocolComments
, 'protocol_item'),
3420 (self
.PpiList
, self
._PpiComments
, 'ppi_item'),
3421 (GuidList
, self
._GuidComments
, 'guid_item')
3423 for Item
in GenList
:
3424 for CName
in Item
[0]:
3426 if CName
in Item
[1]:
3427 Comments
= '\n '.join(Item
[1][CName
])
3430 Entry
= Comments
+ '\n ' + CName
3431 AsBuiltInfDict
[Item
[2]].append(Entry
)
3432 PatchList
= parsePcdInfoFromMapFile(
3433 os
.path
.join(self
.OutputDir
, self
.Name
+ '.map'),
3434 os
.path
.join(self
.OutputDir
, self
.Name
+ '.efi')
3437 for PatchPcd
in PatchList
:
3438 if PatchPcd
[0] not in PatchablePcds
:
3440 Pcd
= PatchablePcds
[PatchPcd
[0]]
3442 if Pcd
.DatumType
!= 'VOID*':
3443 HexFormat
= '0x%02x'
3444 if Pcd
.DatumType
== 'UINT16':
3445 HexFormat
= '0x%04x'
3446 elif Pcd
.DatumType
== 'UINT32':
3447 HexFormat
= '0x%08x'
3448 elif Pcd
.DatumType
== 'UINT64':
3449 HexFormat
= '0x%016x'
3450 PcdValue
= HexFormat
% int(Pcd
.DefaultValue
, 0)
3452 if Pcd
.MaxDatumSize
== None or Pcd
.MaxDatumSize
== '':
3453 EdkLogger
.error("build", AUTOGEN_ERROR
,
3454 "Unknown [MaxDatumSize] of PCD [%s.%s]" % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
3456 ArraySize
= int(Pcd
.MaxDatumSize
, 0)
3457 PcdValue
= Pcd
.DefaultValue
3458 if PcdValue
[0] != '{':
3460 if PcdValue
[0] == 'L':
3462 PcdValue
= PcdValue
.lstrip('L')
3463 PcdValue
= eval(PcdValue
)
3465 for Index
in range(0, len(PcdValue
)):
3467 CharVal
= ord(PcdValue
[Index
])
3468 NewValue
= NewValue
+ '0x%02x' % (CharVal
& 0x00FF) + ', ' \
3469 + '0x%02x' % (CharVal
>> 8) + ', '
3471 NewValue
= NewValue
+ '0x%02x' % (ord(PcdValue
[Index
]) % 0x100) + ', '
3474 Padding
= Padding
* 2
3475 ArraySize
= ArraySize
/ 2
3476 if ArraySize
< (len(PcdValue
) + 1):
3477 EdkLogger
.error("build", AUTOGEN_ERROR
,
3478 "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
3480 if ArraySize
> len(PcdValue
) + 1:
3481 NewValue
= NewValue
+ Padding
* (ArraySize
- len(PcdValue
) - 1)
3482 PcdValue
= NewValue
+ Padding
.strip().rstrip(',') + '}'
3483 elif len(PcdValue
.split(',')) <= ArraySize
:
3484 PcdValue
= PcdValue
.rstrip('}') + ', 0x00' * (ArraySize
- len(PcdValue
.split(',')))
3487 EdkLogger
.error("build", AUTOGEN_ERROR
,
3488 "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
)
3490 PcdItem
= '%s.%s|%s|0x%X' % \
3491 (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
, PcdValue
, PatchPcd
[1])
3493 if (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
) in self
._PcdComments
:
3494 PcdComments
= '\n '.join(self
._PcdComments
[Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
])
3496 PcdItem
= PcdComments
+ '\n ' + PcdItem
3497 AsBuiltInfDict
['patchablepcd_item'].append(PcdItem
)
3500 for Pcd
in Pcds
+ VfrPcds
:
3505 if Pcd
.Type
== TAB_PCDS_DYNAMIC_EX_HII
:
3506 for SkuName
in Pcd
.SkuInfoList
:
3507 SkuInfo
= Pcd
.SkuInfoList
[SkuName
]
3508 SkuId
= SkuInfo
.SkuId
3509 HiiInfo
= '## %s|%s|%s' % (SkuInfo
.VariableName
, SkuInfo
.VariableGuid
, SkuInfo
.VariableOffset
)
3513 # Don't generate duplicated HII PCD
3515 if (SkuId
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
) in HiiPcds
:
3518 HiiPcds
.append((SkuId
, Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
))
3519 if (Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
) in self
._PcdComments
:
3520 PcdCommentList
= self
._PcdComments
[Pcd
.TokenSpaceGuidCName
, Pcd
.TokenCName
][:]
3524 for Index
, Comment
in enumerate(PcdCommentList
):
3525 for Usage
in UsageList
:
3526 if Comment
.find(Usage
) != -1:
3530 if UsageIndex
!= -1:
3531 PcdCommentList
[UsageIndex
] = '## %s %s %s' % (UsageStr
, HiiInfo
, PcdCommentList
[UsageIndex
].replace(UsageStr
, ''))
3533 PcdCommentList
.append('## UNDEFINED ' + HiiInfo
)
3534 PcdComments
= '\n '.join(PcdCommentList
)
3535 PcdEntry
= Pcd
.TokenSpaceGuidCName
+ '.' + Pcd
.TokenCName
3537 PcdEntry
= PcdComments
+ '\n ' + PcdEntry
3538 AsBuiltInfDict
['pcd_item'] += [PcdEntry
]
3539 for Item
in self
.BuildOption
:
3540 if 'FLAGS' in self
.BuildOption
[Item
]:
3541 AsBuiltInfDict
['flags_item'] += ['%s:%s_%s_%s_%s_FLAGS = %s' % (self
.ToolChainFamily
, self
.BuildTarget
, self
.ToolChain
, self
.Arch
, Item
, self
.BuildOption
[Item
]['FLAGS'].strip())]
3543 # Generated LibraryClasses section in comments.
3544 for Library
in self
.LibraryAutoGenList
:
3545 AsBuiltInfDict
['libraryclasses_item'] += [Library
.MetaFile
.File
.replace('\\', '/')]
3547 # Generated depex expression section in comments.
3548 AsBuiltInfDict
['depexsection_item'] = ''
3549 DepexExpresion
= self
._GetDepexExpresionString
()
3551 AsBuiltInfDict
['depexsection_item'] = DepexExpresion
3553 AsBuiltInf
= TemplateString()
3554 AsBuiltInf
.Append(gAsBuiltInfHeaderString
.Replace(AsBuiltInfDict
))
3556 SaveFileOnChange(os
.path
.join(self
.OutputDir
, self
.Name
+ '.inf'), str(AsBuiltInf
), False)
3558 self
.IsAsBuiltInfCreated
= True
3560 ## Create makefile for the module and its dependent libraries
3562 # @param CreateLibraryMakeFile Flag indicating if or not the makefiles of
3563 # dependent libraries will be created
3565 def CreateMakeFile(self
, CreateLibraryMakeFile
=True):
3566 # Ignore generating makefile when it is a binary module
3567 if self
.IsBinaryModule
:
3570 if self
.IsMakeFileCreated
:
3573 if not self
.IsLibrary
and CreateLibraryMakeFile
:
3574 for LibraryAutoGen
in self
.LibraryAutoGenList
:
3575 LibraryAutoGen
.CreateMakeFile()
3577 if len(self
.CustomMakefile
) == 0:
3578 Makefile
= GenMake
.ModuleMakefile(self
)
3580 Makefile
= GenMake
.CustomMakefile(self
)
3581 if Makefile
.Generate():
3582 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "Generated makefile for module %s [%s]" %
3583 (self
.Name
, self
.Arch
))
3585 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "Skipped the generation of makefile for module %s [%s]" %
3586 (self
.Name
, self
.Arch
))
3588 self
.IsMakeFileCreated
= True
3590 def CopyBinaryFiles(self
):
3591 for File
in self
.Module
.Binaries
:
3593 DstPath
= os
.path
.join(self
.OutputDir
, os
.path
.basename(SrcPath
))
3594 CopyLongFilePath(SrcPath
, DstPath
)
3595 ## Create autogen code for the module and its dependent libraries
3597 # @param CreateLibraryCodeFile Flag indicating if or not the code of
3598 # dependent libraries will be created
3600 def CreateCodeFile(self
, CreateLibraryCodeFile
=True):
3601 if self
.IsCodeFileCreated
:
3604 # Need to generate PcdDatabase even PcdDriver is binarymodule
3605 if self
.IsBinaryModule
and self
.PcdIsDriver
!= '':
3606 CreatePcdDatabaseCode(self
, TemplateString(), TemplateString())
3608 if self
.IsBinaryModule
:
3610 self
.CopyBinaryFiles()
3613 if not self
.IsLibrary
and CreateLibraryCodeFile
:
3614 for LibraryAutoGen
in self
.LibraryAutoGenList
:
3615 LibraryAutoGen
.CreateCodeFile()
3618 IgoredAutoGenList
= []
3620 for File
in self
.AutoGenFileList
:
3621 if GenC
.Generate(File
.Path
, self
.AutoGenFileList
[File
], File
.IsBinary
):
3622 #Ignore Edk AutoGen.c
3623 if self
.AutoGenVersion
< 0x00010005 and File
.Name
== 'AutoGen.c':
3626 AutoGenList
.append(str(File
))
3628 IgoredAutoGenList
.append(str(File
))
3630 # Skip the following code for EDK I inf
3631 if self
.AutoGenVersion
< 0x00010005:
3634 for ModuleType
in self
.DepexList
:
3635 # Ignore empty [depex] section or [depex] section for "USER_DEFINED" module
3636 if len(self
.DepexList
[ModuleType
]) == 0 or ModuleType
== "USER_DEFINED":
3639 Dpx
= GenDepex
.DependencyExpression(self
.DepexList
[ModuleType
], ModuleType
, True)
3640 DpxFile
= gAutoGenDepexFileName
% {"module_name" : self
.Name
}
3642 if len(Dpx
.PostfixNotation
) <> 0:
3643 self
.DepexGenerated
= True
3645 if Dpx
.Generate(path
.join(self
.OutputDir
, DpxFile
)):
3646 AutoGenList
.append(str(DpxFile
))
3648 IgoredAutoGenList
.append(str(DpxFile
))
3650 if IgoredAutoGenList
== []:
3651 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "Generated [%s] files for module %s [%s]" %
3652 (" ".join(AutoGenList
), self
.Name
, self
.Arch
))
3653 elif AutoGenList
== []:
3654 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "Skipped the generation of [%s] files for module %s [%s]" %
3655 (" ".join(IgoredAutoGenList
), self
.Name
, self
.Arch
))
3657 EdkLogger
.debug(EdkLogger
.DEBUG_9
, "Generated [%s] (skipped %s) files for module %s [%s]" %
3658 (" ".join(AutoGenList
), " ".join(IgoredAutoGenList
), self
.Name
, self
.Arch
))
3660 self
.IsCodeFileCreated
= True
3663 ## Summarize the ModuleAutoGen objects of all libraries used by this module
3664 def _GetLibraryAutoGenList(self
):
3665 if self
._LibraryAutoGenList
== None:
3666 self
._LibraryAutoGenList
= []
3667 for Library
in self
.DependentLibraryList
:
3674 self
.PlatformInfo
.MetaFile
3676 if La
not in self
._LibraryAutoGenList
:
3677 self
._LibraryAutoGenList
.append(La
)
3678 for Lib
in La
.CodaTargetList
:
3679 self
._ApplyBuildRule
(Lib
.Target
, TAB_UNKNOWN_FILE
)
3680 return self
._LibraryAutoGenList
3682 Module
= property(_GetModule
)
3683 Name
= property(_GetBaseName
)
3684 Guid
= property(_GetGuid
)
3685 Version
= property(_GetVersion
)
3686 ModuleType
= property(_GetModuleType
)
3687 ComponentType
= property(_GetComponentType
)
3688 BuildType
= property(_GetBuildType
)
3689 PcdIsDriver
= property(_GetPcdIsDriver
)
3690 AutoGenVersion
= property(_GetAutoGenVersion
)
3691 Macros
= property(_GetMacros
)
3692 Specification
= property(_GetSpecification
)
3694 IsLibrary
= property(_IsLibrary
)
3695 IsBinaryModule
= property(_IsBinaryModule
)
3696 BuildDir
= property(_GetBuildDir
)
3697 OutputDir
= property(_GetOutputDir
)
3698 DebugDir
= property(_GetDebugDir
)
3699 MakeFileDir
= property(_GetMakeFileDir
)
3700 CustomMakefile
= property(_GetCustomMakefile
)
3702 IncludePathList
= property(_GetIncludePathList
)
3703 AutoGenFileList
= property(_GetAutoGenFileList
)
3704 UnicodeFileList
= property(_GetUnicodeFileList
)
3705 SourceFileList
= property(_GetSourceFileList
)
3706 BinaryFileList
= property(_GetBinaryFiles
) # FileType : [File List]
3707 Targets
= property(_GetTargets
)
3708 IntroTargetList
= property(_GetIntroTargetList
)
3709 CodaTargetList
= property(_GetFinalTargetList
)
3710 FileTypes
= property(_GetFileTypes
)
3711 BuildRules
= property(_GetBuildRules
)
3713 DependentPackageList
= property(_GetDependentPackageList
)
3714 DependentLibraryList
= property(_GetLibraryList
)
3715 LibraryAutoGenList
= property(_GetLibraryAutoGenList
)
3716 DerivedPackageList
= property(_GetDerivedPackageList
)
3718 ModulePcdList
= property(_GetModulePcdList
)
3719 LibraryPcdList
= property(_GetLibraryPcdList
)
3720 GuidList
= property(_GetGuidList
)
3721 ProtocolList
= property(_GetProtocolList
)
3722 PpiList
= property(_GetPpiList
)
3723 DepexList
= property(_GetDepexTokenList
)
3724 DxsFile
= property(_GetDxsFile
)
3725 DepexExpressionList
= property(_GetDepexExpressionTokenList
)
3726 BuildOption
= property(_GetModuleBuildOption
)
3727 BuildOptionIncPathList
= property(_GetBuildOptionIncPathList
)
3728 BuildCommand
= property(_GetBuildCommand
)
3730 FixedAtBuildPcds
= property(_GetFixedAtBuildPcds
)
3732 # This acts like the main() function for the script, unless it is 'import'ed into another script.
3733 if __name__
== '__main__':