2 # process compress section generation
4 # Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
6 # This program and the accompanying materials
7 # are licensed and made available under the terms and conditions of the BSD License
8 # which accompanies this distribution. The full text of the license may be found at
9 # http://opensource.org/licenses/bsd-license.php
11 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 import Common
.LongFilePathOs
as os
22 from GenFdsGlobalVariable
import GenFdsGlobalVariable
23 from CommonDataClass
.FdfClass
import CompressSectionClassObject
25 ## generate compress section
28 class CompressSection (CompressSectionClassObject
) :
30 ## compress types: PI standard and non PI standard
38 # @param self The object pointer
41 CompressSectionClassObject
.__init
__(self
)
43 ## GenSection() method
45 # Generate compressed section
47 # @param self The object pointer
48 # @param OutputPath Where to place output file
49 # @param ModuleName Which module this section belongs to
50 # @param SecNum Index of section
51 # @param KeyStringList Filter for inputs of section generation
52 # @param FfsInf FfsInfStatement object that contains this section data
53 # @param Dict dictionary contains macro and its value
54 # @retval tuple (Generated file name, section alignment)
56 def GenSection(self
, OutputPath
, ModuleName
, SecNum
, KeyStringList
, FfsInf
= None, Dict
= {}, IsMakefile
= False):
58 if FfsInf
is not None:
59 self
.CompType
= FfsInf
.__ExtendMacro
__(self
.CompType
)
60 self
.Alignment
= FfsInf
.__ExtendMacro
__(self
.Alignment
)
66 for Sect
in self
.SectionList
:
68 SecIndex
= '%s.%d' %(SecNum
, Index
)
69 ReturnSectList
, AlignValue
= Sect
.GenSection(OutputPath
, ModuleName
, SecIndex
, KeyStringList
, FfsInf
, Dict
, IsMakefile
=IsMakefile
)
70 if AlignValue
is not None:
73 if GenFdsGlobalVariable
.GetAlignment (AlignValue
) > GenFdsGlobalVariable
.GetAlignment (MaxAlign
):
75 if ReturnSectList
!= []:
76 if AlignValue
is None:
78 for FileData
in ReturnSectList
:
79 SectFiles
+= (FileData
,)
80 SectAlign
.append(AlignValue
)
82 OutputFile
= OutputPath
+ \
87 Ffs
.SectionSuffix
['COMPRESS']
88 OutputFile
= os
.path
.normpath(OutputFile
)
89 DummyFile
= OutputFile
+ '.dummy'
90 GenFdsGlobalVariable
.GenerateSection(DummyFile
, SectFiles
, InputAlign
=SectAlign
, IsMakefile
=IsMakefile
)
92 GenFdsGlobalVariable
.GenerateSection(OutputFile
, [DummyFile
], Section
.Section
.SectionType
['COMPRESS'],
93 CompressionType
=self
.CompTypeDict
[self
.CompType
], IsMakefile
=IsMakefile
)
95 OutputFileList
.append(OutputFile
)
96 return OutputFileList
, self
.Alignment