Check In tool source code based on Build tool project revision r1655.
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / FfsInfStatement.py
CommitLineData
30fdf114
LG
1## @file\r
2# process FFS generation from INF statement\r
3#\r
4# Copyright (c) 2007, Intel Corporation\r
5#\r
6# All rights reserved. This program and the accompanying materials\r
7# are licensed and made available under the terms and conditions of the BSD License\r
8# which accompanies this distribution. The full text of the license may be found at\r
9# http://opensource.org/licenses/bsd-license.php\r
10#\r
11# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13#\r
14\r
15##\r
16# Import Modules\r
17#\r
18import Rule\r
19import os\r
20import shutil\r
21from GenFdsGlobalVariable import GenFdsGlobalVariable\r
22import Ffs\r
23import subprocess\r
24import sys\r
25import Section\r
26import RuleSimpleFile\r
27import RuleComplexFile\r
28from CommonDataClass.FdfClass import FfsInfStatementClassObject\r
29from Common.String import *\r
30from Common.Misc import PathClass\r
31from Common.Misc import GuidStructureByteArrayToGuidString\r
32from Common import EdkLogger\r
33from Common.BuildToolError import *\r
34\r
35## generate FFS from INF\r
36#\r
37#\r
38class FfsInfStatement(FfsInfStatementClassObject):\r
39 ## The constructor\r
40 #\r
41 # @param self The object pointer\r
42 #\r
43 def __init__(self):\r
44 FfsInfStatementClassObject.__init__(self)\r
45 self.TargetOverrideList = []\r
46 self.ShadowFromInfFile = None\r
47 self.KeepRelocFromRule = None\r
48 self.InDsc = True\r
49 self.OptRomDefs = {}\r
50 \r
51 ## __InfParse() method\r
52 #\r
53 # Parse inf file to get module information\r
54 #\r
55 # @param self The object pointer\r
56 # @param Dict dictionary contains macro and value pair\r
57 #\r
58 def __InfParse__(self, Dict = {}):\r
59\r
60 GenFdsGlobalVariable.VerboseLogger( " Begine parsing INf file : %s" %self.InfFileName)\r
61\r
62 self.InfFileName = self.InfFileName.replace('$(WORKSPACE)', '')\r
63 if self.InfFileName[0] == '\\' or self.InfFileName[0] == '/' :\r
64 self.InfFileName = self.InfFileName[1:]\r
65\r
66 if self.InfFileName.find('$') == -1:\r
67 InfPath = NormPath(self.InfFileName)\r
68 if not os.path.exists(InfPath):\r
69 InfPath = GenFdsGlobalVariable.ReplaceWorkspaceMacro(InfPath)\r
70 if not os.path.exists(InfPath):\r
71 EdkLogger.error("GenFds", GENFDS_ERROR, "Non-existant Module %s !" % (self.InfFileName))\r
72\r
73 self.CurrentArch = self.GetCurrentArch()\r
74 #\r
75 # Get the InfClass object\r
76 #\r
77\r
78 PathClassObj = PathClass(self.InfFileName, GenFdsGlobalVariable.WorkSpaceDir)\r
79 ErrorCode, ErrorInfo = PathClassObj.Validate()\r
80 if ErrorCode != 0:\r
81 EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)\r
82 \r
83 if self.CurrentArch != None:\r
84\r
85 Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, self.CurrentArch]\r
86 #\r
87 # Set Ffs BaseName, MdouleGuid, ModuleType, Version, OutputPath\r
88 #\r
89 self.BaseName = Inf.BaseName\r
90 self.ModuleGuid = Inf.Guid\r
91 self.ModuleType = Inf.ModuleType\r
92 if Inf.AutoGenVersion < 0x00010005:\r
93 self.ModuleType = Inf.ComponentType\r
94 self.VersionString = Inf.Version\r
95 self.BinFileList = Inf.Binaries\r
96 self.SourceFileList = Inf.Sources\r
97 if self.KeepReloc == None and Inf.Shadow:\r
98 self.ShadowFromInfFile = Inf.Shadow\r
99\r
100 else:\r
101 Inf = GenFdsGlobalVariable.WorkSpace.BuildObject[PathClassObj, 'COMMON']\r
102 self.BaseName = Inf.BaseName\r
103 self.ModuleGuid = Inf.Guid\r
104 self.ModuleType = Inf.ModuleType\r
105 self.VersionString = Inf.Version\r
106 self.BinFileList = Inf.Binaries\r
107 self.SourceFileList = Inf.Sources\r
108 if self.BinFileList == []:\r
109 EdkLogger.error("GenFds", GENFDS_ERROR,\r
110 "INF %s specified in FDF could not be found in build ARCH %s!" \\r
111 % (self.InfFileName, GenFdsGlobalVariable.ArchList))\r
112\r
113 if len(self.SourceFileList) != 0 and not self.InDsc:\r
114 EdkLogger.warn("GenFds", GENFDS_ERROR, "Module %s NOT found in DSC file; Is it really a binary module?" % (self.InfFileName))\r
115\r
116 if Inf._Defs != None and len(Inf._Defs) > 0:\r
117 self.OptRomDefs.update(Inf._Defs)\r
118 \r
119 GenFdsGlobalVariable.VerboseLogger( "BaseName : %s" %self.BaseName)\r
120 GenFdsGlobalVariable.VerboseLogger("ModuleGuid : %s" %self.ModuleGuid)\r
121 GenFdsGlobalVariable.VerboseLogger("ModuleType : %s" %self.ModuleType)\r
122 GenFdsGlobalVariable.VerboseLogger("VersionString : %s" %self.VersionString)\r
123 GenFdsGlobalVariable.VerboseLogger("InfFileName :%s" %self.InfFileName)\r
124\r
125 #\r
126 # Set OutputPath = ${WorkSpace}\Build\Fv\Ffs\${ModuleGuid}+ ${MdouleName}\\r
127 #\r
128\r
129 self.OutputPath = os.path.join(GenFdsGlobalVariable.FfsDir, \\r
130 self.ModuleGuid + self.BaseName)\r
131 if not os.path.exists(self.OutputPath) :\r
132 os.makedirs(self.OutputPath)\r
133\r
134 self.EfiOutputPath = self.__GetEFIOutPutPath__()\r
135 GenFdsGlobalVariable.VerboseLogger( "ModuelEFIPath: " + self.EfiOutputPath)\r
136\r
137 ## GenFfs() method\r
138 #\r
139 # Generate FFS\r
140 #\r
141 # @param self The object pointer\r
142 # @param Dict dictionary contains macro and value pair\r
143 # @retval string Generated FFS file name\r
144 #\r
145 def GenFfs(self, Dict = {}):\r
146 #\r
147 # Parse Inf file get Module related information\r
148 #\r
149\r
150 self.__InfParse__(Dict)\r
151 #\r
152 # Get the rule of how to generate Ffs file\r
153 #\r
154 Rule = self.__GetRule__()\r
155 GenFdsGlobalVariable.VerboseLogger( "Packing binaries from inf file : %s" %self.InfFileName)\r
156 #FileType = Ffs.Ffs.ModuleTypeToFileType[Rule.ModuleType]\r
157 #\r
158 # For the rule only has simpleFile\r
159 #\r
160 if isinstance (Rule, RuleSimpleFile.RuleSimpleFile) :\r
161 SectionOutputList = self.__GenSimpleFileSection__(Rule)\r
162 FfsOutput = self.__GenSimpleFileFfs__(Rule, SectionOutputList)\r
163 return FfsOutput\r
164 #\r
165 # For Rule has ComplexFile\r
166 #\r
167 elif isinstance(Rule, RuleComplexFile.RuleComplexFile):\r
168 InputSectList, InputSectAlignments = self.__GenComplexFileSection__(Rule)\r
169 FfsOutput = self.__GenComplexFileFfs__(Rule, InputSectList, InputSectAlignments)\r
170\r
171 return FfsOutput\r
172\r
173 ## __ExtendMacro__() method\r
174 #\r
175 # Replace macro with its value\r
176 #\r
177 # @param self The object pointer\r
178 # @param String The string to be replaced\r
179 # @retval string Macro replaced string\r
180 #\r
181 def __ExtendMacro__ (self, String):\r
182 MacroDict = {\r
183 '$(INF_OUTPUT)' : self.EfiOutputPath,\r
184 '$(MODULE_NAME)' : self.BaseName,\r
185 '$(BUILD_NUMBER)': self.BuildNum,\r
186 '$(INF_VERSION)' : self.VersionString,\r
187 '$(NAMED_GUID)' : self.ModuleGuid\r
188 }\r
189 String = GenFdsGlobalVariable.MacroExtend(String, MacroDict)\r
190 return String\r
191\r
192 ## __GetRule__() method\r
193 #\r
194 # Get correct rule for generating FFS for this INF\r
195 #\r
196 # @param self The object pointer\r
197 # @retval Rule Rule object\r
198 #\r
199 def __GetRule__ (self) :\r
200 CurrentArchList = []\r
201 if self.CurrentArch == None:\r
202 CurrentArchList = ['common']\r
203 else:\r
204 CurrentArchList.append(self.CurrentArch)\r
205\r
206 for CurrentArch in CurrentArchList:\r
207 RuleName = 'RULE' + \\r
208 '.' + \\r
209 CurrentArch.upper() + \\r
210 '.' + \\r
211 self.ModuleType.upper()\r
212 if self.Rule != None:\r
213 RuleName = RuleName + \\r
214 '.' + \\r
215 self.Rule.upper()\r
216\r
217 Rule = GenFdsGlobalVariable.FdfParser.Profile.RuleDict.get(RuleName)\r
218 if Rule != None:\r
219 GenFdsGlobalVariable.VerboseLogger ("Want To Find Rule Name is : " + RuleName)\r
220 return Rule\r
221\r
222 RuleName = 'RULE' + \\r
223 '.' + \\r
224 'COMMON' + \\r
225 '.' + \\r
226 self.ModuleType.upper()\r
227\r
228 if self.Rule != None:\r
229 RuleName = RuleName + \\r
230 '.' + \\r
231 self.Rule.upper()\r
232\r
233 GenFdsGlobalVariable.VerboseLogger ('Trying to apply common rule %s for INF %s' % (RuleName, self.InfFileName))\r
234\r
235 Rule = GenFdsGlobalVariable.FdfParser.Profile.RuleDict.get(RuleName)\r
236 if Rule != None:\r
237 GenFdsGlobalVariable.VerboseLogger ("Want To Find Rule Name is : " + RuleName)\r
238 return Rule\r
239\r
240 if Rule == None :\r
241 EdkLogger.error("GenFds", GENFDS_ERROR, 'Don\'t Find common rule %s for INF %s' \\r
242 % (RuleName, self.InfFileName))\r
243\r
244 ## __GetPlatformArchList__() method\r
245 #\r
246 # Get Arch list this INF built under\r
247 #\r
248 # @param self The object pointer\r
249 # @retval list Arch list\r
250 #\r
251 def __GetPlatformArchList__(self):\r
252\r
253 InfFileKey = os.path.normpath(os.path.join(GenFdsGlobalVariable.WorkSpaceDir, self.InfFileName))\r
254 DscArchList = []\r
255 PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'IA32']\r
256 if PlatformDataBase != None:\r
257 if InfFileKey in PlatformDataBase.Modules:\r
258 DscArchList.append ('IA32')\r
259\r
260 PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'X64']\r
261 if PlatformDataBase != None:\r
262 if InfFileKey in PlatformDataBase.Modules:\r
263 DscArchList.append ('X64')\r
264\r
265 PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'IPF']\r
266 if PlatformDataBase != None:\r
267 if InfFileKey in (PlatformDataBase.Modules):\r
268 DscArchList.append ('IPF')\r
269\r
270 PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'ARM']\r
271 if PlatformDataBase != None:\r
272 if InfFileKey in (PlatformDataBase.Modules):\r
273 DscArchList.append ('ARM')\r
274\r
275 PlatformDataBase = GenFdsGlobalVariable.WorkSpace.BuildObject[GenFdsGlobalVariable.ActivePlatform, 'EBC']\r
276 if PlatformDataBase != None:\r
277 if InfFileKey in (PlatformDataBase.Modules):\r
278 DscArchList.append ('EBC')\r
279\r
280 return DscArchList\r
281\r
282 ## GetCurrentArch() method\r
283 #\r
284 # Get Arch list of the module from this INF is to be placed into flash\r
285 #\r
286 # @param self The object pointer\r
287 # @retval list Arch list\r
288 #\r
289 def GetCurrentArch(self) :\r
290\r
291 TargetArchList = GenFdsGlobalVariable.ArchList\r
292\r
293 PlatformArchList = self.__GetPlatformArchList__()\r
294\r
295 CurArchList = TargetArchList\r
296 if PlatformArchList != []:\r
297 CurArchList = list(set (TargetArchList) & set (PlatformArchList))\r
298 GenFdsGlobalVariable.VerboseLogger ("Valid target architecture(s) is : " + " ".join(CurArchList))\r
299\r
300 ArchList = []\r
301 if self.KeyStringList != []:\r
302 for Key in self.KeyStringList:\r
303 Key = GenFdsGlobalVariable.MacroExtend(Key)\r
304 Target, Tag, Arch = Key.split('_')\r
305 if Arch in CurArchList:\r
306 ArchList.append(Arch)\r
307 if Target not in self.TargetOverrideList:\r
308 self.TargetOverrideList.append(Target)\r
309 else:\r
310 ArchList = CurArchList\r
311\r
312 UseArchList = TargetArchList\r
313 if self.UseArch != None:\r
314 UseArchList = []\r
315 UseArchList.append(self.UseArch)\r
316 ArchList = list(set (UseArchList) & set (ArchList))\r
317\r
318 self.InfFileName = NormPath(self.InfFileName)\r
319 if len(PlatformArchList) == 0:\r
320 self.InDsc = False\r
321 PathClassObj = PathClass(self.InfFileName, GenFdsGlobalVariable.WorkSpaceDir)\r
322 ErrorCode, ErrorInfo = PathClassObj.Validate()\r
323 if ErrorCode != 0:\r
324 EdkLogger.error("GenFds", ErrorCode, ExtraData=ErrorInfo)\r
325 if len(ArchList) == 1:\r
326 Arch = ArchList[0]\r
327 return Arch\r
328 elif len(ArchList) > 1:\r
329 if len(PlatformArchList) == 0:\r
330 EdkLogger.error("GenFds", GENFDS_ERROR, "GenFds command line option has multiple ARCHs %s. Not able to determine which ARCH is valid for Module %s !" % (str(ArchList), self.InfFileName))\r
331 else:\r
332 EdkLogger.error("GenFds", GENFDS_ERROR, "Module built under multiple ARCHs %s. Not able to determine which output to put into flash for Module %s !" % (str(ArchList), self.InfFileName))\r
333 else:\r
334 EdkLogger.error("GenFds", GENFDS_ERROR, "Module %s appears under ARCH %s in platform %s, but current deduced ARCH is %s, so NO build output could be put into flash." \\r
335 % (self.InfFileName, str(PlatformArchList), GenFdsGlobalVariable.ActivePlatform, str(set (UseArchList) & set (TargetArchList))))\r
336\r
337 ## __GetEFIOutPutPath__() method\r
338 #\r
339 # Get the output path for generated files\r
340 #\r
341 # @param self The object pointer\r
342 # @retval string Path that output files from this INF go to\r
343 #\r
344 def __GetEFIOutPutPath__(self):\r
345 Arch = ''\r
346 OutputPath = ''\r
347 (ModulePath, FileName) = os.path.split(self.InfFileName)\r
348 Index = FileName.find('.')\r
349 FileName = FileName[0:Index]\r
350 Arch = "NoneArch"\r
351 if self.CurrentArch != None:\r
352 Arch = self.CurrentArch\r
353\r
354 OutputPath = os.path.join(GenFdsGlobalVariable.OutputDirDict[Arch],\r
355 Arch ,\r
356 ModulePath,\r
357 FileName,\r
358 'OUTPUT'\r
359 )\r
360 OutputPath = os.path.realpath(OutputPath)\r
361 return OutputPath\r
362\r
363 ## __GenSimpleFileSection__() method\r
364 #\r
365 # Generate section by specified file name or a list of files with file extension\r
366 #\r
367 # @param self The object pointer\r
368 # @param Rule The rule object used to generate section\r
369 # @retval string File name of the generated section file\r
370 #\r
371 def __GenSimpleFileSection__(self, Rule):\r
372 #\r
373 # Prepare the parameter of GenSection\r
374 #\r
375 FileList = []\r
376 OutputFileList = []\r
377 if Rule.FileName != None:\r
378 GenSecInputFile = self.__ExtendMacro__(Rule.FileName)\r
379 else:\r
380 FileList, IsSect = Section.Section.GetFileList(self, '', Rule.FileExtension)\r
381\r
382 Index = 1\r
383 SectionType = Rule.SectionType\r
384 NoStrip = True\r
385 if self.ModuleType in ('SEC', 'PEI_CORE', 'PEIM'):\r
386 if self.KeepReloc != None:\r
387 NoStrip = self.KeepReloc\r
388 elif Rule.KeepReloc != None:\r
389 NoStrip = Rule.KeepReloc\r
390 elif self.ShadowFromInfFile != None:\r
391 NoStrip = self.ShadowFromInfFile\r
392\r
393 if FileList != [] :\r
394 for File in FileList:\r
395\r
396 SecNum = '%d' %Index\r
397 GenSecOutputFile= self.__ExtendMacro__(Rule.NameGuid) + \\r
398 Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + SecNum\r
399 Index = Index + 1\r
400 OutputFile = os.path.join(self.OutputPath, GenSecOutputFile)\r
401\r
402 if not NoStrip:\r
403 FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')\r
404 if not os.path.exists(FileBeforeStrip) or \\r
405 (os.path.getmtime(File) > os.path.getmtime(FileBeforeStrip)):\r
406 shutil.copyfile(File, FileBeforeStrip)\r
407 StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')\r
408 GenFdsGlobalVariable.GenerateFirmwareImage(\r
409 StrippedFile,\r
410 [GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)],\r
411 Strip=True\r
412 )\r
413 File = StrippedFile\r
414\r
415 if SectionType == 'TE':\r
416 TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')\r
417 GenFdsGlobalVariable.GenerateFirmwareImage(\r
418 TeFile,\r
419 [GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)],\r
420 Type='te'\r
421 )\r
422 File = TeFile\r
423\r
424 GenFdsGlobalVariable.GenerateSection(OutputFile, [File], Section.Section.SectionType[SectionType])\r
425 OutputFileList.append(OutputFile)\r
426 else:\r
427 SecNum = '%d' %Index\r
428 GenSecOutputFile= self.__ExtendMacro__(Rule.NameGuid) + \\r
429 Ffs.Ffs.SectionSuffix[SectionType] + 'SEC' + SecNum\r
430 OutputFile = os.path.join(self.OutputPath, GenSecOutputFile)\r
431\r
432 if not NoStrip:\r
433 FileBeforeStrip = os.path.join(self.OutputPath, ModuleName + '.reloc')\r
434 if not os.path.exists(FileBeforeStrip) or \\r
435 (os.path.getmtime(GenSecInputFile) > os.path.getmtime(FileBeforeStrip)):\r
436 shutil.copyfile(GenSecInputFile, FileBeforeStrip)\r
437 StrippedFile = os.path.join(self.OutputPath, ModuleName + '.stipped')\r
438 GenFdsGlobalVariable.GenerateFirmwareImage(\r
439 StrippedFile,\r
440 [GenFdsGlobalVariable.MacroExtend(GenSecInputFile, Dict, self.CurrentArch)],\r
441 Strip=True\r
442 )\r
443 GenSecInputFile = StrippedFile\r
444\r
445 if SectionType == 'TE':\r
446 TeFile = os.path.join( self.OutputPath, self.ModuleGuid + 'Te.raw')\r
447 GenFdsGlobalVariable.GenerateFirmwareImage(\r
448 TeFile,\r
449 [GenFdsGlobalVariable.MacroExtend(File, Dict, self.CurrentArch)],\r
450 Type='te'\r
451 )\r
452 GenSecInputFile = TeFile\r
453\r
454 GenFdsGlobalVariable.GenerateSection(OutputFile, [GenSecInputFile], Section.Section.SectionType[SectionType])\r
455 OutputFileList.append(OutputFile)\r
456\r
457 return OutputFileList\r
458\r
459 ## __GenSimpleFileFfs__() method\r
460 #\r
461 # Generate FFS\r
462 #\r
463 # @param self The object pointer\r
464 # @param Rule The rule object used to generate section\r
465 # @param InputFileList The output file list from GenSection\r
466 # @retval string Generated FFS file name\r
467 #\r
468 def __GenSimpleFileFfs__(self, Rule, InputFileList):\r
469 FfsOutput = self.OutputPath + \\r
470 os.sep + \\r
471 self.__ExtendMacro__(Rule.NameGuid) + \\r
472 '.ffs'\r
473\r
474 GenFdsGlobalVariable.VerboseLogger(self.__ExtendMacro__(Rule.NameGuid))\r
475 InputSection = []\r
476 SectionAlignments = []\r
477 for InputFile in InputFileList:\r
478 InputSection.append(InputFile)\r
479 SectionAlignments.append(Rule.Alignment)\r
480\r
481 if Rule.NameGuid != None and Rule.NameGuid.startswith('PCD('):\r
482 PcdValue = GenFdsGlobalVariable.GetPcdValue(Rule.NameGuid)\r
483 if len(PcdValue) == 0:\r
484 EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' \\r
485 % (Rule.NameGuid))\r
486 if PcdValue.startswith('{'):\r
487 PcdValue = GuidStructureByteArrayToGuidString(PcdValue)\r
488 RegistryGuidStr = PcdValue\r
489 if len(RegistryGuidStr) == 0:\r
490 EdkLogger.error("GenFds", GENFDS_ERROR, 'GUID value for %s in wrong format.' \\r
491 % (Rule.NameGuid))\r
492 self.ModuleGuid = RegistryGuidStr\r
493\r
494 GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputSection,\r
495 Ffs.Ffs.FdfFvFileTypeToFileType[Rule.FvFileType],\r
496 self.ModuleGuid, Fixed=Rule.Fixed,\r
497 CheckSum=Rule.CheckSum, Align=Rule.Alignment,\r
498 SectionAlign=SectionAlignments\r
499 )\r
500 return FfsOutput\r
501\r
502 ## __GenComplexFileSection__() method\r
503 #\r
504 # Generate section by sections in Rule\r
505 #\r
506 # @param self The object pointer\r
507 # @param Rule The rule object used to generate section\r
508 # @retval string File name of the generated section file\r
509 #\r
510 def __GenComplexFileSection__(self, Rule):\r
511 if self.ModuleType in ('SEC', 'PEI_CORE', 'PEIM'):\r
512 if Rule.KeepReloc != None:\r
513 self.KeepRelocFromRule = Rule.KeepReloc\r
514 SectFiles = []\r
515 SectAlignments = []\r
516 Index = 1\r
517 for Sect in Rule.SectionList:\r
518 SecIndex = '%d' %Index\r
519 SectList = []\r
520 if Rule.KeyStringList != []:\r
521 SectList, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, SecIndex, Rule.KeyStringList, self)\r
522 else :\r
523 SectList, Align = Sect.GenSection(self.OutputPath , self.ModuleGuid, SecIndex, self.KeyStringList, self)\r
524 for SecName in SectList :\r
525 SectFiles.append(SecName)\r
526 SectAlignments.append(Align)\r
527 Index = Index + 1\r
528 return SectFiles, SectAlignments\r
529\r
530 ## __GenComplexFileFfs__() method\r
531 #\r
532 # Generate FFS\r
533 #\r
534 # @param self The object pointer\r
535 # @param Rule The rule object used to generate section\r
536 # @param InputFileList The output file list from GenSection\r
537 # @retval string Generated FFS file name\r
538 #\r
539 def __GenComplexFileFfs__(self, Rule, InputFile, Alignments):\r
540\r
541 if Rule.NameGuid != None and Rule.NameGuid.startswith('PCD('):\r
542 PcdValue = GenFdsGlobalVariable.GetPcdValue(Rule.NameGuid)\r
543 if len(PcdValue) == 0:\r
544 EdkLogger.error("GenFds", GENFDS_ERROR, '%s NOT defined.' \\r
545 % (Rule.NameGuid))\r
546 if PcdValue.startswith('{'):\r
547 PcdValue = GuidStructureByteArrayToGuidString(PcdValue)\r
548 RegistryGuidStr = PcdValue\r
549 if len(RegistryGuidStr) == 0:\r
550 EdkLogger.error("GenFds", GENFDS_ERROR, 'GUID value for %s in wrong format.' \\r
551 % (Rule.NameGuid))\r
552 self.ModuleGuid = RegistryGuidStr\r
553\r
554 FfsOutput = os.path.join( self.OutputPath, self.ModuleGuid + '.ffs')\r
555 GenFdsGlobalVariable.GenerateFfs(FfsOutput, InputFile,\r
556 Ffs.Ffs.FdfFvFileTypeToFileType[Rule.FvFileType],\r
557 self.ModuleGuid, Fixed=Rule.Fixed,\r
558 CheckSum=Rule.CheckSum, Align=Rule.Alignment,\r
559 SectionAlign=Alignments\r
560 )\r
561 return FfsOutput\r
562\r
563 ## __GetGenFfsCmdParameter__() method\r
564 #\r
565 # Create parameter string for GenFfs\r
566 #\r
567 # @param self The object pointer\r
568 # @param Rule The rule object used to generate section\r
569 # @retval tuple (FileType, Fixed, CheckSum, Alignment)\r
570 #\r
571 def __GetGenFfsCmdParameter__(self, Rule):\r
572 result = tuple()\r
573 result += ('-t', Ffs.Ffs.FdfFvFileTypeToFileType[Rule.FvFileType])\r
574 if Rule.Fixed != False:\r
575 result += ('-x',)\r
576 if Rule.CheckSum != False:\r
577 result += ('-s',)\r
578\r
579 if Rule.Alignment != None and Rule.Alignment != '':\r
580 result += ('-a', Rule.Alignment)\r
581\r
582 return result\r