2 # process compress section generation
4 # Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
6 # SPDX-License-Identifier: BSD-2-Clause-Patent
12 from __future__
import absolute_import
13 from .Ffs
import SectionSuffix
16 import Common
.LongFilePathOs
as os
17 from .GenFdsGlobalVariable
import GenFdsGlobalVariable
18 from CommonDataClass
.FdfClass
import CompressSectionClassObject
19 from Common
.DataType
import *
21 ## generate compress section
24 class CompressSection (CompressSectionClassObject
) :
26 ## compress types: PI standard and non PI standard
34 # @param self The object pointer
37 CompressSectionClassObject
.__init
__(self
)
39 ## GenSection() method
41 # Generate compressed section
43 # @param self The object pointer
44 # @param OutputPath Where to place output file
45 # @param ModuleName Which module this section belongs to
46 # @param SecNum Index of section
47 # @param KeyStringList Filter for inputs of section generation
48 # @param FfsInf FfsInfStatement object that contains this section data
49 # @param Dict dictionary contains macro and its value
50 # @retval tuple (Generated file name, section alignment)
52 def GenSection(self
, OutputPath
, ModuleName
, SecNum
, KeyStringList
, FfsInf
= None, Dict
= None, IsMakefile
= False):
54 if FfsInf
is not None:
55 self
.CompType
= FfsInf
.__ExtendMacro
__(self
.CompType
)
56 self
.Alignment
= FfsInf
.__ExtendMacro
__(self
.Alignment
)
64 for Sect
in self
.SectionList
:
66 SecIndex
= '%s.%d' %(SecNum
, Index
)
67 ReturnSectList
, AlignValue
= Sect
.GenSection(OutputPath
, ModuleName
, SecIndex
, KeyStringList
, FfsInf
, Dict
, IsMakefile
=IsMakefile
)
68 if AlignValue
is not None:
71 if GenFdsGlobalVariable
.GetAlignment (AlignValue
) > GenFdsGlobalVariable
.GetAlignment (MaxAlign
):
73 if ReturnSectList
!= []:
74 if AlignValue
is None:
76 for FileData
in ReturnSectList
:
77 SectFiles
+= (FileData
,)
78 SectAlign
.append(AlignValue
)
80 OutputFile
= OutputPath
+ \
85 SectionSuffix
['COMPRESS']
86 OutputFile
= os
.path
.normpath(OutputFile
)
87 DummyFile
= OutputFile
+ '.dummy'
88 GenFdsGlobalVariable
.GenerateSection(DummyFile
, SectFiles
, InputAlign
=SectAlign
, IsMakefile
=IsMakefile
)
90 GenFdsGlobalVariable
.GenerateSection(OutputFile
, [DummyFile
], Section
.Section
.SectionType
['COMPRESS'],
91 CompressionType
=self
.CompTypeDict
[self
.CompType
], IsMakefile
=IsMakefile
)
93 OutputFileList
.append(OutputFile
)
94 return OutputFileList
, self
.Alignment