]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/GenFds/CompressSection.py
BaseTools: remove redundant if comparison
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / CompressSection.py
CommitLineData
30fdf114
LG
1## @file\r
2# process compress section generation\r
3#\r
37de70b7 4# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
30fdf114 5#\r
40d841f6 6# This program and the accompanying materials\r
30fdf114
LG
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
18from Ffs import Ffs\r
19import Section\r
20import subprocess\r
97fa0ee9 21import Common.LongFilePathOs as os\r
30fdf114
LG
22from GenFdsGlobalVariable import GenFdsGlobalVariable\r
23from CommonDataClass.FdfClass import CompressSectionClassObject\r
8bb63e37 24from Common.DataType import *\r
30fdf114
LG
25\r
26## generate compress section\r
27#\r
28#\r
29class CompressSection (CompressSectionClassObject) :\r
30\r
31 ## compress types: PI standard and non PI standard\r
32 CompTypeDict = {\r
52302d4d
LG
33 'PI_STD' : 'PI_STD',\r
34 'PI_NONE' : 'PI_NONE'\r
30fdf114
LG
35 }\r
36\r
37 ## The constructor\r
38 #\r
39 # @param self The object pointer\r
40 #\r
41 def __init__(self):\r
42 CompressSectionClassObject.__init__(self)\r
43\r
44 ## GenSection() method\r
45 #\r
46 # Generate compressed section\r
47 #\r
48 # @param self The object pointer\r
49 # @param OutputPath Where to place output file\r
50 # @param ModuleName Which module this section belongs to\r
51 # @param SecNum Index of section\r
52 # @param KeyStringList Filter for inputs of section generation\r
53 # @param FfsInf FfsInfStatement object that contains this section data\r
54 # @param Dict dictionary contains macro and its value\r
55 # @retval tuple (Generated file name, section alignment)\r
56 #\r
37de70b7 57 def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}, IsMakefile = False):\r
30fdf114 58\r
4231a819 59 if FfsInf is not None:\r
30fdf114
LG
60 self.CompType = FfsInf.__ExtendMacro__(self.CompType)\r
61 self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)\r
62\r
63 SectFiles = tuple()\r
ce2818e4 64 SectAlign = []\r
30fdf114 65 Index = 0\r
4f735fc8 66 MaxAlign = None\r
30fdf114
LG
67 for Sect in self.SectionList:\r
68 Index = Index + 1\r
69 SecIndex = '%s.%d' %(SecNum, Index)\r
37de70b7 70 ReturnSectList, AlignValue = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf, Dict, IsMakefile=IsMakefile)\r
4231a819
CJ
71 if AlignValue is not None:\r
72 if MaxAlign is None:\r
4f735fc8
FY
73 MaxAlign = AlignValue\r
74 if GenFdsGlobalVariable.GetAlignment (AlignValue) > GenFdsGlobalVariable.GetAlignment (MaxAlign):\r
75 MaxAlign = AlignValue\r
30fdf114 76 if ReturnSectList != []:\r
4231a819 77 if AlignValue is None:\r
4f735fc8 78 AlignValue = "1"\r
30fdf114 79 for FileData in ReturnSectList:\r
37de70b7 80 SectFiles += (FileData,)\r
ce2818e4 81 SectAlign.append(AlignValue)\r
30fdf114
LG
82\r
83 OutputFile = OutputPath + \\r
84 os.sep + \\r
85 ModuleName + \\r
8bb63e37 86 SUP_MODULE_SEC + \\r
30fdf114
LG
87 SecNum + \\r
88 Ffs.SectionSuffix['COMPRESS']\r
89 OutputFile = os.path.normpath(OutputFile)\r
ce2818e4
FY
90 DummyFile = OutputFile + '.dummy'\r
91 GenFdsGlobalVariable.GenerateSection(DummyFile, SectFiles, InputAlign=SectAlign, IsMakefile=IsMakefile)\r
30fdf114 92\r
ce2818e4 93 GenFdsGlobalVariable.GenerateSection(OutputFile, [DummyFile], Section.Section.SectionType['COMPRESS'],\r
37de70b7 94 CompressionType=self.CompTypeDict[self.CompType], IsMakefile=IsMakefile)\r
30fdf114
LG
95 OutputFileList = []\r
96 OutputFileList.append(OutputFile)\r
97 return OutputFileList, self.Alignment\r
98\r
99\r