Home | History | Annotate | Download | only in GenFds
      1 ## @file

      2 # process compress section generation

      3 #

      4 #  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>

      5 #

      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

     10 #

     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.

     13 #

     14 
     15 ##

     16 # Import Modules

     17 #

     18 from Ffs import Ffs
     19 import Section
     20 import subprocess
     21 import Common.LongFilePathOs as os
     22 from GenFdsGlobalVariable import GenFdsGlobalVariable
     23 from CommonDataClass.FdfClass import CompressSectionClassObject
     24 
     25 ## generate compress section

     26 #

     27 #

     28 class CompressSection (CompressSectionClassObject) :
     29 
     30     ## compress types: PI standard and non PI standard

     31     CompTypeDict = {
     32         'PI_STD'  : 'PI_STD',
     33         'PI_NONE' : 'PI_NONE'
     34     }
     35 
     36     ## The constructor

     37     #

     38     #   @param  self        The object pointer

     39     #

     40     def __init__(self):
     41         CompressSectionClassObject.__init__(self)
     42 
     43     ## GenSection() method

     44     #

     45     #   Generate compressed section

     46     #

     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)

     55     #

     56     def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}):
     57 
     58         if FfsInf != None:
     59             self.CompType = FfsInf.__ExtendMacro__(self.CompType)
     60             self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)
     61 
     62         SectFiles = tuple()
     63         Index = 0
     64         for Sect in self.SectionList:
     65             Index = Index + 1
     66             SecIndex = '%s.%d' %(SecNum, Index)
     67             ReturnSectList, AlignValue = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList, FfsInf, Dict)
     68             if ReturnSectList != []:
     69                 for FileData in ReturnSectList:
     70                    SectFiles += (FileData,)
     71 
     72 
     73         OutputFile = OutputPath + \
     74                      os.sep     + \
     75                      ModuleName + \
     76                      'SEC'      + \
     77                      SecNum     + \
     78                      Ffs.SectionSuffix['COMPRESS']
     79         OutputFile = os.path.normpath(OutputFile)
     80 
     81         GenFdsGlobalVariable.GenerateSection(OutputFile, SectFiles, Section.Section.SectionType['COMPRESS'],
     82                                              CompressionType=self.CompTypeDict[self.CompType])
     83         OutputFileList = []
     84         OutputFileList.append(OutputFile)
     85         return OutputFileList, self.Alignment
     86 
     87 
     88