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