]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/DataSection.py
2 # process data section generation
4 # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
6 # SPDX-License-Identifier: BSD-2-Clause-Patent
12 from __future__
import absolute_import
14 from .GenFdsGlobalVariable
import GenFdsGlobalVariable
16 from .Ffs
import SectionSuffix
17 import Common
.LongFilePathOs
as os
18 from CommonDataClass
.FdfClass
import DataSectionClassObject
19 from Common
.Misc
import PeImageClass
20 from Common
.LongFilePathSupport
import CopyLongFilePath
21 from Common
.DataType
import *
23 ## generate data section
26 class DataSection (DataSectionClassObject
):
29 # @param self The object pointer
32 DataSectionClassObject
.__init
__(self
)
34 ## GenSection() method
36 # Generate compressed section
38 # @param self The object pointer
39 # @param OutputPath Where to place output file
40 # @param ModuleName Which module this section belongs to
41 # @param SecNum Index of section
42 # @param KeyStringList Filter for inputs of section generation
43 # @param FfsInf FfsInfStatement object that contains this section data
44 # @param Dict dictionary contains macro and its value
45 # @retval tuple (Generated file name list, section alignment)
47 def GenSection(self
, OutputPath
, ModuleName
, SecNum
, keyStringList
, FfsFile
= None, Dict
= None, IsMakefile
= False):
49 # Prepare the parameter of GenSection
53 if FfsFile
is not None:
54 self
.SectFileName
= GenFdsGlobalVariable
.ReplaceWorkspaceMacro(self
.SectFileName
)
55 self
.SectFileName
= GenFdsGlobalVariable
.MacroExtend(self
.SectFileName
, Dict
, FfsFile
.CurrentArch
)
57 self
.SectFileName
= GenFdsGlobalVariable
.ReplaceWorkspaceMacro(self
.SectFileName
)
58 self
.SectFileName
= GenFdsGlobalVariable
.MacroExtend(self
.SectFileName
, Dict
)
60 """Check Section file exist or not !"""
62 if not os
.path
.exists(self
.SectFileName
):
63 self
.SectFileName
= os
.path
.join (GenFdsGlobalVariable
.WorkSpaceDir
,
66 """Copy Map file to Ffs output"""
67 Filename
= GenFdsGlobalVariable
.MacroExtend(self
.SectFileName
)
68 if Filename
[(len(Filename
)-4):] == '.efi':
69 MapFile
= Filename
.replace('.efi', '.map')
70 CopyMapFile
= os
.path
.join(OutputPath
, ModuleName
+ '.map')
72 if GenFdsGlobalVariable
.CopyList
== []:
73 GenFdsGlobalVariable
.CopyList
= [(MapFile
, CopyMapFile
)]
75 GenFdsGlobalVariable
.CopyList
.append((MapFile
, CopyMapFile
))
77 if os
.path
.exists(MapFile
):
78 if not os
.path
.exists(CopyMapFile
) or (os
.path
.getmtime(MapFile
) > os
.path
.getmtime(CopyMapFile
)):
79 CopyLongFilePath(MapFile
, CopyMapFile
)
81 #Get PE Section alignment when align is set to AUTO
82 if self
.Alignment
== 'Auto' and self
.SecType
in (BINARY_FILE_TYPE_TE
, BINARY_FILE_TYPE_PE32
):
85 if self
.SecType
in (BINARY_FILE_TYPE_TE
, BINARY_FILE_TYPE_PE32
):
86 if self
.KeepReloc
is not None:
87 NoStrip
= self
.KeepReloc
90 FileBeforeStrip
= os
.path
.join(OutputPath
, ModuleName
+ '.efi')
91 if not os
.path
.exists(FileBeforeStrip
) or \
92 (os
.path
.getmtime(self
.SectFileName
) > os
.path
.getmtime(FileBeforeStrip
)):
93 CopyLongFilePath(self
.SectFileName
, FileBeforeStrip
)
94 StrippedFile
= os
.path
.join(OutputPath
, ModuleName
+ '.stripped')
95 GenFdsGlobalVariable
.GenerateFirmwareImage(
97 [GenFdsGlobalVariable
.MacroExtend(self
.SectFileName
, Dict
)],
99 IsMakefile
= IsMakefile
101 self
.SectFileName
= StrippedFile
103 if self
.SecType
== BINARY_FILE_TYPE_TE
:
104 TeFile
= os
.path
.join( OutputPath
, ModuleName
+ 'Te.raw')
105 GenFdsGlobalVariable
.GenerateFirmwareImage(
107 [GenFdsGlobalVariable
.MacroExtend(self
.SectFileName
, Dict
)],
109 IsMakefile
= IsMakefile
111 self
.SectFileName
= TeFile
113 OutputFile
= os
.path
.join (OutputPath
, ModuleName
+ SUP_MODULE_SEC
+ SecNum
+ SectionSuffix
.get(self
.SecType
))
114 OutputFile
= os
.path
.normpath(OutputFile
)
115 GenFdsGlobalVariable
.GenerateSection(OutputFile
, [self
.SectFileName
], Section
.Section
.SectionType
.get(self
.SecType
), IsMakefile
= IsMakefile
)
116 FileList
= [OutputFile
]
117 return FileList
, self
.Alignment