]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/GuidSection.py
2 # process GUIDed 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.
22 from GenFdsGlobalVariable
import GenFdsGlobalVariable
23 from CommonDataClass
.FdfClass
import GuidSectionClassObject
24 from Common
import ToolDefClassObject
26 from Common
import EdkLogger
27 from Common
.BuildToolError
import *
29 ## generate GUIDed section
32 class GuidSection(GuidSectionClassObject
) :
36 # @param self The object pointer
39 GuidSectionClassObject
.__init
__(self
)
41 ## GenSection() method
43 # Generate GUIDed section
45 # @param self The object pointer
46 # @param OutputPath Where to place output file
47 # @param ModuleName Which module this section belongs to
48 # @param SecNum Index of section
49 # @param KeyStringList Filter for inputs of section generation
50 # @param FfsInf FfsInfStatement object that contains this section data
51 # @param Dict dictionary contains macro and its value
52 # @retval tuple (Generated file name, section alignment)
54 def GenSection(self
, OutputPath
, ModuleName
, SecNum
, KeyStringList
, FfsInf
= None, Dict
= {}):
56 # Generate all section
58 self
.KeyStringList
= KeyStringList
59 self
.CurrentArchList
= GenFdsGlobalVariable
.ArchList
61 self
.Alignment
= FfsInf
.__ExtendMacro
__(self
.Alignment
)
62 self
.NameGuid
= FfsInf
.__ExtendMacro
__(self
.NameGuid
)
63 self
.SectionType
= FfsInf
.__ExtendMacro
__(self
.SectionType
)
64 self
.CurrentArchList
= [FfsInf
.CurrentArch
]
68 for Sect
in self
.SectionList
:
70 SecIndex
= '%s.%d' %(SecNum
,Index
)
71 ReturnSectList
, align
= Sect
.GenSection(OutputPath
, ModuleName
, SecIndex
, KeyStringList
,FfsInf
, Dict
)
72 if ReturnSectList
!= []:
73 for file in ReturnSectList
:
77 OutputFile
= OutputPath
+ \
82 Ffs
.SectionSuffix
['GUIDED']
83 OutputFile
= os
.path
.normpath(OutputFile
)
86 if self
.NameGuid
!= None:
87 ExternalTool
= self
.__FindExtendTool
__()
89 # If not have GUID , call default
92 if self
.NameGuid
== None :
93 GenFdsGlobalVariable
.VerboseLogger( "Use GenSection function Generate CRC32 Section")
94 GenFdsGlobalVariable
.GenerateSection(OutputFile
, SectFile
, Section
.Section
.SectionType
[self
.SectionType
])
96 OutputFileList
.append(OutputFile
)
97 return OutputFileList
, self
.Alignment
98 #or GUID not in External Tool List
99 elif ExternalTool
== None:
100 EdkLogger
.error("GenFds", GENFDS_ERROR
, "No tool found with GUID %s" % self
.NameGuid
)
103 # Call GenSection with DUMMY section type.
105 GenFdsGlobalVariable
.GenerateSection(OutputFile
+".dummy", SectFile
)
107 # Use external tool process the Output
109 InputFile
= OutputFile
+".dummy"
110 TempFile
= OutputPath
+ \
116 TempFile
= os
.path
.normpath(TempFile
)
128 GenFdsGlobalVariable
.GuidTool(TempFile
, [InputFile
], ExternalTool
, '-e')
131 # Call Gensection Add Secntion Header
134 if self
.ProcessRequired
== True:
135 Attribute
= 'PROCSSING_REQUIRED'
136 if self
.AuthStatusValid
== True:
137 Attribute
= 'AUTH_STATUS_VALID'
138 GenFdsGlobalVariable
.GenerateSection(OutputFile
, [TempFile
], Section
.Section
.SectionType
['GUIDED'],
139 Guid
=self
.NameGuid
, GuidAttr
=Attribute
)
141 OutputFileList
.append(OutputFile
)
142 return OutputFileList
, self
.Alignment
144 ## __FindExtendTool()
146 # Find location of tools to process section data
148 # @param self The object pointer
150 def __FindExtendTool__(self
):
151 # if user not specify filter, try to deduce it from global data.
152 if self
.KeyStringList
== None or self
.KeyStringList
== []:
153 Target
= GenFdsGlobalVariable
.TargetName
154 ToolChain
= GenFdsGlobalVariable
.ToolChainTag
155 ToolDb
= ToolDefClassObject
.ToolDefDict(GenFdsGlobalVariable
.WorkSpaceDir
).ToolsDefTxtDatabase
156 if ToolChain
not in ToolDb
['TOOL_CHAIN_TAG']:
157 EdkLogger
.error("GenFds", GENFDS_ERROR
, "Can not find external tool because tool tag %s is not defined in tools_def.txt!" % ToolChain
)
158 self
.KeyStringList
= [Target
+'_'+ToolChain
+'_'+self
.CurrentArchList
[0]]
159 for Arch
in self
.CurrentArchList
:
160 if Target
+'_'+ToolChain
+'_'+Arch
not in self
.KeyStringList
:
161 self
.KeyStringList
.append(Target
+'_'+ToolChain
+'_'+Arch
)
163 ToolDefinition
= ToolDefClassObject
.ToolDefDict(GenFdsGlobalVariable
.WorkSpaceDir
).ToolsDefTxtDictionary
165 for ToolDef
in ToolDefinition
.items():
166 if self
.NameGuid
== ToolDef
[1]:
167 KeyList
= ToolDef
[0].split('_')
173 if Key
in self
.KeyStringList
and KeyList
[4] == 'GUID':
175 ToolPath
= ToolDefinition
.get( Key
+ \
180 if ToolPathTmp
== None:
181 ToolPathTmp
= ToolPath
183 if ToolPathTmp
!= ToolPath
:
184 EdkLogger
.error("GenFds", GENFDS_ERROR
, "Don't know which tool to use, %s or %s ?" % (ToolPathTmp
, ToolPath
))