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