]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/AutoGen/AutoGen.py
Sync BaseTools Branch (version r2149) to EDKII main trunk.
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / AutoGen.py
CommitLineData
52302d4d
LG
1## @file\r
2# Generate AutoGen.h, AutoGen.c and *.depex files\r
3#\r
da92f276 4# Copyright (c) 2007 - 2011, Intel Corporation. All rights reserved.<BR>\r
40d841f6 5# This program and the accompanying materials\r
52302d4d
LG
6# are licensed and made available under the terms and conditions of the BSD License\r
7# which accompanies this distribution. The full text of the license may be found at\r
8# http://opensource.org/licenses/bsd-license.php\r
9#\r
10# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12#\r
13\r
14## Import Modules\r
15#\r
16import os\r
17import re\r
18import os.path as path\r
19import copy\r
20\r
21import GenC\r
22import GenMake\r
23import GenDepex\r
24from StringIO import StringIO\r
25\r
26from StrGather import *\r
27from BuildEngine import BuildRule\r
28\r
29from Common.BuildToolError import *\r
30from Common.DataType import *\r
31from Common.Misc import *\r
32from Common.String import *\r
33import Common.GlobalData as GlobalData\r
34from GenFds.FdfParser import *\r
35from CommonDataClass.CommonClass import SkuInfoClass\r
36from Workspace.BuildClassObject import *\r
e56468c0 37import Common.VpdInfoFile as VpdInfoFile\r
52302d4d
LG
38\r
39## Regular expression for splitting Dependency Expression stirng into tokens\r
40gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)")\r
41\r
42## Mapping Makefile type\r
43gMakeTypeMap = {"MSFT":"nmake", "GCC":"gmake"}\r
44\r
45\r
46## Build rule configuration file\r
47gBuildRuleFile = 'Conf/build_rule.txt'\r
48\r
49## default file name for AutoGen\r
50gAutoGenCodeFileName = "AutoGen.c"\r
51gAutoGenHeaderFileName = "AutoGen.h"\r
52gAutoGenStringFileName = "%(module_name)sStrDefs.h"\r
53gAutoGenStringFormFileName = "%(module_name)sStrDefs.hpk"\r
54gAutoGenDepexFileName = "%(module_name)s.depex"\r
55\r
da92f276
LG
56#\r
57# Template string to generic AsBuilt INF\r
58#\r
59gAsBuiltInfHeaderString = TemplateString("""## @file\r
60# ${module_name}\r
61#\r
62# DO NOT EDIT\r
63# FILE auto-generated Binary INF\r
64#\r
65##\r
66\r
67[Defines]\r
68 INF_VERSION = 0x00010016\r
69 BASE_NAME = ${module_name}\r
70 FILE_GUID = ${module_guid}\r
71 MODULE_TYPE = ${module_module_type}\r
72 VERSION_STRING = ${module_version_string}${BEGIN}\r
73 UEFI_SPECIFICATION_VERSION = ${module_uefi_specification_version}${END}${BEGIN}\r
74 PI_SPECIFICATION_VERSION = ${module_pi_specification_version}${END}\r
75\r
76[Packages]${BEGIN}\r
77 ${package_item}${END}\r
78\r
79[Binaries.${module_arch}]${BEGIN}\r
80 ${binary_item}${END}\r
81\r
82[PcdEx]${BEGIN}\r
83 ${pcd_item}${END}\r
84\r
85## @AsBuilt${BEGIN}\r
86## ${flags_item}${END}\r
87""")\r
88\r
52302d4d
LG
89## Base class for AutoGen\r
90#\r
91# This class just implements the cache mechanism of AutoGen objects.\r
92#\r
93class AutoGen(object):\r
94 # database to maintain the objects of xxxAutoGen\r
95 _CACHE_ = {} # (BuildTarget, ToolChain) : {ARCH : {platform file: AutoGen object}}}\r
96\r
97 ## Factory method\r
98 #\r
99 # @param Class class object of real AutoGen class\r
100 # (WorkspaceAutoGen, ModuleAutoGen or PlatformAutoGen)\r
101 # @param Workspace Workspace directory or WorkspaceAutoGen object\r
102 # @param MetaFile The path of meta file\r
103 # @param Target Build target\r
104 # @param Toolchain Tool chain name\r
105 # @param Arch Target arch\r
106 # @param *args The specific class related parameters\r
107 # @param **kwargs The specific class related dict parameters\r
108 #\r
109 def __new__(Class, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r
110 # check if the object has been created\r
111 Key = (Target, Toolchain)\r
112 if Key not in Class._CACHE_ or Arch not in Class._CACHE_[Key] \\r
113 or MetaFile not in Class._CACHE_[Key][Arch]:\r
114 AutoGenObject = super(AutoGen, Class).__new__(Class)\r
115 # call real constructor\r
116 if not AutoGenObject._Init(Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r
117 return None\r
118 if Key not in Class._CACHE_:\r
119 Class._CACHE_[Key] = {}\r
120 if Arch not in Class._CACHE_[Key]:\r
121 Class._CACHE_[Key][Arch] = {}\r
122 Class._CACHE_[Key][Arch][MetaFile] = AutoGenObject\r
123 else:\r
124 AutoGenObject = Class._CACHE_[Key][Arch][MetaFile]\r
125\r
126 return AutoGenObject\r
127\r
128 ## hash() operator\r
129 #\r
130 # The file path of platform file will be used to represent hash value of this object\r
131 #\r
132 # @retval int Hash value of the file path of platform file\r
133 #\r
134 def __hash__(self):\r
135 return hash(self.MetaFile)\r
136\r
137 ## str() operator\r
138 #\r
139 # The file path of platform file will be used to represent this object\r
140 #\r
141 # @retval string String of platform file path\r
142 #\r
143 def __str__(self):\r
144 return str(self.MetaFile)\r
145\r
146 ## "==" operator\r
147 def __eq__(self, Other):\r
148 return Other and self.MetaFile == Other\r
149\r
150## Workspace AutoGen class\r
151#\r
152# This class is used mainly to control the whole platform build for different\r
153# architecture. This class will generate top level makefile.\r
154#\r
155class WorkspaceAutoGen(AutoGen):\r
156 ## Real constructor of WorkspaceAutoGen\r
157 #\r
158 # This method behaves the same as __init__ except that it needs explict invoke\r
159 # (in super class's __new__ method)\r
160 #\r
161 # @param WorkspaceDir Root directory of workspace\r
162 # @param ActivePlatform Meta-file of active platform\r
163 # @param Target Build target\r
164 # @param Toolchain Tool chain name\r
165 # @param ArchList List of architecture of current build\r
166 # @param MetaFileDb Database containing meta-files\r
167 # @param BuildConfig Configuration of build\r
168 # @param ToolDefinition Tool chain definitions\r
169 # @param FlashDefinitionFile File of flash definition\r
170 # @param Fds FD list to be generated\r
171 # @param Fvs FV list to be generated\r
172 # @param SkuId SKU id from command line\r
173 #\r
174 def _Init(self, WorkspaceDir, ActivePlatform, Target, Toolchain, ArchList, MetaFileDb,\r
f3decdc3 175 BuildConfig, ToolDefinition, FlashDefinitionFile='', Fds=[], Fvs=[], SkuId='', UniFlag=None):\r
52302d4d
LG
176 self.MetaFile = ActivePlatform.MetaFile\r
177 self.WorkspaceDir = WorkspaceDir\r
178 self.Platform = ActivePlatform\r
179 self.BuildTarget = Target\r
180 self.ToolChain = Toolchain\r
181 self.ArchList = ArchList\r
182 self.SkuId = SkuId\r
f3decdc3 183 self.UniFlag = UniFlag\r
52302d4d
LG
184\r
185 self.BuildDatabase = MetaFileDb\r
186 self.TargetTxt = BuildConfig\r
187 self.ToolDef = ToolDefinition\r
188 self.FdfFile = FlashDefinitionFile\r
189 self.FdTargetList = Fds\r
190 self.FvTargetList = Fvs\r
191 self.AutoGenObjectList = []\r
192\r
193 # there's many relative directory operations, so ...\r
194 os.chdir(self.WorkspaceDir)\r
195\r
196 # parse FDF file to get PCDs in it, if any\r
197 if self.FdfFile != None and self.FdfFile != '':\r
08dd311f
LG
198 #\r
199 # Make global macros available when parsing FDF file\r
200 #\r
201 InputMacroDict.update(self.BuildDatabase.WorkspaceDb._GlobalMacros)\r
52302d4d
LG
202 Fdf = FdfParser(self.FdfFile.Path)\r
203 Fdf.ParseFile()\r
204 PcdSet = Fdf.Profile.PcdDict\r
205 ModuleList = Fdf.Profile.InfList\r
206 self.FdfProfile = Fdf.Profile\r
207 else:\r
208 PcdSet = {}\r
209 ModuleList = []\r
210 self.FdfProfile = None\r
211 \r
212 # apply SKU and inject PCDs from Flash Definition file\r
213 for Arch in self.ArchList:\r
214 Platform = self.BuildDatabase[self.MetaFile, Arch]\r
215 Platform.SkuName = self.SkuId\r
216 for Name, Guid in PcdSet:\r
217 Platform.AddPcd(Name, Guid, PcdSet[Name, Guid])\r
218\r
219 Pa = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)\r
220 #\r
221 # Explicitly collect platform's dynamic PCDs\r
222 #\r
223 Pa.CollectPlatformDynamicPcds()\r
224 self.AutoGenObjectList.append(Pa)\r
6780eef1
LG
225 \r
226 #\r
227 # Check PCDs token value conflict in each DEC file.\r
228 #\r
229 self._CheckAllPcdsTokenValueConflict()\r
230 \r
52302d4d
LG
231 self._BuildDir = None\r
232 self._FvDir = None\r
233 self._MakeFileDir = None\r
234 self._BuildCommand = None\r
235\r
236 return True\r
237\r
238 def __repr__(self):\r
239 return "%s [%s]" % (self.MetaFile, ", ".join(self.ArchList))\r
240\r
241 ## Return the directory to store FV files\r
242 def _GetFvDir(self):\r
243 if self._FvDir == None:\r
244 self._FvDir = path.join(self.BuildDir, 'FV')\r
245 return self._FvDir\r
246\r
247 ## Return the directory to store all intermediate and final files built\r
248 def _GetBuildDir(self):\r
249 return self.AutoGenObjectList[0].BuildDir\r
250\r
251 ## Return the build output directory platform specifies\r
252 def _GetOutputDir(self):\r
253 return self.Platform.OutputDirectory\r
254\r
255 ## Return platform name\r
256 def _GetName(self):\r
257 return self.Platform.PlatformName\r
258\r
259 ## Return meta-file GUID\r
260 def _GetGuid(self):\r
261 return self.Platform.Guid\r
262\r
263 ## Return platform version\r
264 def _GetVersion(self):\r
265 return self.Platform.Version\r
266\r
267 ## Return paths of tools\r
268 def _GetToolDefinition(self):\r
269 return self.AutoGenObjectList[0].ToolDefinition\r
270\r
271 ## Return directory of platform makefile\r
272 #\r
273 # @retval string Makefile directory\r
274 #\r
275 def _GetMakeFileDir(self):\r
276 if self._MakeFileDir == None:\r
277 self._MakeFileDir = self.BuildDir\r
278 return self._MakeFileDir\r
279\r
280 ## Return build command string\r
281 #\r
282 # @retval string Build command string\r
283 #\r
284 def _GetBuildCommand(self):\r
285 if self._BuildCommand == None:\r
286 # BuildCommand should be all the same. So just get one from platform AutoGen\r
287 self._BuildCommand = self.AutoGenObjectList[0].BuildCommand\r
288 return self._BuildCommand\r
6780eef1
LG
289 \r
290 ## Check the PCDs token value conflict in each DEC file.\r
291 #\r
292 # Will cause build break and raise error message while two PCDs conflict.\r
293 # \r
294 # @return None\r
295 #\r
296 def _CheckAllPcdsTokenValueConflict(self):\r
297 if len(self.BuildDatabase.WorkspaceDb.PackageList) >= 1:\r
298 for Package in self.BuildDatabase.WorkspaceDb.PackageList:\r
299 PcdList = Package.Pcds.values()\r
300 PcdList.sort(lambda x, y: cmp(x.TokenValue, y.TokenValue)) \r
301 Count = 0\r
302 while (Count < len(PcdList) - 1) :\r
303 Item = PcdList[Count]\r
304 ItemNext = PcdList[Count + 1]\r
305 #\r
306 # Make sure in the same token space the TokenValue should be unique\r
307 #\r
308 if (Item.TokenValue == ItemNext.TokenValue):\r
309 SameTokenValuePcdList = []\r
310 SameTokenValuePcdList.append(Item)\r
311 SameTokenValuePcdList.append(ItemNext)\r
312 RemainPcdListLength = len(PcdList) - Count - 2\r
313 for ValueSameCount in range(RemainPcdListLength):\r
314 if PcdList[len(PcdList) - RemainPcdListLength + ValueSameCount].TokenValue == Item.TokenValue:\r
315 SameTokenValuePcdList.append(PcdList[len(PcdList) - RemainPcdListLength + ValueSameCount])\r
316 else:\r
317 break;\r
318 #\r
319 # Sort same token value PCD list with TokenGuid and TokenCName\r
320 #\r
321 SameTokenValuePcdList.sort(lambda x, y: cmp("%s.%s"%(x.TokenSpaceGuidCName, x.TokenCName), "%s.%s"%(y.TokenSpaceGuidCName, y.TokenCName))) \r
322 SameTokenValuePcdListCount = 0 \r
323 while (SameTokenValuePcdListCount < len(SameTokenValuePcdList) - 1):\r
324 TemListItem = SameTokenValuePcdList[SameTokenValuePcdListCount]\r
325 TemListItemNext = SameTokenValuePcdList[SameTokenValuePcdListCount + 1] \r
326 \r
327 if (TemListItem.TokenSpaceGuidCName == TemListItemNext.TokenSpaceGuidCName) and (TemListItem.TokenCName != TemListItemNext.TokenCName):\r
328 EdkLogger.error(\r
329 'build',\r
330 FORMAT_INVALID,\r
331 "The TokenValue [%s] of PCD [%s.%s] is conflict with: [%s.%s] in %s"\\r
332 % (TemListItem.TokenValue, TemListItem.TokenSpaceGuidCName, TemListItem.TokenCName, TemListItemNext.TokenSpaceGuidCName, TemListItemNext.TokenCName, Package),\r
333 ExtraData=None\r
334 )\r
335 SameTokenValuePcdListCount += 1\r
336 Count += SameTokenValuePcdListCount\r
337 Count += 1\r
338 \r
339 PcdList = Package.Pcds.values()\r
340 PcdList.sort(lambda x, y: cmp("%s.%s"%(x.TokenSpaceGuidCName, x.TokenCName), "%s.%s"%(y.TokenSpaceGuidCName, y.TokenCName)))\r
341 Count = 0\r
342 while (Count < len(PcdList) - 1) :\r
343 Item = PcdList[Count]\r
344 ItemNext = PcdList[Count + 1] \r
345 #\r
346 # Check PCDs with same TokenSpaceGuidCName.TokenCName have same token value as well.\r
347 #\r
348 if (Item.TokenSpaceGuidCName == ItemNext.TokenSpaceGuidCName) and (Item.TokenCName == ItemNext.TokenCName) and (Item.TokenValue != ItemNext.TokenValue):\r
349 EdkLogger.error(\r
350 'build',\r
351 FORMAT_INVALID,\r
352 "The TokenValue [%s] of PCD [%s.%s] in %s defined in two places should be same as well."\\r
353 % (Item.TokenValue, Item.TokenSpaceGuidCName, Item.TokenCName, Package),\r
354 ExtraData=None\r
355 )\r
356 Count += 1\r
357 \r
52302d4d 358\r
e56468c0 359 ## Create makefile for the platform and modules in it\r
52302d4d
LG
360 #\r
361 # @param CreateDepsMakeFile Flag indicating if the makefile for\r
362 # modules will be created as well\r
363 #\r
364 def CreateMakeFile(self, CreateDepsMakeFile=False):\r
365 # create makefile for platform\r
366 Makefile = GenMake.TopLevelMakefile(self)\r
367 if Makefile.Generate():\r
368 EdkLogger.debug(EdkLogger.DEBUG_9, "Generated makefile for platform [%s] %s\n" %\r
369 (self.MetaFile, self.ArchList))\r
370 else:\r
371 EdkLogger.debug(EdkLogger.DEBUG_9, "Skipped the generation of makefile for platform [%s] %s\n" %\r
372 (self.MetaFile, self.ArchList))\r
373\r
374 if CreateDepsMakeFile:\r
375 for Pa in self.AutoGenObjectList:\r
376 Pa.CreateMakeFile(CreateDepsMakeFile)\r
377\r
378 ## Create autogen code for platform and modules\r
379 #\r
380 # Since there's no autogen code for platform, this method will do nothing\r
381 # if CreateModuleCodeFile is set to False.\r
382 #\r
383 # @param CreateDepsCodeFile Flag indicating if creating module's\r
384 # autogen code file or not\r
385 #\r
386 def CreateCodeFile(self, CreateDepsCodeFile=False):\r
387 if not CreateDepsCodeFile:\r
388 return\r
389 for Pa in self.AutoGenObjectList:\r
390 Pa.CreateCodeFile(CreateDepsCodeFile)\r
391\r
392 Name = property(_GetName)\r
393 Guid = property(_GetGuid)\r
394 Version = property(_GetVersion)\r
395 OutputDir = property(_GetOutputDir)\r
396\r
397 ToolDefinition = property(_GetToolDefinition) # toolcode : tool path\r
398\r
399 BuildDir = property(_GetBuildDir)\r
400 FvDir = property(_GetFvDir)\r
401 MakeFileDir = property(_GetMakeFileDir)\r
402 BuildCommand = property(_GetBuildCommand)\r
403\r
404## AutoGen class for platform\r
405#\r
406# PlatformAutoGen class will process the original information in platform\r
407# file in order to generate makefile for platform.\r
408#\r
409class PlatformAutoGen(AutoGen):\r
410 #\r
411 # Used to store all PCDs for both PEI and DXE phase, in order to generate \r
412 # correct PCD database\r
413 # \r
414 _DynaPcdList_ = []\r
415 _NonDynaPcdList_ = []\r
6780eef1
LG
416 \r
417 #\r
418 # The priority list while override build option \r
419 #\r
420 PrioList = {"0x11111" : 16, # TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE (Highest)\r
421 "0x01111" : 15, # ******_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE\r
422 "0x10111" : 14, # TARGET_*********_ARCH_COMMANDTYPE_ATTRIBUTE\r
423 "0x00111" : 13, # ******_*********_ARCH_COMMANDTYPE_ATTRIBUTE \r
424 "0x11011" : 12, # TARGET_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE\r
425 "0x01011" : 11, # ******_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE\r
426 "0x10011" : 10, # TARGET_*********_****_COMMANDTYPE_ATTRIBUTE\r
427 "0x00011" : 9, # ******_*********_****_COMMANDTYPE_ATTRIBUTE\r
428 "0x11101" : 8, # TARGET_TOOLCHAIN_ARCH_***********_ATTRIBUTE\r
429 "0x01101" : 7, # ******_TOOLCHAIN_ARCH_***********_ATTRIBUTE\r
430 "0x10101" : 6, # TARGET_*********_ARCH_***********_ATTRIBUTE\r
431 "0x00101" : 5, # ******_*********_ARCH_***********_ATTRIBUTE\r
432 "0x11001" : 4, # TARGET_TOOLCHAIN_****_***********_ATTRIBUTE\r
433 "0x01001" : 3, # ******_TOOLCHAIN_****_***********_ATTRIBUTE\r
434 "0x10001" : 2, # TARGET_*********_****_***********_ATTRIBUTE\r
435 "0x00001" : 1} # ******_*********_****_***********_ATTRIBUTE (Lowest)\r
436 \r
52302d4d
LG
437 ## The real constructor of PlatformAutoGen\r
438 #\r
439 # This method is not supposed to be called by users of PlatformAutoGen. It's\r
440 # only used by factory method __new__() to do real initialization work for an\r
441 # object of PlatformAutoGen\r
442 #\r
443 # @param Workspace WorkspaceAutoGen object\r
444 # @param PlatformFile Platform file (DSC file)\r
445 # @param Target Build target (DEBUG, RELEASE)\r
446 # @param Toolchain Name of tool chain\r
447 # @param Arch arch of the platform supports\r
448 #\r
449 def _Init(self, Workspace, PlatformFile, Target, Toolchain, Arch):\r
450 EdkLogger.debug(EdkLogger.DEBUG_9, "AutoGen platform [%s] [%s]" % (PlatformFile, Arch))\r
451 GlobalData.gProcessingFile = "%s [%s, %s, %s]" % (PlatformFile, Arch, Toolchain, Target)\r
452\r
453 self.MetaFile = PlatformFile\r
454 self.Workspace = Workspace\r
455 self.WorkspaceDir = Workspace.WorkspaceDir\r
456 self.ToolChain = Toolchain\r
457 self.BuildTarget = Target\r
458 self.Arch = Arch\r
459 self.SourceDir = PlatformFile.SubDir\r
460 self.SourceOverrideDir = None\r
461 self.FdTargetList = self.Workspace.FdTargetList\r
462 self.FvTargetList = self.Workspace.FvTargetList\r
463 self.AllPcdList = []\r
464\r
465 # flag indicating if the makefile/C-code file has been created or not\r
466 self.IsMakeFileCreated = False\r
467 self.IsCodeFileCreated = False\r
468\r
469 self._Platform = None\r
470 self._Name = None\r
471 self._Guid = None\r
472 self._Version = None\r
473\r
474 self._BuildRule = None\r
475 self._SourceDir = None\r
476 self._BuildDir = None\r
477 self._OutputDir = None\r
478 self._FvDir = None\r
479 self._MakeFileDir = None\r
480 self._FdfFile = None\r
481\r
482 self._PcdTokenNumber = None # (TokenCName, TokenSpaceGuidCName) : GeneratedTokenNumber\r
483 self._DynamicPcdList = None # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]\r
484 self._NonDynamicPcdList = None # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]\r
485\r
486 self._ToolDefinitions = None\r
487 self._ToolDefFile = None # toolcode : tool path\r
488 self._ToolChainFamily = None\r
489 self._BuildRuleFamily = None\r
490 self._BuildOption = None # toolcode : option\r
491 self._EdkBuildOption = None # edktoolcode : option\r
492 self._EdkIIBuildOption = None # edkiitoolcode : option\r
493 self._PackageList = None\r
494 self._ModuleAutoGenList = None\r
495 self._LibraryAutoGenList = None\r
496 self._BuildCommand = None\r
497\r
498 # get the original module/package/platform objects\r
499 self.BuildDatabase = Workspace.BuildDatabase\r
500 return True\r
501\r
502 def __repr__(self):\r
503 return "%s [%s]" % (self.MetaFile, self.Arch)\r
504\r
505 ## Create autogen code for platform and modules\r
506 #\r
507 # Since there's no autogen code for platform, this method will do nothing\r
508 # if CreateModuleCodeFile is set to False.\r
509 #\r
510 # @param CreateModuleCodeFile Flag indicating if creating module's\r
511 # autogen code file or not\r
512 #\r
513 def CreateCodeFile(self, CreateModuleCodeFile=False):\r
514 # only module has code to be greated, so do nothing if CreateModuleCodeFile is False\r
515 if self.IsCodeFileCreated or not CreateModuleCodeFile:\r
516 return\r
517\r
518 for Ma in self.ModuleAutoGenList:\r
519 Ma.CreateCodeFile(True)\r
520\r
521 # don't do this twice\r
522 self.IsCodeFileCreated = True\r
523\r
524 ## Create makefile for the platform and mdoules in it\r
525 #\r
526 # @param CreateModuleMakeFile Flag indicating if the makefile for\r
527 # modules will be created as well\r
528 #\r
529 def CreateMakeFile(self, CreateModuleMakeFile=False):\r
530 if CreateModuleMakeFile:\r
531 for ModuleFile in self.Platform.Modules:\r
532 Ma = ModuleAutoGen(self.Workspace, ModuleFile, self.BuildTarget,\r
533 self.ToolChain, self.Arch, self.MetaFile)\r
534 Ma.CreateMakeFile(True)\r
da92f276 535 Ma.CreateAsBuiltInf()\r
52302d4d
LG
536\r
537 # no need to create makefile for the platform more than once\r
538 if self.IsMakeFileCreated:\r
539 return\r
540\r
541 # create makefile for platform\r
542 Makefile = GenMake.PlatformMakefile(self)\r
543 if Makefile.Generate():\r
544 EdkLogger.debug(EdkLogger.DEBUG_9, "Generated makefile for platform [%s] [%s]\n" %\r
545 (self.MetaFile, self.Arch))\r
546 else:\r
547 EdkLogger.debug(EdkLogger.DEBUG_9, "Skipped the generation of makefile for platform [%s] [%s]\n" %\r
548 (self.MetaFile, self.Arch))\r
549 self.IsMakeFileCreated = True\r
550\r
551 ## Collect dynamic PCDs\r
552 #\r
553 # Gather dynamic PCDs list from each module and their settings from platform\r
554 # This interface should be invoked explicitly when platform action is created.\r
555 #\r
556 def CollectPlatformDynamicPcds(self):\r
557 # for gathering error information\r
558 NoDatumTypePcdList = set()\r
559\r
560 self._GuidValue = {}\r
561 for F in self.Platform.Modules.keys():\r
562 M = ModuleAutoGen(self.Workspace, F, self.BuildTarget, self.ToolChain, self.Arch, self.MetaFile)\r
563 #GuidValue.update(M.Guids)\r
564 \r
565 self.Platform.Modules[F].M = M\r
566 \r
567 for PcdFromModule in M.ModulePcdList+M.LibraryPcdList:\r
568 # make sure that the "VOID*" kind of datum has MaxDatumSize set\r
569 if PcdFromModule.DatumType == "VOID*" and PcdFromModule.MaxDatumSize == None:\r
570 NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, F))\r
571\r
572 if PcdFromModule.Type in GenC.gDynamicPcd or PcdFromModule.Type in GenC.gDynamicExPcd:\r
573 #\r
574 # If a dynamic PCD used by a PEM module/PEI module & DXE module,\r
575 # it should be stored in Pcd PEI database, If a dynamic only\r
576 # used by DXE module, it should be stored in DXE PCD database.\r
577 # The default Phase is DXE\r
578 #\r
579 if M.ModuleType in ["PEIM", "PEI_CORE"]:\r
580 PcdFromModule.Phase = "PEI"\r
581 if PcdFromModule not in self._DynaPcdList_:\r
582 self._DynaPcdList_.append(PcdFromModule)\r
583 elif PcdFromModule.Phase == 'PEI':\r
584 # overwrite any the same PCD existing, if Phase is PEI\r
585 Index = self._DynaPcdList_.index(PcdFromModule)\r
586 self._DynaPcdList_[Index] = PcdFromModule\r
587 elif PcdFromModule not in self._NonDynaPcdList_:\r
588 self._NonDynaPcdList_.append(PcdFromModule)\r
589\r
590 # print out error information and break the build, if error found\r
591 if len(NoDatumTypePcdList) > 0:\r
592 NoDatumTypePcdListString = "\n\t\t".join(NoDatumTypePcdList)\r
593 EdkLogger.error("build", AUTOGEN_ERROR, "PCD setting error",\r
594 File=self.MetaFile,\r
595 ExtraData="\n\tPCD(s) without MaxDatumSize:\n\t\t%s\n"\r
596 % NoDatumTypePcdListString)\r
597 self._NonDynamicPcdList = self._NonDynaPcdList_\r
598 self._DynamicPcdList = self._DynaPcdList_\r
599 self.AllPcdList = self._NonDynamicPcdList + self._DynamicPcdList\r
600 \r
601 #\r
602 # Sort dynamic PCD list to:\r
603 # 1) If PCD's datum type is VOID* and value is unicode string which starts with L, the PCD item should \r
604 # try to be put header of dynamicd List\r
605 # 2) If PCD is HII type, the PCD item should be put after unicode type PCD\r
606 #\r
607 # The reason of sorting is make sure the unicode string is in double-byte alignment in string table.\r
608 #\r
609 UnicodePcdArray = []\r
610 HiiPcdArray = []\r
611 OtherPcdArray = []\r
6780eef1 612 VpdPcdDict = {}\r
e56468c0 613 VpdFile = VpdInfoFile.VpdInfoFile()\r
614 NeedProcessVpdMapFile = False \r
615 \r
616 if (self.Workspace.ArchList[-1] == self.Arch): \r
617 for Pcd in self._DynamicPcdList:\r
e56468c0 618 # just pick the a value to determine whether is unicode string type\r
619 Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]\r
620 Sku.VpdOffset = Sku.VpdOffset.strip()\r
621 \r
622 PcdValue = Sku.DefaultValue\r
623 if Pcd.DatumType == 'VOID*' and PcdValue.startswith("L"):\r
624 # if found PCD which datum value is unicode string the insert to left size of UnicodeIndex\r
625 UnicodePcdArray.append(Pcd)\r
626 elif len(Sku.VariableName) > 0:\r
627 # if found HII type PCD then insert to right of UnicodeIndex\r
628 HiiPcdArray.append(Pcd)\r
629 else:\r
630 OtherPcdArray.append(Pcd)\r
e56468c0 631 if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:\r
6780eef1
LG
632 VpdPcdDict[(Pcd.TokenCName, Pcd.TokenSpaceGuidCName)] = Pcd \r
633 \r
634 PlatformPcds = self.Platform.Pcds.keys()\r
635 PlatformPcds.sort() \r
636 #\r
637 # Add VPD type PCD into VpdFile and determine whether the VPD PCD need to be fixed up.\r
638 #\r
639 for PcdKey in PlatformPcds:\r
640 Pcd = self.Platform.Pcds[PcdKey] \r
641 if Pcd.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:\r
642 Pcd = VpdPcdDict[PcdKey]\r
643 Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]]\r
644 Sku.VpdOffset = Sku.VpdOffset.strip() \r
645 #\r
646 # Fix the optional data of VPD PCD.\r
647 #\r
648 if (Pcd.DatumType.strip() != "VOID*"):\r
649 if Sku.DefaultValue == '':\r
650 Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]].DefaultValue = Pcd.MaxDatumSize\r
651 Pcd.MaxDatumSize = None\r
652 else:\r
653 EdkLogger.error("build", AUTOGEN_ERROR, "PCD setting error",\r
654 File=self.MetaFile,\r
655 ExtraData="\n\tPCD: %s.%s format incorrect in DSC: %s\n\t\t\n"\r
656 % (Pcd.TokenSpaceGuidCName, Pcd.TokenCName, self.Platform.MetaFile.Path)) \r
657 \r
658 VpdFile.Add(Pcd, Sku.VpdOffset)\r
659 # if the offset of a VPD is *, then it need to be fixed up by third party tool.\r
660 if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":\r
661 NeedProcessVpdMapFile = True\r
662 if self.Platform.VpdToolGuid == None or self.Platform.VpdToolGuid == '':\r
663 EdkLogger.error("Build", FILE_NOT_FOUND, \\r
664 "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
665 \r
e56468c0 666 \r
667 #\r
668 # Fix the PCDs define in VPD PCD section that never referenced by module.\r
669 # An example is PCD for signature usage.\r
6780eef1
LG
670 # \r
671 for DscPcd in PlatformPcds:\r
e56468c0 672 DscPcdEntry = self.Platform.Pcds[DscPcd]\r
673 if DscPcdEntry.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:\r
674 if not (self.Platform.VpdToolGuid == None or self.Platform.VpdToolGuid == ''):\r
675 FoundFlag = False\r
676 for VpdPcd in VpdFile._VpdArray.keys():\r
677 # This PCD has been referenced by module\r
678 if (VpdPcd.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \\r
679 (VpdPcd.TokenCName == DscPcdEntry.TokenCName):\r
680 FoundFlag = True\r
681 \r
682 # Not found, it should be signature\r
683 if not FoundFlag :\r
684 # just pick the a value to determine whether is unicode string type\r
685 Sku = DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]]\r
686 Sku.VpdOffset = Sku.VpdOffset.strip() \r
687 \r
688 # Need to iterate DEC pcd information to get the value & datumtype\r
689 for eachDec in self.PackageList:\r
690 for DecPcd in eachDec.Pcds:\r
691 DecPcdEntry = eachDec.Pcds[DecPcd]\r
692 if (DecPcdEntry.TokenSpaceGuidCName == DscPcdEntry.TokenSpaceGuidCName) and \\r
693 (DecPcdEntry.TokenCName == DscPcdEntry.TokenCName):\r
08dd311f
LG
694 # Print warning message to let the developer make a determine.\r
695 EdkLogger.warn("build", "Unreferenced vpd pcd used!",\r
696 File=self.MetaFile, \\r
697 ExtraData = "PCD: %s.%s used in the DSC file %s is unreferenced." \\r
698 %(DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, self.Platform.MetaFile.Path)) \r
699 \r
e56468c0 700 DscPcdEntry.DatumType = DecPcdEntry.DatumType\r
701 DscPcdEntry.DefaultValue = DecPcdEntry.DefaultValue\r
08dd311f
LG
702 # Only fix the value while no value provided in DSC file.\r
703 if (Sku.DefaultValue == "" or Sku.DefaultValue==None):\r
704 DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]].DefaultValue = DecPcdEntry.DefaultValue\r
705 \r
e56468c0 706 \r
707 VpdFile.Add(DscPcdEntry, Sku.VpdOffset)\r
708 # if the offset of a VPD is *, then it need to be fixed up by third party tool.\r
709 if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":\r
710 NeedProcessVpdMapFile = True \r
711 \r
712 \r
713 if (self.Platform.FlashDefinition == None or self.Platform.FlashDefinition == '') and \\r
714 VpdFile.GetCount() != 0:\r
715 EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, \r
716 "Fail to get FLASH_DEFINITION definition in DSC file %s which is required when DSC contains VPD PCD." % str(self.Platform.MetaFile))\r
717 \r
718 if VpdFile.GetCount() != 0:\r
719 WorkspaceDb = self.BuildDatabase.WorkspaceDb\r
720 DscTimeStamp = WorkspaceDb.GetTimeStamp(WorkspaceDb.GetFileId(str(self.Platform.MetaFile)))\r
721 FvPath = os.path.join(self.BuildDir, "FV")\r
722 if not os.path.exists(FvPath):\r
723 try:\r
724 os.makedirs(FvPath)\r
725 except:\r
726 EdkLogger.error("build", FILE_WRITE_FAILURE, "Fail to create FV folder under %s" % self.BuildDir)\r
727 \r
08dd311f
LG
728 \r
729 VpdFilePath = os.path.join(FvPath, "%s.txt" % self.Platform.VpdToolGuid)\r
730\r
e56468c0 731 \r
732 if not os.path.exists(VpdFilePath) or os.path.getmtime(VpdFilePath) < DscTimeStamp:\r
733 VpdFile.Write(VpdFilePath)\r
734 \r
735 # retrieve BPDG tool's path from tool_def.txt according to VPD_TOOL_GUID defined in DSC file.\r
736 BPDGToolName = None\r
737 for ToolDef in self.ToolDefinition.values():\r
738 if ToolDef.has_key("GUID") and ToolDef["GUID"] == self.Platform.VpdToolGuid:\r
739 if not ToolDef.has_key("PATH"):\r
740 EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "PATH attribute was not provided for BPDG guid tool %s in tools_def.txt" % self.Platform.VpdToolGuid)\r
741 BPDGToolName = ToolDef["PATH"]\r
742 break\r
743 # Call third party GUID BPDG tool.\r
744 if BPDGToolName != None:\r
08dd311f 745 VpdInfoFile.CallExtenalBPDGTool(BPDGToolName, VpdFilePath)\r
e56468c0 746 else:\r
747 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
748 \r
749 # Process VPD map file generated by third party BPDG tool\r
750 if NeedProcessVpdMapFile:\r
08dd311f 751 VpdMapFilePath = os.path.join(self.BuildDir, "FV", "%s.map" % self.Platform.VpdToolGuid)\r
e56468c0 752 if os.path.exists(VpdMapFilePath):\r
753 VpdFile.Read(VpdMapFilePath)\r
754 \r
755 # Fixup "*" offset\r
756 for Pcd in self._DynamicPcdList:\r
757 # just pick the a value to determine whether is unicode string type\r
758 Sku = Pcd.SkuInfoList[Pcd.SkuInfoList.keys()[0]] \r
759 if Sku.VpdOffset == "*":\r
6780eef1 760 Sku.VpdOffset = VpdFile.GetOffset(Pcd)[0]\r
e56468c0 761 else:\r
762 EdkLogger.error("build", FILE_READ_FAILURE, "Can not find VPD map file %s to fix up VPD offset." % VpdMapFilePath)\r
763 \r
764 # Delete the DynamicPcdList At the last time enter into this function \r
765 del self._DynamicPcdList[:] \r
52302d4d
LG
766 self._DynamicPcdList.extend(UnicodePcdArray)\r
767 self._DynamicPcdList.extend(HiiPcdArray)\r
768 self._DynamicPcdList.extend(OtherPcdArray)\r
769 \r
770 \r
771 ## Return the platform build data object\r
772 def _GetPlatform(self):\r
773 if self._Platform == None:\r
774 self._Platform = self.BuildDatabase[self.MetaFile, self.Arch]\r
775 return self._Platform\r
776\r
777 ## Return platform name\r
778 def _GetName(self):\r
779 return self.Platform.PlatformName\r
780\r
781 ## Return the meta file GUID\r
782 def _GetGuid(self):\r
783 return self.Platform.Guid\r
784\r
785 ## Return the platform version\r
786 def _GetVersion(self):\r
787 return self.Platform.Version\r
788\r
789 ## Return the FDF file name\r
790 def _GetFdfFile(self):\r
791 if self._FdfFile == None:\r
792 if self.Workspace.FdfFile != "":\r
793 self._FdfFile= path.join(self.WorkspaceDir, self.Workspace.FdfFile)\r
794 else:\r
795 self._FdfFile = ''\r
796 return self._FdfFile\r
797\r
798 ## Return the build output directory platform specifies\r
799 def _GetOutputDir(self):\r
800 return self.Platform.OutputDirectory\r
801\r
802 ## Return the directory to store all intermediate and final files built\r
803 def _GetBuildDir(self):\r
804 if self._BuildDir == None:\r
805 if os.path.isabs(self.OutputDir):\r
806 self._BuildDir = path.join(\r
807 path.abspath(self.OutputDir),\r
808 self.BuildTarget + "_" + self.ToolChain,\r
809 )\r
810 else:\r
811 self._BuildDir = path.join(\r
812 self.WorkspaceDir,\r
813 self.OutputDir,\r
814 self.BuildTarget + "_" + self.ToolChain,\r
815 )\r
816 return self._BuildDir\r
817\r
818 ## Return directory of platform makefile\r
819 #\r
820 # @retval string Makefile directory\r
821 #\r
822 def _GetMakeFileDir(self):\r
823 if self._MakeFileDir == None:\r
824 self._MakeFileDir = path.join(self.BuildDir, self.Arch)\r
825 return self._MakeFileDir\r
826\r
827 ## Return build command string\r
828 #\r
829 # @retval string Build command string\r
830 #\r
831 def _GetBuildCommand(self):\r
832 if self._BuildCommand == None:\r
833 self._BuildCommand = []\r
834 if "MAKE" in self.ToolDefinition and "PATH" in self.ToolDefinition["MAKE"]:\r
835 self._BuildCommand += SplitOption(self.ToolDefinition["MAKE"]["PATH"])\r
836 if "FLAGS" in self.ToolDefinition["MAKE"]:\r
837 NewOption = self.ToolDefinition["MAKE"]["FLAGS"].strip()\r
838 if NewOption != '':\r
6780eef1 839 self._BuildCommand += SplitOption(NewOption)\r
52302d4d
LG
840 return self._BuildCommand\r
841\r
842 ## Get tool chain definition\r
843 #\r
844 # Get each tool defition for given tool chain from tools_def.txt and platform\r
845 #\r
846 def _GetToolDefinition(self):\r
847 if self._ToolDefinitions == None:\r
848 ToolDefinition = self.Workspace.ToolDef.ToolsDefTxtDictionary\r
849 if TAB_TOD_DEFINES_COMMAND_TYPE not in self.Workspace.ToolDef.ToolsDefTxtDatabase:\r
850 EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "No tools found in configuration",\r
851 ExtraData="[%s]" % self.MetaFile)\r
852 self._ToolDefinitions = {}\r
853 DllPathList = set()\r
854 for Def in ToolDefinition:\r
855 Target, Tag, Arch, Tool, Attr = Def.split("_")\r
856 if Target != self.BuildTarget or Tag != self.ToolChain or Arch != self.Arch:\r
857 continue\r
858\r
859 Value = ToolDefinition[Def]\r
860 # don't record the DLL\r
861 if Attr == "DLL":\r
862 DllPathList.add(Value)\r
863 continue\r
864\r
865 if Tool not in self._ToolDefinitions:\r
866 self._ToolDefinitions[Tool] = {}\r
867 self._ToolDefinitions[Tool][Attr] = Value\r
868\r
869 ToolsDef = ''\r
870 MakePath = ''\r
871 if GlobalData.gOptions.SilentMode and "MAKE" in self._ToolDefinitions:\r
872 if "FLAGS" not in self._ToolDefinitions["MAKE"]:\r
873 self._ToolDefinitions["MAKE"]["FLAGS"] = ""\r
874 self._ToolDefinitions["MAKE"]["FLAGS"] += " -s"\r
875 MakeFlags = ''\r
876 for Tool in self._ToolDefinitions:\r
877 for Attr in self._ToolDefinitions[Tool]:\r
878 Value = self._ToolDefinitions[Tool][Attr]\r
879 if Tool in self.BuildOption and Attr in self.BuildOption[Tool]:\r
880 # check if override is indicated\r
881 if self.BuildOption[Tool][Attr].startswith('='):\r
882 Value = self.BuildOption[Tool][Attr][1:]\r
883 else:\r
884 Value += " " + self.BuildOption[Tool][Attr]\r
885\r
886 if Attr == "PATH":\r
887 # Don't put MAKE definition in the file\r
888 if Tool == "MAKE":\r
889 MakePath = Value\r
890 else:\r
891 ToolsDef += "%s = %s\n" % (Tool, Value)\r
892 elif Attr != "DLL":\r
893 # Don't put MAKE definition in the file\r
894 if Tool == "MAKE":\r
895 if Attr == "FLAGS":\r
896 MakeFlags = Value\r
897 else:\r
898 ToolsDef += "%s_%s = %s\n" % (Tool, Attr, Value)\r
899 ToolsDef += "\n"\r
900\r
901 SaveFileOnChange(self.ToolDefinitionFile, ToolsDef)\r
902 for DllPath in DllPathList:\r
903 os.environ["PATH"] = DllPath + os.pathsep + os.environ["PATH"]\r
904 os.environ["MAKE_FLAGS"] = MakeFlags\r
905\r
906 return self._ToolDefinitions\r
907\r
908 ## Return the paths of tools\r
909 def _GetToolDefFile(self):\r
910 if self._ToolDefFile == None:\r
911 self._ToolDefFile = os.path.join(self.MakeFileDir, "TOOLS_DEF." + self.Arch)\r
912 return self._ToolDefFile\r
913\r
914 ## Retrieve the toolchain family of given toolchain tag. Default to 'MSFT'.\r
915 def _GetToolChainFamily(self):\r
916 if self._ToolChainFamily == None:\r
917 ToolDefinition = self.Workspace.ToolDef.ToolsDefTxtDatabase\r
918 if TAB_TOD_DEFINES_FAMILY not in ToolDefinition \\r
919 or self.ToolChain not in ToolDefinition[TAB_TOD_DEFINES_FAMILY] \\r
920 or not ToolDefinition[TAB_TOD_DEFINES_FAMILY][self.ToolChain]:\r
921 EdkLogger.verbose("No tool chain family found in configuration for %s. Default to MSFT." \\r
922 % self.ToolChain)\r
923 self._ToolChainFamily = "MSFT"\r
924 else:\r
925 self._ToolChainFamily = ToolDefinition[TAB_TOD_DEFINES_FAMILY][self.ToolChain]\r
926 return self._ToolChainFamily\r
927\r
928 def _GetBuildRuleFamily(self):\r
929 if self._BuildRuleFamily == None:\r
930 ToolDefinition = self.Workspace.ToolDef.ToolsDefTxtDatabase\r
931 if TAB_TOD_DEFINES_BUILDRULEFAMILY not in ToolDefinition \\r
932 or self.ToolChain not in ToolDefinition[TAB_TOD_DEFINES_BUILDRULEFAMILY] \\r
933 or not ToolDefinition[TAB_TOD_DEFINES_BUILDRULEFAMILY][self.ToolChain]:\r
934 EdkLogger.verbose("No tool chain family found in configuration for %s. Default to MSFT." \\r
935 % self.ToolChain)\r
936 self._BuildRuleFamily = "MSFT"\r
937 else:\r
938 self._BuildRuleFamily = ToolDefinition[TAB_TOD_DEFINES_BUILDRULEFAMILY][self.ToolChain]\r
939 return self._BuildRuleFamily\r
940\r
941 ## Return the build options specific for all modules in this platform\r
942 def _GetBuildOptions(self):\r
943 if self._BuildOption == None:\r
944 self._BuildOption = self._ExpandBuildOption(self.Platform.BuildOptions)\r
945 return self._BuildOption\r
946\r
947 ## Return the build options specific for EDK modules in this platform\r
948 def _GetEdkBuildOptions(self):\r
949 if self._EdkBuildOption == None:\r
950 self._EdkBuildOption = self._ExpandBuildOption(self.Platform.BuildOptions, EDK_NAME)\r
951 return self._EdkBuildOption\r
952\r
953 ## Return the build options specific for EDKII modules in this platform\r
954 def _GetEdkIIBuildOptions(self):\r
955 if self._EdkIIBuildOption == None:\r
956 self._EdkIIBuildOption = self._ExpandBuildOption(self.Platform.BuildOptions, EDKII_NAME)\r
957 return self._EdkIIBuildOption\r
958\r
959 ## Parse build_rule.txt in $(WORKSPACE)/Conf/build_rule.txt\r
960 #\r
961 # @retval BuildRule object\r
962 #\r
963 def _GetBuildRule(self):\r
964 if self._BuildRule == None:\r
965 BuildRuleFile = None\r
966 if TAB_TAT_DEFINES_BUILD_RULE_CONF in self.Workspace.TargetTxt.TargetTxtDictionary:\r
967 BuildRuleFile = self.Workspace.TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_BUILD_RULE_CONF]\r
968 if BuildRuleFile in [None, '']:\r
969 BuildRuleFile = gBuildRuleFile\r
970 self._BuildRule = BuildRule(BuildRuleFile)\r
971 return self._BuildRule\r
972\r
973 ## Summarize the packages used by modules in this platform\r
974 def _GetPackageList(self):\r
975 if self._PackageList == None:\r
976 self._PackageList = set()\r
977 for La in self.LibraryAutoGenList:\r
978 self._PackageList.update(La.DependentPackageList)\r
979 for Ma in self.ModuleAutoGenList:\r
980 self._PackageList.update(Ma.DependentPackageList)\r
981 self._PackageList = list(self._PackageList)\r
982 return self._PackageList\r
983\r
984 ## Get list of non-dynamic PCDs\r
985 def _GetNonDynamicPcdList(self):\r
e56468c0 986 if self._NonDynamicPcdList == None:\r
987 self.CollectPlatformDynamicPcds()\r
52302d4d
LG
988 return self._NonDynamicPcdList\r
989\r
990 ## Get list of dynamic PCDs\r
991 def _GetDynamicPcdList(self):\r
e56468c0 992 if self._DynamicPcdList == None:\r
993 self.CollectPlatformDynamicPcds()\r
52302d4d
LG
994 return self._DynamicPcdList\r
995\r
996 ## Generate Token Number for all PCD\r
997 def _GetPcdTokenNumbers(self):\r
998 if self._PcdTokenNumber == None:\r
999 self._PcdTokenNumber = sdict()\r
1000 TokenNumber = 1\r
1001 for Pcd in self.DynamicPcdList:\r
1002 if Pcd.Phase == "PEI":\r
1003 EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))\r
1004 self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber\r
1005 TokenNumber += 1\r
1006\r
1007 for Pcd in self.DynamicPcdList:\r
1008 if Pcd.Phase == "DXE":\r
1009 EdkLogger.debug(EdkLogger.DEBUG_5, "%s %s (%s) -> %d" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Pcd.Phase, TokenNumber))\r
1010 self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber\r
1011 TokenNumber += 1\r
1012\r
1013 for Pcd in self.NonDynamicPcdList:\r
1014 self._PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName] = TokenNumber\r
1015 TokenNumber += 1\r
1016 return self._PcdTokenNumber\r
1017\r
1018 ## Summarize ModuleAutoGen objects of all modules/libraries to be built for this platform\r
1019 def _GetAutoGenObjectList(self):\r
1020 self._ModuleAutoGenList = []\r
1021 self._LibraryAutoGenList = []\r
1022 for ModuleFile in self.Platform.Modules:\r
1023 Ma = ModuleAutoGen(\r
1024 self.Workspace,\r
1025 ModuleFile,\r
1026 self.BuildTarget,\r
1027 self.ToolChain,\r
1028 self.Arch,\r
1029 self.MetaFile\r
1030 )\r
1031 if Ma not in self._ModuleAutoGenList:\r
1032 self._ModuleAutoGenList.append(Ma)\r
1033 for La in Ma.LibraryAutoGenList:\r
1034 if La not in self._LibraryAutoGenList:\r
1035 self._LibraryAutoGenList.append(La)\r
1036\r
1037 ## Summarize ModuleAutoGen objects of all modules to be built for this platform\r
1038 def _GetModuleAutoGenList(self):\r
1039 if self._ModuleAutoGenList == None:\r
1040 self._GetAutoGenObjectList()\r
1041 return self._ModuleAutoGenList\r
1042\r
1043 ## Summarize ModuleAutoGen objects of all libraries to be built for this platform\r
1044 def _GetLibraryAutoGenList(self):\r
1045 if self._LibraryAutoGenList == None:\r
1046 self._GetAutoGenObjectList()\r
1047 return self._LibraryAutoGenList\r
1048\r
1049 ## Test if a module is supported by the platform\r
1050 #\r
1051 # An error will be raised directly if the module or its arch is not supported\r
1052 # by the platform or current configuration\r
1053 #\r
1054 def ValidModule(self, Module):\r
1055 return Module in self.Platform.Modules or Module in self.Platform.LibraryInstances\r
1056\r
1057 ## Resolve the library classes in a module to library instances\r
1058 #\r
1059 # This method will not only resolve library classes but also sort the library\r
1060 # instances according to the dependency-ship.\r
1061 #\r
1062 # @param Module The module from which the library classes will be resolved\r
1063 #\r
1064 # @retval library_list List of library instances sorted\r
1065 #\r
1066 def ApplyLibraryInstance(self, Module):\r
1067 ModuleType = Module.ModuleType\r
1068\r
1069 # for overridding library instances with module specific setting\r
1070 PlatformModule = self.Platform.Modules[str(Module)]\r
1071\r
1072 # add forced library instances (specified under LibraryClasses sections)\r
da92f276
LG
1073 #\r
1074 # If a module has a MODULE_TYPE of USER_DEFINED,\r
1075 # do not link in NULL library class instances from the global [LibraryClasses.*] sections.\r
1076 #\r
1077 if Module.ModuleType != SUP_MODULE_USER_DEFINED:\r
1078 for LibraryClass in self.Platform.LibraryClasses.GetKeys():\r
1079 if LibraryClass.startswith("NULL") and self.Platform.LibraryClasses[LibraryClass, Module.ModuleType]:\r
1080 Module.LibraryClasses[LibraryClass] = self.Platform.LibraryClasses[LibraryClass, Module.ModuleType]\r
52302d4d
LG
1081\r
1082 # add forced library instances (specified in module overrides)\r
1083 for LibraryClass in PlatformModule.LibraryClasses:\r
1084 if LibraryClass.startswith("NULL"):\r
1085 Module.LibraryClasses[LibraryClass] = PlatformModule.LibraryClasses[LibraryClass]\r
1086\r
1087 # R9 module\r
1088 LibraryConsumerList = [Module]\r
1089 Constructor = []\r
1090 ConsumedByList = sdict()\r
1091 LibraryInstance = sdict()\r
1092\r
1093 EdkLogger.verbose("")\r
1094 EdkLogger.verbose("Library instances of module [%s] [%s]:" % (str(Module), self.Arch))\r
1095 while len(LibraryConsumerList) > 0:\r
1096 M = LibraryConsumerList.pop()\r
1097 for LibraryClassName in M.LibraryClasses:\r
1098 if LibraryClassName not in LibraryInstance:\r
1099 # override library instance for this module\r
1100 if LibraryClassName in PlatformModule.LibraryClasses:\r
1101 LibraryPath = PlatformModule.LibraryClasses[LibraryClassName]\r
1102 else:\r
1103 LibraryPath = self.Platform.LibraryClasses[LibraryClassName, ModuleType]\r
1104 if LibraryPath == None or LibraryPath == "":\r
1105 LibraryPath = M.LibraryClasses[LibraryClassName]\r
1106 if LibraryPath == None or LibraryPath == "":\r
1107 EdkLogger.error("build", RESOURCE_NOT_AVAILABLE,\r
1108 "Instance of library class [%s] is not found" % LibraryClassName,\r
1109 File=self.MetaFile,\r
1110 ExtraData="in [%s] [%s]\n\tconsumed by module [%s]" % (str(M), self.Arch, str(Module)))\r
1111\r
1112 LibraryModule = self.BuildDatabase[LibraryPath, self.Arch]\r
1113 # for those forced library instance (NULL library), add a fake library class\r
1114 if LibraryClassName.startswith("NULL"):\r
1115 LibraryModule.LibraryClass.append(LibraryClassObject(LibraryClassName, [ModuleType]))\r
1116 elif LibraryModule.LibraryClass == None \\r
1117 or len(LibraryModule.LibraryClass) == 0 \\r
1118 or (ModuleType != 'USER_DEFINED'\r
1119 and ModuleType not in LibraryModule.LibraryClass[0].SupModList):\r
1120 # only USER_DEFINED can link against any library instance despite of its SupModList\r
1121 EdkLogger.error("build", OPTION_MISSING,\r
1122 "Module type [%s] is not supported by library instance [%s]" \\r
1123 % (ModuleType, LibraryPath), File=self.MetaFile,\r
1124 ExtraData="consumed by [%s]" % str(Module))\r
1125\r
1126 LibraryInstance[LibraryClassName] = LibraryModule\r
1127 LibraryConsumerList.append(LibraryModule)\r
1128 EdkLogger.verbose("\t" + str(LibraryClassName) + " : " + str(LibraryModule))\r
1129 else:\r
1130 LibraryModule = LibraryInstance[LibraryClassName]\r
1131\r
1132 if LibraryModule == None:\r
1133 continue\r
1134\r
1135 if LibraryModule.ConstructorList != [] and LibraryModule not in Constructor:\r
1136 Constructor.append(LibraryModule)\r
1137\r
1138 if LibraryModule not in ConsumedByList:\r
1139 ConsumedByList[LibraryModule] = []\r
1140 # don't add current module itself to consumer list\r
1141 if M != Module:\r
1142 if M in ConsumedByList[LibraryModule]:\r
1143 continue\r
1144 ConsumedByList[LibraryModule].append(M)\r
1145 #\r
1146 # Initialize the sorted output list to the empty set\r
1147 #\r
1148 SortedLibraryList = []\r
1149 #\r
1150 # Q <- Set of all nodes with no incoming edges\r
1151 #\r
1152 LibraryList = [] #LibraryInstance.values()\r
1153 Q = []\r
1154 for LibraryClassName in LibraryInstance:\r
1155 M = LibraryInstance[LibraryClassName]\r
1156 LibraryList.append(M)\r
1157 if ConsumedByList[M] == []:\r
1158 Q.append(M)\r
1159\r
1160 #\r
1161 # start the DAG algorithm\r
1162 #\r
1163 while True:\r
1164 EdgeRemoved = True\r
1165 while Q == [] and EdgeRemoved:\r
1166 EdgeRemoved = False\r
1167 # for each node Item with a Constructor\r
1168 for Item in LibraryList:\r
1169 if Item not in Constructor:\r
1170 continue\r
1171 # for each Node without a constructor with an edge e from Item to Node\r
1172 for Node in ConsumedByList[Item]:\r
1173 if Node in Constructor:\r
1174 continue\r
1175 # remove edge e from the graph if Node has no constructor\r
1176 ConsumedByList[Item].remove(Node)\r
1177 EdgeRemoved = True\r
1178 if ConsumedByList[Item] == []:\r
1179 # insert Item into Q\r
1180 Q.insert(0, Item)\r
1181 break\r
1182 if Q != []:\r
1183 break\r
1184 # DAG is done if there's no more incoming edge for all nodes\r
1185 if Q == []:\r
1186 break\r
1187\r
1188 # remove node from Q\r
1189 Node = Q.pop()\r
1190 # output Node\r
1191 SortedLibraryList.append(Node)\r
1192\r
1193 # for each node Item with an edge e from Node to Item do\r
1194 for Item in LibraryList:\r
1195 if Node not in ConsumedByList[Item]:\r
1196 continue\r
1197 # remove edge e from the graph\r
1198 ConsumedByList[Item].remove(Node)\r
1199\r
1200 if ConsumedByList[Item] != []:\r
1201 continue\r
1202 # insert Item into Q, if Item has no other incoming edges\r
1203 Q.insert(0, Item)\r
1204\r
1205 #\r
1206 # if any remaining node Item in the graph has a constructor and an incoming edge, then the graph has a cycle\r
1207 #\r
1208 for Item in LibraryList:\r
1209 if ConsumedByList[Item] != [] and Item in Constructor and len(Constructor) > 1:\r
1210 ErrorMessage = "\tconsumed by " + "\n\tconsumed by ".join([str(L) for L in ConsumedByList[Item]])\r
1211 EdkLogger.error("build", BUILD_ERROR, 'Library [%s] with constructors has a cycle' % str(Item),\r
1212 ExtraData=ErrorMessage, File=self.MetaFile)\r
1213 if Item not in SortedLibraryList:\r
1214 SortedLibraryList.append(Item)\r
1215\r
1216 #\r
1217 # Build the list of constructor and destructir names\r
1218 # The DAG Topo sort produces the destructor order, so the list of constructors must generated in the reverse order\r
1219 #\r
1220 SortedLibraryList.reverse()\r
1221 return SortedLibraryList\r
1222\r
1223\r
1224 ## Override PCD setting (type, value, ...)\r
1225 #\r
1226 # @param ToPcd The PCD to be overrided\r
1227 # @param FromPcd The PCD overrideing from\r
1228 #\r
1229 def _OverridePcd(self, ToPcd, FromPcd, Module=""):\r
1230 #\r
1231 # in case there's PCDs coming from FDF file, which have no type given.\r
1232 # at this point, ToPcd.Type has the type found from dependent\r
1233 # package\r
1234 #\r
1235 if FromPcd != None:\r
1236 if ToPcd.Pending and FromPcd.Type not in [None, '']:\r
1237 ToPcd.Type = FromPcd.Type\r
e56468c0 1238 elif (ToPcd.Type not in [None, '']) and (FromPcd.Type not in [None, ''])\\r
1239 and (ToPcd.Type != FromPcd.Type) and (ToPcd.Type in FromPcd.Type):\r
1240 if ToPcd.Type.strip() == "DynamicEx":\r
1241 ToPcd.Type = FromPcd.Type \r
52302d4d
LG
1242 elif ToPcd.Type not in [None, ''] and FromPcd.Type not in [None, ''] \\r
1243 and ToPcd.Type != FromPcd.Type:\r
1244 EdkLogger.error("build", OPTION_CONFLICT, "Mismatched PCD type",\r
1245 ExtraData="%s.%s is defined as [%s] in module %s, but as [%s] in platform."\\r
1246 % (ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName,\r
1247 ToPcd.Type, Module, FromPcd.Type),\r
1248 File=self.MetaFile)\r
1249\r
1250 if FromPcd.MaxDatumSize not in [None, '']:\r
1251 ToPcd.MaxDatumSize = FromPcd.MaxDatumSize\r
1252 if FromPcd.DefaultValue not in [None, '']:\r
1253 ToPcd.DefaultValue = FromPcd.DefaultValue\r
1254 if FromPcd.TokenValue not in [None, '']:\r
1255 ToPcd.TokenValue = FromPcd.TokenValue\r
1256 if FromPcd.MaxDatumSize not in [None, '']:\r
1257 ToPcd.MaxDatumSize = FromPcd.MaxDatumSize\r
1258 if FromPcd.DatumType not in [None, '']:\r
1259 ToPcd.DatumType = FromPcd.DatumType\r
1260 if FromPcd.SkuInfoList not in [None, '', []]:\r
1261 ToPcd.SkuInfoList = FromPcd.SkuInfoList\r
1262\r
1263 # check the validation of datum\r
1264 IsValid, Cause = CheckPcdDatum(ToPcd.DatumType, ToPcd.DefaultValue)\r
1265 if not IsValid:\r
1266 EdkLogger.error('build', FORMAT_INVALID, Cause, File=self.MetaFile,\r
1267 ExtraData="%s.%s" % (ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName))\r
1268\r
1269 if ToPcd.DatumType == "VOID*" and ToPcd.MaxDatumSize in ['', None]:\r
1270 EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for PCD %s.%s" \\r
1271 % (ToPcd.TokenSpaceGuidCName, ToPcd.TokenCName))\r
1272 Value = ToPcd.DefaultValue\r
1273 if Value in [None, '']:\r
1274 ToPcd.MaxDatumSize = 1\r
1275 elif Value[0] == 'L':\r
1276 ToPcd.MaxDatumSize = str(len(Value) * 2)\r
1277 elif Value[0] == '{':\r
1278 ToPcd.MaxDatumSize = str(len(Value.split(',')))\r
1279 else:\r
1280 ToPcd.MaxDatumSize = str(len(Value))\r
1281\r
1282 # apply default SKU for dynamic PCDS if specified one is not available\r
1283 if (ToPcd.Type in PCD_DYNAMIC_TYPE_LIST or ToPcd.Type in PCD_DYNAMIC_EX_TYPE_LIST) \\r
1284 and ToPcd.SkuInfoList in [None, {}, '']:\r
1285 if self.Platform.SkuName in self.Platform.SkuIds:\r
1286 SkuName = self.Platform.SkuName\r
1287 else:\r
1288 SkuName = 'DEFAULT'\r
1289 ToPcd.SkuInfoList = {\r
1290 SkuName : SkuInfoClass(SkuName, self.Platform.SkuIds[SkuName], '', '', '', '', '', ToPcd.DefaultValue)\r
1291 }\r
1292\r
1293 ## Apply PCD setting defined platform to a module\r
1294 #\r
1295 # @param Module The module from which the PCD setting will be overrided\r
1296 #\r
1297 # @retval PCD_list The list PCDs with settings from platform\r
1298 #\r
1299 def ApplyPcdSetting(self, Module, Pcds):\r
1300 # for each PCD in module\r
1301 for Name,Guid in Pcds:\r
1302 PcdInModule = Pcds[Name,Guid]\r
1303 # find out the PCD setting in platform\r
1304 if (Name,Guid) in self.Platform.Pcds:\r
1305 PcdInPlatform = self.Platform.Pcds[Name,Guid]\r
1306 else:\r
1307 PcdInPlatform = None\r
1308 # then override the settings if any\r
1309 self._OverridePcd(PcdInModule, PcdInPlatform, Module)\r
1310 # resolve the VariableGuid value\r
1311 for SkuId in PcdInModule.SkuInfoList:\r
1312 Sku = PcdInModule.SkuInfoList[SkuId]\r
1313 if Sku.VariableGuid == '': continue\r
1314 Sku.VariableGuidValue = GuidValue(Sku.VariableGuid, self.PackageList)\r
1315 if Sku.VariableGuidValue == None:\r
1316 PackageList = "\n\t".join([str(P) for P in self.PackageList])\r
1317 EdkLogger.error(\r
1318 'build',\r
1319 RESOURCE_NOT_AVAILABLE,\r
1320 "Value of GUID [%s] is not found in" % Sku.VariableGuid,\r
1321 ExtraData=PackageList + "\n\t(used with %s.%s from module %s)" \\r
1322 % (Guid, Name, str(Module)),\r
1323 File=self.MetaFile\r
1324 )\r
1325\r
1326 # override PCD settings with module specific setting\r
1327 if Module in self.Platform.Modules:\r
1328 PlatformModule = self.Platform.Modules[str(Module)]\r
1329 for Key in PlatformModule.Pcds:\r
1330 if Key in Pcds:\r
1331 self._OverridePcd(Pcds[Key], PlatformModule.Pcds[Key], Module)\r
1332 return Pcds.values()\r
1333\r
1334 ## Resolve library names to library modules\r
1335 #\r
1336 # (for R8.x modules)\r
1337 #\r
1338 # @param Module The module from which the library names will be resolved\r
1339 #\r
1340 # @retval library_list The list of library modules\r
1341 #\r
1342 def ResolveLibraryReference(self, Module):\r
1343 EdkLogger.verbose("")\r
1344 EdkLogger.verbose("Library instances of module [%s] [%s]:" % (str(Module), self.Arch))\r
1345 LibraryConsumerList = [Module]\r
1346\r
1347 # "CompilerStub" is a must for R8 modules\r
1348 if Module.Libraries:\r
1349 Module.Libraries.append("CompilerStub")\r
1350 LibraryList = []\r
1351 while len(LibraryConsumerList) > 0:\r
1352 M = LibraryConsumerList.pop()\r
1353 for LibraryName in M.Libraries:\r
1354 Library = self.Platform.LibraryClasses[LibraryName, ':dummy:']\r
1355 if Library == None:\r
1356 for Key in self.Platform.LibraryClasses.data.keys():\r
1357 if LibraryName.upper() == Key.upper():\r
1358 Library = self.Platform.LibraryClasses[Key, ':dummy:']\r
1359 break\r
1360 if Library == None:\r
1361 EdkLogger.warn("build", "Library [%s] is not found" % LibraryName, File=str(M),\r
1362 ExtraData="\t%s [%s]" % (str(Module), self.Arch))\r
1363 continue\r
1364\r
1365 if Library not in LibraryList:\r
1366 LibraryList.append(Library)\r
1367 LibraryConsumerList.append(Library)\r
1368 EdkLogger.verbose("\t" + LibraryName + " : " + str(Library) + ' ' + str(type(Library)))\r
1369 return LibraryList\r
1370\r
6780eef1
LG
1371 ## Calculate the priority value of the build option\r
1372 #\r
1373 # @param Key Build option definition contain: TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE\r
1374 #\r
1375 # @retval Value Priority value based on the priority list.\r
1376 #\r
1377 def CalculatePriorityValue(self, Key):\r
1378 Target, ToolChain, Arch, CommandType, Attr = Key.split('_') \r
1379 PriorityValue = 0x11111 \r
1380 if Target == "*":\r
1381 PriorityValue &= 0x01111\r
1382 if ToolChain == "*":\r
1383 PriorityValue &= 0x10111\r
1384 if Arch == "*":\r
1385 PriorityValue &= 0x11011\r
1386 if CommandType == "*":\r
1387 PriorityValue &= 0x11101\r
1388 if Attr == "*":\r
1389 PriorityValue &= 0x11110\r
1390 \r
1391 return self.PrioList["0x%0.5x"%PriorityValue]\r
1392 \r
1393\r
52302d4d
LG
1394 ## Expand * in build option key\r
1395 #\r
1396 # @param Options Options to be expanded\r
1397 #\r
1398 # @retval options Options expanded\r
6780eef1 1399 # \r
52302d4d
LG
1400 def _ExpandBuildOption(self, Options, ModuleStyle=None):\r
1401 BuildOptions = {}\r
1402 FamilyMatch = False\r
1403 FamilyIsNull = True\r
6780eef1
LG
1404 \r
1405 OverrideList = {}\r
1406 #\r
1407 # Construct a list contain the build options which need override.\r
1408 #\r
1409 for Key in Options:\r
1410 #\r
1411 # Key[0] -- tool family\r
1412 # Key[1] -- TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE\r
1413 #\r
1414 if Key[0] == self.BuildRuleFamily :\r
1415 Target, ToolChain, Arch, CommandType, Attr = Key[1].split('_')\r
1416 if Target == self.BuildTarget or Target == "*":\r
1417 if ToolChain == self.ToolChain or ToolChain == "*":\r
1418 if Arch == self.Arch or Arch == "*":\r
1419 if Options[Key].startswith("="):\r
1420 if OverrideList.get(Key[1]) != None: \r
1421 OverrideList.pop(Key[1])\r
1422 OverrideList[Key[1]] = Options[Key]\r
1423 \r
1424 #\r
1425 # Use the highest priority value. \r
1426 #\r
1427 if (len(OverrideList) >= 2):\r
1428 KeyList = OverrideList.keys()\r
1429 for Index in range(len(KeyList)):\r
1430 NowKey = KeyList[Index]\r
1431 Target1, ToolChain1, Arch1, CommandType1, Attr1 = NowKey.split("_")\r
1432 for Index1 in range(len(KeyList) - Index - 1):\r
1433 NextKey = KeyList[Index1 + Index + 1]\r
1434 #\r
1435 # Compare two Key, if one is included by another, choose the higher priority one\r
1436 # \r
1437 Target2, ToolChain2, Arch2, CommandType2, Attr2 = NextKey.split("_")\r
1438 if Target1 == Target2 or Target1 == "*" or Target2 == "*":\r
1439 if ToolChain1 == ToolChain2 or ToolChain1 == "*" or ToolChain2 == "*":\r
1440 if Arch1 == Arch2 or Arch1 == "*" or Arch2 == "*":\r
1441 if CommandType1 == CommandType2 or CommandType1 == "*" or CommandType2 == "*":\r
1442 if Attr1 == Attr2 or Attr1 == "*" or Attr2 == "*":\r
1443 if self.CalculatePriorityValue(NowKey) > self.CalculatePriorityValue(NextKey):\r
1444 if Options.get((self.BuildRuleFamily, NextKey)) != None: \r
1445 Options.pop((self.BuildRuleFamily, NextKey))\r
1446 else:\r
1447 if Options.get((self.BuildRuleFamily, NowKey)) != None: \r
1448 Options.pop((self.BuildRuleFamily, NowKey))\r
1449 \r
1450 \r
52302d4d
LG
1451 for Key in Options:\r
1452 if ModuleStyle != None and len (Key) > 2:\r
1453 # Check Module style is EDK or EDKII.\r
1454 # Only append build option for the matched style module.\r
1455 if ModuleStyle == EDK_NAME and Key[2] != EDK_NAME:\r
1456 continue\r
1457 elif ModuleStyle == EDKII_NAME and Key[2] != EDKII_NAME:\r
1458 continue\r
1459 Family = Key[0]\r
1460 Target, Tag, Arch, Tool, Attr = Key[1].split("_")\r
1461 # if tool chain family doesn't match, skip it\r
1462 if Tool in self.ToolDefinition and Family != "":\r
1463 FamilyIsNull = False\r
1464 if self.ToolDefinition[Tool].get(TAB_TOD_DEFINES_BUILDRULEFAMILY, "") != "":\r
1465 if Family != self.ToolDefinition[Tool][TAB_TOD_DEFINES_BUILDRULEFAMILY]:\r
1466 continue\r
1467 elif Family != self.ToolDefinition[Tool][TAB_TOD_DEFINES_FAMILY]:\r
1468 continue\r
1469 FamilyMatch = True\r
1470 # expand any wildcard\r
1471 if Target == "*" or Target == self.BuildTarget:\r
1472 if Tag == "*" or Tag == self.ToolChain:\r
1473 if Arch == "*" or Arch == self.Arch:\r
1474 if Tool not in BuildOptions:\r
1475 BuildOptions[Tool] = {}\r
1476 if Attr != "FLAGS" or Attr not in BuildOptions[Tool]:\r
1477 BuildOptions[Tool][Attr] = Options[Key]\r
1478 else:\r
1479 # append options for the same tool\r
1480 BuildOptions[Tool][Attr] += " " + Options[Key]\r
1481 # Build Option Family has been checked, which need't to be checked again for family.\r
1482 if FamilyMatch or FamilyIsNull:\r
1483 return BuildOptions\r
1484 \r
1485 for Key in Options:\r
1486 if ModuleStyle != None and len (Key) > 2:\r
1487 # Check Module style is EDK or EDKII.\r
1488 # Only append build option for the matched style module.\r
1489 if ModuleStyle == EDK_NAME and Key[2] != EDK_NAME:\r
1490 continue\r
1491 elif ModuleStyle == EDKII_NAME and Key[2] != EDKII_NAME:\r
1492 continue\r
1493 Family = Key[0]\r
1494 Target, Tag, Arch, Tool, Attr = Key[1].split("_")\r
1495 # if tool chain family doesn't match, skip it\r
1496 if Tool not in self.ToolDefinition or Family =="":\r
1497 continue\r
1498 # option has been added before\r
1499 if Family != self.ToolDefinition[Tool][TAB_TOD_DEFINES_FAMILY]:\r
1500 continue\r
1501\r
1502 # expand any wildcard\r
1503 if Target == "*" or Target == self.BuildTarget:\r
1504 if Tag == "*" or Tag == self.ToolChain:\r
1505 if Arch == "*" or Arch == self.Arch:\r
1506 if Tool not in BuildOptions:\r
1507 BuildOptions[Tool] = {}\r
1508 if Attr != "FLAGS" or Attr not in BuildOptions[Tool]:\r
1509 BuildOptions[Tool][Attr] = Options[Key]\r
1510 else:\r
1511 # append options for the same tool\r
1512 BuildOptions[Tool][Attr] += " " + Options[Key]\r
1513 return BuildOptions\r
1514\r
1515 ## Append build options in platform to a module\r
1516 #\r
1517 # @param Module The module to which the build options will be appened\r
1518 #\r
1519 # @retval options The options appended with build options in platform\r
1520 #\r
1521 def ApplyBuildOption(self, Module):\r
1522 # Get the different options for the different style module\r
1523 if Module.AutoGenVersion < 0x00010005:\r
1524 PlatformOptions = self.EdkBuildOption\r
1525 else:\r
1526 PlatformOptions = self.EdkIIBuildOption\r
1527 ModuleOptions = self._ExpandBuildOption(Module.BuildOptions)\r
1528 if Module in self.Platform.Modules:\r
1529 PlatformModule = self.Platform.Modules[str(Module)]\r
1530 PlatformModuleOptions = self._ExpandBuildOption(PlatformModule.BuildOptions)\r
1531 else:\r
1532 PlatformModuleOptions = {}\r
1533\r
1534 AllTools = set(ModuleOptions.keys() + PlatformOptions.keys() + PlatformModuleOptions.keys() + self.ToolDefinition.keys())\r
1535 BuildOptions = {}\r
1536 for Tool in AllTools:\r
1537 if Tool not in BuildOptions:\r
1538 BuildOptions[Tool] = {}\r
1539\r
1540 for Options in [self.ToolDefinition, ModuleOptions, PlatformOptions, PlatformModuleOptions]:\r
1541 if Tool not in Options:\r
1542 continue\r
1543 for Attr in Options[Tool]:\r
1544 Value = Options[Tool][Attr]\r
1545 if Attr not in BuildOptions[Tool]:\r
1546 BuildOptions[Tool][Attr] = ""\r
1547 # check if override is indicated\r
1548 if Value.startswith('='):\r
1549 BuildOptions[Tool][Attr] = Value[1:]\r
1550 else:\r
1551 BuildOptions[Tool][Attr] += " " + Value\r
f3decdc3
LG
1552 if Module.AutoGenVersion < 0x00010005 and self.Workspace.UniFlag != None:\r
1553 #\r
1554 # Override UNI flag only for EDK module.\r
1555 #\r
1556 if 'BUILD' not in BuildOptions:\r
1557 BuildOptions['BUILD'] = {}\r
1558 BuildOptions['BUILD']['FLAGS'] = self.Workspace.UniFlag\r
52302d4d
LG
1559 return BuildOptions\r
1560\r
1561 Platform = property(_GetPlatform)\r
1562 Name = property(_GetName)\r
1563 Guid = property(_GetGuid)\r
1564 Version = property(_GetVersion)\r
1565\r
1566 OutputDir = property(_GetOutputDir)\r
1567 BuildDir = property(_GetBuildDir)\r
1568 MakeFileDir = property(_GetMakeFileDir)\r
1569 FdfFile = property(_GetFdfFile)\r
1570\r
1571 PcdTokenNumber = property(_GetPcdTokenNumbers) # (TokenCName, TokenSpaceGuidCName) : GeneratedTokenNumber\r
1572 DynamicPcdList = property(_GetDynamicPcdList) # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]\r
1573 NonDynamicPcdList = property(_GetNonDynamicPcdList) # [(TokenCName1, TokenSpaceGuidCName1), (TokenCName2, TokenSpaceGuidCName2), ...]\r
1574 PackageList = property(_GetPackageList)\r
1575\r
1576 ToolDefinition = property(_GetToolDefinition) # toolcode : tool path\r
1577 ToolDefinitionFile = property(_GetToolDefFile) # toolcode : lib path\r
1578 ToolChainFamily = property(_GetToolChainFamily)\r
1579 BuildRuleFamily = property(_GetBuildRuleFamily)\r
1580 BuildOption = property(_GetBuildOptions) # toolcode : option\r
1581 EdkBuildOption = property(_GetEdkBuildOptions) # edktoolcode : option\r
1582 EdkIIBuildOption = property(_GetEdkIIBuildOptions) # edkiitoolcode : option\r
1583\r
1584 BuildCommand = property(_GetBuildCommand)\r
1585 BuildRule = property(_GetBuildRule)\r
1586 ModuleAutoGenList = property(_GetModuleAutoGenList)\r
1587 LibraryAutoGenList = property(_GetLibraryAutoGenList)\r
1588\r
1589## ModuleAutoGen class\r
1590#\r
1591# This class encapsules the AutoGen behaviors for the build tools. In addition to\r
1592# the generation of AutoGen.h and AutoGen.c, it will generate *.depex file according\r
1593# to the [depex] section in module's inf file.\r
1594#\r
1595class ModuleAutoGen(AutoGen):\r
1596 ## The real constructor of ModuleAutoGen\r
1597 #\r
1598 # This method is not supposed to be called by users of ModuleAutoGen. It's\r
1599 # only used by factory method __new__() to do real initialization work for an\r
1600 # object of ModuleAutoGen\r
1601 #\r
1602 # @param Workspace EdkIIWorkspaceBuild object\r
1603 # @param ModuleFile The path of module file\r
1604 # @param Target Build target (DEBUG, RELEASE)\r
1605 # @param Toolchain Name of tool chain\r
1606 # @param Arch The arch the module supports\r
1607 # @param PlatformFile Platform meta-file\r
1608 #\r
1609 def _Init(self, Workspace, ModuleFile, Target, Toolchain, Arch, PlatformFile):\r
1610 EdkLogger.debug(EdkLogger.DEBUG_9, "AutoGen module [%s] [%s]" % (ModuleFile, Arch))\r
1611 GlobalData.gProcessingFile = "%s [%s, %s, %s]" % (ModuleFile, Arch, Toolchain, Target)\r
1612\r
1613 self.Workspace = Workspace\r
1614 self.WorkspaceDir = Workspace.WorkspaceDir\r
1615\r
1616 self.MetaFile = ModuleFile\r
1617 self.PlatformInfo = PlatformAutoGen(Workspace, PlatformFile, Target, Toolchain, Arch)\r
1618 # check if this module is employed by active platform\r
1619 if not self.PlatformInfo.ValidModule(self.MetaFile):\r
1620 EdkLogger.verbose("Module [%s] for [%s] is not employed by active platform\n" \\r
1621 % (self.MetaFile, Arch))\r
1622 return False\r
1623\r
1624 self.SourceDir = self.MetaFile.SubDir\r
1625 self.SourceOverrideDir = None\r
1626 # use overrided path defined in DSC file\r
1627 if self.MetaFile.Key in GlobalData.gOverrideDir:\r
1628 self.SourceOverrideDir = GlobalData.gOverrideDir[self.MetaFile.Key]\r
1629\r
1630 self.ToolChain = Toolchain\r
1631 self.BuildTarget = Target\r
1632 self.Arch = Arch\r
1633 self.ToolChainFamily = self.PlatformInfo.ToolChainFamily\r
1634 self.BuildRuleFamily = self.PlatformInfo.BuildRuleFamily\r
1635\r
1636 self.IsMakeFileCreated = False\r
1637 self.IsCodeFileCreated = False\r
da92f276
LG
1638 self.IsAsBuiltInfCreated = False\r
1639 self.DepexGenerated = False\r
52302d4d
LG
1640\r
1641 self.BuildDatabase = self.Workspace.BuildDatabase\r
1642\r
1643 self._Module = None\r
1644 self._Name = None\r
1645 self._Guid = None\r
1646 self._Version = None\r
1647 self._ModuleType = None\r
1648 self._ComponentType = None\r
1649 self._PcdIsDriver = None\r
1650 self._AutoGenVersion = None\r
1651 self._LibraryFlag = None\r
1652 self._CustomMakefile = None\r
1653 self._Macro = None\r
1654\r
1655 self._BuildDir = None\r
1656 self._OutputDir = None\r
1657 self._DebugDir = None\r
1658 self._MakeFileDir = None\r
1659\r
1660 self._IncludePathList = None\r
1661 self._AutoGenFileList = None\r
1662 self._UnicodeFileList = None\r
1663 self._SourceFileList = None\r
1664 self._ObjectFileList = None\r
1665 self._BinaryFileList = None\r
1666\r
1667 self._DependentPackageList = None\r
1668 self._DependentLibraryList = None\r
1669 self._LibraryAutoGenList = None\r
1670 self._DerivedPackageList = None\r
1671 self._ModulePcdList = None\r
1672 self._LibraryPcdList = None\r
1673 self._GuidList = None\r
1674 self._ProtocolList = None\r
1675 self._PpiList = None\r
1676 self._DepexList = None\r
1677 self._DepexExpressionList = None\r
1678 self._BuildOption = None\r
1679 self._BuildTargets = None\r
1680 self._IntroBuildTargetList = None\r
1681 self._FinalBuildTargetList = None\r
1682 self._FileTypes = None\r
1683 self._BuildRules = None\r
1684\r
1685 return True\r
1686\r
1687 def __repr__(self):\r
1688 return "%s [%s]" % (self.MetaFile, self.Arch)\r
1689\r
1690 # Macros could be used in build_rule.txt (also Makefile)\r
1691 def _GetMacros(self):\r
1692 if self._Macro == None:\r
1693 self._Macro = sdict()\r
1694 self._Macro["WORKSPACE" ] = self.WorkspaceDir\r
1695 self._Macro["MODULE_NAME" ] = self.Name\r
1696 self._Macro["MODULE_GUID" ] = self.Guid\r
1697 self._Macro["MODULE_VERSION" ] = self.Version\r
1698 self._Macro["MODULE_TYPE" ] = self.ModuleType\r
1699 self._Macro["MODULE_FILE" ] = str(self.MetaFile)\r
1700 self._Macro["MODULE_FILE_BASE_NAME" ] = self.MetaFile.BaseName\r
1701 self._Macro["MODULE_RELATIVE_DIR" ] = self.SourceDir\r
1702 self._Macro["MODULE_DIR" ] = self.SourceDir\r
1703\r
1704 self._Macro["BASE_NAME" ] = self.Name\r
1705\r
1706 self._Macro["ARCH" ] = self.Arch\r
1707 self._Macro["TOOLCHAIN" ] = self.ToolChain\r
1708 self._Macro["TOOLCHAIN_TAG" ] = self.ToolChain\r
1709 self._Macro["TARGET" ] = self.BuildTarget\r
1710\r
1711 self._Macro["BUILD_DIR" ] = self.PlatformInfo.BuildDir\r
1712 self._Macro["BIN_DIR" ] = os.path.join(self.PlatformInfo.BuildDir, self.Arch)\r
1713 self._Macro["LIB_DIR" ] = os.path.join(self.PlatformInfo.BuildDir, self.Arch)\r
1714 self._Macro["MODULE_BUILD_DIR" ] = self.BuildDir\r
1715 self._Macro["OUTPUT_DIR" ] = self.OutputDir\r
1716 self._Macro["DEBUG_DIR" ] = self.DebugDir\r
1717 return self._Macro\r
1718\r
1719 ## Return the module build data object\r
1720 def _GetModule(self):\r
1721 if self._Module == None:\r
1722 self._Module = self.Workspace.BuildDatabase[self.MetaFile, self.Arch]\r
1723 return self._Module\r
1724\r
1725 ## Return the module name\r
1726 def _GetBaseName(self):\r
1727 return self.Module.BaseName\r
1728\r
1729 ## Return the module SourceOverridePath\r
1730 def _GetSourceOverridePath(self):\r
1731 return self.Module.SourceOverridePath\r
1732\r
1733 ## Return the module meta-file GUID\r
1734 def _GetGuid(self):\r
1735 return self.Module.Guid\r
1736\r
1737 ## Return the module version\r
1738 def _GetVersion(self):\r
1739 return self.Module.Version\r
1740\r
1741 ## Return the module type\r
1742 def _GetModuleType(self):\r
1743 return self.Module.ModuleType\r
1744\r
1745 ## Return the component type (for R8.x style of module)\r
1746 def _GetComponentType(self):\r
1747 return self.Module.ComponentType\r
1748\r
1749 ## Return the build type\r
1750 def _GetBuildType(self):\r
1751 return self.Module.BuildType\r
1752\r
1753 ## Return the PCD_IS_DRIVER setting\r
1754 def _GetPcdIsDriver(self):\r
1755 return self.Module.PcdIsDriver\r
1756\r
1757 ## Return the autogen version, i.e. module meta-file version\r
1758 def _GetAutoGenVersion(self):\r
1759 return self.Module.AutoGenVersion\r
1760\r
1761 ## Check if the module is library or not\r
1762 def _IsLibrary(self):\r
1763 if self._LibraryFlag == None:\r
1764 if self.Module.LibraryClass != None and self.Module.LibraryClass != []:\r
1765 self._LibraryFlag = True\r
1766 else:\r
1767 self._LibraryFlag = False\r
1768 return self._LibraryFlag\r
1769\r
1770 ## Return the directory to store intermediate files of the module\r
1771 def _GetBuildDir(self):\r
1772 if self._BuildDir == None:\r
1773 self._BuildDir = path.join(\r
1774 self.PlatformInfo.BuildDir,\r
1775 self.Arch,\r
1776 self.SourceDir,\r
1777 self.MetaFile.BaseName\r
1778 )\r
1779 CreateDirectory(self._BuildDir)\r
1780 return self._BuildDir\r
1781\r
1782 ## Return the directory to store the intermediate object files of the mdoule\r
1783 def _GetOutputDir(self):\r
1784 if self._OutputDir == None:\r
1785 self._OutputDir = path.join(self.BuildDir, "OUTPUT")\r
1786 CreateDirectory(self._OutputDir)\r
1787 return self._OutputDir\r
1788\r
1789 ## Return the directory to store auto-gened source files of the mdoule\r
1790 def _GetDebugDir(self):\r
1791 if self._DebugDir == None:\r
1792 self._DebugDir = path.join(self.BuildDir, "DEBUG")\r
1793 CreateDirectory(self._DebugDir)\r
1794 return self._DebugDir\r
1795\r
1796 ## Return the path of custom file\r
1797 def _GetCustomMakefile(self):\r
1798 if self._CustomMakefile == None:\r
1799 self._CustomMakefile = {}\r
1800 for Type in self.Module.CustomMakefile:\r
1801 if Type in gMakeTypeMap:\r
1802 MakeType = gMakeTypeMap[Type]\r
1803 else:\r
1804 MakeType = 'nmake'\r
1805 if self.SourceOverrideDir != None:\r
1806 File = os.path.join(self.SourceOverrideDir, self.Module.CustomMakefile[Type])\r
1807 if not os.path.exists(File):\r
1808 File = os.path.join(self.SourceDir, self.Module.CustomMakefile[Type])\r
1809 else:\r
1810 File = os.path.join(self.SourceDir, self.Module.CustomMakefile[Type])\r
1811 self._CustomMakefile[MakeType] = File\r
1812 return self._CustomMakefile\r
1813\r
1814 ## Return the directory of the makefile\r
1815 #\r
1816 # @retval string The directory string of module's makefile\r
1817 #\r
1818 def _GetMakeFileDir(self):\r
1819 return self.BuildDir\r
1820\r
1821 ## Return build command string\r
1822 #\r
1823 # @retval string Build command string\r
1824 #\r
1825 def _GetBuildCommand(self):\r
1826 return self.PlatformInfo.BuildCommand\r
1827\r
1828 ## Get object list of all packages the module and its dependent libraries belong to\r
1829 #\r
1830 # @retval list The list of package object\r
1831 #\r
1832 def _GetDerivedPackageList(self):\r
1833 PackageList = []\r
1834 for M in [self.Module] + self.DependentLibraryList:\r
1835 for Package in M.Packages:\r
1836 if Package in PackageList:\r
1837 continue\r
1838 PackageList.append(Package)\r
1839 return PackageList\r
1840\r
1841 ## Merge dependency expression\r
1842 #\r
1843 # @retval list The token list of the dependency expression after parsed\r
1844 #\r
1845 def _GetDepexTokenList(self):\r
1846 if self._DepexList == None:\r
1847 self._DepexList = {}\r
1848 if self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:\r
1849 return self._DepexList\r
1850\r
1851 self._DepexList[self.ModuleType] = []\r
1852\r
1853 for ModuleType in self._DepexList:\r
1854 DepexList = self._DepexList[ModuleType]\r
1855 #\r
1856 # Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion\r
1857 #\r
1858 for M in [self.Module] + self.DependentLibraryList:\r
1859 Inherited = False\r
1860 for D in M.Depex[self.Arch, ModuleType]:\r
1861 if DepexList != []:\r
1862 DepexList.append('AND')\r
1863 DepexList.append('(')\r
1864 DepexList.extend(D)\r
1865 if DepexList[-1] == 'END': # no need of a END at this time\r
1866 DepexList.pop()\r
1867 DepexList.append(')')\r
1868 Inherited = True\r
1869 if Inherited:\r
1870 EdkLogger.verbose("DEPEX[%s] (+%s) = %s" % (self.Name, M.BaseName, DepexList))\r
1871 if 'BEFORE' in DepexList or 'AFTER' in DepexList:\r
1872 break\r
1873 if len(DepexList) > 0:\r
1874 EdkLogger.verbose('')\r
1875 return self._DepexList\r
1876\r
1877 ## Merge dependency expression\r
1878 #\r
1879 # @retval list The token list of the dependency expression after parsed\r
1880 #\r
1881 def _GetDepexExpressionTokenList(self):\r
1882 if self._DepexExpressionList == None:\r
1883 self._DepexExpressionList = {}\r
1884 if self.IsLibrary or TAB_DEPENDENCY_EXPRESSION_FILE in self.FileTypes:\r
1885 return self._DepexExpressionList\r
1886\r
1887 self._DepexExpressionList[self.ModuleType] = ''\r
1888\r
1889 for ModuleType in self._DepexExpressionList:\r
1890 DepexExpressionList = self._DepexExpressionList[ModuleType]\r
1891 #\r
1892 # Append depex from dependent libraries, if not "BEFORE", "AFTER" expresion\r
1893 #\r
1894 for M in [self.Module] + self.DependentLibraryList:\r
1895 Inherited = False\r
1896 for D in M.DepexExpression[self.Arch, ModuleType]:\r
1897 if DepexExpressionList != '':\r
1898 DepexExpressionList += ' AND '\r
1899 DepexExpressionList += '('\r
1900 DepexExpressionList += D\r
1901 DepexExpressionList = DepexExpressionList.rstrip('END').strip()\r
1902 DepexExpressionList += ')'\r
1903 Inherited = True\r
1904 if Inherited:\r
1905 EdkLogger.verbose("DEPEX[%s] (+%s) = %s" % (self.Name, M.BaseName, DepexExpressionList))\r
1906 if 'BEFORE' in DepexExpressionList or 'AFTER' in DepexExpressionList:\r
1907 break\r
1908 if len(DepexExpressionList) > 0:\r
1909 EdkLogger.verbose('')\r
1910 self._DepexExpressionList[ModuleType] = DepexExpressionList\r
1911 return self._DepexExpressionList\r
1912\r
1913 ## Return the list of specification version required for the module\r
1914 #\r
1915 # @retval list The list of specification defined in module file\r
1916 #\r
1917 def _GetSpecification(self):\r
1918 return self.Module.Specification\r
1919\r
1920 ## Tool option for the module build\r
1921 #\r
1922 # @param PlatformInfo The object of PlatformBuildInfo\r
1923 # @retval dict The dict containing valid options\r
1924 #\r
1925 def _GetModuleBuildOption(self):\r
1926 if self._BuildOption == None:\r
1927 self._BuildOption = self.PlatformInfo.ApplyBuildOption(self.Module)\r
1928 return self._BuildOption\r
1929\r
1930 ## Return a list of files which can be built from source\r
1931 #\r
1932 # What kind of files can be built is determined by build rules in\r
1933 # $(WORKSPACE)/Conf/build_rule.txt and toolchain family.\r
1934 #\r
1935 def _GetSourceFileList(self):\r
1936 if self._SourceFileList == None:\r
1937 self._SourceFileList = []\r
1938 for F in self.Module.Sources:\r
1939 # match tool chain\r
08dd311f 1940 if F.TagName not in ("", "*", self.ToolChain):\r
52302d4d
LG
1941 EdkLogger.debug(EdkLogger.DEBUG_9, "The toolchain [%s] for processing file [%s] is found, "\r
1942 "but [%s] is needed" % (F.TagName, str(F), self.ToolChain))\r
1943 continue\r
1944 # match tool chain family\r
08dd311f 1945 if F.ToolChainFamily not in ("", "*", self.ToolChainFamily):\r
52302d4d
LG
1946 EdkLogger.debug(\r
1947 EdkLogger.DEBUG_0,\r
1948 "The file [%s] must be built by tools of [%s], " \\r
1949 "but current toolchain family is [%s]" \\r
1950 % (str(F), F.ToolChainFamily, self.ToolChainFamily))\r
1951 continue\r
1952\r
1953 # add the file path into search path list for file including\r
1954 if F.Dir not in self.IncludePathList and self.AutoGenVersion >= 0x00010005:\r
1955 self.IncludePathList.insert(0, F.Dir)\r
1956 self._SourceFileList.append(F)\r
1957 self._ApplyBuildRule(F, TAB_UNKNOWN_FILE)\r
1958 return self._SourceFileList\r
1959\r
1960 ## Return the list of unicode files\r
1961 def _GetUnicodeFileList(self):\r
1962 if self._UnicodeFileList == None:\r
1963 if TAB_UNICODE_FILE in self.FileTypes:\r
1964 self._UnicodeFileList = self.FileTypes[TAB_UNICODE_FILE]\r
1965 else:\r
1966 self._UnicodeFileList = []\r
1967 return self._UnicodeFileList\r
1968\r
1969 ## Return a list of files which can be built from binary\r
1970 #\r
1971 # "Build" binary files are just to copy them to build directory.\r
1972 #\r
1973 # @retval list The list of files which can be built later\r
1974 #\r
1975 def _GetBinaryFiles(self):\r
1976 if self._BinaryFileList == None:\r
1977 self._BinaryFileList = []\r
1978 for F in self.Module.Binaries:\r
1979 if F.Target not in ['COMMON', '*'] and F.Target != self.BuildTarget:\r
1980 continue\r
1981 self._BinaryFileList.append(F)\r
1982 self._ApplyBuildRule(F, F.Type)\r
1983 return self._BinaryFileList\r
1984\r
1985 def _GetBuildRules(self):\r
1986 if self._BuildRules == None:\r
1987 BuildRules = {}\r
1988 BuildRuleDatabase = self.PlatformInfo.BuildRule\r
1989 for Type in BuildRuleDatabase.FileTypeList:\r
1990 #first try getting build rule by BuildRuleFamily\r
1991 RuleObject = BuildRuleDatabase[Type, self.BuildType, self.Arch, self.BuildRuleFamily]\r
1992 if not RuleObject:\r
1993 # build type is always module type, but ...\r
1994 if self.ModuleType != self.BuildType:\r
1995 RuleObject = BuildRuleDatabase[Type, self.ModuleType, self.Arch, self.BuildRuleFamily]\r
1996 #second try getting build rule by ToolChainFamily\r
1997 if not RuleObject:\r
1998 RuleObject = BuildRuleDatabase[Type, self.BuildType, self.Arch, self.ToolChainFamily]\r
1999 if not RuleObject:\r
2000 # build type is always module type, but ...\r
2001 if self.ModuleType != self.BuildType:\r
2002 RuleObject = BuildRuleDatabase[Type, self.ModuleType, self.Arch, self.ToolChainFamily]\r
2003 if not RuleObject:\r
2004 continue\r
2005 RuleObject = RuleObject.Instantiate(self.Macros)\r
2006 BuildRules[Type] = RuleObject\r
2007 for Ext in RuleObject.SourceFileExtList:\r
2008 BuildRules[Ext] = RuleObject\r
2009 self._BuildRules = BuildRules\r
2010 return self._BuildRules\r
2011\r
2012 def _ApplyBuildRule(self, File, FileType):\r
2013 if self._BuildTargets == None:\r
2014 self._IntroBuildTargetList = set()\r
2015 self._FinalBuildTargetList = set()\r
2016 self._BuildTargets = {}\r
2017 self._FileTypes = {}\r
2018\r
2019 LastTarget = None\r
2020 RuleChain = []\r
2021 SourceList = [File]\r
2022 Index = 0\r
2023 while Index < len(SourceList):\r
2024 Source = SourceList[Index]\r
2025 Index = Index + 1\r
2026\r
2027 if Source != File:\r
2028 CreateDirectory(Source.Dir)\r
2029\r
2030 if File.IsBinary and File == Source and self._BinaryFileList != None and File in self._BinaryFileList:\r
da92f276
LG
2031 # Skip all files that are not binary libraries\r
2032 if not self.IsLibrary:\r
2033 continue\r
52302d4d
LG
2034 RuleObject = self.BuildRules[TAB_DEFAULT_BINARY_FILE]\r
2035 elif FileType in self.BuildRules:\r
2036 RuleObject = self.BuildRules[FileType]\r
2037 elif Source.Ext in self.BuildRules:\r
2038 RuleObject = self.BuildRules[Source.Ext]\r
2039 else:\r
2040 # stop at no more rules\r
2041 if LastTarget:\r
2042 self._FinalBuildTargetList.add(LastTarget)\r
2043 break\r
2044\r
2045 FileType = RuleObject.SourceFileType\r
2046 if FileType not in self._FileTypes:\r
2047 self._FileTypes[FileType] = set()\r
2048 self._FileTypes[FileType].add(Source)\r
2049\r
2050 # stop at STATIC_LIBRARY for library\r
2051 if self.IsLibrary and FileType == TAB_STATIC_LIBRARY:\r
2052 if LastTarget:\r
2053 self._FinalBuildTargetList.add(LastTarget)\r
2054 break\r
2055\r
2056 Target = RuleObject.Apply(Source)\r
2057 if not Target:\r
2058 if LastTarget:\r
2059 self._FinalBuildTargetList.add(LastTarget)\r
2060 break\r
2061 elif not Target.Outputs:\r
2062 # Only do build for target with outputs\r
2063 self._FinalBuildTargetList.add(Target)\r
2064\r
2065 if FileType not in self._BuildTargets:\r
2066 self._BuildTargets[FileType] = set()\r
2067 self._BuildTargets[FileType].add(Target)\r
2068\r
2069 if not Source.IsBinary and Source == File:\r
2070 self._IntroBuildTargetList.add(Target)\r
2071\r
2072 # to avoid cyclic rule\r
2073 if FileType in RuleChain:\r
2074 break\r
2075\r
2076 RuleChain.append(FileType)\r
2077 SourceList.extend(Target.Outputs)\r
2078 LastTarget = Target\r
2079 FileType = TAB_UNKNOWN_FILE\r
2080\r
2081 def _GetTargets(self):\r
2082 if self._BuildTargets == None:\r
2083 self._IntroBuildTargetList = set()\r
2084 self._FinalBuildTargetList = set()\r
2085 self._BuildTargets = {}\r
2086 self._FileTypes = {}\r
2087\r
2088 #TRICK: call _GetSourceFileList to apply build rule for binary files\r
2089 if self.SourceFileList:\r
2090 pass\r
2091\r
2092 #TRICK: call _GetBinaryFileList to apply build rule for binary files\r
2093 if self.BinaryFileList:\r
2094 pass\r
2095\r
2096 return self._BuildTargets\r
2097\r
2098 def _GetIntroTargetList(self):\r
2099 self._GetTargets()\r
2100 return self._IntroBuildTargetList\r
2101\r
2102 def _GetFinalTargetList(self):\r
2103 self._GetTargets()\r
2104 return self._FinalBuildTargetList\r
2105\r
2106 def _GetFileTypes(self):\r
2107 self._GetTargets()\r
2108 return self._FileTypes\r
2109\r
2110 ## Get the list of package object the module depends on\r
2111 #\r
2112 # @retval list The package object list\r
2113 #\r
2114 def _GetDependentPackageList(self):\r
2115 return self.Module.Packages\r
2116\r
2117 ## Return the list of auto-generated code file\r
2118 #\r
2119 # @retval list The list of auto-generated file\r
2120 #\r
2121 def _GetAutoGenFileList(self):\r
2122 UniStringAutoGenC = True\r
2123 UniStringBinBuffer = None\r
2124 if self.BuildType == 'UEFI_HII':\r
2125 UniStringBinBuffer = StringIO()\r
2126 UniStringAutoGenC = False\r
2127 if self._AutoGenFileList == None:\r
2128 self._AutoGenFileList = {}\r
2129 AutoGenC = TemplateString()\r
2130 AutoGenH = TemplateString()\r
2131 StringH = TemplateString()\r
2132 GenC.CreateCode(self, AutoGenC, AutoGenH, StringH, UniStringAutoGenC, UniStringBinBuffer)\r
2133 if str(AutoGenC) != "" and TAB_C_CODE_FILE in self.FileTypes:\r
2134 AutoFile = PathClass(gAutoGenCodeFileName, self.DebugDir)\r
2135 self._AutoGenFileList[AutoFile] = str(AutoGenC)\r
2136 self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)\r
2137 if str(AutoGenH) != "":\r
2138 AutoFile = PathClass(gAutoGenHeaderFileName, self.DebugDir)\r
2139 self._AutoGenFileList[AutoFile] = str(AutoGenH)\r
2140 self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)\r
2141 if str(StringH) != "":\r
2142 AutoFile = PathClass(gAutoGenStringFileName % {"module_name":self.Name}, self.DebugDir)\r
2143 self._AutoGenFileList[AutoFile] = str(StringH)\r
2144 self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)\r
2145 if UniStringBinBuffer != None and UniStringBinBuffer.getvalue() != "":\r
2146 AutoFile = PathClass(gAutoGenStringFormFileName % {"module_name":self.Name}, self.OutputDir)\r
2147 self._AutoGenFileList[AutoFile] = UniStringBinBuffer.getvalue()\r
2148 AutoFile.IsBinary = True\r
2149 self._ApplyBuildRule(AutoFile, TAB_UNKNOWN_FILE)\r
2150 if UniStringBinBuffer != None:\r
2151 UniStringBinBuffer.close()\r
2152 return self._AutoGenFileList\r
2153\r
2154 ## Return the list of library modules explicitly or implicityly used by this module\r
2155 def _GetLibraryList(self):\r
2156 if self._DependentLibraryList == None:\r
2157 # only merge library classes and PCD for non-library module\r
2158 if self.IsLibrary:\r
2159 self._DependentLibraryList = []\r
2160 else:\r
2161 if self.AutoGenVersion < 0x00010005:\r
2162 self._DependentLibraryList = self.PlatformInfo.ResolveLibraryReference(self.Module)\r
2163 else:\r
2164 self._DependentLibraryList = self.PlatformInfo.ApplyLibraryInstance(self.Module)\r
2165 return self._DependentLibraryList\r
2166\r
2167 ## Get the list of PCDs from current module\r
2168 #\r
2169 # @retval list The list of PCD\r
2170 #\r
2171 def _GetModulePcdList(self):\r
2172 if self._ModulePcdList == None:\r
2173 # apply PCD settings from platform\r
2174 self._ModulePcdList = self.PlatformInfo.ApplyPcdSetting(self.Module, self.Module.Pcds)\r
2175 return self._ModulePcdList\r
2176\r
2177 ## Get the list of PCDs from dependent libraries\r
2178 #\r
2179 # @retval list The list of PCD\r
2180 #\r
2181 def _GetLibraryPcdList(self):\r
2182 if self._LibraryPcdList == None:\r
2183 Pcds = {}\r
2184 if not self.IsLibrary:\r
2185 # get PCDs from dependent libraries\r
2186 for Library in self.DependentLibraryList:\r
2187 for Key in Library.Pcds:\r
2188 # skip duplicated PCDs\r
2189 if Key in self.Module.Pcds or Key in Pcds:\r
2190 continue\r
2191 Pcds[Key] = copy.copy(Library.Pcds[Key])\r
2192 # apply PCD settings from platform\r
2193 self._LibraryPcdList = self.PlatformInfo.ApplyPcdSetting(self.Module, Pcds)\r
2194 else:\r
2195 self._LibraryPcdList = []\r
2196 return self._LibraryPcdList\r
2197\r
2198 ## Get the GUID value mapping\r
2199 #\r
2200 # @retval dict The mapping between GUID cname and its value\r
2201 #\r
2202 def _GetGuidList(self):\r
2203 if self._GuidList == None:\r
2204 self._GuidList = self.Module.Guids\r
2205 for Library in self.DependentLibraryList:\r
2206 self._GuidList.update(Library.Guids)\r
2207 return self._GuidList\r
2208\r
2209 ## Get the protocol value mapping\r
2210 #\r
2211 # @retval dict The mapping between protocol cname and its value\r
2212 #\r
2213 def _GetProtocolList(self):\r
2214 if self._ProtocolList == None:\r
2215 self._ProtocolList = self.Module.Protocols\r
2216 for Library in self.DependentLibraryList:\r
2217 self._ProtocolList.update(Library.Protocols)\r
2218 return self._ProtocolList\r
2219\r
2220 ## Get the PPI value mapping\r
2221 #\r
2222 # @retval dict The mapping between PPI cname and its value\r
2223 #\r
2224 def _GetPpiList(self):\r
2225 if self._PpiList == None:\r
2226 self._PpiList = self.Module.Ppis\r
2227 for Library in self.DependentLibraryList:\r
2228 self._PpiList.update(Library.Ppis)\r
2229 return self._PpiList\r
2230\r
2231 ## Get the list of include search path\r
2232 #\r
2233 # @retval list The list path\r
2234 #\r
2235 def _GetIncludePathList(self):\r
2236 if self._IncludePathList == None:\r
2237 self._IncludePathList = []\r
2238 if self.AutoGenVersion < 0x00010005:\r
2239 for Inc in self.Module.Includes:\r
2240 if Inc not in self._IncludePathList:\r
2241 self._IncludePathList.append(Inc)\r
2242 # for r8 modules\r
2243 Inc = path.join(Inc, self.Arch.capitalize())\r
2244 if os.path.exists(Inc) and Inc not in self._IncludePathList:\r
2245 self._IncludePathList.append(Inc)\r
2246 # r8 module needs to put DEBUG_DIR at the end of search path and not to use SOURCE_DIR all the time\r
2247 self._IncludePathList.append(self.DebugDir)\r
2248 else:\r
2249 self._IncludePathList.append(self.MetaFile.Dir)\r
2250 self._IncludePathList.append(self.DebugDir)\r
2251\r
2252 for Package in self.Module.Packages:\r
2253 PackageDir = path.join(self.WorkspaceDir, Package.MetaFile.Dir)\r
2254 if PackageDir not in self._IncludePathList:\r
2255 self._IncludePathList.append(PackageDir)\r
2256 for Inc in Package.Includes:\r
2257 if Inc not in self._IncludePathList:\r
2258 self._IncludePathList.append(str(Inc))\r
2259 return self._IncludePathList\r
2260\r
da92f276
LG
2261 ## Create AsBuilt INF file the module\r
2262 #\r
2263 def CreateAsBuiltInf(self):\r
2264 if self.IsAsBuiltInfCreated:\r
2265 return\r
2266 \r
2267 # Skip the following code for EDK I inf\r
2268 if self.AutoGenVersion < 0x00010005:\r
2269 return\r
2270 \r
2271 # Skip the following code for libraries\r
2272 if self.IsLibrary:\r
2273 return\r
2274 \r
2275 # Skip the following code for modules with no source files\r
2276 if self.SourceFileList == None or self.SourceFileList == []:\r
2277 return\r
2278\r
2279 # Skip the following code for modules without any binary files\r
2280 if self.BinaryFileList <> None and self.BinaryFileList <> []:\r
2281 return\r
2282 \r
2283 ### TODO: How to handles mixed source and binary modules\r
2284\r
2285 # Find all DynamicEx PCDs used by this module and dependent libraries\r
2286 # Also find all packages that the DynamicEx PCDs depend on\r
2287 Pcds = []\r
2288 Packages = [] \r
2289 for Pcd in self.ModulePcdList + self.LibraryPcdList:\r
2290 if Pcd.Type in GenC.gDynamicExPcd:\r
2291 if Pcd not in Pcds:\r
2292 Pcds += [Pcd]\r
2293 for Package in self.DerivedPackageList:\r
2294 if Package not in Packages:\r
2295 if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'DynamicEx') in Package.Pcds:\r
2296 Packages += [Package]\r
2297 elif (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, 'Dynamic') in Package.Pcds:\r
2298 Packages += [Package]\r
2299\r
2300 ModuleType = self.ModuleType\r
2301 if ModuleType == 'UEFI_DRIVER' and self.DepexGenerated:\r
2302 ModuleType = 'DXE_DRIVER'\r
2303\r
2304 AsBuiltInfDict = {\r
2305 'module_name' : self.Name,\r
2306 'module_guid' : self.Guid,\r
2307 'module_module_type' : ModuleType,\r
2308 'module_version_string' : self.Version,\r
2309 'module_uefi_specification_version' : [],\r
2310 'module_pi_specification_version' : [],\r
2311 'module_arch' : self.Arch,\r
2312 'package_item' : ['%s' % (Package.MetaFile.File.replace('\\','/')) for Package in Packages],\r
2313 'binary_item' : [],\r
2314 'pcd_item' : [],\r
2315 'flags_item' : []\r
2316 }\r
2317\r
2318 if 'UEFI_SPECIFICATION_VERSION' in self.Specification:\r
2319 AsBuiltInfDict['module_uefi_specification_version'] += [self.Specification['UEFI_SPECIFICATION_VERSION']]\r
2320 if 'PI_SPECIFICATION_VERSION' in self.Specification:\r
2321 AsBuiltInfDict['module_pi_specification_version'] += [self.Specification['PI_SPECIFICATION_VERSION']]\r
2322\r
2323 OutputDir = self.OutputDir.replace('\\','/').strip('/')\r
2324 if self.ModuleType in ['BASE', 'USER_DEFINED']:\r
2325 for Item in self.CodaTargetList:\r
2326 File = Item.Target.Path.replace('\\','/').strip('/').replace(OutputDir,'').strip('/')\r
2327 if Item.Target.Ext.lower() == '.aml': \r
2328 AsBuiltInfDict['binary_item'] += ['ASL|' + File]\r
2329 elif Item.Target.Ext.lower() == '.acpi': \r
2330 AsBuiltInfDict['binary_item'] += ['ACPI|' + File]\r
2331 else:\r
2332 AsBuiltInfDict['binary_item'] += ['BIN|' + File]\r
2333 else:\r
2334 for Item in self.CodaTargetList:\r
2335 File = Item.Target.Path.replace('\\','/').strip('/').replace(OutputDir,'').strip('/')\r
2336 if Item.Target.Ext.lower() == '.efi': \r
2337 AsBuiltInfDict['binary_item'] += ['PE32|' + self.Name + '.efi']\r
2338 else:\r
2339 AsBuiltInfDict['binary_item'] += ['BIN|' + File]\r
2340 if self.DepexGenerated:\r
2341 if self.ModuleType in ['PEIM']:\r
2342 AsBuiltInfDict['binary_item'] += ['PEI_DEPEX|' + self.Name + '.depex']\r
2343 if self.ModuleType in ['DXE_DRIVER','DXE_RUNTIME_DRIVER','DXE_SAL_DRIVER','UEFI_DRIVER']:\r
2344 AsBuiltInfDict['binary_item'] += ['DXE_DEPEX|' + self.Name + '.depex']\r
2345 if self.ModuleType in ['DXE_SMM_DRIVER']:\r
2346 AsBuiltInfDict['binary_item'] += ['SMM_DEPEX|' + self.Name + '.depex']\r
2347\r
2348 for Pcd in Pcds:\r
2349 AsBuiltInfDict['pcd_item'] += [Pcd.TokenSpaceGuidCName + '.' + Pcd.TokenCName]\r
2350 \r
2351 for Item in self.BuildOption:\r
2352 if 'FLAGS' in self.BuildOption[Item]:\r
2353 AsBuiltInfDict['flags_item'] += ['%s:%s_%s_%s_%s_FLAGS = %s' % (self.ToolChainFamily, self.BuildTarget, self.ToolChain, self.Arch, Item, self.BuildOption[Item]['FLAGS'].strip())]\r
2354 \r
2355 AsBuiltInf = TemplateString()\r
2356 AsBuiltInf.Append(gAsBuiltInfHeaderString.Replace(AsBuiltInfDict))\r
2357 \r
2358 SaveFileOnChange(os.path.join(self.OutputDir, self.Name + '.inf'), str(AsBuiltInf), False)\r
2359 \r
2360 self.IsAsBuiltInfCreated = True\r
2361 \r
52302d4d
LG
2362 ## Create makefile for the module and its dependent libraries\r
2363 #\r
2364 # @param CreateLibraryMakeFile Flag indicating if or not the makefiles of\r
2365 # dependent libraries will be created\r
2366 #\r
2367 def CreateMakeFile(self, CreateLibraryMakeFile=True):\r
2368 if self.IsMakeFileCreated:\r
2369 return\r
2370\r
2371 if not self.IsLibrary and CreateLibraryMakeFile:\r
2372 for LibraryAutoGen in self.LibraryAutoGenList:\r
2373 LibraryAutoGen.CreateMakeFile()\r
2374\r
2375 if len(self.CustomMakefile) == 0:\r
2376 Makefile = GenMake.ModuleMakefile(self)\r
2377 else:\r
2378 Makefile = GenMake.CustomMakefile(self)\r
2379 if Makefile.Generate():\r
2380 EdkLogger.debug(EdkLogger.DEBUG_9, "Generated makefile for module %s [%s]" %\r
2381 (self.Name, self.Arch))\r
2382 else:\r
2383 EdkLogger.debug(EdkLogger.DEBUG_9, "Skipped the generation of makefile for module %s [%s]" %\r
2384 (self.Name, self.Arch))\r
2385\r
2386 self.IsMakeFileCreated = True\r
2387\r
2388 ## Create autogen code for the module and its dependent libraries\r
2389 #\r
2390 # @param CreateLibraryCodeFile Flag indicating if or not the code of\r
2391 # dependent libraries will be created\r
2392 #\r
2393 def CreateCodeFile(self, CreateLibraryCodeFile=True):\r
2394 if self.IsCodeFileCreated:\r
2395 return\r
2396\r
2397 if not self.IsLibrary and CreateLibraryCodeFile:\r
2398 for LibraryAutoGen in self.LibraryAutoGenList:\r
2399 LibraryAutoGen.CreateCodeFile()\r
2400\r
2401 AutoGenList = []\r
2402 IgoredAutoGenList = []\r
2403\r
2404 for File in self.AutoGenFileList:\r
2405 if GenC.Generate(File.Path, self.AutoGenFileList[File], File.IsBinary):\r
2406 #Ignore R8 AutoGen.c\r
2407 if self.AutoGenVersion < 0x00010005 and File.Name == 'AutoGen.c':\r
2408 continue\r
2409\r
2410 AutoGenList.append(str(File))\r
2411 else:\r
2412 IgoredAutoGenList.append(str(File))\r
2413\r
2414 # Skip the following code for EDK I inf\r
2415 if self.AutoGenVersion < 0x00010005:\r
2416 return\r
2417\r
2418 for ModuleType in self.DepexList:\r
40d841f6
LG
2419 # Ignore empty [depex] section or [depex] section for "USER_DEFINED" module\r
2420 if len(self.DepexList[ModuleType]) == 0 or ModuleType == "USER_DEFINED":\r
52302d4d 2421 continue\r
40d841f6 2422\r
52302d4d
LG
2423 Dpx = GenDepex.DependencyExpression(self.DepexList[ModuleType], ModuleType, True)\r
2424 DpxFile = gAutoGenDepexFileName % {"module_name" : self.Name}\r
2425\r
da92f276
LG
2426 if len(Dpx.PostfixNotation) <> 0:\r
2427 self.DepexGenerated = True\r
2428\r
52302d4d
LG
2429 if Dpx.Generate(path.join(self.OutputDir, DpxFile)):\r
2430 AutoGenList.append(str(DpxFile))\r
2431 else:\r
2432 IgoredAutoGenList.append(str(DpxFile))\r
2433\r
2434 if IgoredAutoGenList == []:\r
2435 EdkLogger.debug(EdkLogger.DEBUG_9, "Generated [%s] files for module %s [%s]" %\r
2436 (" ".join(AutoGenList), self.Name, self.Arch))\r
2437 elif AutoGenList == []:\r
2438 EdkLogger.debug(EdkLogger.DEBUG_9, "Skipped the generation of [%s] files for module %s [%s]" %\r
2439 (" ".join(IgoredAutoGenList), self.Name, self.Arch))\r
2440 else:\r
2441 EdkLogger.debug(EdkLogger.DEBUG_9, "Generated [%s] (skipped %s) files for module %s [%s]" %\r
2442 (" ".join(AutoGenList), " ".join(IgoredAutoGenList), self.Name, self.Arch))\r
2443\r
2444 self.IsCodeFileCreated = True\r
2445 return AutoGenList\r
2446\r
2447 ## Summarize the ModuleAutoGen objects of all libraries used by this module\r
2448 def _GetLibraryAutoGenList(self):\r
2449 if self._LibraryAutoGenList == None:\r
2450 self._LibraryAutoGenList = []\r
2451 for Library in self.DependentLibraryList:\r
2452 La = ModuleAutoGen(\r
2453 self.Workspace,\r
2454 Library.MetaFile,\r
2455 self.BuildTarget,\r
2456 self.ToolChain,\r
2457 self.Arch,\r
2458 self.PlatformInfo.MetaFile\r
2459 )\r
2460 if La not in self._LibraryAutoGenList:\r
2461 self._LibraryAutoGenList.append(La)\r
2462 for Lib in La.CodaTargetList:\r
2463 self._ApplyBuildRule(Lib.Target, TAB_UNKNOWN_FILE)\r
2464 return self._LibraryAutoGenList\r
2465\r
52302d4d
LG
2466 Module = property(_GetModule)\r
2467 Name = property(_GetBaseName)\r
2468 Guid = property(_GetGuid)\r
2469 Version = property(_GetVersion)\r
2470 ModuleType = property(_GetModuleType)\r
2471 ComponentType = property(_GetComponentType)\r
2472 BuildType = property(_GetBuildType)\r
2473 PcdIsDriver = property(_GetPcdIsDriver)\r
2474 AutoGenVersion = property(_GetAutoGenVersion)\r
2475 Macros = property(_GetMacros)\r
2476 Specification = property(_GetSpecification)\r
2477\r
2478 IsLibrary = property(_IsLibrary)\r
2479\r
2480 BuildDir = property(_GetBuildDir)\r
2481 OutputDir = property(_GetOutputDir)\r
2482 DebugDir = property(_GetDebugDir)\r
2483 MakeFileDir = property(_GetMakeFileDir)\r
2484 CustomMakefile = property(_GetCustomMakefile)\r
2485\r
2486 IncludePathList = property(_GetIncludePathList)\r
2487 AutoGenFileList = property(_GetAutoGenFileList)\r
2488 UnicodeFileList = property(_GetUnicodeFileList)\r
2489 SourceFileList = property(_GetSourceFileList)\r
2490 BinaryFileList = property(_GetBinaryFiles) # FileType : [File List]\r
2491 Targets = property(_GetTargets)\r
2492 IntroTargetList = property(_GetIntroTargetList)\r
2493 CodaTargetList = property(_GetFinalTargetList)\r
2494 FileTypes = property(_GetFileTypes)\r
2495 BuildRules = property(_GetBuildRules)\r
2496\r
2497 DependentPackageList = property(_GetDependentPackageList)\r
2498 DependentLibraryList = property(_GetLibraryList)\r
2499 LibraryAutoGenList = property(_GetLibraryAutoGenList)\r
2500 DerivedPackageList = property(_GetDerivedPackageList)\r
2501\r
2502 ModulePcdList = property(_GetModulePcdList)\r
2503 LibraryPcdList = property(_GetLibraryPcdList)\r
2504 GuidList = property(_GetGuidList)\r
2505 ProtocolList = property(_GetProtocolList)\r
2506 PpiList = property(_GetPpiList)\r
2507 DepexList = property(_GetDepexTokenList)\r
2508 DepexExpressionList = property(_GetDepexExpressionTokenList)\r
2509 BuildOption = property(_GetModuleBuildOption)\r
2510 BuildCommand = property(_GetBuildCommand)\r
2511\r
2512# This acts like the main() function for the script, unless it is 'import'ed into another script.\r
2513if __name__ == '__main__':\r
2514 pass\r
2515\r