Commit | Line | Data |
---|---|---|
52302d4d LG |
1 | ## @file\r |
2 | # Generate AutoGen.h, AutoGen.c and *.depex files\r | |
3 | #\r | |
e74cea4c | 4 | # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r |
3f34e36d LD |
5 | # Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.<BR>\r |
6 | #\r | |
40d841f6 | 7 | # This program and the accompanying materials\r |
52302d4d LG |
8 | # are licensed and made available under the terms and conditions of the BSD License\r |
9 | # which accompanies this distribution. The full text of the license may be found at\r | |
10 | # http://opensource.org/licenses/bsd-license.php\r | |
11 | #\r | |
12 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | #\r | |
15 | \r | |
16 | ## Import Modules\r | |
17 | #\r | |
1be2ed90 | 18 | import Common.LongFilePathOs as os\r |
52302d4d LG |
19 | import re\r |
20 | import os.path as path\r | |
21 | import copy\r | |
867d1cd4 | 22 | import uuid\r |
52302d4d LG |
23 | \r |
24 | import GenC\r | |
25 | import GenMake\r | |
26 | import GenDepex\r | |
27 | from StringIO import StringIO\r | |
28 | \r | |
29 | from StrGather import *\r | |
30 | from BuildEngine import BuildRule\r | |
31 | \r | |
1be2ed90 | 32 | from Common.LongFilePathSupport import CopyLongFilePath\r |
52302d4d LG |
33 | from Common.BuildToolError import *\r |
34 | from Common.DataType import *\r | |
35 | from Common.Misc import *\r | |
5a57246e | 36 | from Common.StringUtils import *\r |
52302d4d LG |
37 | import Common.GlobalData as GlobalData\r |
38 | from GenFds.FdfParser import *\r | |
39 | from CommonDataClass.CommonClass import SkuInfoClass\r | |
40 | from Workspace.BuildClassObject import *\r | |
e8a47801 | 41 | from GenPatchPcdTable.GenPatchPcdTable import parsePcdInfoFromMapFile\r |
e56468c0 | 42 | import Common.VpdInfoFile as VpdInfoFile\r |
e8a47801 LG |
43 | from GenPcdDb import CreatePcdDatabaseCode\r |
44 | from Workspace.MetaFileCommentParser import UsageList\r | |
c14b5861 | 45 | from Workspace.WorkspaceCommon import GetModuleLibInstances\r |
05cc51ad | 46 | from Common.MultipleWorkspace import MultipleWorkspace as mws\r |
97fa0ee9 | 47 | import InfSectionParser\r |
c17956e0 | 48 | import datetime\r |
36d083ef | 49 | import hashlib\r |
8518bf0b | 50 | from GenVar import VariableMgr,var_info\r |
9006a2c6 | 51 | from collections import OrderedDict\r |
a993dc03 | 52 | from collections import defaultdict\r |
caf74495 | 53 | from Workspace.WorkspaceCommon import OrderedListDict\r |
97fa0ee9 | 54 | \r |
e8a47801 | 55 | ## Regular expression for splitting Dependency Expression string into tokens\r |
52302d4d LG |
56 | gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")\r |
57 | \r | |
c8802c3d CJ |
58 | ## Regular expression for match: PCD(xxxx.yyy)\r |
59 | gPCDAsGuidPattern = re.compile(r"^PCD\(.+\..+\)$")\r | |
60 | \r | |
61 | #\r | |
62 | # Regular expression for finding Include Directories, the difference between MSFT and INTEL/GCC/RVCT\r | |
63 | # is the former use /I , the Latter used -I to specify include directories\r | |
64 | #\r | |
65 | gBuildOptIncludePatternMsft = re.compile(r"(?:.*?)/I[ \t]*([^ ]*)", re.MULTILINE | re.DOTALL)\r | |
66 | gBuildOptIncludePatternOther = re.compile(r"(?:.*?)-I[ \t]*([^ ]*)", re.MULTILINE | re.DOTALL)\r | |
67 | \r | |
97fa0ee9 YL |
68 | #\r |
69 | # Match name = variable\r | |
70 | #\r | |
71 | gEfiVarStoreNamePattern = re.compile("\s*name\s*=\s*(\w+)")\r | |
72 | #\r | |
73 | # The format of guid in efivarstore statement likes following and must be correct:\r | |
74 | # guid = {0xA04A27f4, 0xDF00, 0x4D42, {0xB5, 0x52, 0x39, 0x51, 0x13, 0x02, 0x11, 0x3D}}\r | |
75 | #\r | |
76 | gEfiVarStoreGuidPattern = re.compile("\s*guid\s*=\s*({.*?{.*?}\s*})")\r | |
77 | \r | |
52302d4d LG |
78 | ## Mapping Makefile type\r |
79 | gMakeTypeMap = {"MSFT":"nmake", "GCC":"gmake"}\r | |
80 | \r | |
81 | \r | |
82 | ## Build rule configuration file\r | |
51de5c30 | 83 | gDefaultBuildRuleFile = 'build_rule.txt'\r |
52302d4d | 84 | \r |
86601b78 | 85 | ## Tools definition configuration file\r |
51de5c30 | 86 | gDefaultToolsDefFile = 'tools_def.txt'\r |
86601b78 | 87 | \r |
64b2609f LG |
88 | ## Build rule default version\r |
89 | AutoGenReqBuildRuleVerNum = "0.1"\r | |
90 | \r | |
52302d4d LG |
91 | ## default file name for AutoGen\r |
92 | gAutoGenCodeFileName = "AutoGen.c"\r | |
93 | gAutoGenHeaderFileName = "AutoGen.h"\r | |
94 | gAutoGenStringFileName = "%(module_name)sStrDefs.h"\r | |
95 | gAutoGenStringFormFileName = "%(module_name)sStrDefs.hpk"\r | |
96 | gAutoGenDepexFileName = "%(module_name)s.depex"\r | |
333ba578 YZ |
97 | gAutoGenImageDefFileName = "%(module_name)sImgDefs.h"\r |
98 | gAutoGenIdfFileName = "%(module_name)sIdf.hpk"\r | |
97fa0ee9 YL |
99 | gInfSpecVersion = "0x00010017"\r |
100 | \r | |
da92f276 LG |
101 | #\r |
102 | # Template string to generic AsBuilt INF\r | |
103 | #\r | |
e8a47801 | 104 | gAsBuiltInfHeaderString = TemplateString("""${header_comments}\r |
da92f276 | 105 | \r |
97fa0ee9 YL |
106 | # DO NOT EDIT\r |
107 | # FILE auto-generated\r | |
108 | \r | |
da92f276 | 109 | [Defines]\r |
97fa0ee9 | 110 | INF_VERSION = ${module_inf_version}\r |
da92f276 LG |
111 | BASE_NAME = ${module_name}\r |
112 | FILE_GUID = ${module_guid}\r | |
97fa0ee9 YL |
113 | MODULE_TYPE = ${module_module_type}${BEGIN}\r |
114 | VERSION_STRING = ${module_version_string}${END}${BEGIN}\r | |
e8a47801 | 115 | PCD_IS_DRIVER = ${pcd_is_driver_string}${END}${BEGIN}\r |
da92f276 | 116 | UEFI_SPECIFICATION_VERSION = ${module_uefi_specification_version}${END}${BEGIN}\r |
97fa0ee9 YL |
117 | PI_SPECIFICATION_VERSION = ${module_pi_specification_version}${END}${BEGIN}\r |
118 | ENTRY_POINT = ${module_entry_point}${END}${BEGIN}\r | |
119 | UNLOAD_IMAGE = ${module_unload_image}${END}${BEGIN}\r | |
120 | CONSTRUCTOR = ${module_constructor}${END}${BEGIN}\r | |
121 | DESTRUCTOR = ${module_destructor}${END}${BEGIN}\r | |
122 | SHADOW = ${module_shadow}${END}${BEGIN}\r | |
123 | PCI_VENDOR_ID = ${module_pci_vendor_id}${END}${BEGIN}\r | |
124 | PCI_DEVICE_ID = ${module_pci_device_id}${END}${BEGIN}\r | |
125 | PCI_CLASS_CODE = ${module_pci_class_code}${END}${BEGIN}\r | |
126 | PCI_REVISION = ${module_pci_revision}${END}${BEGIN}\r | |
127 | BUILD_NUMBER = ${module_build_number}${END}${BEGIN}\r | |
128 | SPEC = ${module_spec}${END}${BEGIN}\r | |
129 | UEFI_HII_RESOURCE_SECTION = ${module_uefi_hii_resource_section}${END}${BEGIN}\r | |
130 | MODULE_UNI_FILE = ${module_uni_file}${END}\r | |
131 | \r | |
132 | [Packages.${module_arch}]${BEGIN}\r | |
da92f276 LG |
133 | ${package_item}${END}\r |
134 | \r | |
135 | [Binaries.${module_arch}]${BEGIN}\r | |
136 | ${binary_item}${END}\r | |
137 | \r | |
e8a47801 LG |
138 | [PatchPcd.${module_arch}]${BEGIN}\r |
139 | ${patchablepcd_item}\r | |
140 | ${END}\r | |
97fa0ee9 | 141 | \r |
e8a47801 LG |
142 | [Protocols.${module_arch}]${BEGIN}\r |
143 | ${protocol_item}\r | |
144 | ${END}\r | |
97fa0ee9 | 145 | \r |
e8a47801 LG |
146 | [Ppis.${module_arch}]${BEGIN}\r |
147 | ${ppi_item}\r | |
148 | ${END}\r | |
97fa0ee9 | 149 | \r |
e8a47801 LG |
150 | [Guids.${module_arch}]${BEGIN}\r |
151 | ${guid_item}\r | |
152 | ${END}\r | |
97fa0ee9 | 153 | \r |
e8a47801 LG |
154 | [PcdEx.${module_arch}]${BEGIN}\r |
155 | ${pcd_item}\r | |
156 | ${END}\r | |
da92f276 | 157 | \r |
97fa0ee9 YL |
158 | [LibraryClasses.${module_arch}]\r |
159 | ## @LIB_INSTANCES${BEGIN}\r | |
160 | # ${libraryclasses_item}${END}\r | |
161 | \r | |
162 | ${depexsection_item}\r | |
163 | \r | |
dfa41b4a YZ |
164 | ${userextension_tianocore_item}\r |
165 | \r | |
97fa0ee9 YL |
166 | ${tail_comments}\r |
167 | \r | |
168 | [BuildOptions.${module_arch}]\r | |
da92f276 LG |
169 | ## @AsBuilt${BEGIN}\r |
170 | ## ${flags_item}${END}\r | |
171 | """)\r | |
172 | \r | |
52302d4d LG |
173 | ## Base class for AutoGen\r |
174 | #\r | |
175 | # This class just implements the cache mechanism of AutoGen objects.\r | |
176 | #\r | |
177 | class AutoGen(object):\r | |
b24e99f7 CJ |
178 | # database to maintain the objects in each child class\r |
179 | __ObjectCache = {} # (BuildTarget, ToolChain, ARCH, platform file): AutoGen object\r | |
52302d4d LG |
180 | \r |
181 | ## Factory method\r | |
182 | #\r | |
183 | # @param Class class object of real AutoGen class\r | |
184 | # (WorkspaceAutoGen, ModuleAutoGen or PlatformAutoGen)\r | |
185 | # @param Workspace Workspace directory or WorkspaceAutoGen object\r | |
186 | # @param MetaFile The path of meta file\r | |
187 | # @param Target Build target\r | |
188 | # @param Toolchain Tool chain name\r | |
189 | # @param Arch Target arch\r | |
190 | # @param *args The specific class related parameters\r | |
191 | # @param **kwargs The specific class related dict parameters\r | |
192 | #\r | |
b24e99f7 | 193 | def __new__(cls, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r |
52302d4d | 194 | # check if the object has been created\r |
b24e99f7 CJ |
195 | Key = (Target, Toolchain, Arch, MetaFile)\r |
196 | try:\r | |
197 | # if it exists, just return it directly\r | |
198 | return cls.__ObjectCache[Key]\r | |
199 | except:\r | |
200 | # it didnt exist. create it, cache it, then return it\r | |
201 | cls.__ObjectCache[Key] = super(AutoGen, cls).__new__(cls)\r | |
202 | return cls.__ObjectCache[Key]\r | |
203 | \r | |
204 | def __init__ (self, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r | |
205 | super(AutoGen, self).__init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs)\r | |
52302d4d LG |
206 | \r |
207 | ## hash() operator\r | |
208 | #\r | |
209 | # The file path of platform file will be used to represent hash value of this object\r | |
210 | #\r | |
211 | # @retval int Hash value of the file path of platform file\r | |
212 | #\r | |
213 | def __hash__(self):\r | |
214 | return hash(self.MetaFile)\r | |
215 | \r | |
216 | ## str() operator\r | |
217 | #\r | |
218 | # The file path of platform file will be used to represent this object\r | |
219 | #\r | |
220 | # @retval string String of platform file path\r | |
221 | #\r | |
222 | def __str__(self):\r | |
223 | return str(self.MetaFile)\r | |
224 | \r | |
225 | ## "==" operator\r | |
226 | def __eq__(self, Other):\r | |
227 | return Other and self.MetaFile == Other\r | |
228 | \r | |
229 | ## Workspace AutoGen class\r | |
230 | #\r | |
231 | # This class is used mainly to control the whole platform build for different\r | |
232 | # architecture. This class will generate top level makefile.\r | |
233 | #\r | |
234 | class WorkspaceAutoGen(AutoGen):\r | |
b24e99f7 CJ |
235 | # call super().__init__ then call the worker function with different parameter count\r |
236 | def __init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r | |
237 | try:\r | |
238 | self._Init\r | |
239 | except:\r | |
240 | super(WorkspaceAutoGen, self).__init__(Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs)\r | |
241 | self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs)\r | |
242 | self._Init = True\r | |
243 | \r | |
244 | ## Initialize WorkspaceAutoGen\r | |
52302d4d LG |
245 | #\r |
246 | # @param WorkspaceDir Root directory of workspace\r | |
247 | # @param ActivePlatform Meta-file of active platform\r | |
248 | # @param Target Build target\r | |
249 | # @param Toolchain Tool chain name\r | |
250 | # @param ArchList List of architecture of current build\r | |
251 | # @param MetaFileDb Database containing meta-files\r | |
252 | # @param BuildConfig Configuration of build\r | |
253 | # @param ToolDefinition Tool chain definitions\r | |
254 | # @param FlashDefinitionFile File of flash definition\r | |
255 | # @param Fds FD list to be generated\r | |
256 | # @param Fvs FV list to be generated\r | |
4234283c | 257 | # @param Caps Capsule list to be generated\r |
52302d4d LG |
258 | # @param SkuId SKU id from command line\r |
259 | #\r | |
b24e99f7 | 260 | def _InitWorker(self, WorkspaceDir, ActivePlatform, Target, Toolchain, ArchList, MetaFileDb,\r |
47fea6af | 261 | BuildConfig, ToolDefinition, FlashDefinitionFile='', Fds=None, Fvs=None, Caps=None, SkuId='', UniFlag=None,\r |
9508d0fa | 262 | Progress=None, BuildModule=None):\r |
0d2711a6 LG |
263 | self.BuildDatabase = MetaFileDb\r |
264 | self.MetaFile = ActivePlatform\r | |
52302d4d | 265 | self.WorkspaceDir = WorkspaceDir\r |
6b1f2cf4 | 266 | self.Platform = self.BuildDatabase[self.MetaFile, TAB_ARCH_COMMON, Target, Toolchain]\r |
d0acc87a | 267 | GlobalData.gActivePlatform = self.Platform\r |
52302d4d LG |
268 | self.BuildTarget = Target\r |
269 | self.ToolChain = Toolchain\r | |
270 | self.ArchList = ArchList\r | |
271 | self.SkuId = SkuId\r | |
f3decdc3 | 272 | self.UniFlag = UniFlag\r |
52302d4d | 273 | \r |
52302d4d LG |
274 | self.TargetTxt = BuildConfig\r |
275 | self.ToolDef = ToolDefinition\r | |
276 | self.FdfFile = FlashDefinitionFile\r | |
066c7154 CJ |
277 | self.FdTargetList = Fds if Fds else []\r |
278 | self.FvTargetList = Fvs if Fvs else []\r | |
279 | self.CapTargetList = Caps if Caps else []\r | |
52302d4d | 280 | self.AutoGenObjectList = []\r |
36d083ef YZ |
281 | self._BuildDir = None\r |
282 | self._FvDir = None\r | |
283 | self._MakeFileDir = None\r | |
284 | self._BuildCommand = None\r | |
726c501c | 285 | self._GuidDict = {}\r |
52302d4d LG |
286 | \r |
287 | # there's many relative directory operations, so ...\r | |
288 | os.chdir(self.WorkspaceDir)\r | |
289 | \r | |
0d2711a6 LG |
290 | #\r |
291 | # Merge Arch\r | |
292 | #\r | |
293 | if not self.ArchList:\r | |
294 | ArchList = set(self.Platform.SupArchList)\r | |
295 | else:\r | |
296 | ArchList = set(self.ArchList) & set(self.Platform.SupArchList)\r | |
297 | if not ArchList:\r | |
298 | EdkLogger.error("build", PARAMETER_INVALID,\r | |
299 | ExtraData = "Invalid ARCH specified. [Valid ARCH: %s]" % (" ".join(self.Platform.SupArchList)))\r | |
300 | elif self.ArchList and len(ArchList) != len(self.ArchList):\r | |
301 | SkippedArchList = set(self.ArchList).symmetric_difference(set(self.Platform.SupArchList))\r | |
302 | EdkLogger.verbose("\nArch [%s] is ignored because the platform supports [%s] only!"\r | |
303 | % (" ".join(SkippedArchList), " ".join(self.Platform.SupArchList)))\r | |
304 | self.ArchList = tuple(ArchList)\r | |
305 | \r | |
306 | # Validate build target\r | |
307 | if self.BuildTarget not in self.Platform.BuildTargets:\r | |
47fea6af | 308 | EdkLogger.error("build", PARAMETER_INVALID,\r |
0d2711a6 LG |
309 | ExtraData="Build target [%s] is not supported by the platform. [Valid target: %s]"\r |
310 | % (self.BuildTarget, " ".join(self.Platform.BuildTargets)))\r | |
311 | \r | |
12d37ace | 312 | \r |
52302d4d | 313 | # parse FDF file to get PCDs in it, if any\r |
0d2711a6 LG |
314 | if not self.FdfFile:\r |
315 | self.FdfFile = self.Platform.FlashDefinition\r | |
47fea6af | 316 | \r |
9508d0fa LG |
317 | EdkLogger.info("")\r |
318 | if self.ArchList:\r | |
319 | EdkLogger.info('%-16s = %s' % ("Architecture(s)", ' '.join(self.ArchList)))\r | |
320 | EdkLogger.info('%-16s = %s' % ("Build target", self.BuildTarget))\r | |
47fea6af YZ |
321 | EdkLogger.info('%-16s = %s' % ("Toolchain", self.ToolChain))\r |
322 | \r | |
9508d0fa LG |
323 | EdkLogger.info('\n%-24s = %s' % ("Active Platform", self.Platform))\r |
324 | if BuildModule:\r | |
325 | EdkLogger.info('%-24s = %s' % ("Active Module", BuildModule))\r | |
47fea6af | 326 | \r |
9508d0fa LG |
327 | if self.FdfFile:\r |
328 | EdkLogger.info('%-24s = %s' % ("Flash Image Definition", self.FdfFile))\r | |
0d2711a6 | 329 | \r |
9508d0fa | 330 | EdkLogger.verbose("\nFLASH_DEFINITION = %s" % self.FdfFile)\r |
47fea6af | 331 | \r |
e74cea4c YZ |
332 | if Progress:\r |
333 | Progress.Start("\nProcessing meta-data")\r | |
47fea6af | 334 | \r |
0d2711a6 | 335 | if self.FdfFile:\r |
df692f02 LG |
336 | #\r |
337 | # Mark now build in AutoGen Phase\r | |
338 | #\r | |
47fea6af | 339 | GlobalData.gAutoGenPhase = True\r |
52302d4d LG |
340 | Fdf = FdfParser(self.FdfFile.Path)\r |
341 | Fdf.ParseFile()\r | |
a0a2cd1e | 342 | GlobalData.gFdfParser = Fdf\r |
0d2711a6 | 343 | GlobalData.gAutoGenPhase = False\r |
52302d4d | 344 | PcdSet = Fdf.Profile.PcdDict\r |
cb04330e YZ |
345 | if Fdf.CurrentFdName and Fdf.CurrentFdName in Fdf.Profile.FdDict:\r |
346 | FdDict = Fdf.Profile.FdDict[Fdf.CurrentFdName]\r | |
347 | for FdRegion in FdDict.RegionList:\r | |
348 | if str(FdRegion.RegionType) is 'FILE' and self.Platform.VpdToolGuid in str(FdRegion.RegionDataList):\r | |
349 | if int(FdRegion.Offset) % 8 != 0:\r | |
350 | EdkLogger.error("build", FORMAT_INVALID, 'The VPD Base Address %s must be 8-byte aligned.' % (FdRegion.Offset))\r | |
52302d4d LG |
351 | ModuleList = Fdf.Profile.InfList\r |
352 | self.FdfProfile = Fdf.Profile\r | |
0d2711a6 LG |
353 | for fvname in self.FvTargetList:\r |
354 | if fvname.upper() not in self.FdfProfile.FvDict:\r | |
355 | EdkLogger.error("build", OPTION_VALUE_INVALID,\r | |
356 | "No such an FV in FDF file: %s" % fvname)\r | |
2502b735 | 357 | \r |
622b1758 YZ |
358 | # In DSC file may use FILE_GUID to override the module, then in the Platform.Modules use FILE_GUIDmodule.inf as key,\r |
359 | # but the path (self.MetaFile.Path) is the real path\r | |
2502b735 YZ |
360 | for key in self.FdfProfile.InfDict:\r |
361 | if key == 'ArchTBD':\r | |
992fbe35 | 362 | MetaFile_cache = defaultdict(set)\r |
2502b735 | 363 | for Arch in self.ArchList:\r |
1530ceda | 364 | Current_Platform_cache = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]\r |
1530ceda CJ |
365 | for Pkey in Current_Platform_cache.Modules:\r |
366 | MetaFile_cache[Arch].add(Current_Platform_cache.Modules[Pkey].MetaFile)\r | |
2502b735 YZ |
367 | for Inf in self.FdfProfile.InfDict[key]:\r |
368 | ModuleFile = PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch)\r | |
369 | for Arch in self.ArchList:\r | |
622b1758 | 370 | if ModuleFile in MetaFile_cache[Arch]:\r |
2502b735 YZ |
371 | break\r |
372 | else:\r | |
373 | ModuleData = self.BuildDatabase[ModuleFile, Arch, Target, Toolchain]\r | |
374 | if not ModuleData.IsBinaryModule:\r | |
375 | EdkLogger.error('build', PARSER_ERROR, "Module %s NOT found in DSC file; Is it really a binary module?" % ModuleFile)\r | |
376 | \r | |
377 | else:\r | |
378 | for Arch in self.ArchList:\r | |
379 | if Arch == key:\r | |
380 | Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]\r | |
b74b419a CJ |
381 | MetaFileList = set()\r |
382 | for Pkey in Platform.Modules:\r | |
383 | MetaFileList.add(Platform.Modules[Pkey].MetaFile)\r | |
2502b735 YZ |
384 | for Inf in self.FdfProfile.InfDict[key]:\r |
385 | ModuleFile = PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch)\r | |
622b1758 | 386 | if ModuleFile in MetaFileList:\r |
2502b735 YZ |
387 | continue\r |
388 | ModuleData = self.BuildDatabase[ModuleFile, Arch, Target, Toolchain]\r | |
389 | if not ModuleData.IsBinaryModule:\r | |
390 | EdkLogger.error('build', PARSER_ERROR, "Module %s NOT found in DSC file; Is it really a binary module?" % ModuleFile)\r | |
391 | \r | |
52302d4d LG |
392 | else:\r |
393 | PcdSet = {}\r | |
394 | ModuleList = []\r | |
395 | self.FdfProfile = None\r | |
0d2711a6 LG |
396 | if self.FdTargetList:\r |
397 | EdkLogger.info("No flash definition file found. FD [%s] will be ignored." % " ".join(self.FdTargetList))\r | |
398 | self.FdTargetList = []\r | |
399 | if self.FvTargetList:\r | |
400 | EdkLogger.info("No flash definition file found. FV [%s] will be ignored." % " ".join(self.FvTargetList))\r | |
401 | self.FvTargetList = []\r | |
402 | if self.CapTargetList:\r | |
403 | EdkLogger.info("No flash definition file found. Capsule [%s] will be ignored." % " ".join(self.CapTargetList))\r | |
404 | self.CapTargetList = []\r | |
47fea6af | 405 | \r |
52302d4d LG |
406 | # apply SKU and inject PCDs from Flash Definition file\r |
407 | for Arch in self.ArchList:\r | |
0d2711a6 | 408 | Platform = self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]\r |
f9fa014e YZ |
409 | PlatformPcds = Platform.Pcds\r |
410 | self._GuidDict = Platform._GuidDict\r | |
6b1f2cf4 CJ |
411 | SourcePcdDict = {TAB_PCDS_DYNAMIC_EX:set(), TAB_PCDS_PATCHABLE_IN_MODULE:set(),TAB_PCDS_DYNAMIC:set(),TAB_PCDS_FIXED_AT_BUILD:set()}\r |
412 | BinaryPcdDict = {TAB_PCDS_DYNAMIC_EX:set(), TAB_PCDS_PATCHABLE_IN_MODULE:set()}\r | |
2a29017e YZ |
413 | SourcePcdDict_Keys = SourcePcdDict.keys()\r |
414 | BinaryPcdDict_Keys = BinaryPcdDict.keys()\r | |
415 | \r | |
416 | # generate the SourcePcdDict and BinaryPcdDict\r | |
6f49996c | 417 | PGen = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)\r |
2a29017e YZ |
418 | for BuildData in PGen.BuildDatabase._CACHE_.values():\r |
419 | if BuildData.Arch != Arch:\r | |
420 | continue\r | |
421 | if BuildData.MetaFile.Ext == '.inf':\r | |
422 | for key in BuildData.Pcds:\r | |
423 | if BuildData.Pcds[key].Pending:\r | |
424 | if key in Platform.Pcds:\r | |
425 | PcdInPlatform = Platform.Pcds[key]\r | |
c93356ad | 426 | if PcdInPlatform.Type:\r |
2a29017e | 427 | BuildData.Pcds[key].Type = PcdInPlatform.Type\r |
74f59e92 | 428 | BuildData.Pcds[key].Pending = False\r |
2a29017e YZ |
429 | \r |
430 | if BuildData.MetaFile in Platform.Modules:\r | |
431 | PlatformModule = Platform.Modules[str(BuildData.MetaFile)]\r | |
432 | if key in PlatformModule.Pcds:\r | |
433 | PcdInPlatform = PlatformModule.Pcds[key]\r | |
c93356ad | 434 | if PcdInPlatform.Type:\r |
2a29017e | 435 | BuildData.Pcds[key].Type = PcdInPlatform.Type\r |
74f59e92 | 436 | BuildData.Pcds[key].Pending = False\r |
5a444dfd YF |
437 | else:\r |
438 | #Pcd used in Library, Pcd Type from reference module if Pcd Type is Pending\r | |
439 | if BuildData.Pcds[key].Pending:\r | |
440 | MGen = ModuleAutoGen(self, BuildData.MetaFile, Target, Toolchain, Arch, self.MetaFile)\r | |
441 | if MGen and MGen.IsLibrary:\r | |
442 | if MGen in PGen.LibraryAutoGenList:\r | |
443 | ReferenceModules = MGen._ReferenceModules\r | |
444 | for ReferenceModule in ReferenceModules:\r | |
445 | if ReferenceModule.MetaFile in Platform.Modules:\r | |
446 | RefPlatformModule = Platform.Modules[str(ReferenceModule.MetaFile)]\r | |
447 | if key in RefPlatformModule.Pcds:\r | |
448 | PcdInReferenceModule = RefPlatformModule.Pcds[key]\r | |
449 | if PcdInReferenceModule.Type:\r | |
450 | BuildData.Pcds[key].Type = PcdInReferenceModule.Type\r | |
451 | BuildData.Pcds[key].Pending = False\r | |
452 | break\r | |
2a29017e | 453 | \r |
6b1f2cf4 | 454 | if TAB_PCDS_DYNAMIC_EX in BuildData.Pcds[key].Type:\r |
2a29017e | 455 | if BuildData.IsBinaryModule:\r |
6b1f2cf4 | 456 | BinaryPcdDict[TAB_PCDS_DYNAMIC_EX].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r |
2a29017e | 457 | else:\r |
6b1f2cf4 | 458 | SourcePcdDict[TAB_PCDS_DYNAMIC_EX].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r |
2a29017e | 459 | \r |
6b1f2cf4 | 460 | elif TAB_PCDS_PATCHABLE_IN_MODULE in BuildData.Pcds[key].Type:\r |
2a29017e YZ |
461 | if BuildData.MetaFile.Ext == '.inf':\r |
462 | if BuildData.IsBinaryModule:\r | |
6b1f2cf4 | 463 | BinaryPcdDict[TAB_PCDS_PATCHABLE_IN_MODULE].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r |
2a29017e | 464 | else:\r |
6b1f2cf4 | 465 | SourcePcdDict[TAB_PCDS_PATCHABLE_IN_MODULE].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r |
2a29017e | 466 | \r |
6b1f2cf4 CJ |
467 | elif TAB_PCDS_DYNAMIC in BuildData.Pcds[key].Type:\r |
468 | SourcePcdDict[TAB_PCDS_DYNAMIC].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r | |
469 | elif TAB_PCDS_FIXED_AT_BUILD in BuildData.Pcds[key].Type:\r | |
470 | SourcePcdDict[TAB_PCDS_FIXED_AT_BUILD].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r | |
2a29017e YZ |
471 | else:\r |
472 | pass\r | |
97cdb33b YZ |
473 | #\r |
474 | # A PCD can only use one type for all source modules\r | |
475 | #\r | |
476 | for i in SourcePcdDict_Keys:\r | |
477 | for j in SourcePcdDict_Keys:\r | |
478 | if i != j:\r | |
ff5635e9 CJ |
479 | Intersections = SourcePcdDict[i].intersection(SourcePcdDict[j])\r |
480 | if len(Intersections) > 0:\r | |
97cdb33b YZ |
481 | EdkLogger.error(\r |
482 | 'build',\r | |
483 | FORMAT_INVALID,\r | |
484 | "Building modules from source INFs, following PCD use %s and %s access method. It must be corrected to use only one access method." % (i, j),\r | |
caf74495 | 485 | ExtraData='\n\t'.join(str(P[1]+'.'+P[0]) for P in Intersections)\r |
97cdb33b | 486 | )\r |
2a29017e YZ |
487 | \r |
488 | #\r | |
489 | # intersection the BinaryPCD for Mixed PCD\r | |
490 | #\r | |
491 | for i in BinaryPcdDict_Keys:\r | |
492 | for j in BinaryPcdDict_Keys:\r | |
493 | if i != j:\r | |
ff5635e9 CJ |
494 | Intersections = BinaryPcdDict[i].intersection(BinaryPcdDict[j])\r |
495 | for item in Intersections:\r | |
2a29017e YZ |
496 | NewPcd1 = (item[0] + '_' + i, item[1])\r |
497 | NewPcd2 = (item[0] + '_' + j, item[1])\r | |
498 | if item not in GlobalData.MixedPcd:\r | |
499 | GlobalData.MixedPcd[item] = [NewPcd1, NewPcd2]\r | |
500 | else:\r | |
501 | if NewPcd1 not in GlobalData.MixedPcd[item]:\r | |
502 | GlobalData.MixedPcd[item].append(NewPcd1)\r | |
503 | if NewPcd2 not in GlobalData.MixedPcd[item]:\r | |
504 | GlobalData.MixedPcd[item].append(NewPcd2)\r | |
2a29017e YZ |
505 | \r |
506 | #\r | |
507 | # intersection the SourcePCD and BinaryPCD for Mixed PCD\r | |
508 | #\r | |
509 | for i in SourcePcdDict_Keys:\r | |
510 | for j in BinaryPcdDict_Keys:\r | |
511 | if i != j:\r | |
ff5635e9 CJ |
512 | Intersections = SourcePcdDict[i].intersection(BinaryPcdDict[j])\r |
513 | for item in Intersections:\r | |
2a29017e YZ |
514 | NewPcd1 = (item[0] + '_' + i, item[1])\r |
515 | NewPcd2 = (item[0] + '_' + j, item[1])\r | |
516 | if item not in GlobalData.MixedPcd:\r | |
517 | GlobalData.MixedPcd[item] = [NewPcd1, NewPcd2]\r | |
518 | else:\r | |
519 | if NewPcd1 not in GlobalData.MixedPcd[item]:\r | |
520 | GlobalData.MixedPcd[item].append(NewPcd1)\r | |
521 | if NewPcd2 not in GlobalData.MixedPcd[item]:\r | |
522 | GlobalData.MixedPcd[item].append(NewPcd2)\r | |
2a29017e YZ |
523 | \r |
524 | for BuildData in PGen.BuildDatabase._CACHE_.values():\r | |
525 | if BuildData.Arch != Arch:\r | |
526 | continue\r | |
527 | for key in BuildData.Pcds:\r | |
528 | for SinglePcd in GlobalData.MixedPcd:\r | |
529 | if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) == SinglePcd:\r | |
530 | for item in GlobalData.MixedPcd[SinglePcd]:\r | |
531 | Pcd_Type = item[0].split('_')[-1]\r | |
eece4292 CJ |
532 | if (Pcd_Type == BuildData.Pcds[key].Type) or (Pcd_Type == TAB_PCDS_DYNAMIC_EX and BuildData.Pcds[key].Type in PCD_DYNAMIC_EX_TYPE_SET) or \\r |
533 | (Pcd_Type == TAB_PCDS_DYNAMIC and BuildData.Pcds[key].Type in PCD_DYNAMIC_TYPE_SET):\r | |
2a29017e YZ |
534 | Value = BuildData.Pcds[key]\r |
535 | Value.TokenCName = BuildData.Pcds[key].TokenCName + '_' + Pcd_Type\r | |
536 | if len(key) == 2:\r | |
537 | newkey = (Value.TokenCName, key[1])\r | |
538 | elif len(key) == 3:\r | |
539 | newkey = (Value.TokenCName, key[1], key[2])\r | |
540 | del BuildData.Pcds[key]\r | |
541 | BuildData.Pcds[newkey] = Value\r | |
542 | break\r | |
2a29017e | 543 | break\r |
2a29017e YZ |
544 | \r |
545 | # handle the mixed pcd in FDF file\r | |
546 | for key in PcdSet:\r | |
547 | if key in GlobalData.MixedPcd:\r | |
548 | Value = PcdSet[key]\r | |
549 | del PcdSet[key]\r | |
550 | for item in GlobalData.MixedPcd[key]:\r | |
551 | PcdSet[item] = Value\r | |
552 | \r | |
97fa0ee9 | 553 | #Collect package set information from INF of FDF\r |
a0a2cd1e FB |
554 | PkgSet = set()\r |
555 | for Inf in ModuleList:\r | |
556 | ModuleFile = PathClass(NormPath(Inf), GlobalData.gWorkspace, Arch)\r | |
557 | if ModuleFile in Platform.Modules:\r | |
558 | continue\r | |
559 | ModuleData = self.BuildDatabase[ModuleFile, Arch, Target, Toolchain]\r | |
560 | PkgSet.update(ModuleData.Packages)\r | |
561 | Pkgs = list(PkgSet) + list(PGen.PackageList)\r | |
6b26dd71 | 562 | DecPcds = set()\r |
6f49996c | 563 | DecPcdsKey = set()\r |
64b2609f | 564 | for Pkg in Pkgs:\r |
25918452 | 565 | for Pcd in Pkg.Pcds:\r |
6b26dd71 | 566 | DecPcds.add((Pcd[0], Pcd[1]))\r |
4afd3d04 | 567 | DecPcdsKey.add((Pcd[0], Pcd[1], Pcd[2]))\r |
64b2609f | 568 | \r |
52302d4d LG |
569 | Platform.SkuName = self.SkuId\r |
570 | for Name, Guid in PcdSet:\r | |
64b2609f LG |
571 | if (Name, Guid) not in DecPcds:\r |
572 | EdkLogger.error(\r | |
573 | 'build',\r | |
574 | PARSER_ERROR,\r | |
575 | "PCD (%s.%s) used in FDF is not declared in DEC files." % (Guid, Name),\r | |
576 | File = self.FdfProfile.PcdFileLineDict[Name, Guid][0],\r | |
577 | Line = self.FdfProfile.PcdFileLineDict[Name, Guid][1]\r | |
578 | )\r | |
4afd3d04 LG |
579 | else:\r |
580 | # Check whether Dynamic or DynamicEx PCD used in FDF file. If used, build break and give a error message.\r | |
581 | if (Name, Guid, TAB_PCDS_FIXED_AT_BUILD) in DecPcdsKey \\r | |
582 | or (Name, Guid, TAB_PCDS_PATCHABLE_IN_MODULE) in DecPcdsKey \\r | |
583 | or (Name, Guid, TAB_PCDS_FEATURE_FLAG) in DecPcdsKey:\r | |
584 | Platform.AddPcd(Name, Guid, PcdSet[Name, Guid])\r | |
585 | continue\r | |
586 | elif (Name, Guid, TAB_PCDS_DYNAMIC) in DecPcdsKey or (Name, Guid, TAB_PCDS_DYNAMIC_EX) in DecPcdsKey:\r | |
587 | EdkLogger.error(\r | |
588 | 'build',\r | |
589 | PARSER_ERROR,\r | |
590 | "Using Dynamic or DynamicEx type of PCD [%s.%s] in FDF file is not allowed." % (Guid, Name),\r | |
591 | File = self.FdfProfile.PcdFileLineDict[Name, Guid][0],\r | |
592 | Line = self.FdfProfile.PcdFileLineDict[Name, Guid][1]\r | |
593 | )\r | |
52302d4d LG |
594 | \r |
595 | Pa = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)\r | |
596 | #\r | |
597 | # Explicitly collect platform's dynamic PCDs\r | |
598 | #\r | |
599 | Pa.CollectPlatformDynamicPcds()\r | |
2bc3256c | 600 | Pa.CollectFixedAtBuildPcds()\r |
52302d4d | 601 | self.AutoGenObjectList.append(Pa)\r |
47fea6af | 602 | \r |
36d083ef YZ |
603 | #\r |
604 | # Generate Package level hash value\r | |
605 | #\r | |
606 | GlobalData.gPackageHash[Arch] = {}\r | |
607 | if GlobalData.gUseHashCache:\r | |
608 | for Pkg in Pkgs:\r | |
609 | self._GenPkgLevelHash(Pkg)\r | |
610 | \r | |
6780eef1 LG |
611 | #\r |
612 | # Check PCDs token value conflict in each DEC file.\r | |
613 | #\r | |
614 | self._CheckAllPcdsTokenValueConflict()\r | |
47fea6af | 615 | \r |
4234283c LG |
616 | #\r |
617 | # Check PCD type and definition between DSC and DEC\r | |
618 | #\r | |
619 | self._CheckPcdDefineAndType()\r | |
97fa0ee9 YL |
620 | \r |
621 | # if self.FdfFile:\r | |
622 | # self._CheckDuplicateInFV(Fdf)\r | |
623 | \r | |
c17956e0 | 624 | #\r |
2d499388 | 625 | # Create BuildOptions Macro & PCD metafile, also add the Active Platform and FDF file.\r |
c17956e0 DL |
626 | #\r |
627 | content = 'gCommandLineDefines: '\r | |
628 | content += str(GlobalData.gCommandLineDefines)\r | |
629 | content += os.linesep\r | |
630 | content += 'BuildOptionPcd: '\r | |
631 | content += str(GlobalData.BuildOptionPcd)\r | |
2d499388 YZ |
632 | content += os.linesep\r |
633 | content += 'Active Platform: '\r | |
634 | content += str(self.Platform)\r | |
635 | content += os.linesep\r | |
636 | if self.FdfFile:\r | |
637 | content += 'Flash Image Definition: '\r | |
638 | content += str(self.FdfFile)\r | |
36d083ef | 639 | content += os.linesep\r |
c17956e0 DL |
640 | SaveFileOnChange(os.path.join(self.BuildDir, 'BuildOptions'), content, False)\r |
641 | \r | |
99adfe9f YZ |
642 | #\r |
643 | # Create PcdToken Number file for Dynamic/DynamicEx Pcd.\r | |
644 | #\r | |
645 | PcdTokenNumber = 'PcdTokenNumber: '\r | |
646 | if Pa.PcdTokenNumber:\r | |
647 | if Pa.DynamicPcdList:\r | |
648 | for Pcd in Pa.DynamicPcdList:\r | |
649 | PcdTokenNumber += os.linesep\r | |
650 | PcdTokenNumber += str((Pcd.TokenCName, Pcd.TokenSpaceGuidCName))\r | |
651 | PcdTokenNumber += ' : '\r | |
652 | PcdTokenNumber += str(Pa.PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName])\r | |
653 | SaveFileOnChange(os.path.join(self.BuildDir, 'PcdTokenNumber'), PcdTokenNumber, False)\r | |
654 | \r | |
c17956e0 DL |
655 | #\r |
656 | # Get set of workspace metafiles\r | |
657 | #\r | |
658 | AllWorkSpaceMetaFiles = self._GetMetaFiles(Target, Toolchain, Arch)\r | |
659 | \r | |
660 | #\r | |
661 | # Retrieve latest modified time of all metafiles\r | |
662 | #\r | |
663 | SrcTimeStamp = 0\r | |
664 | for f in AllWorkSpaceMetaFiles:\r | |
665 | if os.stat(f)[8] > SrcTimeStamp:\r | |
666 | SrcTimeStamp = os.stat(f)[8]\r | |
667 | self._SrcTimeStamp = SrcTimeStamp\r | |
668 | \r | |
36d083ef YZ |
669 | if GlobalData.gUseHashCache:\r |
670 | m = hashlib.md5()\r | |
671 | for files in AllWorkSpaceMetaFiles:\r | |
672 | if files.endswith('.dec'):\r | |
673 | continue\r | |
674 | f = open(files, 'r')\r | |
675 | Content = f.read()\r | |
676 | f.close()\r | |
677 | m.update(Content)\r | |
678 | SaveFileOnChange(os.path.join(self.BuildDir, 'AutoGen.hash'), m.hexdigest(), True)\r | |
679 | GlobalData.gPlatformHash = m.hexdigest()\r | |
680 | \r | |
c17956e0 DL |
681 | #\r |
682 | # Write metafile list to build directory\r | |
683 | #\r | |
684 | AutoGenFilePath = os.path.join(self.BuildDir, 'AutoGen')\r | |
685 | if os.path.exists (AutoGenFilePath):\r | |
686 | os.remove(AutoGenFilePath)\r | |
687 | if not os.path.exists(self.BuildDir):\r | |
688 | os.makedirs(self.BuildDir)\r | |
689 | with open(os.path.join(self.BuildDir, 'AutoGen'), 'w+') as file:\r | |
690 | for f in AllWorkSpaceMetaFiles:\r | |
691 | print >> file, f\r | |
52302d4d LG |
692 | return True\r |
693 | \r | |
36d083ef | 694 | def _GenPkgLevelHash(self, Pkg):\r |
3f34e36d LD |
695 | if Pkg.PackageName in GlobalData.gPackageHash[Pkg.Arch]:\r |
696 | return\r | |
697 | \r | |
36d083ef YZ |
698 | PkgDir = os.path.join(self.BuildDir, Pkg.Arch, Pkg.PackageName)\r |
699 | CreateDirectory(PkgDir)\r | |
700 | HashFile = os.path.join(PkgDir, Pkg.PackageName + '.hash')\r | |
701 | m = hashlib.md5()\r | |
702 | # Get .dec file's hash value\r | |
703 | f = open(Pkg.MetaFile.Path, 'r')\r | |
704 | Content = f.read()\r | |
705 | f.close()\r | |
706 | m.update(Content)\r | |
707 | # Get include files hash value\r | |
708 | if Pkg.Includes:\r | |
3f34e36d | 709 | for inc in sorted(Pkg.Includes, key=lambda x: str(x)):\r |
36d083ef | 710 | for Root, Dirs, Files in os.walk(str(inc)):\r |
3f34e36d | 711 | for File in sorted(Files):\r |
36d083ef YZ |
712 | File_Path = os.path.join(Root, File)\r |
713 | f = open(File_Path, 'r')\r | |
714 | Content = f.read()\r | |
715 | f.close()\r | |
716 | m.update(Content)\r | |
717 | SaveFileOnChange(HashFile, m.hexdigest(), True)\r | |
3f34e36d | 718 | GlobalData.gPackageHash[Pkg.Arch][Pkg.PackageName] = m.hexdigest()\r |
763e8edf | 719 | \r |
c17956e0 DL |
720 | def _GetMetaFiles(self, Target, Toolchain, Arch):\r |
721 | AllWorkSpaceMetaFiles = set()\r | |
722 | #\r | |
723 | # add fdf\r | |
724 | #\r | |
725 | if self.FdfFile:\r | |
726 | AllWorkSpaceMetaFiles.add (self.FdfFile.Path)\r | |
caf74495 JC |
727 | for f in GlobalData.gFdfParser.GetAllIncludedFile():\r |
728 | AllWorkSpaceMetaFiles.add (f.FileName)\r | |
c17956e0 DL |
729 | #\r |
730 | # add dsc\r | |
731 | #\r | |
732 | AllWorkSpaceMetaFiles.add(self.MetaFile.Path)\r | |
733 | \r | |
734 | #\r | |
86601b78 DL |
735 | # add build_rule.txt & tools_def.txt\r |
736 | #\r | |
51de5c30 YZ |
737 | AllWorkSpaceMetaFiles.add(os.path.join(GlobalData.gConfDirectory, gDefaultBuildRuleFile))\r |
738 | AllWorkSpaceMetaFiles.add(os.path.join(GlobalData.gConfDirectory, gDefaultToolsDefFile))\r | |
86601b78 | 739 | \r |
c17956e0 DL |
740 | # add BuildOption metafile\r |
741 | #\r | |
742 | AllWorkSpaceMetaFiles.add(os.path.join(self.BuildDir, 'BuildOptions'))\r | |
743 | \r | |
99adfe9f YZ |
744 | # add PcdToken Number file for Dynamic/DynamicEx Pcd\r |
745 | #\r | |
746 | AllWorkSpaceMetaFiles.add(os.path.join(self.BuildDir, 'PcdTokenNumber'))\r | |
747 | \r | |
c17956e0 | 748 | for Arch in self.ArchList:\r |
c17956e0 DL |
749 | #\r |
750 | # add dec\r | |
751 | #\r | |
caf74495 | 752 | for Package in PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch).PackageList:\r |
c17956e0 DL |
753 | AllWorkSpaceMetaFiles.add(Package.MetaFile.Path)\r |
754 | \r | |
755 | #\r | |
756 | # add included dsc\r | |
757 | #\r | |
caf74495 | 758 | for filePath in self.BuildDatabase[self.MetaFile, Arch, Target, Toolchain]._RawData.IncludedFiles:\r |
c17956e0 DL |
759 | AllWorkSpaceMetaFiles.add(filePath.Path)\r |
760 | \r | |
761 | return AllWorkSpaceMetaFiles\r | |
762 | \r | |
79b74a03 LG |
763 | ## _CheckDuplicateInFV() method\r |
764 | #\r | |
765 | # Check whether there is duplicate modules/files exist in FV section. \r | |
766 | # The check base on the file GUID;\r | |
767 | #\r | |
768 | def _CheckDuplicateInFV(self, Fdf):\r | |
769 | for Fv in Fdf.Profile.FvDict:\r | |
770 | _GuidDict = {}\r | |
771 | for FfsFile in Fdf.Profile.FvDict[Fv].FfsList:\r | |
4231a819 | 772 | if FfsFile.InfFileName and FfsFile.NameGuid is None:\r |
79b74a03 LG |
773 | #\r |
774 | # Get INF file GUID\r | |
775 | #\r | |
47fea6af | 776 | InfFoundFlag = False\r |
79b74a03 | 777 | for Pa in self.AutoGenObjectList:\r |
64b2609f LG |
778 | if InfFoundFlag:\r |
779 | break\r | |
79b74a03 LG |
780 | for Module in Pa.ModuleAutoGenList:\r |
781 | if path.normpath(Module.MetaFile.File) == path.normpath(FfsFile.InfFileName):\r | |
782 | InfFoundFlag = True\r | |
9eb87141 | 783 | if Module.Guid.upper() not in _GuidDict:\r |
79b74a03 | 784 | _GuidDict[Module.Guid.upper()] = FfsFile\r |
64b2609f | 785 | break\r |
79b74a03 | 786 | else:\r |
47fea6af | 787 | EdkLogger.error("build",\r |
79b74a03 | 788 | FORMAT_INVALID,\r |
47fea6af | 789 | "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile.CurrentLineNum,\r |
79b74a03 LG |
790 | FfsFile.CurrentLineContent,\r |
791 | _GuidDict[Module.Guid.upper()].CurrentLineNum,\r | |
792 | _GuidDict[Module.Guid.upper()].CurrentLineContent,\r | |
793 | Module.Guid.upper()),\r | |
794 | ExtraData=self.FdfFile)\r | |
795 | #\r | |
796 | # Some INF files not have entity in DSC file. \r | |
797 | #\r | |
798 | if not InfFoundFlag:\r | |
799 | if FfsFile.InfFileName.find('$') == -1:\r | |
800 | InfPath = NormPath(FfsFile.InfFileName)\r | |
801 | if not os.path.exists(InfPath):\r | |
802 | EdkLogger.error('build', GENFDS_ERROR, "Non-existant Module %s !" % (FfsFile.InfFileName))\r | |
47fea6af | 803 | \r |
79b74a03 LG |
804 | PathClassObj = PathClass(FfsFile.InfFileName, self.WorkspaceDir)\r |
805 | #\r | |
806 | # Here we just need to get FILE_GUID from INF file, use 'COMMON' as ARCH attribute. and use \r | |
807 | # BuildObject from one of AutoGenObjectList is enough.\r | |
808 | #\r | |
6b1f2cf4 | 809 | InfObj = self.AutoGenObjectList[0].BuildDatabase.WorkspaceDb.BuildObject[PathClassObj, TAB_ARCH_COMMON, self.BuildTarget, self.ToolChain]\r |
9eb87141 | 810 | if InfObj.Guid.upper() not in _GuidDict:\r |
79b74a03 LG |
811 | _GuidDict[InfObj.Guid.upper()] = FfsFile\r |
812 | else:\r | |
47fea6af | 813 | EdkLogger.error("build",\r |
79b74a03 | 814 | FORMAT_INVALID,\r |
47fea6af | 815 | "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile.CurrentLineNum,\r |
79b74a03 LG |
816 | FfsFile.CurrentLineContent,\r |
817 | _GuidDict[InfObj.Guid.upper()].CurrentLineNum,\r | |
818 | _GuidDict[InfObj.Guid.upper()].CurrentLineContent,\r | |
819 | InfObj.Guid.upper()),\r | |
820 | ExtraData=self.FdfFile)\r | |
821 | InfFoundFlag = False\r | |
47fea6af | 822 | \r |
4231a819 | 823 | if FfsFile.NameGuid is not None:\r |
79b74a03 LG |
824 | #\r |
825 | # If the NameGuid reference a PCD name. \r | |
826 | # The style must match: PCD(xxxx.yyy)\r | |
827 | #\r | |
c8802c3d | 828 | if gPCDAsGuidPattern.match(FfsFile.NameGuid):\r |
79b74a03 LG |
829 | #\r |
830 | # Replace the PCD value.\r | |
831 | #\r | |
832 | _PcdName = FfsFile.NameGuid.lstrip("PCD(").rstrip(")")\r | |
833 | PcdFoundFlag = False\r | |
834 | for Pa in self.AutoGenObjectList:\r | |
835 | if not PcdFoundFlag:\r | |
836 | for PcdItem in Pa.AllPcdList:\r | |
837 | if (PcdItem.TokenSpaceGuidCName + "." + PcdItem.TokenCName) == _PcdName:\r | |
838 | #\r | |
839 | # First convert from CFormatGuid to GUID string\r | |
840 | #\r | |
841 | _PcdGuidString = GuidStructureStringToGuidString(PcdItem.DefaultValue)\r | |
47fea6af | 842 | \r |
79b74a03 LG |
843 | if not _PcdGuidString:\r |
844 | #\r | |
845 | # Then try Byte array.\r | |
846 | #\r | |
847 | _PcdGuidString = GuidStructureByteArrayToGuidString(PcdItem.DefaultValue)\r | |
47fea6af | 848 | \r |
79b74a03 LG |
849 | if not _PcdGuidString:\r |
850 | #\r | |
851 | # Not Byte array or CFormat GUID, raise error.\r | |
852 | #\r | |
853 | EdkLogger.error("build",\r | |
854 | FORMAT_INVALID,\r | |
47fea6af | 855 | "The format of PCD value is incorrect. PCD: %s , Value: %s\n" % (_PcdName, PcdItem.DefaultValue),\r |
79b74a03 | 856 | ExtraData=self.FdfFile)\r |
47fea6af | 857 | \r |
9eb87141 | 858 | if _PcdGuidString.upper() not in _GuidDict:\r |
79b74a03 LG |
859 | _GuidDict[_PcdGuidString.upper()] = FfsFile\r |
860 | PcdFoundFlag = True\r | |
861 | break\r | |
862 | else:\r | |
47fea6af | 863 | EdkLogger.error("build",\r |
79b74a03 | 864 | FORMAT_INVALID,\r |
47fea6af | 865 | "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile.CurrentLineNum,\r |
79b74a03 LG |
866 | FfsFile.CurrentLineContent,\r |
867 | _GuidDict[_PcdGuidString.upper()].CurrentLineNum,\r | |
868 | _GuidDict[_PcdGuidString.upper()].CurrentLineContent,\r | |
869 | FfsFile.NameGuid.upper()),\r | |
47fea6af YZ |
870 | ExtraData=self.FdfFile)\r |
871 | \r | |
9eb87141 | 872 | if FfsFile.NameGuid.upper() not in _GuidDict:\r |
79b74a03 LG |
873 | _GuidDict[FfsFile.NameGuid.upper()] = FfsFile\r |
874 | else:\r | |
875 | #\r | |
876 | # Two raw file GUID conflict.\r | |
877 | #\r | |
47fea6af | 878 | EdkLogger.error("build",\r |
79b74a03 | 879 | FORMAT_INVALID,\r |
47fea6af | 880 | "Duplicate GUID found for these lines: Line %d: %s and Line %d: %s. GUID: %s" % (FfsFile.CurrentLineNum,\r |
79b74a03 LG |
881 | FfsFile.CurrentLineContent,\r |
882 | _GuidDict[FfsFile.NameGuid.upper()].CurrentLineNum,\r | |
883 | _GuidDict[FfsFile.NameGuid.upper()].CurrentLineContent,\r | |
884 | FfsFile.NameGuid.upper()),\r | |
885 | ExtraData=self.FdfFile)\r | |
47fea6af | 886 | \r |
79b74a03 | 887 | \r |
4234283c | 888 | def _CheckPcdDefineAndType(self):\r |
caf74495 JC |
889 | PcdTypeSet = {TAB_PCDS_FIXED_AT_BUILD,\r |
890 | TAB_PCDS_PATCHABLE_IN_MODULE,\r | |
891 | TAB_PCDS_FEATURE_FLAG,\r | |
892 | TAB_PCDS_DYNAMIC,\r | |
893 | TAB_PCDS_DYNAMIC_EX}\r | |
4234283c LG |
894 | \r |
895 | # This dict store PCDs which are not used by any modules with specified arches\r | |
9006a2c6 | 896 | UnusedPcd = OrderedDict()\r |
4234283c LG |
897 | for Pa in self.AutoGenObjectList:\r |
898 | # Key of DSC's Pcds dictionary is PcdCName, TokenSpaceGuid\r | |
899 | for Pcd in Pa.Platform.Pcds:\r | |
900 | PcdType = Pa.Platform.Pcds[Pcd].Type\r | |
47fea6af | 901 | \r |
4234283c LG |
902 | # If no PCD type, this PCD comes from FDF \r |
903 | if not PcdType:\r | |
904 | continue\r | |
47fea6af | 905 | \r |
4234283c | 906 | # Try to remove Hii and Vpd suffix\r |
6b1f2cf4 CJ |
907 | if PcdType.startswith(TAB_PCDS_DYNAMIC_EX):\r |
908 | PcdType = TAB_PCDS_DYNAMIC_EX\r | |
909 | elif PcdType.startswith(TAB_PCDS_DYNAMIC):\r | |
910 | PcdType = TAB_PCDS_DYNAMIC\r | |
47fea6af | 911 | \r |
4234283c LG |
912 | for Package in Pa.PackageList:\r |
913 | # Key of DEC's Pcds dictionary is PcdCName, TokenSpaceGuid, PcdType\r | |
914 | if (Pcd[0], Pcd[1], PcdType) in Package.Pcds:\r | |
915 | break\r | |
caf74495 | 916 | for Type in PcdTypeSet:\r |
4234283c LG |
917 | if (Pcd[0], Pcd[1], Type) in Package.Pcds:\r |
918 | EdkLogger.error(\r | |
919 | 'build',\r | |
920 | FORMAT_INVALID,\r | |
921 | "Type [%s] of PCD [%s.%s] in DSC file doesn't match the type [%s] defined in DEC file." \\r | |
922 | % (Pa.Platform.Pcds[Pcd].Type, Pcd[1], Pcd[0], Type),\r | |
923 | ExtraData=None\r | |
924 | )\r | |
925 | return\r | |
926 | else:\r | |
927 | UnusedPcd.setdefault(Pcd, []).append(Pa.Arch)\r | |
928 | \r | |
929 | for Pcd in UnusedPcd:\r | |
930 | EdkLogger.warn(\r | |
931 | 'build',\r | |
932 | "The PCD was not specified by any INF module in the platform for the given architecture.\n"\r | |
933 | "\tPCD: [%s.%s]\n\tPlatform: [%s]\n\tArch: %s"\r | |
934 | % (Pcd[1], Pcd[0], os.path.basename(str(self.MetaFile)), str(UnusedPcd[Pcd])),\r | |
935 | ExtraData=None\r | |
936 | )\r | |
937 | \r | |
52302d4d LG |
938 | def __repr__(self):\r |
939 | return "%s [%s]" % (self.MetaFile, ", ".join(self.ArchList))\r | |
940 | \r | |
941 | ## Return the directory to store FV files\r | |
942 | def _GetFvDir(self):\r | |
4231a819 | 943 | if self._FvDir is None:\r |
91fa33ee | 944 | self._FvDir = path.join(self.BuildDir, TAB_FV_DIRECTORY)\r |
52302d4d LG |
945 | return self._FvDir\r |
946 | \r | |
947 | ## Return the directory to store all intermediate and final files built\r | |
948 | def _GetBuildDir(self):\r | |
4231a819 | 949 | if self._BuildDir is None:\r |
36d083ef | 950 | return self.AutoGenObjectList[0].BuildDir\r |
52302d4d LG |
951 | \r |
952 | ## Return the build output directory platform specifies\r | |
953 | def _GetOutputDir(self):\r | |
954 | return self.Platform.OutputDirectory\r | |
955 | \r | |
956 | ## Return platform name\r | |
957 | def _GetName(self):\r | |
958 | return self.Platform.PlatformName\r | |
959 | \r | |
960 | ## Return meta-file GUID\r | |
961 | def _GetGuid(self):\r | |
962 | return self.Platform.Guid\r | |
963 | \r | |
964 | ## Return platform version\r | |
965 | def _GetVersion(self):\r | |
966 | return self.Platform.Version\r | |
967 | \r | |
968 | ## Return paths of tools\r | |
969 | def _GetToolDefinition(self):\r | |
970 | return self.AutoGenObjectList[0].ToolDefinition\r | |
971 | \r | |
972 | ## Return directory of platform makefile\r | |
973 | #\r | |
974 | # @retval string Makefile directory\r | |
975 | #\r | |
976 | def _GetMakeFileDir(self):\r | |
4231a819 | 977 | if self._MakeFileDir is None:\r |
52302d4d LG |
978 | self._MakeFileDir = self.BuildDir\r |
979 | return self._MakeFileDir\r | |
980 | \r | |
981 | ## Return build command string\r | |
982 | #\r | |
983 | # @retval string Build command string\r | |
984 | #\r | |
985 | def _GetBuildCommand(self):\r | |
4231a819 | 986 | if self._BuildCommand is None:\r |
52302d4d LG |
987 | # BuildCommand should be all the same. So just get one from platform AutoGen\r |
988 | self._BuildCommand = self.AutoGenObjectList[0].BuildCommand\r | |
989 | return self._BuildCommand\r | |
47fea6af | 990 | \r |
6780eef1 LG |
991 | ## Check the PCDs token value conflict in each DEC file.\r |
992 | #\r | |
993 | # Will cause build break and raise error message while two PCDs conflict.\r | |
994 | # \r | |
995 | # @return None\r | |
996 | #\r | |
997 | def _CheckAllPcdsTokenValueConflict(self):\r | |
b36d134f LG |
998 | for Pa in self.AutoGenObjectList:\r |
999 | for Package in Pa.PackageList:\r | |
6780eef1 | 1000 | PcdList = Package.Pcds.values()\r |
f827cd07 | 1001 | PcdList.sort(lambda x, y: cmp(int(x.TokenValue, 0), int(y.TokenValue, 0))) \r |
6780eef1 LG |
1002 | Count = 0\r |
1003 | while (Count < len(PcdList) - 1) :\r | |
1004 | Item = PcdList[Count]\r | |
1005 | ItemNext = PcdList[Count + 1]\r | |
1006 | #\r | |
1007 | # Make sure in the same token space the TokenValue should be unique\r | |
1008 | #\r | |
f827cd07 | 1009 | if (int(Item.TokenValue, 0) == int(ItemNext.TokenValue, 0)):\r |
6780eef1 LG |
1010 | SameTokenValuePcdList = []\r |
1011 | SameTokenValuePcdList.append(Item)\r | |
1012 | SameTokenValuePcdList.append(ItemNext)\r | |
1013 | RemainPcdListLength = len(PcdList) - Count - 2\r | |
1014 | for ValueSameCount in range(RemainPcdListLength):\r | |
f827cd07 | 1015 | if int(PcdList[len(PcdList) - RemainPcdListLength + ValueSameCount].TokenValue, 0) == int(Item.TokenValue, 0):\r |
6780eef1 LG |
1016 | SameTokenValuePcdList.append(PcdList[len(PcdList) - RemainPcdListLength + ValueSameCount])\r |
1017 | else:\r | |
1018 | break;\r | |
1019 | #\r | |
1020 | # Sort same token value PCD list with TokenGuid and TokenCName\r | |
1021 | #\r | |
47fea6af YZ |
1022 | SameTokenValuePcdList.sort(lambda x, y: cmp("%s.%s" % (x.TokenSpaceGuidCName, x.TokenCName), "%s.%s" % (y.TokenSpaceGuidCName, y.TokenCName)))\r |
1023 | SameTokenValuePcdListCount = 0\r | |
6780eef1 | 1024 | while (SameTokenValuePcdListCount < len(SameTokenValuePcdList) - 1):\r |
2a29017e | 1025 | Flag = False\r |
47fea6af YZ |
1026 | TemListItem = SameTokenValuePcdList[SameTokenValuePcdListCount]\r |
1027 | TemListItemNext = SameTokenValuePcdList[SameTokenValuePcdListCount + 1]\r | |
1028 | \r | |
6780eef1 | 1029 | if (TemListItem.TokenSpaceGuidCName == TemListItemNext.TokenSpaceGuidCName) and (TemListItem.TokenCName != TemListItemNext.TokenCName):\r |
2a29017e YZ |
1030 | for PcdItem in GlobalData.MixedPcd:\r |
1031 | if (TemListItem.TokenCName, TemListItem.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem] or \\r | |
1032 | (TemListItemNext.TokenCName, TemListItemNext.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:\r | |
1033 | Flag = True\r | |
1034 | if not Flag:\r | |
1035 | EdkLogger.error(\r | |
1036 | 'build',\r | |
1037 | FORMAT_INVALID,\r | |
1038 | "The TokenValue [%s] of PCD [%s.%s] is conflict with: [%s.%s] in %s"\\r | |
1039 | % (TemListItem.TokenValue, TemListItem.TokenSpaceGuidCName, TemListItem.TokenCName, TemListItemNext.TokenSpaceGuidCName, TemListItemNext.TokenCName, Package),\r | |
1040 | ExtraData=None\r | |
1041 | )\r | |
6780eef1 LG |
1042 | SameTokenValuePcdListCount += 1\r |
1043 | Count += SameTokenValuePcdListCount\r | |
1044 | Count += 1\r | |
47fea6af | 1045 | \r |
6780eef1 | 1046 | PcdList = Package.Pcds.values()\r |
47fea6af | 1047 | PcdList.sort(lambda x, y: cmp("%s.%s" % (x.TokenSpaceGuidCName, x.TokenCName), "%s.%s" % (y.TokenSpaceGuidCName, y.TokenCName)))\r |
6780eef1 LG |
1048 | Count = 0\r |
1049 | while (Count < len(PcdList) - 1) :\r | |
1050 | Item = PcdList[Count]\r | |
47fea6af | 1051 | ItemNext = PcdList[Count + 1]\r |
6780eef1 LG |
1052 | #\r |
1053 | # Check PCDs with same TokenSpaceGuidCName.TokenCName have same token value as well.\r | |
1054 | #\r | |
f827cd07 | 1055 | if (Item.TokenSpaceGuidCName == ItemNext.TokenSpaceGuidCName) and (Item.TokenCName == ItemNext.TokenCName) and (int(Item.TokenValue, 0) != int(ItemNext.TokenValue, 0)):\r |
6780eef1 LG |
1056 | EdkLogger.error(\r |
1057 | 'build',\r | |
1058 | FORMAT_INVALID,\r | |
1059 | "The TokenValue [%s] of PCD [%s.%s] in %s defined in two places should be same as well."\\r | |
1060 | % (Item.TokenValue, Item.TokenSpaceGuidCName, Item.TokenCName, Package),\r | |
1061 | ExtraData=None\r | |
1062 | )\r | |
1063 | Count += 1\r | |
97fa0ee9 | 1064 | ## Generate fds command\r |
03af2753 HC |
1065 | def _GenFdsCommand(self):\r |
1066 | return (GenMake.TopLevelMakefile(self)._TEMPLATE_.Replace(GenMake.TopLevelMakefile(self)._TemplateDict)).strip()\r | |
52302d4d | 1067 | \r |
e56468c0 | 1068 | ## Create makefile for the platform and modules in it\r |
52302d4d LG |
1069 | #\r |
1070 | # @param CreateDepsMakeFile Flag indicating if the makefile for\r | |
1071 | # modules will be created as well\r | |
1072 | #\r | |
1073 | def CreateMakeFile(self, CreateDepsMakeFile=False):\r | |
caf74495 JC |
1074 | if not CreateDepsMakeFile:\r |
1075 | return\r | |
1076 | for Pa in self.AutoGenObjectList:\r | |
1077 | Pa.CreateMakeFile(True)\r | |
52302d4d LG |
1078 | \r |
1079 | ## Create autogen code for platform and modules\r | |
1080 | #\r | |
1081 | # Since there's no autogen code for platform, this method will do nothing\r | |
1082 | # if CreateModuleCodeFile is set to False.\r | |
1083 | #\r | |
1084 | # @param CreateDepsCodeFile Flag indicating if creating module's\r | |
1085 | # autogen code file or not\r | |
1086 | #\r | |
1087 | def CreateCodeFile(self, CreateDepsCodeFile=False):\r | |
1088 | if not CreateDepsCodeFile:\r | |
1089 | return\r | |
1090 | for Pa in self.AutoGenObjectList:\r | |
caf74495 | 1091 | Pa.CreateCodeFile(True)\r |
52302d4d | 1092 | \r |
7c1fd323 LG |
1093 | ## Create AsBuilt INF file the platform\r |
1094 | #\r | |
1095 | def CreateAsBuiltInf(self):\r | |
1096 | return\r | |
1097 | \r | |
52302d4d LG |
1098 | Name = property(_GetName)\r |
1099 | Guid = property(_GetGuid)\r | |
1100 | Version = property(_GetVersion)\r | |
1101 | OutputDir = property(_GetOutputDir)\r | |
1102 | \r | |
1103 | ToolDefinition = property(_GetToolDefinition) # toolcode : tool path\r | |
1104 | \r | |
1105 | BuildDir = property(_GetBuildDir)\r | |
1106 | FvDir = property(_GetFvDir)\r | |
1107 | MakeFileDir = property(_GetMakeFileDir)\r | |
1108 | BuildCommand = property(_GetBuildCommand)\r | |
03af2753 | 1109 | GenFdsCommand = property(_GenFdsCommand)\r |
52302d4d LG |
1110 | \r |
1111 | ## AutoGen class for platform\r | |
1112 | #\r | |
1113 | # PlatformAutoGen class will process the original information in platform\r | |
1114 | # file in order to generate makefile for platform.\r | |
1115 | #\r | |
1116 | class PlatformAutoGen(AutoGen):\r | |
b24e99f7 CJ |
1117 | # call super().__init__ then call the worker function with different parameter count\r |
1118 | def __init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r | |
1119 | try:\r | |
1120 | self._Init\r | |
1121 | except:\r | |
1122 | super(PlatformAutoGen, self).__init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs)\r | |
1123 | self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch)\r | |
1124 | self._Init = True\r | |
52302d4d LG |
1125 | #\r |
1126 | # Used to store all PCDs for both PEI and DXE phase, in order to generate \r | |
1127 | # correct PCD database\r | |
1128 | # \r | |
1129 | _DynaPcdList_ = []\r | |
1130 | _NonDynaPcdList_ = []\r | |
61ee1dff | 1131 | _PlatformPcds = {}\r |
6780eef1 LG |
1132 | \r |
1133 | #\r | |
1134 | # The priority list while override build option \r | |
1135 | #\r | |
1136 | PrioList = {"0x11111" : 16, # TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE (Highest)\r | |
1137 | "0x01111" : 15, # ******_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE\r | |
1138 | "0x10111" : 14, # TARGET_*********_ARCH_COMMANDTYPE_ATTRIBUTE\r | |
1139 | "0x00111" : 13, # ******_*********_ARCH_COMMANDTYPE_ATTRIBUTE \r | |
1140 | "0x11011" : 12, # TARGET_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE\r | |
1141 | "0x01011" : 11, # ******_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE\r | |
1142 | "0x10011" : 10, # TARGET_*********_****_COMMANDTYPE_ATTRIBUTE\r | |
1143 | "0x00011" : 9, # ******_*********_****_COMMANDTYPE_ATTRIBUTE\r | |
1144 | "0x11101" : 8, # TARGET_TOOLCHAIN_ARCH_***********_ATTRIBUTE\r | |
1145 | "0x01101" : 7, # ******_TOOLCHAIN_ARCH_***********_ATTRIBUTE\r | |
1146 | "0x10101" : 6, # TARGET_*********_ARCH_***********_ATTRIBUTE\r | |
1147 | "0x00101" : 5, # ******_*********_ARCH_***********_ATTRIBUTE\r | |
1148 | "0x11001" : 4, # TARGET_TOOLCHAIN_****_***********_ATTRIBUTE\r | |
1149 | "0x01001" : 3, # ******_TOOLCHAIN_****_***********_ATTRIBUTE\r | |
1150 | "0x10001" : 2, # TARGET_*********_****_***********_ATTRIBUTE\r | |
1151 | "0x00001" : 1} # ******_*********_****_***********_ATTRIBUTE (Lowest)\r | |
47fea6af | 1152 | \r |
b24e99f7 | 1153 | ## Initialize PlatformAutoGen\r |
52302d4d | 1154 | #\r |
52302d4d LG |
1155 | #\r |
1156 | # @param Workspace WorkspaceAutoGen object\r | |
1157 | # @param PlatformFile Platform file (DSC file)\r | |
1158 | # @param Target Build target (DEBUG, RELEASE)\r | |
1159 | # @param Toolchain Name of tool chain\r | |
1160 | # @param Arch arch of the platform supports\r | |
1161 | #\r | |
b24e99f7 | 1162 | def _InitWorker(self, Workspace, PlatformFile, Target, Toolchain, Arch):\r |
52302d4d LG |
1163 | EdkLogger.debug(EdkLogger.DEBUG_9, "AutoGen platform [%s] [%s]" % (PlatformFile, Arch))\r |
1164 | GlobalData.gProcessingFile = "%s [%s, %s, %s]" % (PlatformFile, Arch, Toolchain, Target)\r | |
1165 | \r | |
1166 | self.MetaFile = PlatformFile\r | |
1167 | self.Workspace = Workspace\r | |
1168 | self.WorkspaceDir = Workspace.WorkspaceDir\r | |
1169 | self.ToolChain = Toolchain\r | |
1170 | self.BuildTarget = Target\r | |
1171 | self.Arch = Arch\r | |
1172 | self.SourceDir = PlatformFile.SubDir\r | |
1173 | self.SourceOverrideDir = None\r | |
1174 | self.FdTargetList = self.Workspace.FdTargetList\r | |
1175 | self.FvTargetList = self.Workspace.FvTargetList\r | |
1176 | self.AllPcdList = []\r | |
a0a2cd1e FB |
1177 | # get the original module/package/platform objects\r |
1178 | self.BuildDatabase = Workspace.BuildDatabase\r | |
8518bf0b | 1179 | self.DscBuildDataObj = Workspace.Platform\r |
35f613d9 | 1180 | self._GuidDict = Workspace._GuidDict\r |
52302d4d LG |
1181 | \r |
1182 | # flag indicating if the makefile/C-code file has been created or not\r | |
1183 | self.IsMakeFileCreated = False\r | |
1184 | self.IsCodeFileCreated = False\r | |
1185 | \r | |
1186 | self._Platform = None\r | |
1187 | self._Name = None\r | |
1188 | self._Guid = None\r | |
1189 | self._Version = None\r | |
1190 | \r | |
1191 | self._BuildRule = None\r | |
1192 | self._SourceDir = None\r | |
1193 | self._BuildDir = None\r | |
1194 | self._OutputDir = None\r | |
1195 | self._FvDir = None\r | |
1196 | self._MakeFileDir = None\r | |
1197 | self._FdfFile = None\r | |
1198 | \r | |
1199 | self._PcdTokenNumber = None # (TokenCName, TokenSpaceGuidCName) : GeneratedTokenNumber\r | |
1200 | self._DynamicPcdList = None # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]\r | |
1201 | self._NonDynamicPcdList = None # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]\r | |
2bc3256c | 1202 | self._NonDynamicPcdDict = {}\r |
52302d4d LG |
1203 | \r |
1204 | self._ToolDefinitions = None\r | |
1205 | self._ToolDefFile = None # toolcode : tool path\r | |
1206 | self._ToolChainFamily = None\r | |
1207 | self._BuildRuleFamily = None\r | |
1208 | self._BuildOption = None # toolcode : option\r | |
1209 | self._EdkBuildOption = None # edktoolcode : option\r | |
1210 | self._EdkIIBuildOption = None # edkiitoolcode : option\r | |
1211 | self._PackageList = None\r | |
1212 | self._ModuleAutoGenList = None\r | |
1213 | self._LibraryAutoGenList = None\r | |
1214 | self._BuildCommand = None\r | |
a0a2cd1e FB |
1215 | self._AsBuildInfList = []\r |
1216 | self._AsBuildModuleList = []\r | |
47854fd5 LG |
1217 | \r |
1218 | self.VariableInfo = None\r | |
1219 | \r | |
4231a819 | 1220 | if GlobalData.gFdfParser is not None:\r |
a0a2cd1e FB |
1221 | self._AsBuildInfList = GlobalData.gFdfParser.Profile.InfList\r |
1222 | for Inf in self._AsBuildInfList:\r | |
1223 | InfClass = PathClass(NormPath(Inf), GlobalData.gWorkspace, self.Arch)\r | |
1224 | M = self.BuildDatabase[InfClass, self.Arch, self.BuildTarget, self.ToolChain]\r | |
1225 | if not M.IsSupportedArch:\r | |
1226 | continue\r | |
1227 | self._AsBuildModuleList.append(InfClass)\r | |
03af2753 HC |
1228 | # get library/modules for build\r |
1229 | self.LibraryBuildDirectoryList = []\r | |
1230 | self.ModuleBuildDirectoryList = []\r | |
47854fd5 | 1231 | \r |
52302d4d LG |
1232 | return True\r |
1233 | \r | |
1234 | def __repr__(self):\r | |
1235 | return "%s [%s]" % (self.MetaFile, self.Arch)\r | |
1236 | \r | |
1237 | ## Create autogen code for platform and modules\r | |
1238 | #\r | |
1239 | # Since there's no autogen code for platform, this method will do nothing\r | |
1240 | # if CreateModuleCodeFile is set to False.\r | |
1241 | #\r | |
1242 | # @param CreateModuleCodeFile Flag indicating if creating module's\r | |
1243 | # autogen code file or not\r | |
1244 | #\r | |
1245 | def CreateCodeFile(self, CreateModuleCodeFile=False):\r | |
1246 | # only module has code to be greated, so do nothing if CreateModuleCodeFile is False\r | |
1247 | if self.IsCodeFileCreated or not CreateModuleCodeFile:\r | |
1248 | return\r | |
1249 | \r | |
1250 | for Ma in self.ModuleAutoGenList:\r | |
1251 | Ma.CreateCodeFile(True)\r | |
1252 | \r | |
1253 | # don't do this twice\r | |
1254 | self.IsCodeFileCreated = True\r | |
1255 | \r | |
03af2753 HC |
1256 | ## Generate Fds Command\r |
1257 | def _GenFdsCommand(self):\r | |
1258 | return self.Workspace.GenFdsCommand\r | |
481252bb | 1259 | \r |
52302d4d LG |
1260 | ## Create makefile for the platform and mdoules in it\r |
1261 | #\r | |
1262 | # @param CreateModuleMakeFile Flag indicating if the makefile for\r | |
1263 | # modules will be created as well\r | |
1264 | #\r | |
37de70b7 | 1265 | def CreateMakeFile(self, CreateModuleMakeFile=False, FfsCommand = {}):\r |
52302d4d LG |
1266 | if CreateModuleMakeFile:\r |
1267 | for ModuleFile in self.Platform.Modules:\r | |
1268 | Ma = ModuleAutoGen(self.Workspace, ModuleFile, self.BuildTarget,\r | |
1269 | self.ToolChain, self.Arch, self.MetaFile)\r | |
37de70b7 YZ |
1270 | if (ModuleFile.File, self.Arch) in FfsCommand:\r |
1271 | Ma.CreateMakeFile(True, FfsCommand[ModuleFile.File, self.Arch])\r | |
1272 | else:\r | |
1273 | Ma.CreateMakeFile(True)\r | |
97fa0ee9 | 1274 | #Ma.CreateAsBuiltInf()\r |
52302d4d LG |
1275 | \r |
1276 | # no need to create makefile for the platform more than once\r | |
1277 | if self.IsMakeFileCreated:\r | |
1278 | return\r | |
1279 | \r | |
03af2753 | 1280 | # create library/module build dirs for platform\r |
52302d4d | 1281 | Makefile = GenMake.PlatformMakefile(self)\r |
03af2753 HC |
1282 | self.LibraryBuildDirectoryList = Makefile.GetLibraryBuildDirectoryList()\r |
1283 | self.ModuleBuildDirectoryList = Makefile.GetModuleBuildDirectoryList()\r | |
1284 | \r | |
52302d4d LG |
1285 | self.IsMakeFileCreated = True\r |
1286 | \r | |
2bc3256c LG |
1287 | ## Deal with Shared FixedAtBuild Pcds\r |
1288 | #\r | |
1289 | def CollectFixedAtBuildPcds(self):\r | |
1290 | for LibAuto in self.LibraryAutoGenList:\r | |
1291 | FixedAtBuildPcds = {} \r | |
1292 | ShareFixedAtBuildPcdsSameValue = {} \r | |
1293 | for Module in LibAuto._ReferenceModules: \r | |
8b0e6782 | 1294 | for Pcd in Module.FixedAtBuildPcds + LibAuto.FixedAtBuildPcds:\r |
2bc3256c LG |
1295 | key = ".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName)) \r |
1296 | if key not in FixedAtBuildPcds:\r | |
1297 | ShareFixedAtBuildPcdsSameValue[key] = True\r | |
1298 | FixedAtBuildPcds[key] = Pcd.DefaultValue\r | |
1299 | else:\r | |
1300 | if FixedAtBuildPcds[key] != Pcd.DefaultValue:\r | |
1301 | ShareFixedAtBuildPcdsSameValue[key] = False \r | |
1302 | for Pcd in LibAuto.FixedAtBuildPcds:\r | |
1303 | key = ".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName))\r | |
1304 | if (Pcd.TokenCName,Pcd.TokenSpaceGuidCName) not in self.NonDynamicPcdDict:\r | |
1305 | continue\r | |
1306 | else:\r | |
1307 | DscPcd = self.NonDynamicPcdDict[(Pcd.TokenCName,Pcd.TokenSpaceGuidCName)]\r | |
6b1f2cf4 | 1308 | if DscPcd.Type != TAB_PCDS_FIXED_AT_BUILD:\r |
2bc3256c LG |
1309 | continue\r |
1310 | if key in ShareFixedAtBuildPcdsSameValue and ShareFixedAtBuildPcdsSameValue[key]: \r | |
eca980c0 | 1311 | LibAuto.ConstPcd[key] = FixedAtBuildPcds[key]\r |
2bc3256c | 1312 | \r |
34952f49 | 1313 | def CollectVariables(self, DynamicPcdSet):\r |
47854fd5 LG |
1314 | \r |
1315 | VpdRegionSize = 0\r | |
1316 | VpdRegionBase = 0\r | |
1317 | if self.Workspace.FdfFile:\r | |
1318 | FdDict = self.Workspace.FdfProfile.FdDict[GlobalData.gFdfParser.CurrentFdName]\r | |
1319 | for FdRegion in FdDict.RegionList:\r | |
1320 | for item in FdRegion.RegionDataList:\r | |
1321 | if self.Platform.VpdToolGuid.strip() and self.Platform.VpdToolGuid in item:\r | |
1322 | VpdRegionSize = FdRegion.Size\r | |
1323 | VpdRegionBase = FdRegion.Offset\r | |
1324 | break\r | |
1325 | \r | |
1326 | \r | |
8518bf0b | 1327 | VariableInfo = VariableMgr(self.DscBuildDataObj._GetDefaultStores(),self.DscBuildDataObj._GetSkuIds())\r |
47854fd5 LG |
1328 | VariableInfo.SetVpdRegionMaxSize(VpdRegionSize)\r |
1329 | VariableInfo.SetVpdRegionOffset(VpdRegionBase)\r | |
34952f49 LG |
1330 | Index = 0\r |
1331 | for Pcd in DynamicPcdSet:\r | |
8518bf0b LG |
1332 | pcdname = ".".join((Pcd.TokenSpaceGuidCName,Pcd.TokenCName))\r |
1333 | for SkuName in Pcd.SkuInfoList:\r | |
1334 | Sku = Pcd.SkuInfoList[SkuName]\r | |
1335 | SkuId = Sku.SkuId\r | |
4231a819 | 1336 | if SkuId is None or SkuId == '':\r |
8518bf0b LG |
1337 | continue\r |
1338 | if len(Sku.VariableName) > 0:\r | |
1339 | VariableGuidStructure = Sku.VariableGuidValue\r | |
1340 | VariableGuid = GuidStructureStringToGuidString(VariableGuidStructure)\r | |
a3623244 | 1341 | for StorageName in Sku.DefaultStoreDict:\r |
e6bf3cfd | 1342 | VariableInfo.append_variable(var_info(Index,pcdname,StorageName,SkuName, StringToArray(Sku.VariableName),VariableGuid, Sku.VariableOffset, Sku.VariableAttribute , Sku.HiiDefaultValue,Sku.DefaultStoreDict[StorageName],Pcd.DatumType))\r |
34952f49 LG |
1343 | Index += 1\r |
1344 | return VariableInfo\r | |
47854fd5 LG |
1345 | \r |
1346 | def UpdateNVStoreMaxSize(self,OrgVpdFile):\r | |
0b6c5954 | 1347 | if self.VariableInfo:\r |
91fa33ee | 1348 | VpdMapFilePath = os.path.join(self.BuildDir, TAB_FV_DIRECTORY, "%s.map" % self.Platform.VpdToolGuid)\r |
0b6c5954 LG |
1349 | PcdNvStoreDfBuffer = [item for item in self._DynamicPcdList if item.TokenCName == "PcdNvStoreDefaultValueBuffer" and item.TokenSpaceGuidCName == "gEfiMdeModulePkgTokenSpaceGuid"]\r |
1350 | \r | |
1351 | if PcdNvStoreDfBuffer:\r | |
1352 | if os.path.exists(VpdMapFilePath):\r | |
1353 | OrgVpdFile.Read(VpdMapFilePath)\r | |
1354 | PcdItems = OrgVpdFile.GetOffset(PcdNvStoreDfBuffer[0])\r | |
8ac16789 | 1355 | NvStoreOffset = PcdItems.values()[0].strip() if PcdItems else '0'\r |
0b6c5954 LG |
1356 | else:\r |
1357 | EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)\r | |
1358 | \r | |
1359 | NvStoreOffset = int(NvStoreOffset,16) if NvStoreOffset.upper().startswith("0X") else int(NvStoreOffset)\r | |
55c84777 | 1360 | default_skuobj = PcdNvStoreDfBuffer[0].SkuInfoList.get(TAB_DEFAULT)\r |
0b6c5954 LG |
1361 | maxsize = self.VariableInfo.VpdRegionSize - NvStoreOffset if self.VariableInfo.VpdRegionSize else len(default_skuobj.DefaultValue.split(","))\r |
1362 | var_data = self.VariableInfo.PatchNVStoreDefaultMaxSize(maxsize)\r | |
1363 | \r | |
1364 | if var_data and default_skuobj:\r | |
1365 | default_skuobj.DefaultValue = var_data\r | |
1366 | PcdNvStoreDfBuffer[0].DefaultValue = var_data\r | |
1367 | PcdNvStoreDfBuffer[0].SkuInfoList.clear()\r | |
55c84777 | 1368 | PcdNvStoreDfBuffer[0].SkuInfoList[TAB_DEFAULT] = default_skuobj\r |
0b6c5954 | 1369 | PcdNvStoreDfBuffer[0].MaxDatumSize = str(len(default_skuobj.DefaultValue.split(",")))\r |
47854fd5 LG |
1370 | \r |
1371 | return OrgVpdFile\r | |
1372 | \r | |
52302d4d LG |
1373 | ## Collect dynamic PCDs\r |
1374 | #\r | |
1375 | # Gather dynamic PCDs list from each module and their settings from platform\r | |
1376 | # This interface should be invoked explicitly when platform action is created.\r | |
1377 | #\r | |
1378 | def CollectPlatformDynamicPcds(self):\r | |
763e8edf | 1379 | \r |
2a29017e YZ |
1380 | for key in self.Platform.Pcds:\r |
1381 | for SinglePcd in GlobalData.MixedPcd:\r | |
1382 | if (self.Platform.Pcds[key].TokenCName, self.Platform.Pcds[key].TokenSpaceGuidCName) == SinglePcd:\r | |
1383 | for item in GlobalData.MixedPcd[SinglePcd]:\r | |
1384 | Pcd_Type = item[0].split('_')[-1]\r | |
eece4292 CJ |
1385 | if (Pcd_Type == self.Platform.Pcds[key].Type) or (Pcd_Type == TAB_PCDS_DYNAMIC_EX and self.Platform.Pcds[key].Type in PCD_DYNAMIC_EX_TYPE_SET) or \\r |
1386 | (Pcd_Type == TAB_PCDS_DYNAMIC and self.Platform.Pcds[key].Type in PCD_DYNAMIC_TYPE_SET):\r | |
2a29017e YZ |
1387 | Value = self.Platform.Pcds[key]\r |
1388 | Value.TokenCName = self.Platform.Pcds[key].TokenCName + '_' + Pcd_Type\r | |
1389 | if len(key) == 2:\r | |
1390 | newkey = (Value.TokenCName, key[1])\r | |
1391 | elif len(key) == 3:\r | |
1392 | newkey = (Value.TokenCName, key[1], key[2])\r | |
1393 | del self.Platform.Pcds[key]\r | |
1394 | self.Platform.Pcds[newkey] = Value\r | |
1395 | break\r | |
2a29017e | 1396 | break\r |
2a29017e | 1397 | \r |
52302d4d LG |
1398 | # for gathering error information\r |
1399 | NoDatumTypePcdList = set()\r | |
a0a2cd1e FB |
1400 | FdfModuleList = []\r |
1401 | for InfName in self._AsBuildInfList:\r | |
05cc51ad | 1402 | InfName = mws.join(self.WorkspaceDir, InfName)\r |
a0a2cd1e | 1403 | FdfModuleList.append(os.path.normpath(InfName))\r |
52302d4d LG |
1404 | for F in self.Platform.Modules.keys():\r |
1405 | M = ModuleAutoGen(self.Workspace, F, self.BuildTarget, self.ToolChain, self.Arch, self.MetaFile)\r | |
1406 | #GuidValue.update(M.Guids)\r | |
1407 | \r | |
1408 | self.Platform.Modules[F].M = M\r | |
47fea6af YZ |
1409 | \r |
1410 | for PcdFromModule in M.ModulePcdList + M.LibraryPcdList:\r | |
52302d4d | 1411 | # make sure that the "VOID*" kind of datum has MaxDatumSize set\r |
c93356ad | 1412 | if PcdFromModule.DatumType == TAB_VOID and not PcdFromModule.MaxDatumSize:\r |
52302d4d LG |
1413 | NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, F))\r |
1414 | \r | |
97fa0ee9 | 1415 | # Check the PCD from Binary INF or Source INF\r |
a0a2cd1e FB |
1416 | if M.IsBinaryModule == True:\r |
1417 | PcdFromModule.IsFromBinaryInf = True\r | |
97fa0ee9 YL |
1418 | \r |
1419 | # Check the PCD from DSC or not \r | |
9eb87141 CJ |
1420 | PcdFromModule.IsFromDsc = (PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuidCName) in self.Platform.Pcds\r |
1421 | \r | |
eece4292 | 1422 | if PcdFromModule.Type in PCD_DYNAMIC_TYPE_SET or PcdFromModule.Type in PCD_DYNAMIC_EX_TYPE_SET:\r |
a0a2cd1e FB |
1423 | if F.Path not in FdfModuleList:\r |
1424 | # If one of the Source built modules listed in the DSC is not listed \r | |
1425 | # in FDF modules, and the INF lists a PCD can only use the PcdsDynamic \r | |
1426 | # access method (it is only listed in the DEC file that declares the \r | |
1427 | # PCD as PcdsDynamic), then build tool will report warning message\r | |
1428 | # notify the PI that they are attempting to build a module that must \r | |
1429 | # be included in a flash image in order to be functional. These Dynamic \r | |
1430 | # PCD will not be added into the Database unless it is used by other \r | |
1431 | # modules that are included in the FDF file.\r | |
eece4292 | 1432 | if PcdFromModule.Type in PCD_DYNAMIC_TYPE_SET and \\r |
a0a2cd1e FB |
1433 | PcdFromModule.IsFromBinaryInf == False:\r |
1434 | # Print warning message to let the developer make a determine.\r | |
a0a2cd1e FB |
1435 | continue\r |
1436 | # If one of the Source built modules listed in the DSC is not listed in \r | |
1437 | # FDF modules, and the INF lists a PCD can only use the PcdsDynamicEx \r | |
1438 | # access method (it is only listed in the DEC file that declares the \r | |
1439 | # PCD as PcdsDynamicEx), then DO NOT break the build; DO NOT add the \r | |
1440 | # PCD to the Platform's PCD Database.\r | |
eece4292 | 1441 | if PcdFromModule.Type in PCD_DYNAMIC_EX_TYPE_SET:\r |
a0a2cd1e | 1442 | continue\r |
52302d4d LG |
1443 | #\r |
1444 | # If a dynamic PCD used by a PEM module/PEI module & DXE module,\r | |
1445 | # it should be stored in Pcd PEI database, If a dynamic only\r | |
1446 | # used by DXE module, it should be stored in DXE PCD database.\r | |
1447 | # The default Phase is DXE\r | |
1448 | #\r | |
88c6c1b6 | 1449 | if M.ModuleType in SUP_MODULE_SET_PEI:\r |
52302d4d LG |
1450 | PcdFromModule.Phase = "PEI"\r |
1451 | if PcdFromModule not in self._DynaPcdList_:\r | |
1452 | self._DynaPcdList_.append(PcdFromModule)\r | |
1453 | elif PcdFromModule.Phase == 'PEI':\r | |
1454 | # overwrite any the same PCD existing, if Phase is PEI\r | |
1455 | Index = self._DynaPcdList_.index(PcdFromModule)\r | |
1456 | self._DynaPcdList_[Index] = PcdFromModule\r | |
1457 | elif PcdFromModule not in self._NonDynaPcdList_:\r | |
1458 | self._NonDynaPcdList_.append(PcdFromModule)\r | |
a0a2cd1e FB |
1459 | elif PcdFromModule in self._NonDynaPcdList_ and PcdFromModule.IsFromBinaryInf == True:\r |
1460 | Index = self._NonDynaPcdList_.index(PcdFromModule)\r | |
1461 | if self._NonDynaPcdList_[Index].IsFromBinaryInf == False:\r | |
1462 | #The PCD from Binary INF will override the same one from source INF\r | |
1463 | self._NonDynaPcdList_.remove (self._NonDynaPcdList_[Index])\r | |
1464 | PcdFromModule.Pending = False\r | |
1465 | self._NonDynaPcdList_.append (PcdFromModule)\r | |
1563349a | 1466 | DscModuleSet = {os.path.normpath(ModuleInf.Path) for ModuleInf in self.Platform.Modules}\r |
a0a2cd1e FB |
1467 | # add the PCD from modules that listed in FDF but not in DSC to Database \r |
1468 | for InfName in FdfModuleList:\r | |
1563349a | 1469 | if InfName not in DscModuleSet:\r |
a0a2cd1e FB |
1470 | InfClass = PathClass(InfName)\r |
1471 | M = self.BuildDatabase[InfClass, self.Arch, self.BuildTarget, self.ToolChain]\r | |
1472 | # If a module INF in FDF but not in current arch's DSC module list, it must be module (either binary or source) \r | |
1473 | # for different Arch. PCDs in source module for different Arch is already added before, so skip the source module here. \r | |
1474 | # For binary module, if in current arch, we need to list the PCDs into database. \r | |
1475 | if not M.IsSupportedArch:\r | |
1476 | continue\r | |
1477 | # Override the module PCD setting by platform setting\r | |
1478 | ModulePcdList = self.ApplyPcdSetting(M, M.Pcds)\r | |
1479 | for PcdFromModule in ModulePcdList:\r | |
1480 | PcdFromModule.IsFromBinaryInf = True\r | |
1481 | PcdFromModule.IsFromDsc = False\r | |
1482 | # Only allow the DynamicEx and Patchable PCD in AsBuild INF\r | |
eece4292 | 1483 | if PcdFromModule.Type not in PCD_DYNAMIC_EX_TYPE_SET and PcdFromModule.Type not in TAB_PCDS_PATCHABLE_IN_MODULE:\r |
a0a2cd1e FB |
1484 | EdkLogger.error("build", AUTOGEN_ERROR, "PCD setting error",\r |
1485 | File=self.MetaFile,\r | |
1486 | ExtraData="\n\tExisted %s PCD %s in:\n\t\t%s\n"\r | |
1487 | % (PcdFromModule.Type, PcdFromModule.TokenCName, InfName))\r | |
1488 | # make sure that the "VOID*" kind of datum has MaxDatumSize set\r | |
c93356ad | 1489 | if PcdFromModule.DatumType == TAB_VOID and not PcdFromModule.MaxDatumSize:\r |
a0a2cd1e | 1490 | NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, InfName))\r |
88c6c1b6 | 1491 | if M.ModuleType in SUP_MODULE_SET_PEI:\r |
a0a2cd1e | 1492 | PcdFromModule.Phase = "PEI"\r |
eece4292 | 1493 | if PcdFromModule not in self._DynaPcdList_ and PcdFromModule.Type in PCD_DYNAMIC_EX_TYPE_SET:\r |
a0a2cd1e FB |
1494 | self._DynaPcdList_.append(PcdFromModule)\r |
1495 | elif PcdFromModule not in self._NonDynaPcdList_ and PcdFromModule.Type in TAB_PCDS_PATCHABLE_IN_MODULE:\r | |
1496 | self._NonDynaPcdList_.append(PcdFromModule)\r | |
eece4292 | 1497 | if PcdFromModule in self._DynaPcdList_ and PcdFromModule.Phase == 'PEI' and PcdFromModule.Type in PCD_DYNAMIC_EX_TYPE_SET:\r |
97fa0ee9 YL |
1498 | # Overwrite the phase of any the same PCD existing, if Phase is PEI.\r |
1499 | # It is to solve the case that a dynamic PCD used by a PEM module/PEI \r | |
1500 | # module & DXE module at a same time.\r | |
1501 | # Overwrite the type of the PCDs in source INF by the type of AsBuild\r | |
1502 | # INF file as DynamicEx. \r | |
a0a2cd1e FB |
1503 | Index = self._DynaPcdList_.index(PcdFromModule)\r |
1504 | self._DynaPcdList_[Index].Phase = PcdFromModule.Phase\r | |
1505 | self._DynaPcdList_[Index].Type = PcdFromModule.Type\r | |
1506 | for PcdFromModule in self._NonDynaPcdList_:\r | |
1507 | # If a PCD is not listed in the DSC file, but binary INF files used by \r | |
1508 | # this platform all (that use this PCD) list the PCD in a [PatchPcds] \r | |
1509 | # section, AND all source INF files used by this platform the build \r | |
1510 | # that use the PCD list the PCD in either a [Pcds] or [PatchPcds] \r | |
1511 | # section, then the tools must NOT add the PCD to the Platform's PCD\r | |
1512 | # Database; the build must assign the access method for this PCD as \r | |
1513 | # PcdsPatchableInModule.\r | |
1514 | if PcdFromModule not in self._DynaPcdList_:\r | |
1515 | continue\r | |
1516 | Index = self._DynaPcdList_.index(PcdFromModule)\r | |
1517 | if PcdFromModule.IsFromDsc == False and \\r | |
1518 | PcdFromModule.Type in TAB_PCDS_PATCHABLE_IN_MODULE and \\r | |
1519 | PcdFromModule.IsFromBinaryInf == True and \\r | |
1520 | self._DynaPcdList_[Index].IsFromBinaryInf == False:\r | |
1521 | Index = self._DynaPcdList_.index(PcdFromModule)\r | |
1522 | self._DynaPcdList_.remove (self._DynaPcdList_[Index])\r | |
52302d4d LG |
1523 | \r |
1524 | # print out error information and break the build, if error found\r | |
1525 | if len(NoDatumTypePcdList) > 0:\r | |
1526 | NoDatumTypePcdListString = "\n\t\t".join(NoDatumTypePcdList)\r | |
1527 | EdkLogger.error("build", AUTOGEN_ERROR, "PCD setting error",\r | |
1528 | File=self.MetaFile,\r | |
1529 | ExtraData="\n\tPCD(s) without MaxDatumSize:\n\t\t%s\n"\r | |
1530 | % NoDatumTypePcdListString)\r | |
1531 | self._NonDynamicPcdList = self._NonDynaPcdList_\r | |
1532 | self._DynamicPcdList = self._DynaPcdList_\r | |
52302d4d LG |
1533 | #\r |
1534 | # Sort dynamic PCD list to:\r | |
1535 | # 1) If PCD's datum type is VOID* and value is unicode string which starts with L, the PCD item should \r | |
1536 | # try to be put header of dynamicd List\r | |
1537 | # 2) If PCD is HII type, the PCD item should be put after unicode type PCD\r | |
1538 | #\r | |
1539 | # The reason of sorting is make sure the unicode string is in double-byte alignment in string table.\r | |
1540 | #\r | |
0b6c5954 LG |
1541 | UnicodePcdArray = set()\r |
1542 | HiiPcdArray = set()\r | |
1543 | OtherPcdArray = set()\r | |
6780eef1 | 1544 | VpdPcdDict = {}\r |
e56468c0 | 1545 | VpdFile = VpdInfoFile.VpdInfoFile()\r |
61ee1dff YZ |
1546 | NeedProcessVpdMapFile = False\r |
1547 | \r | |
9eb87141 CJ |
1548 | for pcd in self.Platform.Pcds:\r |
1549 | if pcd not in self._PlatformPcds:\r | |
61ee1dff YZ |
1550 | self._PlatformPcds[pcd] = self.Platform.Pcds[pcd]\r |
1551 | \r | |
ae7b6df8 LG |
1552 | for item in self._PlatformPcds:\r |
1553 | if self._PlatformPcds[item].DatumType and self._PlatformPcds[item].DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r | |
656d2539 | 1554 | self._PlatformPcds[item].DatumType = TAB_VOID\r |
ae7b6df8 | 1555 | \r |
e56468c0 | 1556 | if (self.Workspace.ArchList[-1] == self.Arch): \r |
1557 | for Pcd in self._DynamicPcdList:\r | |
e56468c0 | 1558 | # just pick the a value to determine whether is unicode string type\r |
9eb87141 | 1559 | Sku = Pcd.SkuInfoList.values()[0]\r |
e56468c0 | 1560 | Sku.VpdOffset = Sku.VpdOffset.strip()\r |
47fea6af | 1561 | \r |
ae7b6df8 | 1562 | if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r |
656d2539 | 1563 | Pcd.DatumType = TAB_VOID\r |
ae7b6df8 | 1564 | \r |
e56468c0 | 1565 | # if found PCD which datum value is unicode string the insert to left size of UnicodeIndex\r |
e56468c0 | 1566 | # if found HII type PCD then insert to right of UnicodeIndex\r |
e56468c0 | 1567 | if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:\r |
47fea6af YZ |
1568 | VpdPcdDict[(Pcd.TokenCName, Pcd.TokenSpaceGuidCName)] = Pcd\r |
1569 | \r | |
34952f49 LG |
1570 | #Collect DynamicHii PCD values and assign it to DynamicExVpd PCD gEfiMdeModulePkgTokenSpaceGuid.PcdNvStoreDefaultValueBuffer\r |
1571 | PcdNvStoreDfBuffer = VpdPcdDict.get(("PcdNvStoreDefaultValueBuffer","gEfiMdeModulePkgTokenSpaceGuid"))\r | |
1572 | if PcdNvStoreDfBuffer:\r | |
47854fd5 | 1573 | self.VariableInfo = self.CollectVariables(self._DynamicPcdList)\r |
47854fd5 | 1574 | vardump = self.VariableInfo.dump()\r |
626bece4 | 1575 | if vardump:\r |
2b8a6c44 | 1576 | PcdNvStoreDfBuffer.DefaultValue = vardump\r |
626bece4 LG |
1577 | for skuname in PcdNvStoreDfBuffer.SkuInfoList:\r |
1578 | PcdNvStoreDfBuffer.SkuInfoList[skuname].DefaultValue = vardump\r | |
1579 | PcdNvStoreDfBuffer.MaxDatumSize = str(len(vardump.split(",")))\r | |
34952f49 | 1580 | \r |
caf74495 | 1581 | PlatformPcds = sorted(self._PlatformPcds.keys())\r |
6780eef1 LG |
1582 | #\r |
1583 | # Add VPD type PCD into VpdFile and determine whether the VPD PCD need to be fixed up.\r | |
1584 | #\r | |
626bece4 | 1585 | VpdSkuMap = {}\r |
6780eef1 | 1586 | for PcdKey in PlatformPcds:\r |
61ee1dff | 1587 | Pcd = self._PlatformPcds[PcdKey]\r |
e8a47801 LG |
1588 | if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD] and \\r |
1589 | PcdKey in VpdPcdDict:\r | |
1590 | Pcd = VpdPcdDict[PcdKey]\r | |
626bece4 | 1591 | SkuValueMap = {}\r |
55c84777 | 1592 | DefaultSku = Pcd.SkuInfoList.get(TAB_DEFAULT)\r |
8ac16789 LG |
1593 | if DefaultSku:\r |
1594 | PcdValue = DefaultSku.DefaultValue\r | |
1595 | if PcdValue not in SkuValueMap:\r | |
1596 | SkuValueMap[PcdValue] = []\r | |
55c84777 | 1597 | VpdFile.Add(Pcd, TAB_DEFAULT,DefaultSku.VpdOffset)\r |
8ac16789 LG |
1598 | SkuValueMap[PcdValue].append(DefaultSku)\r |
1599 | \r | |
e8a47801 LG |
1600 | for (SkuName,Sku) in Pcd.SkuInfoList.items():\r |
1601 | Sku.VpdOffset = Sku.VpdOffset.strip()\r | |
5a13737a YZ |
1602 | PcdValue = Sku.DefaultValue\r |
1603 | if PcdValue == "":\r | |
1604 | PcdValue = Pcd.DefaultValue\r | |
1605 | if Sku.VpdOffset != '*':\r | |
1606 | if PcdValue.startswith("{"):\r | |
1607 | Alignment = 8\r | |
1608 | elif PcdValue.startswith("L"):\r | |
1609 | Alignment = 2\r | |
1610 | else:\r | |
1611 | Alignment = 1\r | |
ca85291f YZ |
1612 | try:\r |
1613 | VpdOffset = int(Sku.VpdOffset)\r | |
1614 | except:\r | |
1615 | try:\r | |
1616 | VpdOffset = int(Sku.VpdOffset, 16)\r | |
1617 | except:\r | |
1618 | EdkLogger.error("build", FORMAT_INVALID, "Invalid offset value %s for PCD %s.%s." % (Sku.VpdOffset, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))\r | |
1619 | if VpdOffset % Alignment != 0:\r | |
815ada26 YZ |
1620 | if PcdValue.startswith("{"):\r |
1621 | EdkLogger.warn("build", "The offset value of PCD %s.%s is not 8-byte aligned!" %(Pcd.TokenSpaceGuidCName, Pcd.TokenCName), File=self.MetaFile)\r | |
1622 | else:\r | |
1623 | EdkLogger.error("build", FORMAT_INVALID, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, Alignment))\r | |
626bece4 LG |
1624 | if PcdValue not in SkuValueMap:\r |
1625 | SkuValueMap[PcdValue] = []\r | |
8ac16789 | 1626 | VpdFile.Add(Pcd, SkuName,Sku.VpdOffset)\r |
626bece4 | 1627 | SkuValueMap[PcdValue].append(Sku)\r |
e8a47801 LG |
1628 | # if the offset of a VPD is *, then it need to be fixed up by third party tool.\r |
1629 | if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":\r | |
1630 | NeedProcessVpdMapFile = True\r | |
4231a819 | 1631 | if self.Platform.VpdToolGuid is None or self.Platform.VpdToolGuid == '':\r |
e8a47801 LG |
1632 | EdkLogger.error("Build", FILE_NOT_FOUND, \\r |
1633 | "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.")\r | |
47fea6af | 1634 | \r |
626bece4 | 1635 | VpdSkuMap[PcdKey] = SkuValueMap\r |
e56468c0 | 1636 | #\r |
1637 | # Fix the PCDs define in VPD PCD section that never referenced by module.\r | |
1638 | # An example is PCD for signature usage.\r | |
6780eef1 LG |
1639 | # \r |
1640 | for DscPcd in PlatformPcds:\r | |
61ee1dff | 1641 | DscPcdEntry = self._PlatformPcds[DscPcd]\r |
e56468c0 | 1642 | if DscPcdEntry.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:\r |
4231a819 | 1643 | if not (self.Platform.VpdToolGuid is None or self.Platform.VpdToolGuid == ''):\r |
e56468c0 | 1644 | FoundFlag = False\r |
9eb87141 | 1645 | for VpdPcd in VpdFile._VpdArray:\r |
e56468c0 | 1646 | # This PCD has been referenced by module\r |
1647 | if (VpdPcd.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \\r | |
1648 | (VpdPcd.TokenCName == DscPcdEntry.TokenCName):\r | |
1649 | FoundFlag = True\r | |
47fea6af | 1650 | \r |
e56468c0 | 1651 | # Not found, it should be signature\r |
1652 | if not FoundFlag :\r | |
1653 | # just pick the a value to determine whether is unicode string type\r | |
626bece4 | 1654 | SkuValueMap = {}\r |
e827d21d | 1655 | SkuObjList = DscPcdEntry.SkuInfoList.items()\r |
55c84777 | 1656 | DefaultSku = DscPcdEntry.SkuInfoList.get(TAB_DEFAULT)\r |
8ac16789 | 1657 | if DefaultSku:\r |
55c84777 | 1658 | defaultindex = SkuObjList.index((TAB_DEFAULT,DefaultSku))\r |
e827d21d B |
1659 | SkuObjList[0],SkuObjList[defaultindex] = SkuObjList[defaultindex],SkuObjList[0]\r |
1660 | for (SkuName,Sku) in SkuObjList:\r | |
e8a47801 LG |
1661 | Sku.VpdOffset = Sku.VpdOffset.strip() \r |
1662 | \r | |
1663 | # Need to iterate DEC pcd information to get the value & datumtype\r | |
1664 | for eachDec in self.PackageList:\r | |
1665 | for DecPcd in eachDec.Pcds:\r | |
1666 | DecPcdEntry = eachDec.Pcds[DecPcd]\r | |
1667 | if (DecPcdEntry.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \\r | |
1668 | (DecPcdEntry.TokenCName == DscPcdEntry.TokenCName):\r | |
1669 | # Print warning message to let the developer make a determine.\r | |
1670 | EdkLogger.warn("build", "Unreferenced vpd pcd used!",\r | |
1671 | File=self.MetaFile, \\r | |
1672 | ExtraData = "PCD: %s.%s used in the DSC file %s is unreferenced." \\r | |
1673 | %(DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, self.Platform.MetaFile.Path)) \r | |
1674 | \r | |
1675 | DscPcdEntry.DatumType = DecPcdEntry.DatumType\r | |
1676 | DscPcdEntry.DefaultValue = DecPcdEntry.DefaultValue\r | |
1677 | DscPcdEntry.TokenValue = DecPcdEntry.TokenValue\r | |
1678 | DscPcdEntry.TokenSpaceGuidValue = eachDec.Guids[DecPcdEntry.TokenSpaceGuidCName]\r | |
1679 | # Only fix the value while no value provided in DSC file.\r | |
128d435f | 1680 | if not Sku.DefaultValue:\r |
e8a47801 LG |
1681 | DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]].DefaultValue = DecPcdEntry.DefaultValue\r |
1682 | \r | |
1683 | if DscPcdEntry not in self._DynamicPcdList:\r | |
1684 | self._DynamicPcdList.append(DscPcdEntry)\r | |
e8a47801 LG |
1685 | Sku.VpdOffset = Sku.VpdOffset.strip()\r |
1686 | PcdValue = Sku.DefaultValue\r | |
5a13737a YZ |
1687 | if PcdValue == "":\r |
1688 | PcdValue = DscPcdEntry.DefaultValue\r | |
1689 | if Sku.VpdOffset != '*':\r | |
1690 | if PcdValue.startswith("{"):\r | |
1691 | Alignment = 8\r | |
1692 | elif PcdValue.startswith("L"):\r | |
1693 | Alignment = 2\r | |
1694 | else:\r | |
1695 | Alignment = 1\r | |
ca85291f YZ |
1696 | try:\r |
1697 | VpdOffset = int(Sku.VpdOffset)\r | |
1698 | except:\r | |
1699 | try:\r | |
1700 | VpdOffset = int(Sku.VpdOffset, 16)\r | |
1701 | except:\r | |
1702 | EdkLogger.error("build", FORMAT_INVALID, "Invalid offset value %s for PCD %s.%s." % (Sku.VpdOffset, DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName))\r | |
1703 | if VpdOffset % Alignment != 0:\r | |
815ada26 YZ |
1704 | if PcdValue.startswith("{"):\r |
1705 | EdkLogger.warn("build", "The offset value of PCD %s.%s is not 8-byte aligned!" %(DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName), File=self.MetaFile)\r | |
1706 | else:\r | |
1707 | EdkLogger.error("build", FORMAT_INVALID, 'The offset value of PCD %s.%s should be %s-byte aligned.' % (DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, Alignment))\r | |
626bece4 LG |
1708 | if PcdValue not in SkuValueMap:\r |
1709 | SkuValueMap[PcdValue] = []\r | |
8ac16789 | 1710 | VpdFile.Add(DscPcdEntry, SkuName,Sku.VpdOffset)\r |
626bece4 | 1711 | SkuValueMap[PcdValue].append(Sku)\r |
e8a47801 LG |
1712 | if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":\r |
1713 | NeedProcessVpdMapFile = True \r | |
656d2539 | 1714 | if DscPcdEntry.DatumType == TAB_VOID and PcdValue.startswith("L"):\r |
0b6c5954 | 1715 | UnicodePcdArray.add(DscPcdEntry)\r |
e8a47801 | 1716 | elif len(Sku.VariableName) > 0:\r |
0b6c5954 | 1717 | HiiPcdArray.add(DscPcdEntry)\r |
e8a47801 | 1718 | else:\r |
0b6c5954 LG |
1719 | OtherPcdArray.add(DscPcdEntry)\r |
1720 | \r | |
e8a47801 | 1721 | # if the offset of a VPD is *, then it need to be fixed up by third party tool.\r |
626bece4 | 1722 | VpdSkuMap[DscPcd] = SkuValueMap\r |
4231a819 | 1723 | if (self.Platform.FlashDefinition is None or self.Platform.FlashDefinition == '') and \\r |
e56468c0 | 1724 | VpdFile.GetCount() != 0:\r |
1725 | EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, \r | |
1726 | "Fail to get FLASH_DEFINITION definition in DSC file %s which is required when DSC contains VPD PCD." % str(self.Platform.MetaFile))\r | |
47fea6af | 1727 | \r |
e56468c0 | 1728 | if VpdFile.GetCount() != 0:\r |
47854fd5 LG |
1729 | \r |
1730 | self.FixVpdOffset(VpdFile)\r | |
1731 | \r | |
1732 | self.FixVpdOffset(self.UpdateNVStoreMaxSize(VpdFile))\r | |
47fea6af | 1733 | \r |
e56468c0 | 1734 | # Process VPD map file generated by third party BPDG tool\r |
1735 | if NeedProcessVpdMapFile:\r | |
91fa33ee | 1736 | VpdMapFilePath = os.path.join(self.BuildDir, TAB_FV_DIRECTORY, "%s.map" % self.Platform.VpdToolGuid)\r |
e56468c0 | 1737 | if os.path.exists(VpdMapFilePath):\r |
1738 | VpdFile.Read(VpdMapFilePath)\r | |
47fea6af | 1739 | \r |
e56468c0 | 1740 | # Fixup "*" offset\r |
626bece4 LG |
1741 | for pcd in VpdSkuMap:\r |
1742 | vpdinfo = VpdFile.GetVpdInfo(pcd)\r | |
1743 | if vpdinfo is None:\r | |
e56468c0 | 1744 | # just pick the a value to determine whether is unicode string type\r |
626bece4 LG |
1745 | continue\r |
1746 | for pcdvalue in VpdSkuMap[pcd]:\r | |
1747 | for sku in VpdSkuMap[pcd][pcdvalue]:\r | |
1748 | for item in vpdinfo:\r | |
1749 | if item[2] == pcdvalue:\r | |
1750 | sku.VpdOffset = item[1]\r | |
e56468c0 | 1751 | else:\r |
1752 | EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)\r | |
47fea6af | 1753 | \r |
626bece4 LG |
1754 | # Delete the DynamicPcdList At the last time enter into this function\r |
1755 | for Pcd in self._DynamicPcdList:\r | |
1756 | # just pick the a value to determine whether is unicode string type\r | |
9eb87141 | 1757 | Sku = Pcd.SkuInfoList.values()[0]\r |
626bece4 LG |
1758 | Sku.VpdOffset = Sku.VpdOffset.strip()\r |
1759 | \r | |
1760 | if Pcd.DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r | |
656d2539 | 1761 | Pcd.DatumType = TAB_VOID\r |
626bece4 LG |
1762 | \r |
1763 | PcdValue = Sku.DefaultValue\r | |
656d2539 | 1764 | if Pcd.DatumType == TAB_VOID and PcdValue.startswith("L"):\r |
626bece4 | 1765 | # if found PCD which datum value is unicode string the insert to left size of UnicodeIndex\r |
0b6c5954 | 1766 | UnicodePcdArray.add(Pcd)\r |
626bece4 LG |
1767 | elif len(Sku.VariableName) > 0:\r |
1768 | # if found HII type PCD then insert to right of UnicodeIndex\r | |
0b6c5954 | 1769 | HiiPcdArray.add(Pcd)\r |
626bece4 | 1770 | else:\r |
0b6c5954 | 1771 | OtherPcdArray.add(Pcd)\r |
47fea6af | 1772 | del self._DynamicPcdList[:]\r |
0b6c5954 LG |
1773 | self._DynamicPcdList.extend(list(UnicodePcdArray))\r |
1774 | self._DynamicPcdList.extend(list(HiiPcdArray))\r | |
1775 | self._DynamicPcdList.extend(list(OtherPcdArray))\r | |
2b8a6c44 LG |
1776 | allskuset = [(SkuName,Sku.SkuId) for pcd in self._DynamicPcdList for (SkuName,Sku) in pcd.SkuInfoList.items()]\r |
1777 | for pcd in self._DynamicPcdList:\r | |
1778 | if len(pcd.SkuInfoList) == 1:\r | |
1779 | for (SkuName,SkuId) in allskuset:\r | |
1780 | if type(SkuId) in (str,unicode) and eval(SkuId) == 0 or SkuId == 0:\r | |
1781 | continue\r | |
55c84777 | 1782 | pcd.SkuInfoList[SkuName] = copy.deepcopy(pcd.SkuInfoList[TAB_DEFAULT])\r |
65eff519 | 1783 | pcd.SkuInfoList[SkuName].SkuId = SkuId\r |
a0a2cd1e | 1784 | self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList\r |
47854fd5 LG |
1785 | \r |
1786 | def FixVpdOffset(self,VpdFile ):\r | |
91fa33ee | 1787 | FvPath = os.path.join(self.BuildDir, TAB_FV_DIRECTORY)\r |
47854fd5 LG |
1788 | if not os.path.exists(FvPath):\r |
1789 | try:\r | |
1790 | os.makedirs(FvPath)\r | |
1791 | except:\r | |
1792 | EdkLogger.error("build", FILE_WRITE_FAILURE, "Fail to create FV folder under %s" % self.BuildDir)\r | |
1793 | \r | |
1794 | VpdFilePath = os.path.join(FvPath, "%s.txt" % self.Platform.VpdToolGuid)\r | |
1795 | \r | |
1796 | if VpdFile.Write(VpdFilePath):\r | |
1797 | # retrieve BPDG tool's path from tool_def.txt according to VPD_TOOL_GUID defined in DSC file.\r | |
1798 | BPDGToolName = None\r | |
1799 | for ToolDef in self.ToolDefinition.values():\r | |
91fa33ee | 1800 | if ToolDef.has_key(TAB_GUID) and ToolDef[TAB_GUID] == self.Platform.VpdToolGuid:\r |
47854fd5 LG |
1801 | if not ToolDef.has_key("PATH"):\r |
1802 | EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "PATH attribute was not provided for BPDG guid tool %s in tools_def.txt" % self.Platform.VpdToolGuid)\r | |
1803 | BPDGToolName = ToolDef["PATH"]\r | |
1804 | break\r | |
1805 | # Call third party GUID BPDG tool.\r | |
4231a819 | 1806 | if BPDGToolName is not None:\r |
47854fd5 LG |
1807 | VpdInfoFile.CallExtenalBPDGTool(BPDGToolName, VpdFilePath)\r |
1808 | else:\r | |
1809 | 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.")\r | |
1810 | \r | |
52302d4d LG |
1811 | ## Return the platform build data object\r |
1812 | def _GetPlatform(self):\r | |
4231a819 | 1813 | if self._Platform is None:\r |
0d2711a6 | 1814 | self._Platform = self.BuildDatabase[self.MetaFile, self.Arch, self.BuildTarget, self.ToolChain]\r |
52302d4d LG |
1815 | return self._Platform\r |
1816 | \r | |
1817 | ## Return platform name\r | |
1818 | def _GetName(self):\r | |
1819 | return self.Platform.PlatformName\r | |
1820 | \r | |
1821 | ## Return the meta file GUID\r | |
1822 | def _GetGuid(self):\r | |
1823 | return self.Platform.Guid\r | |
1824 | \r | |
1825 | ## Return the platform version\r | |
1826 | def _GetVersion(self):\r | |
1827 | return self.Platform.Version\r | |
1828 | \r | |
1829 | ## Return the FDF file name\r | |
1830 | def _GetFdfFile(self):\r | |
4231a819 | 1831 | if self._FdfFile is None:\r |
52302d4d | 1832 | if self.Workspace.FdfFile != "":\r |
05cc51ad | 1833 | self._FdfFile= mws.join(self.WorkspaceDir, self.Workspace.FdfFile)\r |
52302d4d LG |
1834 | else:\r |
1835 | self._FdfFile = ''\r | |
1836 | return self._FdfFile\r | |
1837 | \r | |
1838 | ## Return the build output directory platform specifies\r | |
1839 | def _GetOutputDir(self):\r | |
1840 | return self.Platform.OutputDirectory\r | |
1841 | \r | |
1842 | ## Return the directory to store all intermediate and final files built\r | |
1843 | def _GetBuildDir(self):\r | |
4231a819 | 1844 | if self._BuildDir is None:\r |
52302d4d LG |
1845 | if os.path.isabs(self.OutputDir):\r |
1846 | self._BuildDir = path.join(\r | |
1847 | path.abspath(self.OutputDir),\r | |
1848 | self.BuildTarget + "_" + self.ToolChain,\r | |
1849 | )\r | |
1850 | else:\r | |
1851 | self._BuildDir = path.join(\r | |
1852 | self.WorkspaceDir,\r | |
1853 | self.OutputDir,\r | |
1854 | self.BuildTarget + "_" + self.ToolChain,\r | |
1855 | )\r | |
97058144 | 1856 | GlobalData.gBuildDirectory = self._BuildDir\r |
52302d4d LG |
1857 | return self._BuildDir\r |
1858 | \r | |
1859 | ## Return directory of platform makefile\r | |
1860 | #\r | |
1861 | # @retval string Makefile directory\r | |
1862 | #\r | |
1863 | def _GetMakeFileDir(self):\r | |
4231a819 | 1864 | if self._MakeFileDir is None:\r |
52302d4d LG |
1865 | self._MakeFileDir = path.join(self.BuildDir, self.Arch)\r |
1866 | return self._MakeFileDir\r | |
1867 | \r | |
1868 | ## Return build command string\r | |
1869 | #\r | |
1870 | # @retval string Build command string\r | |
1871 | #\r | |
1872 | def _GetBuildCommand(self):\r | |
4231a819 | 1873 | if self._BuildCommand is None:\r |
52302d4d LG |
1874 | self._BuildCommand = []\r |
1875 | if "MAKE" in self.ToolDefinition and "PATH" in self.ToolDefinition["MAKE"]:\r | |
1876 | self._BuildCommand += SplitOption(self.ToolDefinition["MAKE"]["PATH"])\r | |
1877 | if "FLAGS" in self.ToolDefinition["MAKE"]:\r | |
1878 | NewOption = self.ToolDefinition["MAKE"]["FLAGS"].strip()\r | |
1879 | if NewOption != '':\r | |
6780eef1 | 1880 | self._BuildCommand += SplitOption(NewOption)\r |
02a908fc YZ |
1881 | if "MAKE" in self.EdkIIBuildOption:\r |
1882 | if "FLAGS" in self.EdkIIBuildOption["MAKE"]:\r | |
1883 | Flags = self.EdkIIBuildOption["MAKE"]["FLAGS"]\r | |
1884 | if Flags.startswith('='):\r | |
1885 | self._BuildCommand = [self._BuildCommand[0]] + [Flags[1:]]\r | |
1886 | else:\r | |
caf74495 | 1887 | self._BuildCommand.append(Flags)\r |
52302d4d LG |
1888 | return self._BuildCommand\r |
1889 | \r | |
1890 | ## Get tool chain definition\r | |
1891 | #\r | |
1892 | # Get each tool defition for given tool chain from tools_def.txt and platform\r | |
1893 | #\r | |
1894 | def _GetToolDefinition(self):\r | |
4231a819 | 1895 | if self._ToolDefinitions is None:\r |
52302d4d LG |
1896 | ToolDefinition = self.Workspace.ToolDef.ToolsDefTxtDictionary\r |
1897 | if TAB_TOD_DEFINES_COMMAND_TYPE not in self.Workspace.ToolDef.ToolsDefTxtDatabase:\r | |
1898 | EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "No tools found in configuration",\r | |
1899 | ExtraData="[%s]" % self.MetaFile)\r | |
1900 | self._ToolDefinitions = {}\r | |
1901 | DllPathList = set()\r | |
1902 | for Def in ToolDefinition:\r | |
1903 | Target, Tag, Arch, Tool, Attr = Def.split("_")\r | |
1904 | if Target != self.BuildTarget or Tag != self.ToolChain or Arch != self.Arch:\r | |
1905 | continue\r | |
1906 | \r | |
1907 | Value = ToolDefinition[Def]\r | |
1908 | # don't record the DLL\r | |
1909 | if Attr == "DLL":\r | |
1910 | DllPathList.add(Value)\r | |
1911 | continue\r | |
1912 | \r | |
1913 | if Tool not in self._ToolDefinitions:\r | |
1914 | self._ToolDefinitions[Tool] = {}\r | |
1915 | self._ToolDefinitions[Tool][Attr] = Value\r | |
1916 | \r | |
1917 | ToolsDef = ''\r | |
52302d4d LG |
1918 | if GlobalData.gOptions.SilentMode and "MAKE" in self._ToolDefinitions:\r |
1919 | if "FLAGS" not in self._ToolDefinitions["MAKE"]:\r | |
1920 | self._ToolDefinitions["MAKE"]["FLAGS"] = ""\r | |
1921 | self._ToolDefinitions["MAKE"]["FLAGS"] += " -s"\r | |
1922 | MakeFlags = ''\r | |
1923 | for Tool in self._ToolDefinitions:\r | |
1924 | for Attr in self._ToolDefinitions[Tool]:\r | |
1925 | Value = self._ToolDefinitions[Tool][Attr]\r | |
1926 | if Tool in self.BuildOption and Attr in self.BuildOption[Tool]:\r | |
1927 | # check if override is indicated\r | |
1928 | if self.BuildOption[Tool][Attr].startswith('='):\r | |
1929 | Value = self.BuildOption[Tool][Attr][1:]\r | |
1930 | else:\r | |
95816356 YZ |
1931 | if Attr != 'PATH':\r |
1932 | Value += " " + self.BuildOption[Tool][Attr]\r | |
1933 | else:\r | |
1934 | Value = self.BuildOption[Tool][Attr]\r | |
52302d4d LG |
1935 | \r |
1936 | if Attr == "PATH":\r | |
1937 | # Don't put MAKE definition in the file\r | |
d98cce8e | 1938 | if Tool != "MAKE":\r |
52302d4d LG |
1939 | ToolsDef += "%s = %s\n" % (Tool, Value)\r |
1940 | elif Attr != "DLL":\r | |
1941 | # Don't put MAKE definition in the file\r | |
1942 | if Tool == "MAKE":\r | |
1943 | if Attr == "FLAGS":\r | |
1944 | MakeFlags = Value\r | |
1945 | else:\r | |
1946 | ToolsDef += "%s_%s = %s\n" % (Tool, Attr, Value)\r | |
1947 | ToolsDef += "\n"\r | |
1948 | \r | |
1949 | SaveFileOnChange(self.ToolDefinitionFile, ToolsDef)\r | |
1950 | for DllPath in DllPathList:\r | |
1951 | os.environ["PATH"] = DllPath + os.pathsep + os.environ["PATH"]\r | |
1952 | os.environ["MAKE_FLAGS"] = MakeFlags\r | |
1953 | \r | |
1954 | return self._ToolDefinitions\r | |
1955 | \r | |
1956 | ## Return the paths of tools\r | |
1957 | def _GetToolDefFile(self):\r | |
4231a819 | 1958 | if self._ToolDefFile is None:\r |
52302d4d LG |
1959 | self._ToolDefFile = os.path.join(self.MakeFileDir, "TOOLS_DEF." + self.Arch)\r |
1960 | return self._ToolDefFile\r | |
1961 | \r | |
1962 | ## Retrieve the toolchain family of given toolchain tag. Default to 'MSFT'.\r | |
1963 | def _GetToolChainFamily(self):\r | |
4231a819 | 1964 | if self._ToolChainFamily is None:\r |
52302d4d LG |
1965 | ToolDefinition = self.Workspace.ToolDef.ToolsDefTxtDatabase\r |
1966 | if TAB_TOD_DEFINES_FAMILY not in ToolDefinition \\r | |
1967 | or self.ToolChain not in ToolDefinition[TAB_TOD_DEFINES_FAMILY] \\r | |
1968 | or not ToolDefinition[TAB_TOD_DEFINES_FAMILY][self.ToolChain]:\r | |
1969 | EdkLogger.verbose("No tool chain family found in configuration for %s. Default to MSFT." \\r | |
1970 | % self.ToolChain)\r | |
1971 | self._ToolChainFamily = "MSFT"\r | |
1972 | else:\r | |
1973 | self._ToolChainFamily = ToolDefinition[TAB_TOD_DEFINES_FAMILY][self.ToolChain]\r | |
1974 | return self._ToolChainFamily\r | |
1975 | \r | |
1976 | def _GetBuildRuleFamily(self):\r | |
4231a819 | 1977 | if self._BuildRuleFamily is None:\r |
52302d4d LG |
1978 | ToolDefinition = self.Workspace.ToolDef.ToolsDefTxtDatabase\r |
1979 | if TAB_TOD_DEFINES_BUILDRULEFAMILY not in ToolDefinition \\r | |
1980 | or self.ToolChain not in ToolDefinition[TAB_TOD_DEFINES_BUILDRULEFAMILY] \\r | |
1981 | or not ToolDefinition[TAB_TOD_DEFINES_BUILDRULEFAMILY][self.ToolChain]:\r | |
1982 | EdkLogger.verbose("No tool chain family found in configuration for %s. Default to MSFT." \\r | |
1983 | % self.ToolChain)\r | |
1984 | self._BuildRuleFamily = "MSFT"\r | |
1985 | else:\r | |
1986 | self._BuildRuleFamily = ToolDefinition[TAB_TOD_DEFINES_BUILDRULEFAMILY][self.ToolChain]\r | |
1987 | return self._BuildRuleFamily\r | |
1988 | \r | |
1989 | ## Return the build options specific for all modules in this platform\r | |
1990 | def _GetBuildOptions(self):\r | |
4231a819 | 1991 | if self._BuildOption is None:\r |
52302d4d LG |
1992 | self._BuildOption = self._ExpandBuildOption(self.Platform.BuildOptions)\r |
1993 | return self._BuildOption\r | |
1994 | \r | |
1995 | ## Return the build options specific for EDK modules in this platform\r | |
1996 | def _GetEdkBuildOptions(self):\r | |
4231a819 | 1997 | if self._EdkBuildOption is None:\r |
52302d4d LG |
1998 | self._EdkBuildOption = self._ExpandBuildOption(self.Platform.BuildOptions, EDK_NAME)\r |
1999 | return self._EdkBuildOption\r | |
2000 | \r | |
2001 | ## Return the build options specific for EDKII modules in this platform\r | |
2002 | def _GetEdkIIBuildOptions(self):\r | |
4231a819 | 2003 | if self._EdkIIBuildOption is None:\r |
52302d4d LG |
2004 | self._EdkIIBuildOption = self._ExpandBuildOption(self.Platform.BuildOptions, EDKII_NAME)\r |
2005 | return self._EdkIIBuildOption\r | |
2006 | \r | |
97fa0ee9 | 2007 | ## Parse build_rule.txt in Conf Directory.\r |
52302d4d LG |
2008 | #\r |
2009 | # @retval BuildRule object\r | |
2010 | #\r | |
2011 | def _GetBuildRule(self):\r | |
4231a819 | 2012 | if self._BuildRule is None:\r |
52302d4d LG |
2013 | BuildRuleFile = None\r |
2014 | if TAB_TAT_DEFINES_BUILD_RULE_CONF in self.Workspace.TargetTxt.TargetTxtDictionary:\r | |
2015 | BuildRuleFile = self.Workspace.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_BUILD_RULE_CONF]\r | |
c93356ad | 2016 | if not BuildRuleFile:\r |
97fa0ee9 | 2017 | BuildRuleFile = gDefaultBuildRuleFile\r |
52302d4d | 2018 | self._BuildRule = BuildRule(BuildRuleFile)\r |
64b2609f LG |
2019 | if self._BuildRule._FileVersion == "":\r |
2020 | self._BuildRule._FileVersion = AutoGenReqBuildRuleVerNum\r | |
2021 | else:\r | |
2022 | if self._BuildRule._FileVersion < AutoGenReqBuildRuleVerNum :\r | |
2023 | # If Build Rule's version is less than the version number required by the tools, halting the build.\r | |
47fea6af | 2024 | EdkLogger.error("build", AUTOGEN_ERROR,\r |
64b2609f LG |
2025 | 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])"\\r |
2026 | % (self._BuildRule._FileVersion, AutoGenReqBuildRuleVerNum))\r | |
47fea6af | 2027 | \r |
52302d4d LG |
2028 | return self._BuildRule\r |
2029 | \r | |
2030 | ## Summarize the packages used by modules in this platform\r | |
2031 | def _GetPackageList(self):\r | |
4231a819 | 2032 | if self._PackageList is None:\r |
52302d4d LG |
2033 | self._PackageList = set()\r |
2034 | for La in self.LibraryAutoGenList:\r | |
2035 | self._PackageList.update(La.DependentPackageList)\r | |
2036 | for Ma in self.ModuleAutoGenList:\r | |
2037 | self._PackageList.update(Ma.DependentPackageList)\r | |
a0a2cd1e FB |
2038 | #Collect package set information from INF of FDF\r |
2039 | PkgSet = set()\r | |
2040 | for ModuleFile in self._AsBuildModuleList:\r | |
2041 | if ModuleFile in self.Platform.Modules:\r | |
2042 | continue\r | |
2043 | ModuleData = self.BuildDatabase[ModuleFile, self.Arch, self.BuildTarget, self.ToolChain]\r | |
2044 | PkgSet.update(ModuleData.Packages)\r | |
2045 | self._PackageList = list(self._PackageList) + list (PkgSet)\r | |
52302d4d LG |
2046 | return self._PackageList\r |
2047 | \r | |
2bc3256c LG |
2048 | def _GetNonDynamicPcdDict(self):\r |
2049 | if self._NonDynamicPcdDict:\r | |
2050 | return self._NonDynamicPcdDict\r | |
2051 | for Pcd in self.NonDynamicPcdList:\r | |
2052 | self._NonDynamicPcdDict[(Pcd.TokenCName,Pcd.TokenSpaceGuidCName)] = Pcd\r | |
2053 | return self._NonDynamicPcdDict\r | |
2054 | \r | |
52302d4d LG |
2055 | ## Get list of non-dynamic PCDs\r |
2056 | def _GetNonDynamicPcdList(self):\r | |
4231a819 | 2057 | if self._NonDynamicPcdList is None:\r |
e56468c0 | 2058 | self.CollectPlatformDynamicPcds()\r |
52302d4d LG |
2059 | return self._NonDynamicPcdList\r |
2060 | \r | |
2061 | ## Get list of dynamic PCDs\r | |
2062 | def _GetDynamicPcdList(self):\r | |
4231a819 | 2063 | if self._DynamicPcdList is None:\r |
e56468c0 | 2064 | self.CollectPlatformDynamicPcds()\r |
52302d4d LG |
2065 | return self._DynamicPcdList\r |
2066 | \r | |
2067 | ## Generate Token Number for all PCD\r | |
2068 | def _GetPcdTokenNumbers(self):\r | |
4231a819 | 2069 | if self._PcdTokenNumber is None:\r |
9006a2c6 | 2070 | self._PcdTokenNumber = OrderedDict()\r |
52302d4d | 2071 | TokenNumber = 1\r |
d0acc87a LG |
2072 | #\r |
2073 | # Make the Dynamic and DynamicEx PCD use within different TokenNumber area. \r | |
2074 | # Such as:\r | |
2075 | # \r | |
2076 | # Dynamic PCD:\r | |
2077 | # TokenNumber 0 ~ 10\r | |
2078 | # DynamicEx PCD:\r | |
2079 | # TokeNumber 11 ~ 20\r | |
2080 | #\r | |
52302d4d | 2081 | for Pcd in self.DynamicPcdList:\r |
caf74495 JC |
2082 | if Pcd.Phase == "PEI" and Pcd.Type in PCD_DYNAMIC_TYPE_SET:\r |
2083 | EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))\r | |
2084 | self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber\r | |
2085 | TokenNumber += 1\r | |
47fea6af | 2086 | \r |
d0acc87a | 2087 | for Pcd in self.DynamicPcdList:\r |
caf74495 JC |
2088 | if Pcd.Phase == "PEI" and Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET:\r |
2089 | EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))\r | |
2090 | self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber\r | |
2091 | TokenNumber += 1\r | |
47fea6af | 2092 | \r |
52302d4d | 2093 | for Pcd in self.DynamicPcdList:\r |
caf74495 JC |
2094 | if Pcd.Phase == "DXE" and Pcd.Type in PCD_DYNAMIC_TYPE_SET:\r |
2095 | EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))\r | |
2096 | self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber\r | |
2097 | TokenNumber += 1\r | |
47fea6af | 2098 | \r |
d0acc87a | 2099 | for Pcd in self.DynamicPcdList:\r |
caf74495 JC |
2100 | if Pcd.Phase == "DXE" and Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET:\r |
2101 | EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))\r | |
2102 | self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber\r | |
2103 | TokenNumber += 1\r | |
47fea6af | 2104 | \r |
52302d4d LG |
2105 | for Pcd in self.NonDynamicPcdList:\r |
2106 | self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber\r | |
2107 | TokenNumber += 1\r | |
2108 | return self._PcdTokenNumber\r | |
2109 | \r | |
2110 | ## Summarize ModuleAutoGen objects of all modules/libraries to be built for this platform\r | |
2111 | def _GetAutoGenObjectList(self):\r | |
2112 | self._ModuleAutoGenList = []\r | |
2113 | self._LibraryAutoGenList = []\r | |
2114 | for ModuleFile in self.Platform.Modules:\r | |
2115 | Ma = ModuleAutoGen(\r | |
2116 | self.Workspace,\r | |
2117 | ModuleFile,\r | |
2118 | self.BuildTarget,\r | |
2119 | self.ToolChain,\r | |
2120 | self.Arch,\r | |
2121 | self.MetaFile\r | |
2122 | )\r | |
2123 | if Ma not in self._ModuleAutoGenList:\r | |
2124 | self._ModuleAutoGenList.append(Ma)\r | |
2125 | for La in Ma.LibraryAutoGenList:\r | |
2126 | if La not in self._LibraryAutoGenList:\r | |
2127 | self._LibraryAutoGenList.append(La)\r | |
2bc3256c LG |
2128 | if Ma not in La._ReferenceModules:\r |
2129 | La._ReferenceModules.append(Ma)\r | |
52302d4d LG |
2130 | \r |
2131 | ## Summarize ModuleAutoGen objects of all modules to be built for this platform\r | |
2132 | def _GetModuleAutoGenList(self):\r | |
4231a819 | 2133 | if self._ModuleAutoGenList is None:\r |
52302d4d LG |
2134 | self._GetAutoGenObjectList()\r |
2135 | return self._ModuleAutoGenList\r | |
2136 | \r | |
2137 | ## Summarize ModuleAutoGen objects of all libraries to be built for this platform\r | |
2138 | def _GetLibraryAutoGenList(self):\r | |
4231a819 | 2139 | if self._LibraryAutoGenList is None:\r |
52302d4d LG |
2140 | self._GetAutoGenObjectList()\r |
2141 | return self._LibraryAutoGenList\r | |
2142 | \r | |
2143 | ## Test if a module is supported by the platform\r | |
2144 | #\r | |
2145 | # An error will be raised directly if the module or its arch is not supported\r | |
2146 | # by the platform or current configuration\r | |
2147 | #\r | |
2148 | def ValidModule(self, Module):\r | |
a0a2cd1e FB |
2149 | return Module in self.Platform.Modules or Module in self.Platform.LibraryInstances \\r |
2150 | or Module in self._AsBuildModuleList\r | |
52302d4d LG |
2151 | \r |
2152 | ## Resolve the library classes in a module to library instances\r | |
2153 | #\r | |
2154 | # This method will not only resolve library classes but also sort the library\r | |
2155 | # instances according to the dependency-ship.\r | |
2156 | #\r | |
2157 | # @param Module The module from which the library classes will be resolved\r | |
2158 | #\r | |
2159 | # @retval library_list List of library instances sorted\r | |
2160 | #\r | |
2161 | def ApplyLibraryInstance(self, Module):\r | |
25193a33 YZ |
2162 | # Cover the case that the binary INF file is list in the FDF file but not DSC file, return empty list directly\r |
2163 | if str(Module) not in self.Platform.Modules:\r | |
2164 | return []\r | |
2165 | \r | |
c14b5861 JC |
2166 | return GetModuleLibInstances(Module,\r |
2167 | self.Platform,\r | |
2168 | self.BuildDatabase,\r | |
2169 | self.Arch,\r | |
2170 | self.BuildTarget,\r | |
2171 | self.ToolChain,\r | |
2172 | self.MetaFile,\r | |
2173 | EdkLogger)\r | |
52302d4d LG |
2174 | \r |
2175 | ## Override PCD setting (type, value, ...)\r | |
2176 | #\r | |
2177 | # @param ToPcd The PCD to be overrided\r | |
2178 | # @param FromPcd The PCD overrideing from\r | |
2179 | #\r | |
a253d217 | 2180 | def _OverridePcd(self, ToPcd, FromPcd, Module="", Msg="", Library=""):\r |
52302d4d LG |
2181 | #\r |
2182 | # in case there's PCDs coming from FDF file, which have no type given.\r | |
2183 | # at this point, ToPcd.Type has the type found from dependent\r | |
2184 | # package\r | |
2185 | #\r | |
2a29017e YZ |
2186 | TokenCName = ToPcd.TokenCName\r |
2187 | for PcdItem in GlobalData.MixedPcd:\r | |
2188 | if (ToPcd.TokenCName, ToPcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:\r | |
2189 | TokenCName = PcdItem[0]\r | |
2190 | break\r | |
4231a819 | 2191 | if FromPcd is not None:\r |
c93356ad | 2192 | if ToPcd.Pending and FromPcd.Type:\r |
52302d4d | 2193 | ToPcd.Type = FromPcd.Type\r |
caf74495 JC |
2194 | elif ToPcd.Type and FromPcd.Type\\r |
2195 | and ToPcd.Type != FromPcd.Type and ToPcd.Type in FromPcd.Type:\r | |
6b1f2cf4 | 2196 | if ToPcd.Type.strip() == TAB_PCDS_DYNAMIC_EX:\r |
47fea6af | 2197 | ToPcd.Type = FromPcd.Type\r |
c93356ad | 2198 | elif ToPcd.Type and FromPcd.Type \\r |
52302d4d | 2199 | and ToPcd.Type != FromPcd.Type:\r |
a253d217 YF |
2200 | if Library:\r |
2201 | Module = str(Module) + " 's library file (" + str(Library) + ")"\r | |
52302d4d | 2202 | EdkLogger.error("build", OPTION_CONFLICT, "Mismatched PCD type",\r |
a253d217 | 2203 | ExtraData="%s.%s is used as [%s] in module %s, but as [%s] in %s."\\r |
2a29017e | 2204 | % (ToPcd.TokenSpaceGuidCName, TokenCName,\r |
a253d217 | 2205 | ToPcd.Type, Module, FromPcd.Type, Msg),\r |
52302d4d LG |
2206 | File=self.MetaFile)\r |
2207 | \r | |
6be94743 | 2208 | if FromPcd.MaxDatumSize:\r |
52302d4d | 2209 | ToPcd.MaxDatumSize = FromPcd.MaxDatumSize\r |
c33081c9 | 2210 | ToPcd.MaxSizeUserSet = FromPcd.MaxDatumSize\r |
6be94743 | 2211 | if FromPcd.DefaultValue:\r |
52302d4d | 2212 | ToPcd.DefaultValue = FromPcd.DefaultValue\r |
6be94743 | 2213 | if FromPcd.TokenValue:\r |
52302d4d | 2214 | ToPcd.TokenValue = FromPcd.TokenValue\r |
6be94743 | 2215 | if FromPcd.DatumType:\r |
52302d4d | 2216 | ToPcd.DatumType = FromPcd.DatumType\r |
6be94743 | 2217 | if FromPcd.SkuInfoList:\r |
52302d4d | 2218 | ToPcd.SkuInfoList = FromPcd.SkuInfoList\r |
726c501c | 2219 | # Add Flexible PCD format parse\r |
726c501c | 2220 | if ToPcd.DefaultValue:\r |
726c501c | 2221 | try:\r |
35f613d9 | 2222 | ToPcd.DefaultValue = ValueExpressionEx(ToPcd.DefaultValue, ToPcd.DatumType, self._GuidDict)(True)\r |
726c501c YZ |
2223 | except BadExpression, Value:\r |
2224 | EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %(ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName, ToPcd.DefaultValue, Value),\r | |
2225 | File=self.MetaFile)\r | |
52302d4d LG |
2226 | \r |
2227 | # check the validation of datum\r | |
2228 | IsValid, Cause = CheckPcdDatum(ToPcd.DatumType, ToPcd.DefaultValue)\r | |
2229 | if not IsValid:\r | |
2230 | EdkLogger.error('build', FORMAT_INVALID, Cause, File=self.MetaFile,\r | |
2a29017e | 2231 | ExtraData="%s.%s" % (ToPcd.TokenSpaceGuidCName, TokenCName))\r |
82a6a960 BF |
2232 | ToPcd.validateranges = FromPcd.validateranges\r |
2233 | ToPcd.validlists = FromPcd.validlists\r | |
2234 | ToPcd.expressions = FromPcd.expressions\r | |
52302d4d | 2235 | \r |
c93356ad | 2236 | if FromPcd is not None and ToPcd.DatumType == TAB_VOID and not ToPcd.MaxDatumSize:\r |
52302d4d | 2237 | EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for PCD %s.%s" \\r |
2a29017e | 2238 | % (ToPcd.TokenSpaceGuidCName, TokenCName))\r |
52302d4d | 2239 | Value = ToPcd.DefaultValue\r |
c93356ad | 2240 | if not Value:\r |
e8a47801 | 2241 | ToPcd.MaxDatumSize = '1'\r |
52302d4d | 2242 | elif Value[0] == 'L':\r |
e8a47801 | 2243 | ToPcd.MaxDatumSize = str((len(Value) - 2) * 2)\r |
52302d4d LG |
2244 | elif Value[0] == '{':\r |
2245 | ToPcd.MaxDatumSize = str(len(Value.split(',')))\r | |
2246 | else:\r | |
e8a47801 | 2247 | ToPcd.MaxDatumSize = str(len(Value) - 1)\r |
52302d4d LG |
2248 | \r |
2249 | # apply default SKU for dynamic PCDS if specified one is not available\r | |
eece4292 | 2250 | if (ToPcd.Type in PCD_DYNAMIC_TYPE_SET or ToPcd.Type in PCD_DYNAMIC_EX_TYPE_SET) \\r |
c93356ad | 2251 | and not ToPcd.SkuInfoList:\r |
52302d4d LG |
2252 | if self.Platform.SkuName in self.Platform.SkuIds:\r |
2253 | SkuName = self.Platform.SkuName\r | |
2254 | else:\r | |
55c84777 | 2255 | SkuName = TAB_DEFAULT\r |
52302d4d | 2256 | ToPcd.SkuInfoList = {\r |
8518bf0b | 2257 | SkuName : SkuInfoClass(SkuName, self.Platform.SkuIds[SkuName][0], '', '', '', '', '', ToPcd.DefaultValue)\r |
52302d4d LG |
2258 | }\r |
2259 | \r | |
2260 | ## Apply PCD setting defined platform to a module\r | |
2261 | #\r | |
2262 | # @param Module The module from which the PCD setting will be overrided\r | |
2263 | #\r | |
2264 | # @retval PCD_list The list PCDs with settings from platform\r | |
2265 | #\r | |
a253d217 | 2266 | def ApplyPcdSetting(self, Module, Pcds, Library=""):\r |
52302d4d | 2267 | # for each PCD in module\r |
47fea6af YZ |
2268 | for Name, Guid in Pcds:\r |
2269 | PcdInModule = Pcds[Name, Guid]\r | |
52302d4d | 2270 | # find out the PCD setting in platform\r |
47fea6af YZ |
2271 | if (Name, Guid) in self.Platform.Pcds:\r |
2272 | PcdInPlatform = self.Platform.Pcds[Name, Guid]\r | |
52302d4d LG |
2273 | else:\r |
2274 | PcdInPlatform = None\r | |
2275 | # then override the settings if any\r | |
a253d217 | 2276 | self._OverridePcd(PcdInModule, PcdInPlatform, Module, Msg="DSC PCD sections", Library=Library)\r |
52302d4d LG |
2277 | # resolve the VariableGuid value\r |
2278 | for SkuId in PcdInModule.SkuInfoList:\r | |
2279 | Sku = PcdInModule.SkuInfoList[SkuId]\r | |
2280 | if Sku.VariableGuid == '': continue\r | |
c28d2e10 | 2281 | Sku.VariableGuidValue = GuidValue(Sku.VariableGuid, self.PackageList, self.MetaFile.Path)\r |
4231a819 | 2282 | if Sku.VariableGuidValue is None:\r |
8252e6bf | 2283 | PackageList = "\n\t".join(str(P) for P in self.PackageList)\r |
52302d4d LG |
2284 | EdkLogger.error(\r |
2285 | 'build',\r | |
2286 | RESOURCE_NOT_AVAILABLE,\r | |
2287 | "Value of GUID [%s] is not found in" % Sku.VariableGuid,\r | |
2288 | ExtraData=PackageList + "\n\t(used with %s.%s from module %s)" \\r | |
2289 | % (Guid, Name, str(Module)),\r | |
2290 | File=self.MetaFile\r | |
2291 | )\r | |
2292 | \r | |
2293 | # override PCD settings with module specific setting\r | |
2294 | if Module in self.Platform.Modules:\r | |
2295 | PlatformModule = self.Platform.Modules[str(Module)]\r | |
2296 | for Key in PlatformModule.Pcds:\r | |
aa9aa47e | 2297 | Flag = False\r |
52302d4d | 2298 | if Key in Pcds:\r |
aa9aa47e YZ |
2299 | ToPcd = Pcds[Key]\r |
2300 | Flag = True\r | |
2301 | elif Key in GlobalData.MixedPcd:\r | |
2302 | for PcdItem in GlobalData.MixedPcd[Key]:\r | |
2303 | if PcdItem in Pcds:\r | |
2304 | ToPcd = Pcds[PcdItem]\r | |
2305 | Flag = True\r | |
2306 | break\r | |
2307 | if Flag:\r | |
a253d217 | 2308 | self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Module, Msg="DSC Components Module scoped PCD section", Library=Library)\r |
cdbf45ad YZ |
2309 | # use PCD value to calculate the MaxDatumSize when it is not specified\r |
2310 | for Name, Guid in Pcds:\r | |
2311 | Pcd = Pcds[Name, Guid]\r | |
c93356ad | 2312 | if Pcd.DatumType == TAB_VOID and not Pcd.MaxDatumSize:\r |
c33081c9 | 2313 | Pcd.MaxSizeUserSet = None\r |
cdbf45ad | 2314 | Value = Pcd.DefaultValue\r |
c93356ad | 2315 | if not Value:\r |
cdbf45ad YZ |
2316 | Pcd.MaxDatumSize = '1'\r |
2317 | elif Value[0] == 'L':\r | |
2318 | Pcd.MaxDatumSize = str((len(Value) - 2) * 2)\r | |
2319 | elif Value[0] == '{':\r | |
2320 | Pcd.MaxDatumSize = str(len(Value.split(',')))\r | |
2321 | else:\r | |
2322 | Pcd.MaxDatumSize = str(len(Value) - 1)\r | |
52302d4d LG |
2323 | return Pcds.values()\r |
2324 | \r | |
2325 | ## Resolve library names to library modules\r | |
2326 | #\r | |
b36d134f | 2327 | # (for Edk.x modules)\r |
52302d4d LG |
2328 | #\r |
2329 | # @param Module The module from which the library names will be resolved\r | |
2330 | #\r | |
2331 | # @retval library_list The list of library modules\r | |
2332 | #\r | |
2333 | def ResolveLibraryReference(self, Module):\r | |
2334 | EdkLogger.verbose("")\r | |
2335 | EdkLogger.verbose("Library instances of module [%s] [%s]:" % (str(Module), self.Arch))\r | |
2336 | LibraryConsumerList = [Module]\r | |
2337 | \r | |
b36d134f | 2338 | # "CompilerStub" is a must for Edk modules\r |
52302d4d LG |
2339 | if Module.Libraries:\r |
2340 | Module.Libraries.append("CompilerStub")\r | |
2341 | LibraryList = []\r | |
2342 | while len(LibraryConsumerList) > 0:\r | |
2343 | M = LibraryConsumerList.pop()\r | |
2344 | for LibraryName in M.Libraries:\r | |
2345 | Library = self.Platform.LibraryClasses[LibraryName, ':dummy:']\r | |
4231a819 | 2346 | if Library is None:\r |
9eb87141 | 2347 | for Key in self.Platform.LibraryClasses.data:\r |
52302d4d LG |
2348 | if LibraryName.upper() == Key.upper():\r |
2349 | Library = self.Platform.LibraryClasses[Key, ':dummy:']\r | |
2350 | break\r | |
4231a819 | 2351 | if Library is None:\r |
52302d4d LG |
2352 | EdkLogger.warn("build", "Library [%s] is not found" % LibraryName, File=str(M),\r |
2353 | ExtraData="\t%s [%s]" % (str(Module), self.Arch))\r | |
2354 | continue\r | |
2355 | \r | |
2356 | if Library not in LibraryList:\r | |
2357 | LibraryList.append(Library)\r | |
2358 | LibraryConsumerList.append(Library)\r | |
2359 | EdkLogger.verbose("\t" + LibraryName + " : " + str(Library) + ' ' + str(type(Library)))\r | |
2360 | return LibraryList\r | |
2361 | \r | |
6780eef1 LG |
2362 | ## Calculate the priority value of the build option\r |
2363 | #\r | |
2364 | # @param Key Build option definition contain: TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE\r | |
2365 | #\r | |
2366 | # @retval Value Priority value based on the priority list.\r | |
2367 | #\r | |
2368 | def CalculatePriorityValue(self, Key):\r | |
47fea6af YZ |
2369 | Target, ToolChain, Arch, CommandType, Attr = Key.split('_')\r |
2370 | PriorityValue = 0x11111\r | |
6780eef1 LG |
2371 | if Target == "*":\r |
2372 | PriorityValue &= 0x01111\r | |
2373 | if ToolChain == "*":\r | |
2374 | PriorityValue &= 0x10111\r | |
2375 | if Arch == "*":\r | |
2376 | PriorityValue &= 0x11011\r | |
2377 | if CommandType == "*":\r | |
2378 | PriorityValue &= 0x11101\r | |
2379 | if Attr == "*":\r | |
2380 | PriorityValue &= 0x11110\r | |
47fea6af YZ |
2381 | \r |
2382 | return self.PrioList["0x%0.5x" % PriorityValue]\r | |
2383 | \r | |
6780eef1 | 2384 | \r |
52302d4d LG |
2385 | ## Expand * in build option key\r |
2386 | #\r | |
2387 | # @param Options Options to be expanded\r | |
2388 | #\r | |
2389 | # @retval options Options expanded\r | |
6780eef1 | 2390 | # \r |
52302d4d LG |
2391 | def _ExpandBuildOption(self, Options, ModuleStyle=None):\r |
2392 | BuildOptions = {}\r | |
2393 | FamilyMatch = False\r | |
2394 | FamilyIsNull = True\r | |
47fea6af | 2395 | \r |
6780eef1 LG |
2396 | OverrideList = {}\r |
2397 | #\r | |
2398 | # Construct a list contain the build options which need override.\r | |
2399 | #\r | |
2400 | for Key in Options:\r | |
2401 | #\r | |
2402 | # Key[0] -- tool family\r | |
2403 | # Key[1] -- TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE\r | |
2404 | #\r | |
1ba5124e | 2405 | if (Key[0] == self.BuildRuleFamily and\r |
4231a819 | 2406 | (ModuleStyle is None or len(Key) < 3 or (len(Key) > 2 and Key[2] == ModuleStyle))):\r |
6780eef1 | 2407 | Target, ToolChain, Arch, CommandType, Attr = Key[1].split('_')\r |
caf74495 JC |
2408 | if (Target == self.BuildTarget or Target == "*") and\\r |
2409 | (ToolChain == self.ToolChain or ToolChain == "*") and\\r | |
2410 | (Arch == self.Arch or Arch == "*") and\\r | |
2411 | Options[Key].startswith("="):\r | |
2412 | \r | |
2413 | if OverrideList.get(Key[1]) is not None:\r | |
2414 | OverrideList.pop(Key[1])\r | |
2415 | OverrideList[Key[1]] = Options[Key]\r | |
6780eef1 LG |
2416 | \r |
2417 | #\r | |
2418 | # Use the highest priority value. \r | |
2419 | #\r | |
2420 | if (len(OverrideList) >= 2):\r | |
47fea6af | 2421 | KeyList = OverrideList.keys()\r |
6780eef1 | 2422 | for Index in range(len(KeyList)):\r |
47fea6af | 2423 | NowKey = KeyList[Index]\r |
6780eef1 LG |
2424 | Target1, ToolChain1, Arch1, CommandType1, Attr1 = NowKey.split("_")\r |
2425 | for Index1 in range(len(KeyList) - Index - 1):\r | |
2426 | NextKey = KeyList[Index1 + Index + 1]\r | |
2427 | #\r | |
2428 | # Compare two Key, if one is included by another, choose the higher priority one\r | |
2429 | # \r | |
2430 | Target2, ToolChain2, Arch2, CommandType2, Attr2 = NextKey.split("_")\r | |
caf74495 JC |
2431 | if (Target1 == Target2 or Target1 == "*" or Target2 == "*") and\\r |
2432 | (ToolChain1 == ToolChain2 or ToolChain1 == "*" or ToolChain2 == "*") and\\r | |
2433 | (Arch1 == Arch2 or Arch1 == "*" or Arch2 == "*") and\\r | |
2434 | (CommandType1 == CommandType2 or CommandType1 == "*" or CommandType2 == "*") and\\r | |
2435 | (Attr1 == Attr2 or Attr1 == "*" or Attr2 == "*"):\r | |
2436 | \r | |
2437 | if self.CalculatePriorityValue(NowKey) > self.CalculatePriorityValue(NextKey):\r | |
2438 | if Options.get((self.BuildRuleFamily, NextKey)) is not None:\r | |
2439 | Options.pop((self.BuildRuleFamily, NextKey))\r | |
2440 | else:\r | |
2441 | if Options.get((self.BuildRuleFamily, NowKey)) is not None:\r | |
2442 | Options.pop((self.BuildRuleFamily, NowKey))\r | |
6780eef1 | 2443 | \r |
52302d4d | 2444 | for Key in Options:\r |
4231a819 | 2445 | if ModuleStyle is not None and len (Key) > 2:\r |
52302d4d LG |
2446 | # Check Module style is EDK or EDKII.\r |
2447 | # Only append build option for the matched style module.\r | |
2448 | if ModuleStyle == EDK_NAME and Key[2] != EDK_NAME:\r | |
2449 | continue\r | |
2450 | elif ModuleStyle == EDKII_NAME and Key[2] != EDKII_NAME:\r | |
2451 | continue\r | |
2452 | Family = Key[0]\r | |
2453 | Target, Tag, Arch, Tool, Attr = Key[1].split("_")\r | |
2454 | # if tool chain family doesn't match, skip it\r | |
2455 | if Tool in self.ToolDefinition and Family != "":\r | |
2456 | FamilyIsNull = False\r | |
2457 | if self.ToolDefinition[Tool].get(TAB_TOD_DEFINES_BUILDRULEFAMILY, "") != "":\r | |
2458 | if Family != self.ToolDefinition[Tool][TAB_TOD_DEFINES_BUILDRULEFAMILY]:\r | |
2459 | continue\r | |
2460 | elif Family != self.ToolDefinition[Tool][TAB_TOD_DEFINES_FAMILY]:\r | |
2461 | continue\r | |
2462 | FamilyMatch = True\r | |
2463 | # expand any wildcard\r | |
2464 | if Target == "*" or Target == self.BuildTarget:\r | |
2465 | if Tag == "*" or Tag == self.ToolChain:\r | |
2466 | if Arch == "*" or Arch == self.Arch:\r | |
2467 | if Tool not in BuildOptions:\r | |
2468 | BuildOptions[Tool] = {}\r | |
5015bee2 | 2469 | if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or Options[Key].startswith('='):\r |
52302d4d LG |
2470 | BuildOptions[Tool][Attr] = Options[Key]\r |
2471 | else:\r | |
95816356 YZ |
2472 | # append options for the same tool except PATH\r |
2473 | if Attr != 'PATH':\r | |
2474 | BuildOptions[Tool][Attr] += " " + Options[Key]\r | |
2475 | else:\r | |
2476 | BuildOptions[Tool][Attr] = Options[Key]\r | |
52302d4d LG |
2477 | # Build Option Family has been checked, which need't to be checked again for family.\r |
2478 | if FamilyMatch or FamilyIsNull:\r | |
2479 | return BuildOptions\r | |
1ba5124e | 2480 | \r |
52302d4d | 2481 | for Key in Options:\r |
4231a819 | 2482 | if ModuleStyle is not None and len (Key) > 2:\r |
52302d4d LG |
2483 | # Check Module style is EDK or EDKII.\r |
2484 | # Only append build option for the matched style module.\r | |
2485 | if ModuleStyle == EDK_NAME and Key[2] != EDK_NAME:\r | |
2486 | continue\r | |
2487 | elif ModuleStyle == EDKII_NAME and Key[2] != EDKII_NAME:\r | |
2488 | continue\r | |
2489 | Family = Key[0]\r | |
2490 | Target, Tag, Arch, Tool, Attr = Key[1].split("_")\r | |
2491 | # if tool chain family doesn't match, skip it\r | |
47fea6af | 2492 | if Tool not in self.ToolDefinition or Family == "":\r |
52302d4d LG |
2493 | continue\r |
2494 | # option has been added before\r | |
2495 | if Family != self.ToolDefinition[Tool][TAB_TOD_DEFINES_FAMILY]:\r | |
2496 | continue\r | |
2497 | \r | |
2498 | # expand any wildcard\r | |
2499 | if Target == "*" or Target == self.BuildTarget:\r | |
2500 | if Tag == "*" or Tag == self.ToolChain:\r | |
2501 | if Arch == "*" or Arch == self.Arch:\r | |
2502 | if Tool not in BuildOptions:\r | |
2503 | BuildOptions[Tool] = {}\r | |
5015bee2 | 2504 | if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or Options[Key].startswith('='):\r |
52302d4d LG |
2505 | BuildOptions[Tool][Attr] = Options[Key]\r |
2506 | else:\r | |
95816356 YZ |
2507 | # append options for the same tool except PATH\r |
2508 | if Attr != 'PATH':\r | |
2509 | BuildOptions[Tool][Attr] += " " + Options[Key]\r | |
2510 | else:\r | |
2511 | BuildOptions[Tool][Attr] = Options[Key]\r | |
52302d4d LG |
2512 | return BuildOptions\r |
2513 | \r | |
2514 | ## Append build options in platform to a module\r | |
2515 | #\r | |
2516 | # @param Module The module to which the build options will be appened\r | |
2517 | #\r | |
2518 | # @retval options The options appended with build options in platform\r | |
2519 | #\r | |
2520 | def ApplyBuildOption(self, Module):\r | |
2521 | # Get the different options for the different style module\r | |
2522 | if Module.AutoGenVersion < 0x00010005:\r | |
2523 | PlatformOptions = self.EdkBuildOption\r | |
35f69db9 | 2524 | ModuleTypeOptions = self.Platform.GetBuildOptionsByModuleType(EDK_NAME, Module.ModuleType)\r |
52302d4d LG |
2525 | else:\r |
2526 | PlatformOptions = self.EdkIIBuildOption\r | |
35f69db9 YL |
2527 | ModuleTypeOptions = self.Platform.GetBuildOptionsByModuleType(EDKII_NAME, Module.ModuleType)\r |
2528 | ModuleTypeOptions = self._ExpandBuildOption(ModuleTypeOptions)\r | |
52302d4d LG |
2529 | ModuleOptions = self._ExpandBuildOption(Module.BuildOptions)\r |
2530 | if Module in self.Platform.Modules:\r | |
2531 | PlatformModule = self.Platform.Modules[str(Module)]\r | |
2532 | PlatformModuleOptions = self._ExpandBuildOption(PlatformModule.BuildOptions)\r | |
2533 | else:\r | |
2534 | PlatformModuleOptions = {}\r | |
2535 | \r | |
fe4bf2f9 | 2536 | BuildRuleOrder = None\r |
35f69db9 | 2537 | for Options in [self.ToolDefinition, ModuleOptions, PlatformOptions, ModuleTypeOptions, PlatformModuleOptions]:\r |
fe4bf2f9 YL |
2538 | for Tool in Options:\r |
2539 | for Attr in Options[Tool]:\r | |
2540 | if Attr == TAB_TOD_DEFINES_BUILDRULEORDER:\r | |
2541 | BuildRuleOrder = Options[Tool][Attr]\r | |
2542 | \r | |
35f69db9 YL |
2543 | AllTools = set(ModuleOptions.keys() + PlatformOptions.keys() +\r |
2544 | PlatformModuleOptions.keys() + ModuleTypeOptions.keys() +\r | |
2545 | self.ToolDefinition.keys())\r | |
339fe8dd | 2546 | BuildOptions = defaultdict(lambda: defaultdict(str))\r |
52302d4d | 2547 | for Tool in AllTools:\r |
35f69db9 | 2548 | for Options in [self.ToolDefinition, ModuleOptions, PlatformOptions, ModuleTypeOptions, PlatformModuleOptions]:\r |
52302d4d LG |
2549 | if Tool not in Options:\r |
2550 | continue\r | |
2551 | for Attr in Options[Tool]:\r | |
fe4bf2f9 YL |
2552 | #\r |
2553 | # Do not generate it in Makefile\r | |
2554 | #\r | |
2555 | if Attr == TAB_TOD_DEFINES_BUILDRULEORDER:\r | |
2556 | continue\r | |
339fe8dd | 2557 | Value = Options[Tool][Attr]\r |
52302d4d LG |
2558 | # check if override is indicated\r |
2559 | if Value.startswith('='):\r | |
339fe8dd | 2560 | BuildOptions[Tool][Attr] = mws.handleWsMacro(Value[1:])\r |
5015bee2 | 2561 | else:\r |
95816356 | 2562 | if Attr != 'PATH':\r |
339fe8dd | 2563 | BuildOptions[Tool][Attr] += " " + mws.handleWsMacro(Value)\r |
95816356 | 2564 | else:\r |
339fe8dd CJ |
2565 | BuildOptions[Tool][Attr] = mws.handleWsMacro(Value)\r |
2566 | \r | |
4231a819 | 2567 | if Module.AutoGenVersion < 0x00010005 and self.Workspace.UniFlag is not None:\r |
f3decdc3 LG |
2568 | #\r |
2569 | # Override UNI flag only for EDK module.\r | |
2570 | #\r | |
f3decdc3 | 2571 | BuildOptions['BUILD']['FLAGS'] = self.Workspace.UniFlag\r |
fe4bf2f9 | 2572 | return BuildOptions, BuildRuleOrder\r |
52302d4d LG |
2573 | \r |
2574 | Platform = property(_GetPlatform)\r | |
2575 | Name = property(_GetName)\r | |
2576 | Guid = property(_GetGuid)\r | |
2577 | Version = property(_GetVersion)\r | |
2578 | \r | |
2579 | OutputDir = property(_GetOutputDir)\r | |
2580 | BuildDir = property(_GetBuildDir)\r | |
2581 | MakeFileDir = property(_GetMakeFileDir)\r | |
2582 | FdfFile = property(_GetFdfFile)\r | |
2583 | \r | |
2584 | PcdTokenNumber = property(_GetPcdTokenNumbers) # (TokenCName, TokenSpaceGuidCName) : GeneratedTokenNumber\r | |
2585 | DynamicPcdList = property(_GetDynamicPcdList) # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]\r | |
2586 | NonDynamicPcdList = property(_GetNonDynamicPcdList) # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]\r | |
2bc3256c | 2587 | NonDynamicPcdDict = property(_GetNonDynamicPcdDict)\r |
52302d4d LG |
2588 | PackageList = property(_GetPackageList)\r |
2589 | \r | |
2590 | ToolDefinition = property(_GetToolDefinition) # toolcode : tool path\r | |
2591 | ToolDefinitionFile = property(_GetToolDefFile) # toolcode : lib path\r | |
2592 | ToolChainFamily = property(_GetToolChainFamily)\r | |
2593 | BuildRuleFamily = property(_GetBuildRuleFamily)\r | |
2594 | BuildOption = property(_GetBuildOptions) # toolcode : option\r | |
2595 | EdkBuildOption = property(_GetEdkBuildOptions) # edktoolcode : option\r | |
2596 | EdkIIBuildOption = property(_GetEdkIIBuildOptions) # edkiitoolcode : option\r | |
2597 | \r | |
2598 | BuildCommand = property(_GetBuildCommand)\r | |
2599 | BuildRule = property(_GetBuildRule)\r | |
2600 | ModuleAutoGenList = property(_GetModuleAutoGenList)\r | |
2601 | LibraryAutoGenList = property(_GetLibraryAutoGenList)\r | |
0923aa1c | 2602 | GenFdsCommand = property(_GenFdsCommand)\r |
52302d4d | 2603 | \r |
caf74495 JC |
2604 | #\r |
2605 | # extend lists contained in a dictionary with lists stored in another dictionary\r | |
2606 | # if CopyToDict is not derived from DefaultDict(list) then this may raise exception\r | |
2607 | #\r | |
2608 | def ExtendCopyDictionaryLists(CopyToDict, CopyFromDict):\r | |
2609 | for Key in CopyFromDict:\r | |
2610 | CopyToDict[Key].extend(CopyFromDict[Key])\r | |
2611 | \r | |
2612 | \r | |
52302d4d LG |
2613 | ## ModuleAutoGen class\r |
2614 | #\r | |
2615 | # This class encapsules the AutoGen behaviors for the build tools. In addition to\r | |
2616 | # the generation of AutoGen.h and AutoGen.c, it will generate *.depex file according\r | |
2617 | # to the [depex] section in module's inf file.\r | |
2618 | #\r | |
2619 | class ModuleAutoGen(AutoGen):\r | |
b24e99f7 CJ |
2620 | # call super().__init__ then call the worker function with different parameter count\r |
2621 | def __init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r | |
2622 | try:\r | |
2623 | self._Init\r | |
2624 | except:\r | |
2625 | super(ModuleAutoGen, self).__init__(Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs)\r | |
2626 | self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch, *args)\r | |
2627 | self._Init = True\r | |
2628 | \r | |
c17956e0 DL |
2629 | ## Cache the timestamps of metafiles of every module in a class variable\r |
2630 | #\r | |
2631 | TimeDict = {}\r | |
2632 | \r | |
b24e99f7 CJ |
2633 | def __new__(cls, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r |
2634 | obj = super(ModuleAutoGen, cls).__new__(cls, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs)\r | |
2635 | # check if this module is employed by active platform\r | |
2636 | if not PlatformAutoGen(Workspace, args[0], Target, Toolchain, Arch).ValidModule(MetaFile):\r | |
2637 | EdkLogger.verbose("Module [%s] for [%s] is not employed by active platform\n" \\r | |
2638 | % (MetaFile, Arch))\r | |
2639 | return None\r | |
2640 | return obj\r | |
2641 | \r | |
2642 | ## Initialize ModuleAutoGen\r | |
52302d4d LG |
2643 | #\r |
2644 | # @param Workspace EdkIIWorkspaceBuild object\r | |
2645 | # @param ModuleFile The path of module file\r | |
2646 | # @param Target Build target (DEBUG, RELEASE)\r | |
2647 | # @param Toolchain Name of tool chain\r | |
2648 | # @param Arch The arch the module supports\r | |
2649 | # @param PlatformFile Platform meta-file\r | |
2650 | #\r | |
b24e99f7 | 2651 | def _InitWorker(self, Workspace, ModuleFile, Target, Toolchain, Arch, PlatformFile):\r |
52302d4d LG |
2652 | EdkLogger.debug(EdkLogger.DEBUG_9, "AutoGen module [%s] [%s]" % (ModuleFile, Arch))\r |
2653 | GlobalData.gProcessingFile = "%s [%s, %s, %s]" % (ModuleFile, Arch, Toolchain, Target)\r | |
2654 | \r | |
2655 | self.Workspace = Workspace\r | |
2656 | self.WorkspaceDir = Workspace.WorkspaceDir\r | |
f9fa014e | 2657 | self._GuidDict = Workspace._GuidDict\r |
52302d4d LG |
2658 | self.MetaFile = ModuleFile\r |
2659 | self.PlatformInfo = PlatformAutoGen(Workspace, PlatformFile, Target, Toolchain, Arch)\r | |
52302d4d LG |
2660 | \r |
2661 | self.SourceDir = self.MetaFile.SubDir\r | |
05cc51ad | 2662 | self.SourceDir = mws.relpath(self.SourceDir, self.WorkspaceDir)\r |
97fa0ee9 | 2663 | \r |
52302d4d LG |
2664 | self.SourceOverrideDir = None\r |
2665 | # use overrided path defined in DSC file\r | |
2666 | if self.MetaFile.Key in GlobalData.gOverrideDir:\r | |
2667 | self.SourceOverrideDir = GlobalData.gOverrideDir[self.MetaFile.Key]\r | |
2668 | \r | |
2669 | self.ToolChain = Toolchain\r | |
2670 | self.BuildTarget = Target\r | |
2671 | self.Arch = Arch\r | |
2672 | self.ToolChainFamily = self.PlatformInfo.ToolChainFamily\r | |
2673 | self.BuildRuleFamily = self.PlatformInfo.BuildRuleFamily\r | |
2674 | \r | |
2675 | self.IsMakeFileCreated = False\r | |
2676 | self.IsCodeFileCreated = False\r | |
da92f276 LG |
2677 | self.IsAsBuiltInfCreated = False\r |
2678 | self.DepexGenerated = False\r | |
52302d4d LG |
2679 | \r |
2680 | self.BuildDatabase = self.Workspace.BuildDatabase\r | |
fe4bf2f9 | 2681 | self.BuildRuleOrder = None\r |
1b8eca8b | 2682 | self.BuildTime = 0\r |
52302d4d LG |
2683 | \r |
2684 | self._Module = None\r | |
2685 | self._Name = None\r | |
2686 | self._Guid = None\r | |
2687 | self._Version = None\r | |
2688 | self._ModuleType = None\r | |
2689 | self._ComponentType = None\r | |
2690 | self._PcdIsDriver = None\r | |
2691 | self._AutoGenVersion = None\r | |
2692 | self._LibraryFlag = None\r | |
2693 | self._CustomMakefile = None\r | |
2694 | self._Macro = None\r | |
2695 | \r | |
2696 | self._BuildDir = None\r | |
2697 | self._OutputDir = None\r | |
37de70b7 | 2698 | self._FfsOutputDir = None\r |
52302d4d LG |
2699 | self._DebugDir = None\r |
2700 | self._MakeFileDir = None\r | |
2701 | \r | |
2702 | self._IncludePathList = None\r | |
2703 | self._AutoGenFileList = None\r | |
2704 | self._UnicodeFileList = None\r | |
5b97eb4c | 2705 | self._VfrFileList = None\r |
333ba578 | 2706 | self._IdfFileList = None\r |
52302d4d LG |
2707 | self._SourceFileList = None\r |
2708 | self._ObjectFileList = None\r | |
2709 | self._BinaryFileList = None\r | |
2710 | \r | |
2711 | self._DependentPackageList = None\r | |
2712 | self._DependentLibraryList = None\r | |
2713 | self._LibraryAutoGenList = None\r | |
2714 | self._DerivedPackageList = None\r | |
2715 | self._ModulePcdList = None\r | |
2716 | self._LibraryPcdList = None\r | |
caf74495 | 2717 | self._PcdComments = OrderedListDict()\r |
52302d4d | 2718 | self._GuidList = None\r |
e8a47801 | 2719 | self._GuidsUsedByPcd = None\r |
caf74495 | 2720 | self._GuidComments = OrderedListDict()\r |
52302d4d | 2721 | self._ProtocolList = None\r |
caf74495 | 2722 | self._ProtocolComments = OrderedListDict()\r |
52302d4d | 2723 | self._PpiList = None\r |
caf74495 JC |
2724 | self._PpiComments = OrderedListDict()\r |
2725 | self._DepexDict = None\r | |
2726 | self._DepexExpressionDict = None\r | |
52302d4d | 2727 | self._BuildOption = None\r |
79b74a03 | 2728 | self._BuildOptionIncPathList = None\r |
52302d4d LG |
2729 | self._BuildTargets = None\r |
2730 | self._IntroBuildTargetList = None\r | |
2731 | self._FinalBuildTargetList = None\r | |
2732 | self._FileTypes = None\r | |
2733 | self._BuildRules = None\r | |
c17956e0 DL |
2734 | \r |
2735 | self._TimeStampPath = None\r | |
2736 | \r | |
2737 | self.AutoGenDepSet = set()\r | |
2738 | \r | |
2bc3256c LG |
2739 | \r |
2740 | ## The Modules referenced to this Library\r | |
2741 | # Only Library has this attribute\r | |
2742 | self._ReferenceModules = [] \r | |
2743 | \r | |
2744 | ## Store the FixedAtBuild Pcds\r | |
2745 | # \r | |
2746 | self._FixedAtBuildPcds = []\r | |
2747 | self.ConstPcd = {}\r | |
52302d4d LG |
2748 | \r |
2749 | def __repr__(self):\r | |
2750 | return "%s [%s]" % (self.MetaFile, self.Arch)\r | |
2751 | \r | |
2bc3256c LG |
2752 | # Get FixedAtBuild Pcds of this Module\r |
2753 | def _GetFixedAtBuildPcds(self):\r | |
2754 | if self._FixedAtBuildPcds:\r | |
2755 | return self._FixedAtBuildPcds\r | |
2756 | for Pcd in self.ModulePcdList:\r | |
6b1f2cf4 | 2757 | if Pcd.Type != TAB_PCDS_FIXED_AT_BUILD:\r |
2bc3256c LG |
2758 | continue\r |
2759 | if Pcd not in self._FixedAtBuildPcds:\r | |
2760 | self._FixedAtBuildPcds.append(Pcd)\r | |
2761 | \r | |
2762 | return self._FixedAtBuildPcds \r | |
2763 | \r | |
867d1cd4 YL |
2764 | def _GetUniqueBaseName(self):\r |
2765 | BaseName = self.Name\r | |
2766 | for Module in self.PlatformInfo.ModuleAutoGenList:\r | |
2767 | if Module.MetaFile == self.MetaFile:\r | |
2768 | continue\r | |
2769 | if Module.Name == self.Name:\r | |
867d1cd4 YL |
2770 | if uuid.UUID(Module.Guid) == uuid.UUID(self.Guid):\r |
2771 | EdkLogger.error("build", FILE_DUPLICATED, 'Modules have same BaseName and FILE_GUID:\n'\r | |
2772 | ' %s\n %s' % (Module.MetaFile, self.MetaFile))\r | |
2773 | BaseName = '%s_%s' % (self.Name, self.Guid)\r | |
2774 | return BaseName\r | |
2775 | \r | |
52302d4d LG |
2776 | # Macros could be used in build_rule.txt (also Makefile)\r |
2777 | def _GetMacros(self):\r | |
4231a819 | 2778 | if self._Macro is None:\r |
9006a2c6 | 2779 | self._Macro = OrderedDict()\r |
52302d4d LG |
2780 | self._Macro["WORKSPACE" ] = self.WorkspaceDir\r |
2781 | self._Macro["MODULE_NAME" ] = self.Name\r | |
867d1cd4 | 2782 | self._Macro["MODULE_NAME_GUID" ] = self._GetUniqueBaseName()\r |
52302d4d LG |
2783 | self._Macro["MODULE_GUID" ] = self.Guid\r |
2784 | self._Macro["MODULE_VERSION" ] = self.Version\r | |
2785 | self._Macro["MODULE_TYPE" ] = self.ModuleType\r | |
2786 | self._Macro["MODULE_FILE" ] = str(self.MetaFile)\r | |
2787 | self._Macro["MODULE_FILE_BASE_NAME" ] = self.MetaFile.BaseName\r | |
2788 | self._Macro["MODULE_RELATIVE_DIR" ] = self.SourceDir\r | |
2789 | self._Macro["MODULE_DIR" ] = self.SourceDir\r | |
2790 | \r | |
2791 | self._Macro["BASE_NAME" ] = self.Name\r | |
2792 | \r | |
2793 | self._Macro["ARCH" ] = self.Arch\r | |
2794 | self._Macro["TOOLCHAIN" ] = self.ToolChain\r | |
2795 | self._Macro["TOOLCHAIN_TAG" ] = self.ToolChain\r | |
0d2711a6 | 2796 | self._Macro["TOOL_CHAIN_TAG" ] = self.ToolChain\r |
52302d4d LG |
2797 | self._Macro["TARGET" ] = self.BuildTarget\r |
2798 | \r | |
2799 | self._Macro["BUILD_DIR" ] = self.PlatformInfo.BuildDir\r | |
2800 | self._Macro["BIN_DIR" ] = os.path.join(self.PlatformInfo.BuildDir, self.Arch)\r | |
2801 | self._Macro["LIB_DIR" ] = os.path.join(self.PlatformInfo.BuildDir, self.Arch)\r | |
2802 | self._Macro["MODULE_BUILD_DIR" ] = self.BuildDir\r | |
2803 | self._Macro["OUTPUT_DIR" ] = self.OutputDir\r | |
2804 | self._Macro["DEBUG_DIR" ] = self.DebugDir\r | |
df1e1b63 YZ |
2805 | self._Macro["DEST_DIR_OUTPUT" ] = self.OutputDir\r |
2806 | self._Macro["DEST_DIR_DEBUG" ] = self.DebugDir\r | |
3570e332 YZ |
2807 | self._Macro["PLATFORM_NAME" ] = self.PlatformInfo.Name\r |
2808 | self._Macro["PLATFORM_GUID" ] = self.PlatformInfo.Guid\r | |
2809 | self._Macro["PLATFORM_VERSION" ] = self.PlatformInfo.Version\r | |
2810 | self._Macro["PLATFORM_RELATIVE_DIR" ] = self.PlatformInfo.SourceDir\r | |
2811 | self._Macro["PLATFORM_DIR" ] = mws.join(self.WorkspaceDir, self.PlatformInfo.SourceDir)\r | |
2812 | self._Macro["PLATFORM_OUTPUT_DIR" ] = self.PlatformInfo.OutputDir\r | |
37de70b7 | 2813 | self._Macro["FFS_OUTPUT_DIR" ] = self.FfsOutputDir\r |
52302d4d LG |
2814 | return self._Macro\r |
2815 | \r | |
2816 | ## Return the module build data object\r | |
2817 | def _GetModule(self):\r | |
4231a819 | 2818 | if self._Module is None:\r |
0d2711a6 | 2819 | self._Module = self.Workspace.BuildDatabase[self.MetaFile, self.Arch, self.BuildTarget, self.ToolChain]\r |
52302d4d LG |
2820 | return self._Module\r |
2821 | \r | |
2822 | ## Return the module name\r | |
2823 | def _GetBaseName(self):\r | |
2824 | return self.Module.BaseName\r | |
2825 | \r | |
b36d134f LG |
2826 | ## Return the module DxsFile if exist\r |
2827 | def _GetDxsFile(self):\r | |
2828 | return self.Module.DxsFile\r | |
2829 | \r | |
52302d4d LG |
2830 | ## Return the module SourceOverridePath\r |
2831 | def _GetSourceOverridePath(self):\r | |
2832 | return self.Module.SourceOverridePath\r | |
2833 | \r | |
2834 | ## Return the module meta-file GUID\r | |
2835 | def _GetGuid(self):\r | |
97fa0ee9 YL |
2836 | #\r |
2837 | # To build same module more than once, the module path with FILE_GUID overridden has\r | |
2838 | # the file name FILE_GUIDmodule.inf, but the relative path (self.MetaFile.File) is the realy path\r | |
2839 | # in DSC. The overridden GUID can be retrieved from file name\r | |
2840 | #\r | |
2841 | if os.path.basename(self.MetaFile.File) != os.path.basename(self.MetaFile.Path):\r | |
2842 | #\r | |
2843 | # Length of GUID is 36\r | |
2844 | #\r | |
2845 | return os.path.basename(self.MetaFile.Path)[:36]\r | |
52302d4d LG |
2846 | return self.Module.Guid\r |
2847 | \r | |
2848 | ## Return the module version\r | |
2849 | def _GetVersion(self):\r | |
2850 | return self.Module.Version\r | |
2851 | \r | |
2852 | ## Return the module type\r | |
2853 | def _GetModuleType(self):\r | |
2854 | return self.Module.ModuleType\r | |
2855 | \r | |
b36d134f | 2856 | ## Return the component type (for Edk.x style of module)\r |
52302d4d LG |
2857 | def _GetComponentType(self):\r |
2858 | return self.Module.ComponentType\r | |
2859 | \r | |
2860 | ## Return the build type\r | |
2861 | def _GetBuildType(self):\r | |
2862 | return self.Module.BuildType\r | |
2863 | \r | |
2864 | ## Return the PCD_IS_DRIVER setting\r | |
2865 | def _GetPcdIsDriver(self):\r | |
2866 | return self.Module.PcdIsDriver\r | |
2867 | \r | |
2868 | ## Return the autogen version, i.e. module meta-file version\r | |
2869 | def _GetAutoGenVersion(self):\r | |
2870 | return self.Module.AutoGenVersion\r | |
2871 | \r | |
2872 | ## Check if the module is library or not\r | |
2873 | def _IsLibrary(self):\r | |
4231a819 | 2874 | if self._LibraryFlag is None:\r |
caf74495 | 2875 | self._LibraryFlag = True if self.Module.LibraryClass else False\r |
52302d4d LG |
2876 | return self._LibraryFlag\r |
2877 | \r | |
e8a47801 LG |
2878 | ## Check if the module is binary module or not\r |
2879 | def _IsBinaryModule(self):\r | |
2880 | return self.Module.IsBinaryModule\r | |
2881 | \r | |
52302d4d LG |
2882 | ## Return the directory to store intermediate files of the module\r |
2883 | def _GetBuildDir(self):\r | |
4231a819 | 2884 | if self._BuildDir is None:\r |
52302d4d LG |
2885 | self._BuildDir = path.join(\r |
2886 | self.PlatformInfo.BuildDir,\r | |
2887 | self.Arch,\r | |
2888 | self.SourceDir,\r | |
2889 | self.MetaFile.BaseName\r | |
2890 | )\r | |
2891 | CreateDirectory(self._BuildDir)\r | |
2892 | return self._BuildDir\r | |
2893 | \r | |
2894 | ## Return the directory to store the intermediate object files of the mdoule\r | |
2895 | def _GetOutputDir(self):\r | |
4231a819 | 2896 | if self._OutputDir is None:\r |
52302d4d LG |
2897 | self._OutputDir = path.join(self.BuildDir, "OUTPUT")\r |
2898 | CreateDirectory(self._OutputDir)\r | |
2899 | return self._OutputDir\r | |
2900 | \r | |
37de70b7 YZ |
2901 | ## Return the directory to store ffs file\r |
2902 | def _GetFfsOutputDir(self):\r | |
4231a819 CJ |
2903 | if self._FfsOutputDir is None:\r |
2904 | if GlobalData.gFdfParser is not None:\r | |
91fa33ee | 2905 | self._FfsOutputDir = path.join(self.PlatformInfo.BuildDir, TAB_FV_DIRECTORY, "Ffs", self.Guid + self.Name)\r |
37de70b7 YZ |
2906 | else:\r |
2907 | self._FfsOutputDir = ''\r | |
2908 | return self._FfsOutputDir\r | |
2909 | \r | |
52302d4d LG |
2910 | ## Return the directory to store auto-gened source files of the mdoule\r |
2911 | def _GetDebugDir(self):\r | |
4231a819 | 2912 | if self._DebugDir is None:\r |
52302d4d LG |
2913 | self._DebugDir = path.join(self.BuildDir, "DEBUG")\r |
2914 | CreateDirectory(self._DebugDir)\r | |
2915 | return self._DebugDir\r | |
2916 | \r | |
2917 | ## Return the path of custom file\r | |
2918 | def _GetCustomMakefile(self):\r | |
4231a819 | 2919 | if self._CustomMakefile is None:\r |
52302d4d LG |
2920 | self._CustomMakefile = {}\r |
2921 | for Type in self.Module.CustomMakefile:\r | |
2922 | if Type in gMakeTypeMap:\r | |
2923 | MakeType = gMakeTypeMap[Type]\r | |
2924 | else:\r | |
2925 | MakeType = 'nmake'\r | |
4231a819 | 2926 | if self.SourceOverrideDir is not None:\r |
52302d4d LG |
2927 | File = os.path.join(self.SourceOverrideDir, self.Module.CustomMakefile[Type])\r |
2928 | if not os.path.exists(File):\r | |
2929 | File = os.path.join(self.SourceDir, self.Module.CustomMakefile[Type])\r | |
2930 | else:\r | |
2931 | File = os.path.join(self.SourceDir, self.Module.CustomMakefile[Type])\r | |
2932 | self._CustomMakefile[MakeType] = File\r | |
2933 | return self._CustomMakefile\r | |
2934 | \r | |
2935 | ## Return the directory of the makefile\r | |
2936 | #\r | |
2937 | # @retval string The directory string of module's makefile\r | |
2938 | #\r | |
2939 | def _GetMakeFileDir(self):\r | |
2940 | return self.BuildDir\r | |
2941 | \r | |
2942 | ## Return build command string\r | |
2943 | #\r | |
2944 | # @retval string Build command string\r | |
2945 | #\r | |
2946 | def _GetBuildCommand(self):\r | |
2947 | return self.PlatformInfo.BuildCommand\r | |
2948 | \r | |
2949 | ## Get object list of all packages the module and its dependent libraries belong to\r | |
2950 | #\r | |
2951 | # @retval list The list of package object\r | |
2952 | #\r | |
2953 | def _GetDerivedPackageList(self):\r | |
2954 | PackageList = []\r | |
2955 | for M in [self.Module] + self.DependentLibraryList:\r | |
2956 | for Package in M.Packages:\r | |
2957 | if Package in PackageList:\r | |
2958 | continue\r | |
2959 | PackageList.append(Package)\r | |
2960 | return PackageList\r | |
97fa0ee9 YL |
2961 | \r |
2962 | ## Get the depex string\r | |
2963 | #\r | |
2964 | # @return : a string contain all depex expresion.\r | |
2965 | def _GetDepexExpresionString(self):\r | |
2966 | DepexStr = ''\r | |
2967 | DepexList = []\r | |
2968 | ## DPX_SOURCE IN Define section.\r | |
2969 | if self.Module.DxsFile:\r | |
2970 | return DepexStr\r | |
2971 | for M in [self.Module] + self.DependentLibraryList:\r | |
2972 | Filename = M.MetaFile.Path\r | |
2973 | InfObj = InfSectionParser.InfSectionParser(Filename)\r | |
2974 | DepexExpresionList = InfObj.GetDepexExpresionList()\r | |
2975 | for DepexExpresion in DepexExpresionList:\r | |
9eb87141 | 2976 | for key in DepexExpresion:\r |
97fa0ee9 | 2977 | Arch, ModuleType = key\r |
518aebe2 | 2978 | DepexExpr = [x for x in DepexExpresion[key] if not str(x).startswith('#')]\r |
97fa0ee9 YL |
2979 | # the type of build module is USER_DEFINED.\r |
2980 | # All different DEPEX section tags would be copied into the As Built INF file\r | |
2981 | # and there would be separate DEPEX section tags\r | |
2982 | if self.ModuleType.upper() == SUP_MODULE_USER_DEFINED:\r | |
2983 | if (Arch.upper() == self.Arch.upper()) and (ModuleType.upper() != TAB_ARCH_COMMON):\r | |
518aebe2 | 2984 | DepexList.append({(Arch, ModuleType): DepexExpr})\r |
97fa0ee9 YL |
2985 | else:\r |
2986 | if Arch.upper() == TAB_ARCH_COMMON or \\r | |
2987 | (Arch.upper() == self.Arch.upper() and \\r | |
2988 | ModuleType.upper() in [TAB_ARCH_COMMON, self.ModuleType.upper()]):\r | |
518aebe2 | 2989 | DepexList.append({(Arch, ModuleType): DepexExpr})\r |
97fa0ee9 YL |
2990 | \r |
2991 | #the type of build module is USER_DEFINED.\r | |
2992 | if self.ModuleType.upper() == SUP_MODULE_USER_DEFINED:\r | |
2993 | for Depex in DepexList:\r | |
9eb87141 | 2994 | for key in Depex:\r |
97fa0ee9 | 2995 | DepexStr += '[Depex.%s.%s]\n' % key\r |
8252e6bf | 2996 | DepexStr += '\n'.join('# '+ val for val in Depex[key])\r |
97fa0ee9 YL |
2997 | DepexStr += '\n\n'\r |
2998 | if not DepexStr:\r | |
2999 | return '[Depex.%s]\n' % self.Arch\r | |
3000 | return DepexStr\r | |
3001 | \r | |
3002 | #the type of build module not is USER_DEFINED.\r | |
3003 | Count = 0\r | |
3004 | for Depex in DepexList:\r | |
3005 | Count += 1\r | |
3006 | if DepexStr != '':\r | |
3007 | DepexStr += ' AND '\r | |
3008 | DepexStr += '('\r | |
3009 | for D in Depex.values():\r | |
8252e6bf | 3010 | DepexStr += ' '.join(val for val in D)\r |
97fa0ee9 YL |
3011 | Index = DepexStr.find('END')\r |
3012 | if Index > -1 and Index == len(DepexStr) - 3:\r | |
3013 | DepexStr = DepexStr[:-3]\r | |
3014 | DepexStr = DepexStr.strip()\r | |
3015 | DepexStr += ')'\r | |
3016 | if Count == 1:\r | |
3017 | DepexStr = DepexStr.lstrip('(').rstrip(')').strip()\r | |
3018 | if not DepexStr:\r | |
3019 | return '[Depex.%s]\n' % self.Arch\r | |
3020 | return '[Depex.%s]\n# ' % self.Arch + DepexStr\r | |
3021 | \r | |
52302d4d LG |
3022 | ## Merge dependency expression\r |
3023 | #\r | |
3024 | # @retval list The token list of the dependency expression after parsed\r | |
3025 | #\r | |
3026 | def _GetDepexTokenList(self):\r | |
caf74495 JC |
3027 | if self._DepexDict is None:\r |
3028 | self._DepexDict = {}\r | |
b36d134f | 3029 | if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:\r |
caf74495 | 3030 | return self._DepexDict\r |
52302d4d | 3031 | \r |
caf74495 | 3032 | self._DepexDict[self.ModuleType] = []\r |
52302d4d | 3033 | \r |
caf74495 JC |
3034 | for ModuleType in self._DepexDict:\r |
3035 | DepexList = self._DepexDict[ModuleType]\r | |
52302d4d LG |
3036 | #\r |
3037 | # Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion\r | |
3038 | #\r | |
3039 | for M in [self.Module] + self.DependentLibraryList:\r | |
3040 | Inherited = False\r | |
3041 | for D in M.Depex[self.Arch, ModuleType]:\r | |
3042 | if DepexList != []:\r | |
3043 | DepexList.append('AND')\r | |
3044 | DepexList.append('(')\r | |
3045 | DepexList.extend(D)\r | |
3046 | if DepexList[-1] == 'END': # no need of a END at this time\r | |
3047 | DepexList.pop()\r | |
3048 | DepexList.append(')')\r | |
3049 | Inherited = True\r | |
3050 | if Inherited:\r | |
3051 | EdkLogger.verbose("DEPEX[%s] (+%s) = %s" % (self.Name, M.BaseName, DepexList))\r | |
3052 | if 'BEFORE' in DepexList or 'AFTER' in DepexList:\r | |
3053 | break\r | |
3054 | if len(DepexList) > 0:\r | |
3055 | EdkLogger.verbose('')\r | |
caf74495 | 3056 | return self._DepexDict\r |
52302d4d LG |
3057 | \r |
3058 | ## Merge dependency expression\r | |
3059 | #\r | |
3060 | # @retval list The token list of the dependency expression after parsed\r | |
3061 | #\r | |
3062 | def _GetDepexExpressionTokenList(self):\r | |
caf74495 JC |
3063 | if self._DepexExpressionDict is None:\r |
3064 | self._DepexExpressionDict = {}\r | |
b36d134f | 3065 | if self.DxsFile or self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:\r |
caf74495 | 3066 | return self._DepexExpressionDict\r |
52302d4d | 3067 | \r |
caf74495 | 3068 | self._DepexExpressionDict[self.ModuleType] = ''\r |
52302d4d | 3069 | \r |
caf74495 JC |
3070 | for ModuleType in self._DepexExpressionDict:\r |
3071 | DepexExpressionString = self._DepexExpressionDict[ModuleType]\r | |
52302d4d LG |
3072 | #\r |
3073 | # Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion\r | |
3074 | #\r | |
3075 | for M in [self.Module] + self.DependentLibraryList:\r | |
3076 | Inherited = False\r | |
3077 | for D in M.DepexExpression[self.Arch, ModuleType]:\r | |
caf74495 JC |
3078 | if DepexExpressionString != '':\r |
3079 | DepexExpressionString += ' AND '\r | |
3080 | DepexExpressionString += '('\r | |
3081 | DepexExpressionString += D\r | |
3082 | DepexExpressionString = DepexExpressionString.rstrip('END').strip()\r | |
3083 | DepexExpressionString += ')'\r | |
52302d4d LG |
3084 | Inherited = True\r |
3085 | if Inherited:\r | |
caf74495 JC |
3086 | EdkLogger.verbose("DEPEX[%s] (+%s) = %s" % (self.Name, M.BaseName, DepexExpressionString))\r |
3087 | if 'BEFORE' in DepexExpressionString or 'AFTER' in DepexExpressionString:\r | |
52302d4d | 3088 | break\r |
caf74495 | 3089 | if len(DepexExpressionString) > 0:\r |
52302d4d | 3090 | EdkLogger.verbose('')\r |
caf74495 JC |
3091 | self._DepexExpressionDict[ModuleType] = DepexExpressionString\r |
3092 | return self._DepexExpressionDict\r | |
52302d4d | 3093 | \r |
dfa41b4a YZ |
3094 | # Get the tiano core user extension, it is contain dependent library.\r |
3095 | # @retval: a list contain tiano core userextension.\r | |
3096 | #\r | |
3097 | def _GetTianoCoreUserExtensionList(self):\r | |
3098 | TianoCoreUserExtentionList = []\r | |
3099 | for M in [self.Module] + self.DependentLibraryList:\r | |
3100 | Filename = M.MetaFile.Path\r | |
3101 | InfObj = InfSectionParser.InfSectionParser(Filename)\r | |
3102 | TianoCoreUserExtenList = InfObj.GetUserExtensionTianoCore()\r | |
3103 | for TianoCoreUserExtent in TianoCoreUserExtenList:\r | |
9eb87141 | 3104 | for Section in TianoCoreUserExtent:\r |
dfa41b4a YZ |
3105 | ItemList = Section.split(TAB_SPLIT)\r |
3106 | Arch = self.Arch\r | |
3107 | if len(ItemList) == 4:\r | |
3108 | Arch = ItemList[3]\r | |
3109 | if Arch.upper() == TAB_ARCH_COMMON or Arch.upper() == self.Arch.upper():\r | |
3110 | TianoCoreList = []\r | |
3111 | TianoCoreList.extend([TAB_SECTION_START + Section + TAB_SECTION_END])\r | |
3112 | TianoCoreList.extend(TianoCoreUserExtent[Section][:])\r | |
3113 | TianoCoreList.append('\n')\r | |
3114 | TianoCoreUserExtentionList.append(TianoCoreList)\r | |
3115 | \r | |
3116 | return TianoCoreUserExtentionList\r | |
3117 | \r | |
52302d4d LG |
3118 | ## Return the list of specification version required for the module\r |
3119 | #\r | |
3120 | # @retval list The list of specification defined in module file\r | |
3121 | #\r | |
3122 | def _GetSpecification(self):\r | |
3123 | return self.Module.Specification\r | |
3124 | \r | |
3125 | ## Tool option for the module build\r | |
3126 | #\r | |
3127 | # @param PlatformInfo The object of PlatformBuildInfo\r | |
3128 | # @retval dict The dict containing valid options\r | |
3129 | #\r | |
3130 | def _GetModuleBuildOption(self):\r | |
4231a819 | 3131 | if self._BuildOption is None:\r |
fe4bf2f9 YL |
3132 | self._BuildOption, self.BuildRuleOrder = self.PlatformInfo.ApplyBuildOption(self.Module)\r |
3133 | if self.BuildRuleOrder:\r | |
3134 | self.BuildRuleOrder = ['.%s' % Ext for Ext in self.BuildRuleOrder.split()]\r | |
52302d4d LG |
3135 | return self._BuildOption\r |
3136 | \r | |
79b74a03 LG |
3137 | ## Get include path list from tool option for the module build\r |
3138 | #\r | |
3139 | # @retval list The include path list\r | |
3140 | #\r | |
3141 | def _GetBuildOptionIncPathList(self):\r | |
4231a819 | 3142 | if self._BuildOptionIncPathList is None:\r |
79b74a03 | 3143 | #\r |
d40b2ee6 | 3144 | # Regular expression for finding Include Directories, the difference between MSFT and INTEL/GCC/RVCT\r |
79b74a03 LG |
3145 | # is the former use /I , the Latter used -I to specify include directories\r |
3146 | #\r | |
3147 | if self.PlatformInfo.ToolChainFamily in ('MSFT'):\r | |
c8802c3d | 3148 | BuildOptIncludeRegEx = gBuildOptIncludePatternMsft\r |
d40b2ee6 | 3149 | elif self.PlatformInfo.ToolChainFamily in ('INTEL', 'GCC', 'RVCT'):\r |
c8802c3d | 3150 | BuildOptIncludeRegEx = gBuildOptIncludePatternOther\r |
d40b2ee6 LG |
3151 | else:\r |
3152 | #\r | |
3153 | # New ToolChainFamily, don't known whether there is option to specify include directories\r | |
3154 | #\r | |
3155 | self._BuildOptionIncPathList = []\r | |
3156 | return self._BuildOptionIncPathList\r | |
79b74a03 LG |
3157 | \r |
3158 | BuildOptionIncPathList = []\r | |
3159 | for Tool in ('CC', 'PP', 'VFRPP', 'ASLPP', 'ASLCC', 'APP', 'ASM'):\r | |
79b74a03 | 3160 | try:\r |
caf74495 | 3161 | FlagOption = self.BuildOption[Tool]['FLAGS']\r |
79b74a03 LG |
3162 | except KeyError:\r |
3163 | FlagOption = ''\r | |
3164 | \r | |
d40b2ee6 | 3165 | if self.PlatformInfo.ToolChainFamily != 'RVCT':\r |
c8802c3d | 3166 | IncPathList = [NormPath(Path, self.Macros) for Path in BuildOptIncludeRegEx.findall(FlagOption)]\r |
d40b2ee6 LG |
3167 | else:\r |
3168 | #\r | |
3169 | # RVCT may specify a list of directory seperated by commas\r | |
3170 | #\r | |
3171 | IncPathList = []\r | |
c8802c3d | 3172 | for Path in BuildOptIncludeRegEx.findall(FlagOption):\r |
d40b2ee6 | 3173 | PathList = GetSplitList(Path, TAB_COMMA_SPLIT)\r |
caf74495 | 3174 | IncPathList.extend(NormPath(PathEntry, self.Macros) for PathEntry in PathList)\r |
d40b2ee6 | 3175 | \r |
79b74a03 LG |
3176 | #\r |
3177 | # EDK II modules must not reference header files outside of the packages they depend on or \r | |
3178 | # within the module's directory tree. Report error if violation.\r | |
3179 | #\r | |
caf74495 | 3180 | if self.AutoGenVersion >= 0x00010005:\r |
79b74a03 LG |
3181 | for Path in IncPathList:\r |
3182 | if (Path not in self.IncludePathList) and (CommonPath([Path, self.MetaFile.Dir]) != self.MetaFile.Dir):\r | |
47fea6af YZ |
3183 | ErrMsg = "The include directory for the EDK II module in this line is invalid %s specified in %s FLAGS '%s'" % (Path, Tool, FlagOption)\r |
3184 | EdkLogger.error("build",\r | |
79b74a03 | 3185 | PARAMETER_INVALID,\r |
47fea6af YZ |
3186 | ExtraData=ErrMsg,\r |
3187 | File=str(self.MetaFile))\r | |
79b74a03 LG |
3188 | \r |
3189 | \r | |
3190 | BuildOptionIncPathList += IncPathList\r | |
3191 | \r | |
3192 | self._BuildOptionIncPathList = BuildOptionIncPathList\r | |
3193 | \r | |
3194 | return self._BuildOptionIncPathList\r | |
3195 | \r | |
52302d4d LG |
3196 | ## Return a list of files which can be built from source\r |
3197 | #\r | |
3198 | # What kind of files can be built is determined by build rules in\r | |
97fa0ee9 | 3199 | # $(CONF_DIRECTORY)/build_rule.txt and toolchain family.\r |
52302d4d LG |
3200 | #\r |
3201 | def _GetSourceFileList(self):\r | |
4231a819 | 3202 | if self._SourceFileList is None:\r |
52302d4d LG |
3203 | self._SourceFileList = []\r |
3204 | for F in self.Module.Sources:\r | |
3205 | # match tool chain\r | |
08dd311f | 3206 | if F.TagName not in ("", "*", self.ToolChain):\r |
52302d4d LG |
3207 | EdkLogger.debug(EdkLogger.DEBUG_9, "The toolchain [%s] for processing file [%s] is found, "\r |
3208 | "but [%s] is needed" % (F.TagName, str(F), self.ToolChain))\r | |
3209 | continue\r | |
e2597799 YZ |
3210 | # match tool chain family or build rule family\r |
3211 | if F.ToolChainFamily not in ("", "*", self.ToolChainFamily, self.BuildRuleFamily):\r | |
52302d4d LG |
3212 | EdkLogger.debug(\r |
3213 | EdkLogger.DEBUG_0,\r | |
3214 | "The file [%s] must be built by tools of [%s], " \\r | |
e2597799 YZ |
3215 | "but current toolchain family is [%s], buildrule family is [%s]" \\r |
3216 | % (str(F), F.ToolChainFamily, self.ToolChainFamily, self.BuildRuleFamily))\r | |
52302d4d LG |
3217 | continue\r |
3218 | \r | |
3219 | # add the file path into search path list for file including\r | |
3220 | if F.Dir not in self.IncludePathList and self.AutoGenVersion >= 0x00010005:\r | |
3221 | self.IncludePathList.insert(0, F.Dir)\r | |
3222 | self._SourceFileList.append(F)\r | |
4cb7bade YZ |
3223 | \r |
3224 | self._MatchBuildRuleOrder(self._SourceFileList)\r | |
3225 | \r | |
3226 | for F in self._SourceFileList:\r | |
52302d4d LG |
3227 | self._ApplyBuildRule(F, TAB_UNKNOWN_FILE)\r |
3228 | return self._SourceFileList\r | |
3229 | \r | |
4cb7bade YZ |
3230 | def _MatchBuildRuleOrder(self, FileList):\r |
3231 | Order_Dict = {}\r | |
3232 | self._GetModuleBuildOption()\r | |
3233 | for SingleFile in FileList:\r | |
3234 | if self.BuildRuleOrder and SingleFile.Ext in self.BuildRuleOrder and SingleFile.Ext in self.BuildRules:\r | |
3235 | key = SingleFile.Path.split(SingleFile.Ext)[0]\r | |
3236 | if key in Order_Dict:\r | |
3237 | Order_Dict[key].append(SingleFile.Ext)\r | |
3238 | else:\r | |
3239 | Order_Dict[key] = [SingleFile.Ext]\r | |
3240 | \r | |
3241 | RemoveList = []\r | |
3242 | for F in Order_Dict:\r | |
3243 | if len(Order_Dict[F]) > 1:\r | |
3244 | Order_Dict[F].sort(key=lambda i: self.BuildRuleOrder.index(i))\r | |
3245 | for Ext in Order_Dict[F][1:]:\r | |
3246 | RemoveList.append(F + Ext)\r | |
3247 | \r | |
3248 | for item in RemoveList:\r | |
3249 | FileList.remove(item)\r | |
3250 | \r | |
3251 | return FileList\r | |
3252 | \r | |
52302d4d LG |
3253 | ## Return the list of unicode files\r |
3254 | def _GetUnicodeFileList(self):\r | |
4231a819 | 3255 | if self._UnicodeFileList is None:\r |
52302d4d LG |
3256 | if TAB_UNICODE_FILE in self.FileTypes:\r |
3257 | self._UnicodeFileList = self.FileTypes[TAB_UNICODE_FILE]\r | |
3258 | else:\r | |
3259 | self._UnicodeFileList = []\r | |
3260 | return self._UnicodeFileList\r | |
3261 | \r | |
5b97eb4c YZ |
3262 | ## Return the list of vfr files\r |
3263 | def _GetVfrFileList(self):\r | |
4231a819 | 3264 | if self._VfrFileList is None:\r |
5b97eb4c YZ |
3265 | if TAB_VFR_FILE in self.FileTypes:\r |
3266 | self._VfrFileList = self.FileTypes[TAB_VFR_FILE]\r | |
3267 | else:\r | |
3268 | self._VfrFileList = []\r | |
3269 | return self._VfrFileList\r | |
3270 | \r | |
333ba578 YZ |
3271 | ## Return the list of Image Definition files\r |
3272 | def _GetIdfFileList(self):\r | |
4231a819 | 3273 | if self._IdfFileList is None:\r |
333ba578 YZ |
3274 | if TAB_IMAGE_FILE in self.FileTypes:\r |
3275 | self._IdfFileList = self.FileTypes[TAB_IMAGE_FILE]\r | |
3276 | else:\r | |
3277 | self._IdfFileList = []\r | |
3278 | return self._IdfFileList\r | |
3279 | \r | |
52302d4d LG |
3280 | ## Return a list of files which can be built from binary\r |
3281 | #\r | |
3282 | # "Build" binary files are just to copy them to build directory.\r | |
3283 | #\r | |
3284 | # @retval list The list of files which can be built later\r | |
3285 | #\r | |
3286 | def _GetBinaryFiles(self):\r | |
4231a819 | 3287 | if self._BinaryFileList is None:\r |
52302d4d LG |
3288 | self._BinaryFileList = []\r |
3289 | for F in self.Module.Binaries:\r | |
6b1f2cf4 | 3290 | if F.Target not in [TAB_ARCH_COMMON, '*'] and F.Target != self.BuildTarget:\r |
52302d4d LG |
3291 | continue\r |
3292 | self._BinaryFileList.append(F)\r | |
3293 | self._ApplyBuildRule(F, F.Type)\r | |
3294 | return self._BinaryFileList\r | |
3295 | \r | |
3296 | def _GetBuildRules(self):\r | |
4231a819 | 3297 | if self._BuildRules is None:\r |
52302d4d LG |
3298 | BuildRules = {}\r |
3299 | BuildRuleDatabase = self.PlatformInfo.BuildRule\r | |
3300 | for Type in BuildRuleDatabase.FileTypeList:\r | |
3301 | #first try getting build rule by BuildRuleFamily\r | |
3302 | RuleObject = BuildRuleDatabase[Type, self.BuildType, self.Arch, self.BuildRuleFamily]\r | |
3303 | if not RuleObject:\r | |
3304 | # build type is always module type, but ...\r | |
3305 | if self.ModuleType != self.BuildType:\r | |
3306 | RuleObject = BuildRuleDatabase[Type, self.ModuleType, self.Arch, self.BuildRuleFamily]\r | |
3307 | #second try getting build rule by ToolChainFamily\r | |
3308 | if not RuleObject:\r | |
3309 | RuleObject = BuildRuleDatabase[Type, self.BuildType, self.Arch, self.ToolChainFamily]\r | |
3310 | if not RuleObject:\r | |
3311 | # build type is always module type, but ...\r | |
3312 | if self.ModuleType != self.BuildType:\r | |
3313 | RuleObject = BuildRuleDatabase[Type, self.ModuleType, self.Arch, self.ToolChainFamily]\r | |
3314 | if not RuleObject:\r | |
3315 | continue\r | |
3316 | RuleObject = RuleObject.Instantiate(self.Macros)\r | |
3317 | BuildRules[Type] = RuleObject\r | |
3318 | for Ext in RuleObject.SourceFileExtList:\r | |
3319 | BuildRules[Ext] = RuleObject\r | |
3320 | self._BuildRules = BuildRules\r | |
3321 | return self._BuildRules\r | |
3322 | \r | |
3323 | def _ApplyBuildRule(self, File, FileType):\r | |
4231a819 | 3324 | if self._BuildTargets is None:\r |
52302d4d LG |
3325 | self._IntroBuildTargetList = set()\r |
3326 | self._FinalBuildTargetList = set()\r | |
a993dc03 CJ |
3327 | self._BuildTargets = defaultdict(set)\r |
3328 | self._FileTypes = defaultdict(set)\r | |
52302d4d | 3329 | \r |
fcd4fbf3 YL |
3330 | SubDirectory = os.path.join(self.OutputDir, File.SubDir)\r |
3331 | if not os.path.exists(SubDirectory):\r | |
3332 | CreateDirectory(SubDirectory)\r | |
52302d4d | 3333 | LastTarget = None\r |
caf74495 | 3334 | RuleChain = set()\r |
52302d4d LG |
3335 | SourceList = [File]\r |
3336 | Index = 0\r | |
fe4bf2f9 YL |
3337 | #\r |
3338 | # Make sure to get build rule order value\r | |
3339 | #\r | |
3340 | self._GetModuleBuildOption()\r | |
3341 | \r | |
52302d4d LG |
3342 | while Index < len(SourceList):\r |
3343 | Source = SourceList[Index]\r | |
3344 | Index = Index + 1\r | |
3345 | \r | |
3346 | if Source != File:\r | |
3347 | CreateDirectory(Source.Dir)\r | |
3348 | \r | |
4231a819 | 3349 | if File.IsBinary and File == Source and self._BinaryFileList is not None and File in self._BinaryFileList:\r |
da92f276 LG |
3350 | # Skip all files that are not binary libraries\r |
3351 | if not self.IsLibrary:\r | |
47fea6af | 3352 | continue\r |
52302d4d LG |
3353 | RuleObject = self.BuildRules[TAB_DEFAULT_BINARY_FILE]\r |
3354 | elif FileType in self.BuildRules:\r | |
3355 | RuleObject = self.BuildRules[FileType]\r | |
3356 | elif Source.Ext in self.BuildRules:\r | |
3357 | RuleObject = self.BuildRules[Source.Ext]\r | |
3358 | else:\r | |
3359 | # stop at no more rules\r | |
3360 | if LastTarget:\r | |
3361 | self._FinalBuildTargetList.add(LastTarget)\r | |
3362 | break\r | |
3363 | \r | |
3364 | FileType = RuleObject.SourceFileType\r | |
52302d4d LG |
3365 | self._FileTypes[FileType].add(Source)\r |
3366 | \r | |
3367 | # stop at STATIC_LIBRARY for library\r | |
3368 | if self.IsLibrary and FileType == TAB_STATIC_LIBRARY:\r | |
3369 | if LastTarget:\r | |
3370 | self._FinalBuildTargetList.add(LastTarget)\r | |
3371 | break\r | |
3372 | \r | |
fe4bf2f9 | 3373 | Target = RuleObject.Apply(Source, self.BuildRuleOrder)\r |
52302d4d LG |
3374 | if not Target:\r |
3375 | if LastTarget:\r | |
3376 | self._FinalBuildTargetList.add(LastTarget)\r | |
3377 | break\r | |
3378 | elif not Target.Outputs:\r | |
3379 | # Only do build for target with outputs\r | |
3380 | self._FinalBuildTargetList.add(Target)\r | |
3381 | \r | |
52302d4d LG |
3382 | self._BuildTargets[FileType].add(Target)\r |
3383 | \r | |
3384 | if not Source.IsBinary and Source == File:\r | |
3385 | self._IntroBuildTargetList.add(Target)\r | |
3386 | \r | |
3387 | # to avoid cyclic rule\r | |
3388 | if FileType in RuleChain:\r | |
3389 | break\r | |
3390 | \r | |
caf74495 | 3391 | RuleChain.add(FileType)\r |
52302d4d LG |
3392 | SourceList.extend(Target.Outputs)\r |
3393 | LastTarget = Target\r | |
3394 | FileType = TAB_UNKNOWN_FILE\r | |
3395 | \r | |
3396 | def _GetTargets(self):\r | |
4231a819 | 3397 | if self._BuildTargets is None:\r |
52302d4d LG |
3398 | self._IntroBuildTargetList = set()\r |
3399 | self._FinalBuildTargetList = set()\r | |
a993dc03 CJ |
3400 | self._BuildTargets = defaultdict(set)\r |
3401 | self._FileTypes = defaultdict(set)\r | |
52302d4d | 3402 | \r |
b36d134f | 3403 | #TRICK: call _GetSourceFileList to apply build rule for source files\r |
52302d4d LG |
3404 | if self.SourceFileList:\r |
3405 | pass\r | |
3406 | \r | |
3407 | #TRICK: call _GetBinaryFileList to apply build rule for binary files\r | |
3408 | if self.BinaryFileList:\r | |
3409 | pass\r | |
3410 | \r | |
3411 | return self._BuildTargets\r | |
3412 | \r | |
3413 | def _GetIntroTargetList(self):\r | |
3414 | self._GetTargets()\r | |
3415 | return self._IntroBuildTargetList\r | |
3416 | \r | |
3417 | def _GetFinalTargetList(self):\r | |
3418 | self._GetTargets()\r | |
3419 | return self._FinalBuildTargetList\r | |
3420 | \r | |
3421 | def _GetFileTypes(self):\r | |
3422 | self._GetTargets()\r | |
3423 | return self._FileTypes\r | |
3424 | \r | |
3425 | ## Get the list of package object the module depends on\r | |
3426 | #\r | |
3427 | # @retval list The package object list\r | |
3428 | #\r | |
3429 | def _GetDependentPackageList(self):\r | |
3430 | return self.Module.Packages\r | |
3431 | \r | |
3432 | ## Return the list of auto-generated code file\r | |
3433 | #\r | |
3434 | # @retval list The list of auto-generated file\r | |
3435 | #\r | |
3436 | def _GetAutoGenFileList(self):\r | |
3437 | UniStringAutoGenC = True\r | |
333ba578 | 3438 | IdfStringAutoGenC = True\r |
4234283c | 3439 | UniStringBinBuffer = StringIO()\r |
333ba578 | 3440 | IdfGenBinBuffer = StringIO()\r |
52302d4d | 3441 | if self.BuildType == 'UEFI_HII':\r |
52302d4d | 3442 | UniStringAutoGenC = False\r |
333ba578 | 3443 | IdfStringAutoGenC = False\r |
4231a819 | 3444 | if self._AutoGenFileList is None:\r |
52302d4d LG |
3445 | self._AutoGenFileList = {}\r |
3446 | AutoGenC = TemplateString()\r | |
3447 | AutoGenH = TemplateString()\r | |
3448 | StringH = TemplateString()\r | |
333ba578 YZ |
3449 | StringIdf = TemplateString()\r |
3450 | GenC.CreateCode(self, AutoGenC, AutoGenH, StringH, UniStringAutoGenC, UniStringBinBuffer, StringIdf, IdfStringAutoGenC, IdfGenBinBuffer)\r | |
07b8564b YL |
3451 | #\r |
3452 | # AutoGen.c is generated if there are library classes in inf, or there are object files\r | |
3453 | #\r | |
3454 | if str(AutoGenC) != "" and (len(self.Module.LibraryClasses) > 0\r | |
3455 | or TAB_OBJECT_FILE in self.FileTypes):\r | |
52302d4d LG |
3456 | AutoFile = PathClass(gAutoGenCodeFileName, self.DebugDir)\r |
3457 | self._AutoGenFileList[AutoFile] = str(AutoGenC)\r | |
3458 | self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)\r | |
3459 | if str(AutoGenH) != "":\r | |
3460 | AutoFile = PathClass(gAutoGenHeaderFileName, self.DebugDir)\r | |
3461 | self._AutoGenFileList[AutoFile] = str(AutoGenH)\r | |
3462 | self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)\r | |
3463 | if str(StringH) != "":\r | |
3464 | AutoFile = PathClass(gAutoGenStringFileName % {"module_name":self.Name}, self.DebugDir)\r | |
3465 | self._AutoGenFileList[AutoFile] = str(StringH)\r | |
3466 | self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)\r | |
4231a819 | 3467 | if UniStringBinBuffer is not None and UniStringBinBuffer.getvalue() != "":\r |
52302d4d LG |
3468 | AutoFile = PathClass(gAutoGenStringFormFileName % {"module_name":self.Name}, self.OutputDir)\r |
3469 | self._AutoGenFileList[AutoFile] = UniStringBinBuffer.getvalue()\r | |
3470 | AutoFile.IsBinary = True\r | |
3471 | self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)\r | |
4231a819 | 3472 | if UniStringBinBuffer is not None:\r |
52302d4d | 3473 | UniStringBinBuffer.close()\r |
333ba578 YZ |
3474 | if str(StringIdf) != "":\r |
3475 | AutoFile = PathClass(gAutoGenImageDefFileName % {"module_name":self.Name}, self.DebugDir)\r | |
3476 | self._AutoGenFileList[AutoFile] = str(StringIdf)\r | |
3477 | self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)\r | |
4231a819 | 3478 | if IdfGenBinBuffer is not None and IdfGenBinBuffer.getvalue() != "":\r |
333ba578 YZ |
3479 | AutoFile = PathClass(gAutoGenIdfFileName % {"module_name":self.Name}, self.OutputDir)\r |
3480 | self._AutoGenFileList[AutoFile] = IdfGenBinBuffer.getvalue()\r | |
3481 | AutoFile.IsBinary = True\r | |
3482 | self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)\r | |
4231a819 | 3483 | if IdfGenBinBuffer is not None:\r |
333ba578 | 3484 | IdfGenBinBuffer.close()\r |
52302d4d LG |
3485 | return self._AutoGenFileList\r |
3486 | \r | |
3487 | ## Return the list of library modules explicitly or implicityly used by this module\r | |
3488 | def _GetLibraryList(self):\r | |
4231a819 | 3489 | if self._DependentLibraryList is None:\r |
52302d4d LG |
3490 | # only merge library classes and PCD for non-library module\r |
3491 | if self.IsLibrary:\r | |
3492 | self._DependentLibraryList = []\r | |
3493 | else:\r | |
3494 | if self.AutoGenVersion < 0x00010005:\r | |
3495 | self._DependentLibraryList = self.PlatformInfo.ResolveLibraryReference(self.Module)\r | |
3496 | else:\r | |
3497 | self._DependentLibraryList = self.PlatformInfo.ApplyLibraryInstance(self.Module)\r | |
3498 | return self._DependentLibraryList\r | |
3499 | \r | |
3500 | ## Get the list of PCDs from current module\r | |
3501 | #\r | |
3502 | # @retval list The list of PCD\r | |
3503 | #\r | |
3504 | def _GetModulePcdList(self):\r | |
4231a819 | 3505 | if self._ModulePcdList is None:\r |
52302d4d LG |
3506 | # apply PCD settings from platform\r |
3507 | self._ModulePcdList = self.PlatformInfo.ApplyPcdSetting(self.Module, self.Module.Pcds)\r | |
caf74495 | 3508 | ExtendCopyDictionaryLists(self._PcdComments, self.Module.PcdComments)\r |
52302d4d LG |
3509 | return self._ModulePcdList\r |
3510 | \r | |
3511 | ## Get the list of PCDs from dependent libraries\r | |
3512 | #\r | |
3513 | # @retval list The list of PCD\r | |
3514 | #\r | |
3515 | def _GetLibraryPcdList(self):\r | |
4231a819 | 3516 | if self._LibraryPcdList is None:\r |
9006a2c6 | 3517 | Pcds = OrderedDict()\r |
52302d4d LG |
3518 | if not self.IsLibrary:\r |
3519 | # get PCDs from dependent libraries\r | |
a253d217 | 3520 | self._LibraryPcdList = []\r |
52302d4d | 3521 | for Library in self.DependentLibraryList:\r |
a253d217 | 3522 | PcdsInLibrary = OrderedDict()\r |
caf74495 | 3523 | ExtendCopyDictionaryLists(self._PcdComments, Library.PcdComments)\r |
52302d4d LG |
3524 | for Key in Library.Pcds:\r |
3525 | # skip duplicated PCDs\r | |
3526 | if Key in self.Module.Pcds or Key in Pcds:\r | |
3527 | continue\r | |
3528 | Pcds[Key] = copy.copy(Library.Pcds[Key])\r | |
a253d217 YF |
3529 | PcdsInLibrary[Key] = Pcds[Key]\r |
3530 | self._LibraryPcdList.extend(self.PlatformInfo.ApplyPcdSetting(self.Module, PcdsInLibrary, Library=Library))\r | |
52302d4d LG |
3531 | else:\r |
3532 | self._LibraryPcdList = []\r | |
3533 | return self._LibraryPcdList\r | |
3534 | \r | |
3535 | ## Get the GUID value mapping\r | |
3536 | #\r | |
3537 | # @retval dict The mapping between GUID cname and its value\r | |
3538 | #\r | |
3539 | def _GetGuidList(self):\r | |
4231a819 | 3540 | if self._GuidList is None:\r |
9006a2c6 | 3541 | self._GuidList = OrderedDict()\r |
8200fcfe | 3542 | self._GuidList.update(self.Module.Guids)\r |
52302d4d LG |
3543 | for Library in self.DependentLibraryList:\r |
3544 | self._GuidList.update(Library.Guids)\r | |
caf74495 JC |
3545 | ExtendCopyDictionaryLists(self._GuidComments, Library.GuidComments)\r |
3546 | ExtendCopyDictionaryLists(self._GuidComments, self.Module.GuidComments)\r | |
52302d4d LG |
3547 | return self._GuidList\r |
3548 | \r | |
e8a47801 | 3549 | def GetGuidsUsedByPcd(self):\r |
4231a819 | 3550 | if self._GuidsUsedByPcd is None:\r |
9006a2c6 | 3551 | self._GuidsUsedByPcd = OrderedDict()\r |
e8a47801 LG |
3552 | self._GuidsUsedByPcd.update(self.Module.GetGuidsUsedByPcd())\r |
3553 | for Library in self.DependentLibraryList:\r | |
3554 | self._GuidsUsedByPcd.update(Library.GetGuidsUsedByPcd())\r | |
3555 | return self._GuidsUsedByPcd\r | |
52302d4d LG |
3556 | ## Get the protocol value mapping\r |
3557 | #\r | |
3558 | # @retval dict The mapping between protocol cname and its value\r | |
3559 | #\r | |
3560 | def _GetProtocolList(self):\r | |
4231a819 | 3561 | if self._ProtocolList is None:\r |
9006a2c6 | 3562 | self._ProtocolList = OrderedDict()\r |
8200fcfe | 3563 | self._ProtocolList.update(self.Module.Protocols)\r |
52302d4d LG |
3564 | for Library in self.DependentLibraryList:\r |
3565 | self._ProtocolList.update(Library.Protocols)\r | |
caf74495 JC |
3566 | ExtendCopyDictionaryLists(self._ProtocolComments, Library.ProtocolComments)\r |
3567 | ExtendCopyDictionaryLists(self._ProtocolComments, self.Module.ProtocolComments)\r | |
52302d4d LG |
3568 | return self._ProtocolList\r |
3569 | \r | |
3570 | ## Get the PPI value mapping\r | |
3571 | #\r | |
3572 | # @retval dict The mapping between PPI cname and its value\r | |
3573 | #\r | |
3574 | def _GetPpiList(self):\r | |
4231a819 | 3575 | if self._PpiList is None:\r |
9006a2c6 | 3576 | self._PpiList = OrderedDict()\r |
8200fcfe | 3577 | self._PpiList.update(self.Module.Ppis)\r |
52302d4d LG |
3578 | for Library in self.DependentLibraryList:\r |
3579 | self._PpiList.update(Library.Ppis)\r | |
caf74495 JC |
3580 | ExtendCopyDictionaryLists(self._PpiComments, Library.PpiComments)\r |
3581 | ExtendCopyDictionaryLists(self._PpiComments, self.Module.PpiComments)\r | |
52302d4d LG |
3582 | return self._PpiList\r |
3583 | \r | |
3584 | ## Get the list of include search path\r | |
3585 | #\r | |
3586 | # @retval list The list path\r | |
3587 | #\r | |
3588 | def _GetIncludePathList(self):\r | |
4231a819 | 3589 | if self._IncludePathList is None:\r |
52302d4d LG |
3590 | self._IncludePathList = []\r |
3591 | if self.AutoGenVersion < 0x00010005:\r | |
3592 | for Inc in self.Module.Includes:\r | |
3593 | if Inc not in self._IncludePathList:\r | |
3594 | self._IncludePathList.append(Inc)\r | |
b36d134f | 3595 | # for Edk modules\r |
52302d4d LG |
3596 | Inc = path.join(Inc, self.Arch.capitalize())\r |
3597 | if os.path.exists(Inc) and Inc not in self._IncludePathList:\r | |
3598 | self._IncludePathList.append(Inc)\r | |
b36d134f | 3599 | # Edk module needs to put DEBUG_DIR at the end of search path and not to use SOURCE_DIR all the time\r |
52302d4d LG |
3600 | self._IncludePathList.append(self.DebugDir)\r |
3601 | else:\r | |
3602 | self._IncludePathList.append(self.MetaFile.Dir)\r | |
3603 | self._IncludePathList.append(self.DebugDir)\r | |
3604 | \r | |
3605 | for Package in self.Module.Packages:\r | |
05cc51ad | 3606 | PackageDir = mws.join(self.WorkspaceDir, Package.MetaFile.Dir)\r |
52302d4d LG |
3607 | if PackageDir not in self._IncludePathList:\r |
3608 | self._IncludePathList.append(PackageDir)\r | |
c28d2e10 YZ |
3609 | IncludesList = Package.Includes\r |
3610 | if Package._PrivateIncludes:\r | |
3611 | if not self.MetaFile.Path.startswith(PackageDir):\r | |
3612 | IncludesList = list(set(Package.Includes).difference(set(Package._PrivateIncludes)))\r | |
3613 | for Inc in IncludesList:\r | |
52302d4d LG |
3614 | if Inc not in self._IncludePathList:\r |
3615 | self._IncludePathList.append(str(Inc))\r | |
3616 | return self._IncludePathList\r | |
3617 | \r | |
725cdb8f | 3618 | def _GetIncludePathLength(self):\r |
caf74495 | 3619 | return sum(len(inc)+1 for inc in self._IncludePathList)\r |
725cdb8f | 3620 | \r |
97fa0ee9 YL |
3621 | ## Get HII EX PCDs which maybe used by VFR\r |
3622 | #\r | |
3623 | # efivarstore used by VFR may relate with HII EX PCDs\r | |
3624 | # Get the variable name and GUID from efivarstore and HII EX PCD\r | |
3625 | # List the HII EX PCDs in As Built INF if both name and GUID match.\r | |
3626 | #\r | |
3627 | # @retval list HII EX PCDs\r | |
3628 | #\r | |
3629 | def _GetPcdsMaybeUsedByVfr(self):\r | |
3630 | if not self.SourceFileList:\r | |
3631 | return []\r | |
3632 | \r | |
29189291 | 3633 | NameGuids = set()\r |
97fa0ee9 YL |
3634 | for SrcFile in self.SourceFileList:\r |
3635 | if SrcFile.Ext.lower() != '.vfr':\r | |
3636 | continue\r | |
3637 | Vfri = os.path.join(self.OutputDir, SrcFile.BaseName + '.i')\r | |
3638 | if not os.path.exists(Vfri):\r | |
3639 | continue\r | |
3640 | VfriFile = open(Vfri, 'r')\r | |
3641 | Content = VfriFile.read()\r | |
3642 | VfriFile.close()\r | |
3643 | Pos = Content.find('efivarstore')\r | |
3644 | while Pos != -1:\r | |
3645 | #\r | |
3646 | # Make sure 'efivarstore' is the start of efivarstore statement\r | |
3647 | # In case of the value of 'name' (name = efivarstore) is equal to 'efivarstore'\r | |
3648 | #\r | |
3649 | Index = Pos - 1\r | |
3650 | while Index >= 0 and Content[Index] in ' \t\r\n':\r | |
3651 | Index -= 1\r | |
3652 | if Index >= 0 and Content[Index] != ';':\r | |
3653 | Pos = Content.find('efivarstore', Pos + len('efivarstore'))\r | |
3654 | continue\r | |
3655 | #\r | |
3656 | # 'efivarstore' must be followed by name and guid\r | |
3657 | #\r | |
3658 | Name = gEfiVarStoreNamePattern.search(Content, Pos)\r | |
3659 | if not Name:\r | |
3660 | break\r | |
3661 | Guid = gEfiVarStoreGuidPattern.search(Content, Pos)\r | |
3662 | if not Guid:\r | |
3663 | break\r | |
3664 | NameArray = ConvertStringToByteArray('L"' + Name.group(1) + '"')\r | |
29189291 | 3665 | NameGuids.add((NameArray, GuidStructureStringToGuidString(Guid.group(1))))\r |
97fa0ee9 YL |
3666 | Pos = Content.find('efivarstore', Name.end())\r |
3667 | if not NameGuids:\r | |
3668 | return []\r | |
3669 | HiiExPcds = []\r | |
3670 | for Pcd in self.PlatformInfo.Platform.Pcds.values():\r | |
3671 | if Pcd.Type != TAB_PCDS_DYNAMIC_EX_HII:\r | |
3672 | continue\r | |
caf74495 | 3673 | for SkuInfo in Pcd.SkuInfoList.values():\r |
c28d2e10 | 3674 | Value = GuidValue(SkuInfo.VariableGuid, self.PlatformInfo.PackageList, self.MetaFile.Path)\r |
97fa0ee9 YL |
3675 | if not Value:\r |
3676 | continue\r | |
caf74495 | 3677 | Name = ConvertStringToByteArray(SkuInfo.VariableName)\r |
97fa0ee9 YL |
3678 | Guid = GuidStructureStringToGuidString(Value)\r |
3679 | if (Name, Guid) in NameGuids and Pcd not in HiiExPcds:\r | |
3680 | HiiExPcds.append(Pcd)\r | |
3681 | break\r | |
3682 | \r | |
3683 | return HiiExPcds\r | |
3684 | \r | |
aeaaf754 YL |
3685 | def _GenOffsetBin(self):\r |
3686 | VfrUniBaseName = {}\r | |
3687 | for SourceFile in self.Module.Sources:\r | |
3688 | if SourceFile.Type.upper() == ".VFR" :\r | |
3689 | #\r | |
3690 | # search the .map file to find the offset of vfr binary in the PE32+/TE file. \r | |
3691 | #\r | |
3692 | VfrUniBaseName[SourceFile.BaseName] = (SourceFile.BaseName + "Bin")\r | |
caf74495 | 3693 | elif SourceFile.Type.upper() == ".UNI" :\r |
aeaaf754 YL |
3694 | #\r |
3695 | # search the .map file to find the offset of Uni strings binary in the PE32+/TE file. \r | |
3696 | #\r | |
3697 | VfrUniBaseName["UniOffsetName"] = (self.Name + "Strings")\r | |
3698 | \r | |
caf74495 | 3699 | if not VfrUniBaseName:\r |
aeaaf754 YL |
3700 | return None\r |
3701 | MapFileName = os.path.join(self.OutputDir, self.Name + ".map")\r | |
3702 | EfiFileName = os.path.join(self.OutputDir, self.Name + ".efi")\r | |
3703 | VfrUniOffsetList = GetVariableOffset(MapFileName, EfiFileName, VfrUniBaseName.values())\r | |
3704 | if not VfrUniOffsetList:\r | |
3705 | return None\r | |
3706 | \r | |
3707 | OutputName = '%sOffset.bin' % self.Name\r | |
3708 | UniVfrOffsetFileName = os.path.join( self.OutputDir, OutputName)\r | |
3709 | \r | |
3710 | try:\r | |
3711 | fInputfile = open(UniVfrOffsetFileName, "wb+", 0)\r | |
3712 | except:\r | |
3713 | EdkLogger.error("build", FILE_OPEN_FAILURE, "File open failed for %s" % UniVfrOffsetFileName,None)\r | |
3714 | \r | |
3715 | # Use a instance of StringIO to cache data\r | |
3716 | fStringIO = StringIO('') \r | |
3717 | \r | |
3718 | for Item in VfrUniOffsetList:\r | |
3719 | if (Item[0].find("Strings") != -1):\r | |
3720 | #\r | |
3721 | # UNI offset in image.\r | |
3722 | # GUID + Offset\r | |
3723 | # { 0x8913c5e0, 0x33f6, 0x4d86, { 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66 } }\r | |
3724 | #\r | |
3725 | UniGuid = [0xe0, 0xc5, 0x13, 0x89, 0xf6, 0x33, 0x86, 0x4d, 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66]\r | |
3726 | UniGuid = [chr(ItemGuid) for ItemGuid in UniGuid]\r | |
3727 | fStringIO.write(''.join(UniGuid)) \r | |
3728 | UniValue = pack ('Q', int (Item[1], 16))\r | |
3729 | fStringIO.write (UniValue)\r | |
3730 | else:\r | |
3731 | #\r | |
3732 | # VFR binary offset in image.\r | |
3733 | # GUID + Offset\r | |
3734 | # { 0xd0bc7cb4, 0x6a47, 0x495f, { 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2 } };\r | |
3735 | #\r | |
3736 | VfrGuid = [0xb4, 0x7c, 0xbc, 0xd0, 0x47, 0x6a, 0x5f, 0x49, 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2]\r | |
3737 | VfrGuid = [chr(ItemGuid) for ItemGuid in VfrGuid]\r | |
3738 | fStringIO.write(''.join(VfrGuid)) \r | |
aeaaf754 YL |
3739 | VfrValue = pack ('Q', int (Item[1], 16))\r |
3740 | fStringIO.write (VfrValue)\r | |
3741 | #\r | |
3742 | # write data into file.\r | |
3743 | #\r | |
3744 | try : \r | |
3745 | fInputfile.write (fStringIO.getvalue())\r | |
3746 | except:\r | |
3747 | EdkLogger.error("build", FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the "\r | |
3748 | "file been locked or using by other applications." %UniVfrOffsetFileName,None)\r | |
3749 | \r | |
3750 | fStringIO.close ()\r | |
3751 | fInputfile.close ()\r | |
3752 | return OutputName\r | |
3753 | \r | |
da92f276 LG |
3754 | ## Create AsBuilt INF file the module\r |
3755 | #\r | |
83397f95 | 3756 | def CreateAsBuiltInf(self, IsOnlyCopy = False):\r |
ac55e478 | 3757 | self.OutputFile = set()\r |
caf74495 JC |
3758 | if IsOnlyCopy and GlobalData.gBinCacheDest:\r |
3759 | self.CopyModuleToCache()\r | |
3760 | return\r | |
83397f95 | 3761 | \r |
da92f276 LG |
3762 | if self.IsAsBuiltInfCreated:\r |
3763 | return\r | |
3764 | \r | |
3765 | # Skip the following code for EDK I inf\r | |
3766 | if self.AutoGenVersion < 0x00010005:\r | |
3767 | return\r | |
3768 | \r | |
3769 | # Skip the following code for libraries\r | |
3770 | if self.IsLibrary:\r | |
3771 | return\r | |
3772 | \r | |
3773 | # Skip the following code for modules with no source files\r | |
6be94743 | 3774 | if not self.SourceFileList:\r |
da92f276 LG |
3775 | return\r |
3776 | \r | |
3777 | # Skip the following code for modules without any binary files\r | |
40857777 | 3778 | if self.BinaryFileList:\r |
da92f276 LG |
3779 | return\r |
3780 | \r | |
3781 | ### TODO: How to handles mixed source and binary modules\r | |
3782 | \r | |
e8a47801 | 3783 | # Find all DynamicEx and PatchableInModule PCDs used by this module and dependent libraries\r |
da92f276 LG |
3784 | # Also find all packages that the DynamicEx PCDs depend on\r |
3785 | Pcds = []\r | |
e5cf9198 | 3786 | PatchablePcds = []\r |
47fea6af | 3787 | Packages = []\r |
e8a47801 LG |
3788 | PcdCheckList = []\r |
3789 | PcdTokenSpaceList = []\r | |
da92f276 | 3790 | for Pcd in self.ModulePcdList + self.LibraryPcdList:\r |
e8a47801 | 3791 | if Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE:\r |
caf74495 | 3792 | PatchablePcds.append(Pcd)\r |
6b1f2cf4 | 3793 | PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, TAB_PCDS_PATCHABLE_IN_MODULE))\r |
eece4292 | 3794 | elif Pcd.Type in PCD_DYNAMIC_EX_TYPE_SET:\r |
e8a47801 | 3795 | if Pcd not in Pcds:\r |
caf74495 | 3796 | Pcds.append(Pcd)\r |
6b1f2cf4 CJ |
3797 | PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, TAB_PCDS_DYNAMIC_EX))\r |
3798 | PcdCheckList.append((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, TAB_PCDS_DYNAMIC))\r | |
e8a47801 | 3799 | PcdTokenSpaceList.append(Pcd.TokenSpaceGuidCName)\r |
9006a2c6 | 3800 | GuidList = OrderedDict()\r |
e8a47801 LG |
3801 | GuidList.update(self.GuidList)\r |
3802 | for TokenSpace in self.GetGuidsUsedByPcd():\r | |
3803 | # If token space is not referred by patch PCD or Ex PCD, remove the GUID from GUID list\r | |
3804 | # The GUIDs in GUIDs section should really be the GUIDs in source INF or referred by Ex an patch PCDs\r | |
3805 | if TokenSpace not in PcdTokenSpaceList and TokenSpace in GuidList:\r | |
3806 | GuidList.pop(TokenSpace)\r | |
3807 | CheckList = (GuidList, self.PpiList, self.ProtocolList, PcdCheckList)\r | |
3808 | for Package in self.DerivedPackageList:\r | |
3809 | if Package in Packages:\r | |
3810 | continue\r | |
3811 | BeChecked = (Package.Guids, Package.Ppis, Package.Protocols, Package.Pcds)\r | |
3812 | Found = False\r | |
3813 | for Index in range(len(BeChecked)):\r | |
3814 | for Item in CheckList[Index]:\r | |
3815 | if Item in BeChecked[Index]:\r | |
caf74495 | 3816 | Packages.append(Package)\r |
e8a47801 LG |
3817 | Found = True\r |
3818 | break\r | |
caf74495 JC |
3819 | if Found:\r |
3820 | break\r | |
da92f276 | 3821 | \r |
97fa0ee9 YL |
3822 | VfrPcds = self._GetPcdsMaybeUsedByVfr()\r |
3823 | for Pkg in self.PlatformInfo.PackageList:\r | |
3824 | if Pkg in Packages:\r | |
3825 | continue\r | |
3826 | for VfrPcd in VfrPcds:\r | |
6b1f2cf4 CJ |
3827 | if ((VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, TAB_PCDS_DYNAMIC_EX) in Pkg.Pcds or\r |
3828 | (VfrPcd.TokenCName, VfrPcd.TokenSpaceGuidCName, TAB_PCDS_DYNAMIC) in Pkg.Pcds):\r | |
caf74495 | 3829 | Packages.append(Pkg)\r |
97fa0ee9 YL |
3830 | break\r |
3831 | \r | |
caf74495 JC |
3832 | ModuleType = SUP_MODULE_DXE_DRIVER if self.ModuleType == SUP_MODULE_UEFI_DRIVER and self.DepexGenerated else self.ModuleType\r |
3833 | DriverType = self.PcdIsDriver if self.PcdIsDriver else ''\r | |
97fa0ee9 YL |
3834 | Guid = self.Guid\r |
3835 | MDefs = self.Module.Defines\r | |
3836 | \r | |
da92f276 LG |
3837 | AsBuiltInfDict = {\r |
3838 | 'module_name' : self.Name,\r | |
97fa0ee9 | 3839 | 'module_guid' : Guid,\r |
da92f276 | 3840 | 'module_module_type' : ModuleType,\r |
97fa0ee9 | 3841 | 'module_version_string' : [MDefs['VERSION_STRING']] if 'VERSION_STRING' in MDefs else [],\r |
e8a47801 | 3842 | 'pcd_is_driver_string' : [],\r |
da92f276 LG |
3843 | 'module_uefi_specification_version' : [],\r |
3844 | 'module_pi_specification_version' : [],\r | |
97fa0ee9 YL |
3845 | 'module_entry_point' : self.Module.ModuleEntryPointList,\r |
3846 | 'module_unload_image' : self.Module.ModuleUnloadImageList,\r | |
3847 | 'module_constructor' : self.Module.ConstructorList,\r | |
3848 | 'module_destructor' : self.Module.DestructorList,\r | |
3849 | 'module_shadow' : [MDefs['SHADOW']] if 'SHADOW' in MDefs else [],\r | |
3850 | 'module_pci_vendor_id' : [MDefs['PCI_VENDOR_ID']] if 'PCI_VENDOR_ID' in MDefs else [],\r | |
3851 | 'module_pci_device_id' : [MDefs['PCI_DEVICE_ID']] if 'PCI_DEVICE_ID' in MDefs else [],\r | |
3852 | 'module_pci_class_code' : [MDefs['PCI_CLASS_CODE']] if 'PCI_CLASS_CODE' in MDefs else [],\r | |
3853 | 'module_pci_revision' : [MDefs['PCI_REVISION']] if 'PCI_REVISION' in MDefs else [],\r | |
3854 | 'module_build_number' : [MDefs['BUILD_NUMBER']] if 'BUILD_NUMBER' in MDefs else [],\r | |
3855 | 'module_spec' : [MDefs['SPEC']] if 'SPEC' in MDefs else [],\r | |
3856 | 'module_uefi_hii_resource_section' : [MDefs['UEFI_HII_RESOURCE_SECTION']] if 'UEFI_HII_RESOURCE_SECTION' in MDefs else [],\r | |
3857 | 'module_uni_file' : [MDefs['MODULE_UNI_FILE']] if 'MODULE_UNI_FILE' in MDefs else [],\r | |
da92f276 | 3858 | 'module_arch' : self.Arch,\r |
caf74495 | 3859 | 'package_item' : [Package.MetaFile.File.replace('\\', '/') for Package in Packages],\r |
da92f276 | 3860 | 'binary_item' : [],\r |
e8a47801 | 3861 | 'patchablepcd_item' : [],\r |
da92f276 | 3862 | 'pcd_item' : [],\r |
e8a47801 LG |
3863 | 'protocol_item' : [],\r |
3864 | 'ppi_item' : [],\r | |
3865 | 'guid_item' : [],\r | |
3866 | 'flags_item' : [],\r | |
3867 | 'libraryclasses_item' : []\r | |
da92f276 | 3868 | }\r |
97fa0ee9 | 3869 | \r |
78bcd52a YZ |
3870 | if 'MODULE_UNI_FILE' in MDefs:\r |
3871 | UNIFile = os.path.join(self.MetaFile.Dir, MDefs['MODULE_UNI_FILE'])\r | |
3872 | if os.path.isfile(UNIFile):\r | |
3873 | shutil.copy2(UNIFile, self.OutputDir)\r | |
3874 | \r | |
97fa0ee9 YL |
3875 | if self.AutoGenVersion > int(gInfSpecVersion, 0):\r |
3876 | AsBuiltInfDict['module_inf_version'] = '0x%08x' % self.AutoGenVersion\r | |
3877 | else:\r | |
3878 | AsBuiltInfDict['module_inf_version'] = gInfSpecVersion\r | |
3879 | \r | |
e8a47801 | 3880 | if DriverType:\r |
caf74495 | 3881 | AsBuiltInfDict['pcd_is_driver_string'].append(DriverType)\r |
da92f276 LG |
3882 | \r |
3883 | if 'UEFI_SPECIFICATION_VERSION' in self.Specification:\r | |
caf74495 | 3884 | AsBuiltInfDict['module_uefi_specification_version'].append(self.Specification['UEFI_SPECIFICATION_VERSION'])\r |
da92f276 | 3885 | if 'PI_SPECIFICATION_VERSION' in self.Specification:\r |
caf74495 | 3886 | AsBuiltInfDict['module_pi_specification_version'].append(self.Specification['PI_SPECIFICATION_VERSION'])\r |
da92f276 | 3887 | \r |
47fea6af | 3888 | OutputDir = self.OutputDir.replace('\\', '/').strip('/')\r |
c7c5a6c4 | 3889 | DebugDir = self.DebugDir.replace('\\', '/').strip('/')\r |
481252bb | 3890 | for Item in self.CodaTargetList:\r |
90456c3c | 3891 | File = Item.Target.Path.replace('\\', '/').strip('/').replace(DebugDir, '').replace(OutputDir, '').strip('/')\r |
ac55e478 | 3892 | self.OutputFile.add(File)\r |
5e2c0ecd YZ |
3893 | if os.path.isabs(File):\r |
3894 | File = File.replace('\\', '/').strip('/').replace(OutputDir, '').strip('/')\r | |
47fea6af | 3895 | if Item.Target.Ext.lower() == '.aml':\r |
caf74495 | 3896 | AsBuiltInfDict['binary_item'].append('ASL|' + File)\r |
47fea6af | 3897 | elif Item.Target.Ext.lower() == '.acpi':\r |
caf74495 | 3898 | AsBuiltInfDict['binary_item'].append('ACPI|' + File)\r |
481252bb | 3899 | elif Item.Target.Ext.lower() == '.efi':\r |
caf74495 | 3900 | AsBuiltInfDict['binary_item'].append('PE32|' + self.Name + '.efi')\r |
da92f276 | 3901 | else:\r |
caf74495 | 3902 | AsBuiltInfDict['binary_item'].append('BIN|' + File)\r |
481252bb | 3903 | if self.DepexGenerated:\r |
ac55e478 | 3904 | self.OutputFile.add(self.Name + '.depex')\r |
8bb63e37 | 3905 | if self.ModuleType in [SUP_MODULE_PEIM]:\r |
caf74495 JC |
3906 | AsBuiltInfDict['binary_item'].append('PEI_DEPEX|' + self.Name + '.depex')\r |
3907 | elif self.ModuleType in [SUP_MODULE_DXE_DRIVER, SUP_MODULE_DXE_RUNTIME_DRIVER, SUP_MODULE_DXE_SAL_DRIVER, SUP_MODULE_UEFI_DRIVER]:\r | |
3908 | AsBuiltInfDict['binary_item'].append('DXE_DEPEX|' + self.Name + '.depex')\r | |
3909 | elif self.ModuleType in [SUP_MODULE_DXE_SMM_DRIVER]:\r | |
3910 | AsBuiltInfDict['binary_item'].append('SMM_DEPEX|' + self.Name + '.depex')\r | |
da92f276 | 3911 | \r |
aeaaf754 YL |
3912 | Bin = self._GenOffsetBin()\r |
3913 | if Bin:\r | |
caf74495 | 3914 | AsBuiltInfDict['binary_item'].append('BIN|%s' % Bin)\r |
ac55e478 | 3915 | self.OutputFile.add(Bin)\r |
aeaaf754 | 3916 | \r |
e8a47801 LG |
3917 | for Root, Dirs, Files in os.walk(OutputDir):\r |
3918 | for File in Files:\r | |
3919 | if File.lower().endswith('.pdb'):\r | |
caf74495 | 3920 | AsBuiltInfDict['binary_item'].append('DISPOSABLE|' + File)\r |
ac55e478 | 3921 | self.OutputFile.add(File)\r |
e8a47801 LG |
3922 | HeaderComments = self.Module.HeaderComments\r |
3923 | StartPos = 0\r | |
3924 | for Index in range(len(HeaderComments)):\r | |
3925 | if HeaderComments[Index].find('@BinaryHeader') != -1:\r | |
3926 | HeaderComments[Index] = HeaderComments[Index].replace('@BinaryHeader', '@file')\r | |
3927 | StartPos = Index\r | |
3928 | break\r | |
3929 | AsBuiltInfDict['header_comments'] = '\n'.join(HeaderComments[StartPos:]).replace(':#', '://')\r | |
97fa0ee9 YL |
3930 | AsBuiltInfDict['tail_comments'] = '\n'.join(self.Module.TailComments)\r |
3931 | \r | |
e8a47801 LG |
3932 | GenList = [\r |
3933 | (self.ProtocolList, self._ProtocolComments, 'protocol_item'),\r | |
3934 | (self.PpiList, self._PpiComments, 'ppi_item'),\r | |
3935 | (GuidList, self._GuidComments, 'guid_item')\r | |
3936 | ]\r | |
3937 | for Item in GenList:\r | |
3938 | for CName in Item[0]:\r | |
caf74495 JC |
3939 | Comments = '\n '.join(Item[1][CName]) if CName in Item[1] else ''\r |
3940 | Entry = Comments + '\n ' + CName if Comments else CName\r | |
e8a47801 LG |
3941 | AsBuiltInfDict[Item[2]].append(Entry)\r |
3942 | PatchList = parsePcdInfoFromMapFile(\r | |
3943 | os.path.join(self.OutputDir, self.Name + '.map'),\r | |
3944 | os.path.join(self.OutputDir, self.Name + '.efi')\r | |
3945 | )\r | |
3946 | if PatchList:\r | |
e5cf9198 YZ |
3947 | for Pcd in PatchablePcds:\r |
3948 | TokenCName = Pcd.TokenCName\r | |
3949 | for PcdItem in GlobalData.MixedPcd:\r | |
3950 | if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:\r | |
3951 | TokenCName = PcdItem[0]\r | |
3952 | break\r | |
3953 | for PatchPcd in PatchList:\r | |
3954 | if TokenCName == PatchPcd[0]:\r | |
3955 | break\r | |
2a29017e | 3956 | else:\r |
e8a47801 | 3957 | continue\r |
e8a47801 | 3958 | PcdValue = ''\r |
7ced8bb4 YZ |
3959 | if Pcd.DatumType == 'BOOLEAN':\r |
3960 | BoolValue = Pcd.DefaultValue.upper()\r | |
3961 | if BoolValue == 'TRUE':\r | |
3962 | Pcd.DefaultValue = '1'\r | |
3963 | elif BoolValue == 'FALSE':\r | |
3964 | Pcd.DefaultValue = '0'\r | |
3965 | \r | |
656d2539 | 3966 | if Pcd.DatumType in TAB_PCD_NUMERIC_TYPES:\r |
e8a47801 | 3967 | HexFormat = '0x%02x'\r |
656d2539 | 3968 | if Pcd.DatumType == TAB_UINT16:\r |
e8a47801 | 3969 | HexFormat = '0x%04x'\r |
656d2539 | 3970 | elif Pcd.DatumType == TAB_UINT32:\r |
e8a47801 | 3971 | HexFormat = '0x%08x'\r |
656d2539 | 3972 | elif Pcd.DatumType == TAB_UINT64:\r |
e8a47801 LG |
3973 | HexFormat = '0x%016x'\r |
3974 | PcdValue = HexFormat % int(Pcd.DefaultValue, 0)\r | |
3975 | else:\r | |
4231a819 | 3976 | if Pcd.MaxDatumSize is None or Pcd.MaxDatumSize == '':\r |
e8a47801 | 3977 | EdkLogger.error("build", AUTOGEN_ERROR,\r |
2a29017e | 3978 | "Unknown [MaxDatumSize] of PCD [%s.%s]" % (Pcd.TokenSpaceGuidCName, TokenCName)\r |
e8a47801 LG |
3979 | )\r |
3980 | ArraySize = int(Pcd.MaxDatumSize, 0)\r | |
3981 | PcdValue = Pcd.DefaultValue\r | |
3982 | if PcdValue[0] != '{':\r | |
3983 | Unicode = False\r | |
3984 | if PcdValue[0] == 'L':\r | |
3985 | Unicode = True\r | |
3986 | PcdValue = PcdValue.lstrip('L')\r | |
3987 | PcdValue = eval(PcdValue)\r | |
3988 | NewValue = '{'\r | |
3989 | for Index in range(0, len(PcdValue)):\r | |
3990 | if Unicode:\r | |
3991 | CharVal = ord(PcdValue[Index])\r | |
3992 | NewValue = NewValue + '0x%02x' % (CharVal & 0x00FF) + ', ' \\r | |
3993 | + '0x%02x' % (CharVal >> 8) + ', '\r | |
3994 | else:\r | |
3995 | NewValue = NewValue + '0x%02x' % (ord(PcdValue[Index]) % 0x100) + ', '\r | |
3996 | Padding = '0x00, '\r | |
3997 | if Unicode:\r | |
3998 | Padding = Padding * 2\r | |
3999 | ArraySize = ArraySize / 2\r | |
4000 | if ArraySize < (len(PcdValue) + 1):\r | |
c33081c9 YZ |
4001 | if Pcd.MaxSizeUserSet:\r |
4002 | EdkLogger.error("build", AUTOGEN_ERROR,\r | |
2a29017e | 4003 | "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, TokenCName)\r |
e8a47801 | 4004 | )\r |
c33081c9 YZ |
4005 | else:\r |
4006 | ArraySize = len(PcdValue) + 1\r | |
e8a47801 LG |
4007 | if ArraySize > len(PcdValue) + 1:\r |
4008 | NewValue = NewValue + Padding * (ArraySize - len(PcdValue) - 1)\r | |
4009 | PcdValue = NewValue + Padding.strip().rstrip(',') + '}'\r | |
4010 | elif len(PcdValue.split(',')) <= ArraySize:\r | |
4011 | PcdValue = PcdValue.rstrip('}') + ', 0x00' * (ArraySize - len(PcdValue.split(',')))\r | |
4012 | PcdValue += '}'\r | |
4013 | else:\r | |
c33081c9 YZ |
4014 | if Pcd.MaxSizeUserSet:\r |
4015 | EdkLogger.error("build", AUTOGEN_ERROR,\r | |
2a29017e | 4016 | "The maximum size of VOID* type PCD '%s.%s' is less than its actual size occupied." % (Pcd.TokenSpaceGuidCName, TokenCName)\r |
e8a47801 | 4017 | )\r |
c33081c9 YZ |
4018 | else:\r |
4019 | ArraySize = len(PcdValue) + 1\r | |
e8a47801 | 4020 | PcdItem = '%s.%s|%s|0x%X' % \\r |
2a29017e | 4021 | (Pcd.TokenSpaceGuidCName, TokenCName, PcdValue, PatchPcd[1])\r |
e8a47801 LG |
4022 | PcdComments = ''\r |
4023 | if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in self._PcdComments:\r | |
4024 | PcdComments = '\n '.join(self._PcdComments[Pcd.TokenSpaceGuidCName, Pcd.TokenCName])\r | |
4025 | if PcdComments:\r | |
4026 | PcdItem = PcdComments + '\n ' + PcdItem\r | |
4027 | AsBuiltInfDict['patchablepcd_item'].append(PcdItem)\r | |
97fa0ee9 | 4028 | \r |
d0ef841c | 4029 | HiiPcds = set()\r |
97fa0ee9 | 4030 | for Pcd in Pcds + VfrPcds:\r |
e8a47801 LG |
4031 | PcdCommentList = []\r |
4032 | HiiInfo = ''\r | |
97fa0ee9 | 4033 | SkuId = ''\r |
2a29017e YZ |
4034 | TokenCName = Pcd.TokenCName\r |
4035 | for PcdItem in GlobalData.MixedPcd:\r | |
4036 | if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:\r | |
4037 | TokenCName = PcdItem[0]\r | |
4038 | break\r | |
e8a47801 LG |
4039 | if Pcd.Type == TAB_PCDS_DYNAMIC_EX_HII:\r |
4040 | for SkuName in Pcd.SkuInfoList:\r | |
4041 | SkuInfo = Pcd.SkuInfoList[SkuName]\r | |
97fa0ee9 | 4042 | SkuId = SkuInfo.SkuId\r |
e8a47801 LG |
4043 | HiiInfo = '## %s|%s|%s' % (SkuInfo.VariableName, SkuInfo.VariableGuid, SkuInfo.VariableOffset)\r |
4044 | break\r | |
97fa0ee9 YL |
4045 | if SkuId:\r |
4046 | #\r | |
4047 | # Don't generate duplicated HII PCD\r | |
4048 | #\r | |
4049 | if (SkuId, Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in HiiPcds:\r | |
4050 | continue\r | |
d0ef841c | 4051 | HiiPcds.add((SkuId, Pcd.TokenSpaceGuidCName, Pcd.TokenCName))\r |
e8a47801 LG |
4052 | if (Pcd.TokenSpaceGuidCName, Pcd.TokenCName) in self._PcdComments:\r |
4053 | PcdCommentList = self._PcdComments[Pcd.TokenSpaceGuidCName, Pcd.TokenCName][:]\r | |
4054 | if HiiInfo:\r | |
4055 | UsageIndex = -1\r | |
97fa0ee9 | 4056 | UsageStr = ''\r |
e8a47801 LG |
4057 | for Index, Comment in enumerate(PcdCommentList):\r |
4058 | for Usage in UsageList:\r | |
4059 | if Comment.find(Usage) != -1:\r | |
97fa0ee9 | 4060 | UsageStr = Usage\r |
e8a47801 LG |
4061 | UsageIndex = Index\r |
4062 | break\r | |
4063 | if UsageIndex != -1:\r | |
97fa0ee9 | 4064 | PcdCommentList[UsageIndex] = '## %s %s %s' % (UsageStr, HiiInfo, PcdCommentList[UsageIndex].replace(UsageStr, '')) \r |
e8a47801 | 4065 | else:\r |
97fa0ee9 | 4066 | PcdCommentList.append('## UNDEFINED ' + HiiInfo)\r |
e8a47801 | 4067 | PcdComments = '\n '.join(PcdCommentList)\r |
2a29017e | 4068 | PcdEntry = Pcd.TokenSpaceGuidCName + '.' + TokenCName\r |
e8a47801 LG |
4069 | if PcdComments:\r |
4070 | PcdEntry = PcdComments + '\n ' + PcdEntry\r | |
caf74495 | 4071 | AsBuiltInfDict['pcd_item'].append(PcdEntry)\r |
da92f276 | 4072 | for Item in self.BuildOption:\r |
481252bb | 4073 | if 'FLAGS' in self.BuildOption[Item]:\r |
caf74495 | 4074 | AsBuiltInfDict['flags_item'].append('%s:%s_%s_%s_%s_FLAGS = %s' % (self.ToolChainFamily, self.BuildTarget, self.ToolChain, self.Arch, Item, self.BuildOption[Item]['FLAGS'].strip()))\r |
97fa0ee9 YL |
4075 | \r |
4076 | # Generated LibraryClasses section in comments.\r | |
4077 | for Library in self.LibraryAutoGenList:\r | |
caf74495 | 4078 | AsBuiltInfDict['libraryclasses_item'].append(Library.MetaFile.File.replace('\\', '/'))\r |
97fa0ee9 | 4079 | \r |
dfa41b4a YZ |
4080 | # Generated UserExtensions TianoCore section.\r |
4081 | # All tianocore user extensions are copied.\r | |
4082 | UserExtStr = ''\r | |
4083 | for TianoCore in self._GetTianoCoreUserExtensionList():\r | |
4084 | UserExtStr += '\n'.join(TianoCore)\r | |
4085 | ExtensionFile = os.path.join(self.MetaFile.Dir, TianoCore[1])\r | |
4086 | if os.path.isfile(ExtensionFile):\r | |
4087 | shutil.copy2(ExtensionFile, self.OutputDir)\r | |
4088 | AsBuiltInfDict['userextension_tianocore_item'] = UserExtStr\r | |
4089 | \r | |
97fa0ee9 | 4090 | # Generated depex expression section in comments.\r |
97fa0ee9 | 4091 | DepexExpresion = self._GetDepexExpresionString()\r |
caf74495 | 4092 | AsBuiltInfDict['depexsection_item'] = DepexExpresion if DepexExpresion else ''\r |
da92f276 LG |
4093 | \r |
4094 | AsBuiltInf = TemplateString()\r | |
4095 | AsBuiltInf.Append(gAsBuiltInfHeaderString.Replace(AsBuiltInfDict))\r | |
4096 | \r | |
4097 | SaveFileOnChange(os.path.join(self.OutputDir, self.Name + '.inf'), str(AsBuiltInf), False)\r | |
4098 | \r | |
4099 | self.IsAsBuiltInfCreated = True\r | |
36d083ef YZ |
4100 | if GlobalData.gBinCacheDest:\r |
4101 | self.CopyModuleToCache()\r | |
4102 | \r | |
4103 | def CopyModuleToCache(self):\r | |
4104 | FileDir = path.join(GlobalData.gBinCacheDest, self.Arch, self.SourceDir, self.MetaFile.BaseName)\r | |
4105 | CreateDirectory (FileDir)\r | |
4106 | HashFile = path.join(self.BuildDir, self.Name + '.hash')\r | |
4107 | ModuleFile = path.join(self.OutputDir, self.Name + '.inf')\r | |
4108 | if os.path.exists(HashFile):\r | |
4109 | shutil.copy2(HashFile, FileDir)\r | |
4110 | if os.path.exists(ModuleFile):\r | |
4111 | shutil.copy2(ModuleFile, FileDir)\r | |
83397f95 YZ |
4112 | if not self.OutputFile:\r |
4113 | Ma = self.Workspace.BuildDatabase[PathClass(ModuleFile), self.Arch, self.BuildTarget, self.ToolChain]\r | |
4114 | self.OutputFile = Ma.Binaries\r | |
36d083ef YZ |
4115 | if self.OutputFile:\r |
4116 | for File in self.OutputFile:\r | |
83397f95 | 4117 | File = str(File)\r |
36d083ef YZ |
4118 | if not os.path.isabs(File):\r |
4119 | File = os.path.join(self.OutputDir, File)\r | |
4120 | if os.path.exists(File):\r | |
4121 | shutil.copy2(File, FileDir)\r | |
4122 | \r | |
4123 | def AttemptModuleCacheCopy(self):\r | |
4124 | if self.IsBinaryModule:\r | |
4125 | return False\r | |
4126 | FileDir = path.join(GlobalData.gBinCacheSource, self.Arch, self.SourceDir, self.MetaFile.BaseName)\r | |
4127 | HashFile = path.join(FileDir, self.Name + '.hash')\r | |
4128 | if os.path.exists(HashFile):\r | |
4129 | f = open(HashFile, 'r')\r | |
4130 | CacheHash = f.read()\r | |
4131 | f.close()\r | |
4132 | if GlobalData.gModuleHash[self.Arch][self.Name]:\r | |
4133 | if CacheHash == GlobalData.gModuleHash[self.Arch][self.Name]:\r | |
4134 | for root, dir, files in os.walk(FileDir):\r | |
4135 | for f in files:\r | |
4136 | if self.Name + '.hash' in f:\r | |
4137 | shutil.copy2(HashFile, self.BuildDir)\r | |
4138 | else:\r | |
4139 | File = path.join(root, f)\r | |
4140 | shutil.copy2(File, self.OutputDir)\r | |
4141 | if self.Name == "PcdPeim" or self.Name == "PcdDxe":\r | |
4142 | CreatePcdDatabaseCode(self, TemplateString(), TemplateString())\r | |
4143 | return True\r | |
4144 | return False\r | |
4145 | \r | |
52302d4d LG |
4146 | ## Create makefile for the module and its dependent libraries\r |
4147 | #\r | |
4148 | # @param CreateLibraryMakeFile Flag indicating if or not the makefiles of\r | |
4149 | # dependent libraries will be created\r | |
4150 | #\r | |
37de70b7 | 4151 | def CreateMakeFile(self, CreateLibraryMakeFile=True, GenFfsList = []):\r |
fae62ff2 | 4152 | # Ignore generating makefile when it is a binary module\r |
a0a2cd1e FB |
4153 | if self.IsBinaryModule:\r |
4154 | return\r | |
fae62ff2 | 4155 | \r |
52302d4d LG |
4156 | if self.IsMakeFileCreated:\r |
4157 | return\r | |
37de70b7 | 4158 | self.GenFfsList = GenFfsList\r |
52302d4d LG |
4159 | if not self.IsLibrary and CreateLibraryMakeFile:\r |
4160 | for LibraryAutoGen in self.LibraryAutoGenList:\r | |
4161 | LibraryAutoGen.CreateMakeFile()\r | |
4162 | \r | |
36513f3a YZ |
4163 | if self.CanSkip():\r |
4164 | return\r | |
4165 | \r | |
52302d4d LG |
4166 | if len(self.CustomMakefile) == 0:\r |
4167 | Makefile = GenMake.ModuleMakefile(self)\r | |
4168 | else:\r | |
4169 | Makefile = GenMake.CustomMakefile(self)\r | |
4170 | if Makefile.Generate():\r | |
4171 | EdkLogger.debug(EdkLogger.DEBUG_9, "Generated makefile for module %s [%s]" %\r | |
4172 | (self.Name, self.Arch))\r | |
4173 | else:\r | |
4174 | EdkLogger.debug(EdkLogger.DEBUG_9, "Skipped the generation of makefile for module %s [%s]" %\r | |
4175 | (self.Name, self.Arch))\r | |
4176 | \r | |
c17956e0 | 4177 | self.CreateTimeStamp(Makefile)\r |
52302d4d LG |
4178 | self.IsMakeFileCreated = True\r |
4179 | \r | |
a0a2cd1e FB |
4180 | def CopyBinaryFiles(self):\r |
4181 | for File in self.Module.Binaries:\r | |
4182 | SrcPath = File.Path\r | |
4183 | DstPath = os.path.join(self.OutputDir , os.path.basename(SrcPath))\r | |
4184 | CopyLongFilePath(SrcPath, DstPath)\r | |
52302d4d LG |
4185 | ## Create autogen code for the module and its dependent libraries\r |
4186 | #\r | |
4187 | # @param CreateLibraryCodeFile Flag indicating if or not the code of\r | |
4188 | # dependent libraries will be created\r | |
4189 | #\r | |
4190 | def CreateCodeFile(self, CreateLibraryCodeFile=True):\r | |
4191 | if self.IsCodeFileCreated:\r | |
4192 | return\r | |
4193 | \r | |
e8a47801 LG |
4194 | # Need to generate PcdDatabase even PcdDriver is binarymodule\r |
4195 | if self.IsBinaryModule and self.PcdIsDriver != '':\r | |
4196 | CreatePcdDatabaseCode(self, TemplateString(), TemplateString())\r | |
4197 | return\r | |
a0a2cd1e | 4198 | if self.IsBinaryModule:\r |
49d9b71d HC |
4199 | if self.IsLibrary:\r |
4200 | self.CopyBinaryFiles()\r | |
a0a2cd1e | 4201 | return\r |
e8a47801 | 4202 | \r |
52302d4d LG |
4203 | if not self.IsLibrary and CreateLibraryCodeFile:\r |
4204 | for LibraryAutoGen in self.LibraryAutoGenList:\r | |
4205 | LibraryAutoGen.CreateCodeFile()\r | |
4206 | \r | |
36513f3a YZ |
4207 | if self.CanSkip():\r |
4208 | return\r | |
4209 | \r | |
52302d4d LG |
4210 | AutoGenList = []\r |
4211 | IgoredAutoGenList = []\r | |
4212 | \r | |
4213 | for File in self.AutoGenFileList:\r | |
4214 | if GenC.Generate(File.Path, self.AutoGenFileList[File], File.IsBinary):\r | |
b36d134f | 4215 | #Ignore Edk AutoGen.c\r |
52302d4d LG |
4216 | if self.AutoGenVersion < 0x00010005 and File.Name == 'AutoGen.c':\r |
4217 | continue\r | |
4218 | \r | |
4219 | AutoGenList.append(str(File))\r | |
4220 | else:\r | |
4221 | IgoredAutoGenList.append(str(File))\r | |
4222 | \r | |
4223 | # Skip the following code for EDK I inf\r | |
4224 | if self.AutoGenVersion < 0x00010005:\r | |
4225 | return\r | |
4226 | \r | |
4227 | for ModuleType in self.DepexList:\r | |
8bb63e37 CJ |
4228 | # Ignore empty [depex] section or [depex] section for SUP_MODULE_USER_DEFINED module\r |
4229 | if len(self.DepexList[ModuleType]) == 0 or ModuleType == SUP_MODULE_USER_DEFINED:\r | |
52302d4d | 4230 | continue\r |
40d841f6 | 4231 | \r |
52302d4d LG |
4232 | Dpx = GenDepex.DependencyExpression(self.DepexList[ModuleType], ModuleType, True)\r |
4233 | DpxFile = gAutoGenDepexFileName % {"module_name" : self.Name}\r | |
4234 | \r | |
da92f276 | 4235 | if len(Dpx.PostfixNotation) <> 0:\r |
0d2711a6 | 4236 | self.DepexGenerated = True\r |
da92f276 | 4237 | \r |
52302d4d LG |
4238 | if Dpx.Generate(path.join(self.OutputDir, DpxFile)):\r |
4239 | AutoGenList.append(str(DpxFile))\r | |
4240 | else:\r | |
4241 | IgoredAutoGenList.append(str(DpxFile))\r | |
4242 | \r | |
4243 | if IgoredAutoGenList == []:\r | |
4244 | EdkLogger.debug(EdkLogger.DEBUG_9, "Generated [%s] files for module %s [%s]" %\r | |
4245 | (" ".join(AutoGenList), self.Name, self.Arch))\r | |
4246 | elif AutoGenList == []:\r | |
4247 | EdkLogger.debug(EdkLogger.DEBUG_9, "Skipped the generation of [%s] files for module %s [%s]" %\r | |
4248 | (" ".join(IgoredAutoGenList), self.Name, self.Arch))\r | |
4249 | else:\r | |
4250 | EdkLogger.debug(EdkLogger.DEBUG_9, "Generated [%s] (skipped %s) files for module %s [%s]" %\r | |
4251 | (" ".join(AutoGenList), " ".join(IgoredAutoGenList), self.Name, self.Arch))\r | |
4252 | \r | |
4253 | self.IsCodeFileCreated = True\r | |
4254 | return AutoGenList\r | |
4255 | \r | |
4256 | ## Summarize the ModuleAutoGen objects of all libraries used by this module\r | |
4257 | def _GetLibraryAutoGenList(self):\r | |
4231a819 | 4258 | if self._LibraryAutoGenList is None:\r |
52302d4d LG |
4259 | self._LibraryAutoGenList = []\r |
4260 | for Library in self.DependentLibraryList:\r | |
4261 | La = ModuleAutoGen(\r | |
4262 | self.Workspace,\r | |
4263 | Library.MetaFile,\r | |
4264 | self.BuildTarget,\r | |
4265 | self.ToolChain,\r | |
4266 | self.Arch,\r | |
4267 | self.PlatformInfo.MetaFile\r | |
4268 | )\r | |
4269 | if La not in self._LibraryAutoGenList:\r | |
4270 | self._LibraryAutoGenList.append(La)\r | |
4271 | for Lib in La.CodaTargetList:\r | |
4272 | self._ApplyBuildRule(Lib.Target, TAB_UNKNOWN_FILE)\r | |
4273 | return self._LibraryAutoGenList\r | |
4274 | \r | |
36d083ef YZ |
4275 | def GenModuleHash(self):\r |
4276 | if self.Arch not in GlobalData.gModuleHash:\r | |
4277 | GlobalData.gModuleHash[self.Arch] = {}\r | |
4278 | m = hashlib.md5()\r | |
4279 | # Add Platform level hash\r | |
4280 | m.update(GlobalData.gPlatformHash)\r | |
4281 | # Add Package level hash\r | |
4282 | if self.DependentPackageList:\r | |
3f34e36d | 4283 | for Pkg in sorted(self.DependentPackageList, key=lambda x: x.PackageName):\r |
36d083ef YZ |
4284 | if Pkg.PackageName in GlobalData.gPackageHash[self.Arch]:\r |
4285 | m.update(GlobalData.gPackageHash[self.Arch][Pkg.PackageName])\r | |
4286 | \r | |
4287 | # Add Library hash\r | |
4288 | if self.LibraryAutoGenList:\r | |
3f34e36d | 4289 | for Lib in sorted(self.LibraryAutoGenList, key=lambda x: x.Name):\r |
36d083ef YZ |
4290 | if Lib.Name not in GlobalData.gModuleHash[self.Arch]:\r |
4291 | Lib.GenModuleHash()\r | |
4292 | m.update(GlobalData.gModuleHash[self.Arch][Lib.Name])\r | |
4293 | \r | |
4294 | # Add Module self\r | |
4295 | f = open(str(self.MetaFile), 'r')\r | |
4296 | Content = f.read()\r | |
4297 | f.close()\r | |
4298 | m.update(Content)\r | |
4299 | # Add Module's source files\r | |
4300 | if self.SourceFileList:\r | |
3f34e36d | 4301 | for File in sorted(self.SourceFileList, key=lambda x: str(x)):\r |
36d083ef YZ |
4302 | f = open(str(File), 'r')\r |
4303 | Content = f.read()\r | |
4304 | f.close()\r | |
4305 | m.update(Content)\r | |
4306 | \r | |
4307 | ModuleHashFile = path.join(self.BuildDir, self.Name + ".hash")\r | |
4308 | if self.Name not in GlobalData.gModuleHash[self.Arch]:\r | |
4309 | GlobalData.gModuleHash[self.Arch][self.Name] = m.hexdigest()\r | |
4310 | if GlobalData.gBinCacheSource:\r | |
caf74495 | 4311 | if self.AttemptModuleCacheCopy():\r |
36d083ef YZ |
4312 | return False\r |
4313 | return SaveFileOnChange(ModuleHashFile, m.hexdigest(), True)\r | |
4314 | \r | |
4315 | ## Decide whether we can skip the ModuleAutoGen process\r | |
4316 | def CanSkipbyHash(self):\r | |
4317 | if GlobalData.gUseHashCache:\r | |
4318 | return not self.GenModuleHash()\r | |
4319 | \r | |
c17956e0 | 4320 | ## Decide whether we can skip the ModuleAutoGen process\r |
36d083ef | 4321 | # If any source file is newer than the module than we cannot skip\r |
c17956e0 DL |
4322 | #\r |
4323 | def CanSkip(self):\r | |
4324 | if not os.path.exists(self.GetTimeStampPath()):\r | |
4325 | return False\r | |
4326 | #last creation time of the module\r | |
4327 | DstTimeStamp = os.stat(self.GetTimeStampPath())[8]\r | |
4328 | \r | |
4329 | SrcTimeStamp = self.Workspace._SrcTimeStamp\r | |
4330 | if SrcTimeStamp > DstTimeStamp:\r | |
4331 | return False\r | |
4332 | \r | |
4333 | with open(self.GetTimeStampPath(),'r') as f:\r | |
4334 | for source in f:\r | |
4335 | source = source.rstrip('\n')\r | |
4a1167df YZ |
4336 | if not os.path.exists(source):\r |
4337 | return False\r | |
c17956e0 DL |
4338 | if source not in ModuleAutoGen.TimeDict :\r |
4339 | ModuleAutoGen.TimeDict[source] = os.stat(source)[8]\r | |
4340 | if ModuleAutoGen.TimeDict[source] > DstTimeStamp:\r | |
4341 | return False\r | |
4342 | return True\r | |
4343 | \r | |
4344 | def GetTimeStampPath(self):\r | |
4231a819 | 4345 | if self._TimeStampPath is None:\r |
c17956e0 DL |
4346 | self._TimeStampPath = os.path.join(self.MakeFileDir, 'AutoGenTimeStamp')\r |
4347 | return self._TimeStampPath\r | |
4348 | def CreateTimeStamp(self, Makefile):\r | |
4349 | \r | |
caf74495 | 4350 | FileSet = {self.MetaFile.Path}\r |
c17956e0 DL |
4351 | \r |
4352 | for SourceFile in self.Module.Sources:\r | |
4353 | FileSet.add (SourceFile.Path)\r | |
4354 | \r | |
4355 | for Lib in self.DependentLibraryList:\r | |
4356 | FileSet.add (Lib.MetaFile.Path)\r | |
4357 | \r | |
4358 | for f in self.AutoGenDepSet:\r | |
4359 | FileSet.add (f.Path)\r | |
4360 | \r | |
4361 | if os.path.exists (self.GetTimeStampPath()):\r | |
4362 | os.remove (self.GetTimeStampPath())\r | |
4363 | with open(self.GetTimeStampPath(), 'w+') as file:\r | |
4364 | for f in FileSet:\r | |
4365 | print >> file, f\r | |
4366 | \r | |
52302d4d LG |
4367 | Module = property(_GetModule)\r |
4368 | Name = property(_GetBaseName)\r | |
4369 | Guid = property(_GetGuid)\r | |
4370 | Version = property(_GetVersion)\r | |
4371 | ModuleType = property(_GetModuleType)\r | |
4372 | ComponentType = property(_GetComponentType)\r | |
4373 | BuildType = property(_GetBuildType)\r | |
4374 | PcdIsDriver = property(_GetPcdIsDriver)\r | |
4375 | AutoGenVersion = property(_GetAutoGenVersion)\r | |
4376 | Macros = property(_GetMacros)\r | |
4377 | Specification = property(_GetSpecification)\r | |
4378 | \r | |
4379 | IsLibrary = property(_IsLibrary)\r | |
e8a47801 | 4380 | IsBinaryModule = property(_IsBinaryModule)\r |
52302d4d LG |
4381 | BuildDir = property(_GetBuildDir)\r |
4382 | OutputDir = property(_GetOutputDir)\r | |
37de70b7 | 4383 | FfsOutputDir = property(_GetFfsOutputDir)\r |
52302d4d LG |
4384 | DebugDir = property(_GetDebugDir)\r |
4385 | MakeFileDir = property(_GetMakeFileDir)\r | |
4386 | CustomMakefile = property(_GetCustomMakefile)\r | |
4387 | \r | |
4388 | IncludePathList = property(_GetIncludePathList)\r | |
725cdb8f | 4389 | IncludePathLength = property(_GetIncludePathLength)\r |
52302d4d LG |
4390 | AutoGenFileList = property(_GetAutoGenFileList)\r |
4391 | UnicodeFileList = property(_GetUnicodeFileList)\r | |
5b97eb4c | 4392 | VfrFileList = property(_GetVfrFileList)\r |
52302d4d LG |
4393 | SourceFileList = property(_GetSourceFileList)\r |
4394 | BinaryFileList = property(_GetBinaryFiles) # FileType : [File List]\r | |
4395 | Targets = property(_GetTargets)\r | |
4396 | IntroTargetList = property(_GetIntroTargetList)\r | |
4397 | CodaTargetList = property(_GetFinalTargetList)\r | |
4398 | FileTypes = property(_GetFileTypes)\r | |
4399 | BuildRules = property(_GetBuildRules)\r | |
333ba578 | 4400 | IdfFileList = property(_GetIdfFileList)\r |
52302d4d LG |
4401 | \r |
4402 | DependentPackageList = property(_GetDependentPackageList)\r | |
4403 | DependentLibraryList = property(_GetLibraryList)\r | |
4404 | LibraryAutoGenList = property(_GetLibraryAutoGenList)\r | |
4405 | DerivedPackageList = property(_GetDerivedPackageList)\r | |
4406 | \r | |
4407 | ModulePcdList = property(_GetModulePcdList)\r | |
4408 | LibraryPcdList = property(_GetLibraryPcdList)\r | |
4409 | GuidList = property(_GetGuidList)\r | |
4410 | ProtocolList = property(_GetProtocolList)\r | |
4411 | PpiList = property(_GetPpiList)\r | |
4412 | DepexList = property(_GetDepexTokenList)\r | |
b36d134f | 4413 | DxsFile = property(_GetDxsFile)\r |
caf74495 | 4414 | DepexExpressionDict = property(_GetDepexExpressionTokenList)\r |
52302d4d | 4415 | BuildOption = property(_GetModuleBuildOption)\r |
79b74a03 | 4416 | BuildOptionIncPathList = property(_GetBuildOptionIncPathList)\r |
52302d4d | 4417 | BuildCommand = property(_GetBuildCommand)\r |
2bc3256c LG |
4418 | \r |
4419 | FixedAtBuildPcds = property(_GetFixedAtBuildPcds)\r | |
52302d4d LG |
4420 | \r |
4421 | # This acts like the main() function for the script, unless it is 'import'ed into another script.\r | |
4422 | if __name__ == '__main__':\r | |
4423 | pass\r | |
4424 | \r |