2009-07-17 11:10:31 +02:00
|
|
|
## @file
|
|
|
|
# process compress section generation
|
|
|
|
#
|
2017-11-22 08:42:25 +01:00
|
|
|
# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
|
2009-07-17 11:10:31 +02:00
|
|
|
#
|
2010-05-18 07:04:32 +02:00
|
|
|
# This program and the accompanying materials
|
2009-07-17 11:10:31 +02:00
|
|
|
# are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
# which accompanies this distribution. The full text of the license may be found at
|
|
|
|
# http://opensource.org/licenses/bsd-license.php
|
|
|
|
#
|
|
|
|
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
#
|
|
|
|
|
|
|
|
##
|
|
|
|
# Import Modules
|
|
|
|
#
|
2018-07-13 12:18:33 +02:00
|
|
|
from __future__ import absolute_import
|
|
|
|
from .Ffs import Ffs
|
|
|
|
from . import Section
|
2009-07-17 11:10:31 +02:00
|
|
|
import subprocess
|
2014-08-28 15:53:34 +02:00
|
|
|
import Common.LongFilePathOs as os
|
2018-07-13 12:18:33 +02:00
|
|
|
from .GenFdsGlobalVariable import GenFdsGlobalVariable
|
2009-07-17 11:10:31 +02:00
|
|
|
from CommonDataClass.FdfClass import CompressSectionClassObject
|
2018-04-26 18:57:53 +02:00
|
|
|
from Common.DataType import *
|
2009-07-17 11:10:31 +02:00
|
|
|
|
|
|
|
## generate compress section
|
|
|
|
#
|
|
|
|
#
|
|
|
|
class CompressSection (CompressSectionClassObject) :
|
|
|
|
|
|
|
|
## compress types: PI standard and non PI standard
|
|
|
|
CompTypeDict = {
|
2010-03-01 00:39:39 +01:00
|
|
|
'PI_STD' : 'PI_STD',
|
|
|
|
'PI_NONE' : 'PI_NONE'
|
2009-07-17 11:10:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
## The constructor
|
|
|
|
#
|
|
|
|
# @param self The object pointer
|
|
|
|
#
|
|
|
|
def __init__(self):
|
|
|
|
CompressSectionClassObject.__init__(self)
|
|
|
|
|
|
|
|
## GenSection() method
|
|
|
|
#
|
|
|
|
# Generate compressed section
|
|
|
|
#
|
|
|
|
# @param self The object pointer
|
|
|
|
# @param OutputPath Where to place output file
|
|
|
|
# @param ModuleName Which module this section belongs to
|
|
|
|
# @param SecNum Index of section
|
|
|
|
# @param KeyStringList Filter for inputs of section generation
|
|
|
|
# @param FfsInf FfsInfStatement object that contains this section data
|
|
|
|
# @param Dict dictionary contains macro and its value
|
|
|
|
# @retval tuple (Generated file name, section alignment)
|
|
|
|
#
|
2017-11-22 08:42:25 +01:00
|
|
|
def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}, IsMakefile = False):
|
2009-07-17 11:10:31 +02:00
|
|
|
|
2018-03-26 22:25:43 +02:00
|
|
|
if FfsInf is not None:
|
2009-07-17 11:10:31 +02:00
|
|
|
self.CompType = FfsInf.__ExtendMacro__(self.CompType)
|
|
|
|
self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)
|
|
|
|
|
|
|
|
SectFiles = tuple()
|
2018-02-09 09:06:07 +01:00
|
|
|
SectAlign = []
|
2009-07-17 11:10:31 +02:00
|
|
|
Index = 0
|
2018-02-06 08:25:53 +01:00
|
|
|
MaxAlign = None
|
2009-07-17 11:10:31 +02:00
|
|
|
for Sect in self.SectionList:
|
|
|
|
Index = Index + 1
|
|
|
|
SecIndex = '%s.%d' %(SecNum, Index)
|
2017-11-22 08:42:25 +01:00
|
|
|
ReturnSectList, AlignValue = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf, Dict, IsMakefile=IsMakefile)
|
2018-03-26 22:25:43 +02:00
|
|
|
if AlignValue is not None:
|
|
|
|
if MaxAlign is None:
|
2018-02-06 08:25:53 +01:00
|
|
|
MaxAlign = AlignValue
|
|
|
|
if GenFdsGlobalVariable.GetAlignment (AlignValue) > GenFdsGlobalVariable.GetAlignment (MaxAlign):
|
|
|
|
MaxAlign = AlignValue
|
2009-07-17 11:10:31 +02:00
|
|
|
if ReturnSectList != []:
|
2018-03-26 22:25:43 +02:00
|
|
|
if AlignValue is None:
|
2018-02-06 08:25:53 +01:00
|
|
|
AlignValue = "1"
|
2009-07-17 11:10:31 +02:00
|
|
|
for FileData in ReturnSectList:
|
2017-11-22 08:42:25 +01:00
|
|
|
SectFiles += (FileData,)
|
2018-02-09 09:06:07 +01:00
|
|
|
SectAlign.append(AlignValue)
|
2009-07-17 11:10:31 +02:00
|
|
|
|
|
|
|
OutputFile = OutputPath + \
|
|
|
|
os.sep + \
|
|
|
|
ModuleName + \
|
2018-04-26 18:57:53 +02:00
|
|
|
SUP_MODULE_SEC + \
|
2009-07-17 11:10:31 +02:00
|
|
|
SecNum + \
|
|
|
|
Ffs.SectionSuffix['COMPRESS']
|
|
|
|
OutputFile = os.path.normpath(OutputFile)
|
2018-02-09 09:06:07 +01:00
|
|
|
DummyFile = OutputFile + '.dummy'
|
|
|
|
GenFdsGlobalVariable.GenerateSection(DummyFile, SectFiles, InputAlign=SectAlign, IsMakefile=IsMakefile)
|
2009-07-17 11:10:31 +02:00
|
|
|
|
2018-02-09 09:06:07 +01:00
|
|
|
GenFdsGlobalVariable.GenerateSection(OutputFile, [DummyFile], Section.Section.SectionType['COMPRESS'],
|
2017-11-22 08:42:25 +01:00
|
|
|
CompressionType=self.CompTypeDict[self.CompType], IsMakefile=IsMakefile)
|
2009-07-17 11:10:31 +02:00
|
|
|
OutputFileList = []
|
|
|
|
OutputFileList.append(OutputFile)
|
|
|
|
return OutputFileList, self.Alignment
|
|
|
|
|
|
|
|
|