]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/GenFds/GuidSection.py
Fix build break caused by adding DebugAgentLib to the DXE Core.
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / GuidSection.py
CommitLineData
30fdf114
LG
1## @file\r
2# process GUIDed section generation\r
3#\r
4# Copyright (c) 2007, Intel Corporation\r
5#\r
6# All rights reserved. This program and the accompanying materials\r
7# are licensed and made available under the terms and conditions of the BSD License\r
8# which accompanies this distribution. The full text of the license may be found at\r
9# http://opensource.org/licenses/bsd-license.php\r
10#\r
11# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13#\r
14\r
15##\r
16# Import Modules\r
17#\r
18import Section\r
19import subprocess\r
20from Ffs import Ffs\r
21import os\r
22from GenFdsGlobalVariable import GenFdsGlobalVariable\r
23from CommonDataClass.FdfClass import GuidSectionClassObject\r
24from Common import ToolDefClassObject\r
25import sys\r
26from Common import EdkLogger\r
27from Common.BuildToolError import *\r
28\r
29## generate GUIDed section\r
30#\r
31#\r
32class GuidSection(GuidSectionClassObject) :\r
33\r
34 ## The constructor\r
35 #\r
36 # @param self The object pointer\r
37 #\r
38 def __init__(self):\r
39 GuidSectionClassObject.__init__(self)\r
40\r
41 ## GenSection() method\r
42 #\r
43 # Generate GUIDed section\r
44 #\r
45 # @param self The object pointer\r
46 # @param OutputPath Where to place output file\r
47 # @param ModuleName Which module this section belongs to\r
48 # @param SecNum Index of section\r
49 # @param KeyStringList Filter for inputs of section generation\r
50 # @param FfsInf FfsInfStatement object that contains this section data\r
51 # @param Dict dictionary contains macro and its value\r
52 # @retval tuple (Generated file name, section alignment)\r
53 #\r
54 def GenSection(self, OutputPath, ModuleName, SecNum, KeyStringList, FfsInf = None, Dict = {}):\r
55 #\r
56 # Generate all section\r
57 #\r
58 self.KeyStringList = KeyStringList\r
59 self.CurrentArchList = GenFdsGlobalVariable.ArchList\r
60 if FfsInf != None:\r
61 self.Alignment = FfsInf.__ExtendMacro__(self.Alignment)\r
62 self.NameGuid = FfsInf.__ExtendMacro__(self.NameGuid)\r
63 self.SectionType = FfsInf.__ExtendMacro__(self.SectionType)\r
64 self.CurrentArchList = [FfsInf.CurrentArch]\r
65\r
66 SectFile = tuple()\r
67 Index = 0\r
68 for Sect in self.SectionList:\r
69 Index = Index + 1\r
70 SecIndex = '%s.%d' %(SecNum,Index)\r
71 ReturnSectList, align = Sect.GenSection(OutputPath, ModuleName, SecIndex, KeyStringList,FfsInf, Dict)\r
72 if ReturnSectList != []:\r
73 for file in ReturnSectList:\r
74 SectFile += (file,)\r
75\r
76\r
77 OutputFile = OutputPath + \\r
78 os.sep + \\r
79 ModuleName + \\r
80 'SEC' + \\r
81 SecNum + \\r
82 Ffs.SectionSuffix['GUIDED']\r
83 OutputFile = os.path.normpath(OutputFile)\r
84\r
85 ExternalTool = None\r
86 if self.NameGuid != None:\r
87 ExternalTool = self.__FindExtendTool__()\r
88 #\r
89 # If not have GUID , call default\r
90 # GENCRC32 section\r
91 #\r
92 if self.NameGuid == None :\r
93 GenFdsGlobalVariable.VerboseLogger( "Use GenSection function Generate CRC32 Section")\r
94 GenFdsGlobalVariable.GenerateSection(OutputFile, SectFile, Section.Section.SectionType[self.SectionType])\r
95 OutputFileList = []\r
96 OutputFileList.append(OutputFile)\r
97 return OutputFileList, self.Alignment\r
98 #or GUID not in External Tool List\r
99 elif ExternalTool == None:\r
100 EdkLogger.error("GenFds", GENFDS_ERROR, "No tool found with GUID %s" % self.NameGuid)\r
101 else:\r
102 #\r
103 # Call GenSection with DUMMY section type.\r
104 #\r
105 GenFdsGlobalVariable.GenerateSection(OutputFile+".dummy", SectFile)\r
106 #\r
107 # Use external tool process the Output\r
108 #\r
109 InputFile = OutputFile+".dummy"\r
110 TempFile = OutputPath + \\r
111 os.sep + \\r
112 ModuleName + \\r
113 'SEC' + \\r
114 SecNum + \\r
115 '.tmp'\r
116 TempFile = os.path.normpath(TempFile)\r
117\r
118 ExternalToolCmd = (\r
119 ExternalTool,\r
120 '-e',\r
121 '-o', TempFile,\r
122 InputFile,\r
123 )\r
124\r
125 #\r
126 # Call external tool\r
127 #\r
128 GenFdsGlobalVariable.GuidTool(TempFile, [InputFile], ExternalTool, '-e')\r
129\r
130 #\r
131 # Call Gensection Add Secntion Header\r
132 #\r
133 Attribute = None\r
134 if self.ProcessRequired == True:\r
135 Attribute = 'PROCSSING_REQUIRED'\r
136 if self.AuthStatusValid == True:\r
137 Attribute = 'AUTH_STATUS_VALID'\r
138 GenFdsGlobalVariable.GenerateSection(OutputFile, [TempFile], Section.Section.SectionType['GUIDED'],\r
139 Guid=self.NameGuid, GuidAttr=Attribute)\r
140 OutputFileList = []\r
141 OutputFileList.append(OutputFile)\r
142 return OutputFileList, self.Alignment\r
143\r
144 ## __FindExtendTool()\r
145 #\r
146 # Find location of tools to process section data\r
147 #\r
148 # @param self The object pointer\r
149 #\r
150 def __FindExtendTool__(self):\r
151 # if user not specify filter, try to deduce it from global data.\r
152 if self.KeyStringList == None or self.KeyStringList == []:\r
153 Target = GenFdsGlobalVariable.TargetName\r
154 ToolChain = GenFdsGlobalVariable.ToolChainTag\r
155 ToolDb = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.WorkSpaceDir).ToolsDefTxtDatabase\r
156 if ToolChain not in ToolDb['TOOL_CHAIN_TAG']:\r
157 EdkLogger.error("GenFds", GENFDS_ERROR, "Can not find external tool because tool tag %s is not defined in tools_def.txt!" % ToolChain)\r
158 self.KeyStringList = [Target+'_'+ToolChain+'_'+self.CurrentArchList[0]]\r
159 for Arch in self.CurrentArchList:\r
160 if Target+'_'+ToolChain+'_'+Arch not in self.KeyStringList:\r
161 self.KeyStringList.append(Target+'_'+ToolChain+'_'+Arch)\r
162 \r
163 ToolDefinition = ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.WorkSpaceDir).ToolsDefTxtDictionary\r
164 ToolPathTmp = None\r
165 for ToolDef in ToolDefinition.items():\r
166 if self.NameGuid == ToolDef[1]:\r
167 KeyList = ToolDef[0].split('_')\r
168 Key = KeyList[0] + \\r
169 '_' + \\r
170 KeyList[1] + \\r
171 '_' + \\r
172 KeyList[2]\r
173 if Key in self.KeyStringList and KeyList[4] == 'GUID':\r
174\r
175 ToolPath = ToolDefinition.get( Key + \\r
176 '_' + \\r
177 KeyList[3] + \\r
178 '_' + \\r
179 'PATH')\r
180 if ToolPathTmp == None:\r
181 ToolPathTmp = ToolPath\r
182 else:\r
183 if ToolPathTmp != ToolPath:\r
184 EdkLogger.error("GenFds", GENFDS_ERROR, "Don't know which tool to use, %s or %s ?" % (ToolPathTmp, ToolPath))\r
185 \r
186 \r
187 return ToolPathTmp\r
188\r
189\r
190\r