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.
18 from __future__
import absolute_import
22 import Common
.LongFilePathOs
as os
23 from .GenFdsGlobalVariable
import GenFdsGlobalVariable
24 from CommonDataClass
.FdfClass
import CompressSectionClassObject
25 from Common
.DataType
import *
27 ## generate compress section
30 class CompressSection (CompressSectionClassObject
) :
32 ## compress types: PI standard and non PI standard
40 # @param self The object pointer
43 CompressSectionClassObject
.__init
__(self
)
45 ## GenSection() method
47 # Generate compressed section
49 # @param self The object pointer
50 # @param OutputPath Where to place output file
51 # @param ModuleName Which module this section belongs to
52 # @param SecNum Index of section
53 # @param KeyStringList Filter for inputs of section generation
54 # @param FfsInf FfsInfStatement object that contains this section data
55 # @param Dict dictionary contains macro and its value
56 # @retval tuple (Generated file name, section alignment)
58 def GenSection(self
, OutputPath
, ModuleName
, SecNum
, KeyStringList
, FfsInf
= None, Dict
= {}, IsMakefile
= False):
60 if FfsInf
is not None:
61 self
.CompType
= FfsInf
.__ExtendMacro
__(self
.CompType
)
62 self
.Alignment
= FfsInf
.__ExtendMacro
__(self
.Alignment
)
68 for Sect
in self
.SectionList
:
70 SecIndex
= '%s.%d' %(SecNum
, Index
)
71 ReturnSectList
, AlignValue
= Sect
.GenSection(OutputPath
, ModuleName
, SecIndex
, KeyStringList
, FfsInf
, Dict
, IsMakefile
=IsMakefile
)
72 if AlignValue
is not None:
75 if GenFdsGlobalVariable
.GetAlignment (AlignValue
) > GenFdsGlobalVariable
.GetAlignment (MaxAlign
):
77 if ReturnSectList
!= []:
78 if AlignValue
is None:
80 for FileData
in ReturnSectList
:
81 SectFiles
+= (FileData
,)
82 SectAlign
.append(AlignValue
)
84 OutputFile
= OutputPath
+ \
89 Ffs
.SectionSuffix
['COMPRESS']
90 OutputFile
= os
.path
.normpath(OutputFile
)
91 DummyFile
= OutputFile
+ '.dummy'
92 GenFdsGlobalVariable
.GenerateSection(DummyFile
, SectFiles
, InputAlign
=SectAlign
, IsMakefile
=IsMakefile
)
94 GenFdsGlobalVariable
.GenerateSection(OutputFile
, [DummyFile
], Section
.Section
.SectionType
['COMPRESS'],
95 CompressionType
=self
.CompTypeDict
[self
.CompType
], IsMakefile
=IsMakefile
)
97 OutputFileList
.append(OutputFile
)
98 return OutputFileList
, self
.Alignment