]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/DataSection.py
2 # process data section generation
4 # Copyright (c) 2007, Intel Corporation
6 # All rights reserved. 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.
19 from GenFdsGlobalVariable
import GenFdsGlobalVariable
23 from CommonDataClass
.FdfClass
import DataSectionClassObject
26 ## generate data section
29 class DataSection (DataSectionClassObject
):
32 # @param self The object pointer
35 DataSectionClassObject
.__init
__(self
)
37 ## GenSection() method
39 # Generate compressed section
41 # @param self The object pointer
42 # @param OutputPath Where to place output file
43 # @param ModuleName Which module this section belongs to
44 # @param SecNum Index of section
45 # @param KeyStringList Filter for inputs of section generation
46 # @param FfsInf FfsInfStatement object that contains this section data
47 # @param Dict dictionary contains macro and its value
48 # @retval tuple (Generated file name list, section alignment)
50 def GenSection(self
, OutputPath
, ModuleName
, SecNum
, keyStringList
, FfsFile
= None, Dict
= {}):
52 # Prepare the parameter of GenSection
55 self
.SectFileName
= GenFdsGlobalVariable
.ReplaceWorkspaceMacro(self
.SectFileName
)
56 self
.SectFileName
= GenFdsGlobalVariable
.MacroExtend(self
.SectFileName
, Dict
, FfsFile
.CurrentArch
)
58 self
.SectFileName
= GenFdsGlobalVariable
.ReplaceWorkspaceMacro(self
.SectFileName
)
59 self
.SectFileName
= GenFdsGlobalVariable
.MacroExtend(self
.SectFileName
, Dict
)
61 """Check Section file exist or not !"""
63 if not os
.path
.exists(self
.SectFileName
):
64 self
.SectFileName
= os
.path
.join (GenFdsGlobalVariable
.WorkSpaceDir
,
67 """Copy Map file to Ffs output"""
68 Filename
= GenFdsGlobalVariable
.MacroExtend(self
.SectFileName
)
69 if Filename
[(len(Filename
)-4):] == '.efi':
70 MapFile
= Filename
.replace('.efi', '.map')
71 if os
.path
.exists(MapFile
):
72 CopyMapFile
= os
.path
.join(OutputPath
, ModuleName
+ '.map')
73 if not os
.path
.exists(CopyMapFile
) or \
74 (os
.path
.getmtime(MapFile
) > os
.path
.getmtime(CopyMapFile
)):
75 shutil
.copyfile(MapFile
, CopyMapFile
)
78 if self
.SecType
in ('TE', 'PE32'):
79 if self
.KeepReloc
!= None:
80 NoStrip
= self
.KeepReloc
83 FileBeforeStrip
= os
.path
.join(OutputPath
, ModuleName
+ '.efi')
84 if not os
.path
.exists(FileBeforeStrip
) or \
85 (os
.path
.getmtime(self
.SectFileName
) > os
.path
.getmtime(FileBeforeStrip
)):
86 shutil
.copyfile(self
.SectFileName
, FileBeforeStrip
)
87 StrippedFile
= os
.path
.join(OutputPath
, ModuleName
+ '.stripped')
88 GenFdsGlobalVariable
.GenerateFirmwareImage(
90 [GenFdsGlobalVariable
.MacroExtend(self
.SectFileName
, Dict
)],
93 self
.SectFileName
= StrippedFile
95 if self
.SecType
== 'TE':
96 TeFile
= os
.path
.join( OutputPath
, ModuleName
+ 'Te.raw')
97 GenFdsGlobalVariable
.GenerateFirmwareImage(
99 [GenFdsGlobalVariable
.MacroExtend(self
.SectFileName
, Dict
)],
102 self
.SectFileName
= TeFile
104 OutputFile
= os
.path
.join (OutputPath
, ModuleName
+ 'SEC' + SecNum
+ Ffs
.SectionSuffix
.get(self
.SecType
))
105 OutputFile
= os
.path
.normpath(OutputFile
)
107 GenFdsGlobalVariable
.GenerateSection(OutputFile
, [self
.SectFileName
], Section
.Section
.SectionType
.get(self
.SecType
))
108 FileList
= [OutputFile
]
109 return FileList
, self
.Alignment