2009-07-17 11:10:31 +02:00
## @file
# section base class
#
2018-04-16 15:52:13 +02:00
# Copyright (c) 2007-2018, 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
#
from CommonDataClass . FdfClass import SectionClassObject
from GenFdsGlobalVariable import GenFdsGlobalVariable
2014-08-15 05:06:48 +02:00
import Common . LongFilePathOs as os , glob
2009-07-17 11:10:31 +02:00
from Common import EdkLogger
from Common . BuildToolError import *
2018-04-26 18:57:56 +02:00
from Common . DataType import *
2009-07-17 11:10:31 +02:00
## section base class
#
#
class Section ( SectionClassObject ) :
SectionType = {
' RAW ' : ' EFI_SECTION_RAW ' ,
' FREEFORM ' : ' EFI_SECTION_FREEFORM_SUBTYPE_GUID ' ,
2018-04-26 18:57:56 +02:00
BINARY_FILE_TYPE_PE32 : ' EFI_SECTION_PE32 ' ,
BINARY_FILE_TYPE_PIC : ' EFI_SECTION_PIC ' ,
BINARY_FILE_TYPE_TE : ' EFI_SECTION_TE ' ,
2009-07-17 11:10:31 +02:00
' FV_IMAGE ' : ' EFI_SECTION_FIRMWARE_VOLUME_IMAGE ' ,
2018-04-26 18:57:56 +02:00
BINARY_FILE_TYPE_DXE_DEPEX : ' EFI_SECTION_DXE_DEPEX ' ,
BINARY_FILE_TYPE_PEI_DEPEX : ' EFI_SECTION_PEI_DEPEX ' ,
2009-07-17 11:10:31 +02:00
' GUIDED ' : ' EFI_SECTION_GUID_DEFINED ' ,
' COMPRESS ' : ' EFI_SECTION_COMPRESSION ' ,
2018-04-26 18:57:56 +02:00
BINARY_FILE_TYPE_UI : ' EFI_SECTION_USER_INTERFACE ' ,
BINARY_FILE_TYPE_SMM_DEPEX : ' EFI_SECTION_SMM_DEPEX '
2009-07-17 11:10:31 +02:00
}
BinFileType = {
2018-04-26 18:57:56 +02:00
BINARY_FILE_TYPE_GUID : ' .guid ' ,
2009-07-17 11:10:31 +02:00
' ACPI ' : ' .acpi ' ,
' ASL ' : ' .asl ' ,
2018-04-26 18:57:56 +02:00
BINARY_FILE_TYPE_UEFI_APP : ' .app ' ,
BINARY_FILE_TYPE_LIB : ' .lib ' ,
BINARY_FILE_TYPE_PE32 : ' .pe32 ' ,
BINARY_FILE_TYPE_PIC : ' .pic ' ,
BINARY_FILE_TYPE_PEI_DEPEX : ' .depex ' ,
2009-07-17 11:10:31 +02:00
' SEC_PEI_DEPEX ' : ' .depex ' ,
2018-04-26 18:57:56 +02:00
BINARY_FILE_TYPE_TE : ' .te ' ,
BINARY_FILE_TYPE_UNI_VER : ' .ver ' ,
BINARY_FILE_TYPE_VER : ' .ver ' ,
BINARY_FILE_TYPE_UNI_UI : ' .ui ' ,
BINARY_FILE_TYPE_UI : ' .ui ' ,
BINARY_FILE_TYPE_BIN : ' .bin ' ,
2009-07-17 11:10:31 +02:00
' RAW ' : ' .raw ' ,
' COMPAT16 ' : ' .comp16 ' ,
2018-04-26 18:57:56 +02:00
BINARY_FILE_TYPE_FV : ' .fv '
2009-07-17 11:10:31 +02:00
}
SectFileType = {
' SEC_GUID ' : ' .sec ' ,
' SEC_PE32 ' : ' .sec ' ,
' SEC_PIC ' : ' .sec ' ,
' SEC_TE ' : ' .sec ' ,
' SEC_VER ' : ' .sec ' ,
' SEC_UI ' : ' .sec ' ,
' SEC_COMPAT16 ' : ' .sec ' ,
' SEC_BIN ' : ' .sec '
}
ToolGuid = {
' 0xa31280ad-0x481e-0x41b6-0x95e8-0x127f-0x4c984779 ' : ' TianoCompress ' ,
' 0xee4e5898-0x3914-0x4259-0x9d6e-0xdc7b-0xd79403cf ' : ' LzmaCompress '
}
## The constructor
#
# @param self The object pointer
#
def __init__ ( self ) :
SectionClassObject . __init__ ( self )
## GenSection() method
#
# virtual function
#
# @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
#
def GenSection ( self , OutputPath , GuidName , SecNum , keyStringList , FfsInf = None , Dict = { } ) :
pass
## GetFileList() method
#
# Generate compressed section
#
# @param self The object pointer
# @param FfsInf FfsInfStatement object that contains file list
# @param FileType File type to get
# @param FileExtension File extension to get
# @param Dict dictionary contains macro and its value
# @retval tuple (File list, boolean)
#
2017-12-07 04:35:16 +01:00
def GetFileList ( FfsInf , FileType , FileExtension , Dict = { } , IsMakefile = False ) :
2018-04-06 01:14:02 +02:00
IsSect = FileType in Section . SectFileType
2009-07-17 11:10:31 +02:00
2018-03-26 22:25:43 +02:00
if FileExtension is not None :
2009-07-17 11:10:31 +02:00
Suffix = FileExtension
elif IsSect :
Suffix = Section . SectionType . get ( FileType )
else :
Suffix = Section . BinFileType . get ( FileType )
2018-03-26 22:25:43 +02:00
if FfsInf is None :
2009-07-17 11:10:31 +02:00
EdkLogger . error ( " GenFds " , GENFDS_ERROR , ' Inf File does not exist! ' )
FileList = [ ]
2018-03-26 22:25:43 +02:00
if FileType is not None :
2009-07-17 11:10:31 +02:00
for File in FfsInf . BinFileList :
2018-04-16 15:52:13 +02:00
if File . Arch == TAB_ARCH_COMMON or FfsInf . CurrentArch == File . Arch :
2014-08-28 15:53:34 +02:00
if File . Type == FileType or ( int ( FfsInf . PiSpecVersion , 16 ) > = 0x0001000A \
2018-04-26 18:57:56 +02:00
and FileType == ' DXE_DPEX ' and File . Type == BINARY_FILE_TYPE_SMM_DEPEX ) \
or ( FileType == BINARY_FILE_TYPE_TE and File . Type == BINARY_FILE_TYPE_PE32 ) :
2009-07-17 11:10:31 +02:00
if ' * ' in FfsInf . TargetOverrideList or File . Target == ' * ' or File . Target in FfsInf . TargetOverrideList or FfsInf . TargetOverrideList == [ ] :
2014-08-28 15:53:34 +02:00
FileList . append ( FfsInf . PatchEfiFile ( File . Path , File . Type ) )
2009-07-17 11:10:31 +02:00
else :
GenFdsGlobalVariable . InfLogger ( " \n Build Target \' %s \' of File %s is not in the Scope of %s specified by INF %s in FDF " % ( File . Target , File . File , FfsInf . TargetOverrideList , FfsInf . InfFileName ) )
else :
GenFdsGlobalVariable . VerboseLogger ( " \n File Type \' %s \' of File %s in %s is not same with file type \' %s \' from Rule in FDF " % ( File . Type , File . File , FfsInf . InfFileName , FileType ) )
else :
GenFdsGlobalVariable . InfLogger ( " \n Current ARCH \' %s \' of File %s is not in the Support Arch Scope of %s specified by INF %s in FDF " % ( FfsInf . CurrentArch , File . File , File . Arch , FfsInf . InfFileName ) )
2018-03-26 22:25:43 +02:00
if ( not IsMakefile and Suffix is not None and os . path . exists ( FfsInf . EfiOutputPath ) ) or ( IsMakefile and Suffix is not None ) :
2015-06-08 11:44:01 +02:00
#
# Get Makefile path and time stamp
#
MakefileDir = FfsInf . EfiOutputPath [ : - len ( ' OUTPUT ' ) ]
Makefile = os . path . join ( MakefileDir , ' Makefile ' )
if not os . path . exists ( Makefile ) :
Makefile = os . path . join ( MakefileDir , ' GNUmakefile ' )
2015-08-26 08:33:31 +02:00
if os . path . exists ( Makefile ) :
2015-06-08 11:44:01 +02:00
# Update to search files with suffix in all sub-dirs.
Tuple = os . walk ( FfsInf . EfiOutputPath )
for Dirpath , Dirnames , Filenames in Tuple :
for F in Filenames :
2016-05-20 10:42:35 +02:00
if os . path . splitext ( F ) [ 1 ] == Suffix :
2015-06-08 11:44:01 +02:00
FullName = os . path . join ( Dirpath , F )
if os . path . getmtime ( FullName ) > os . path . getmtime ( Makefile ) :
FileList . append ( FullName )
2015-08-26 08:33:31 +02:00
if not FileList :
SuffixMap = FfsInf . GetFinalTargetSuffixMap ( )
if Suffix in SuffixMap :
FileList . extend ( SuffixMap [ Suffix ] )
2010-03-01 00:39:39 +01:00
#Process the file lists is alphabetical for a same section type
if len ( FileList ) > 1 :
FileList . sort ( )
2009-07-17 11:10:31 +02:00
return FileList , IsSect
GetFileList = staticmethod ( GetFileList )