]>
Commit | Line | Data |
---|---|---|
30fdf114 LG |
1 | #!/usr/bin/env python |
2 | # | |
3 | # | |
40d841f6 LG |
4 | # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR> |
5 | # This program and the accompanying materials | |
30fdf114 LG |
6 | # are licensed and made available under the terms and conditions of the BSD License |
7 | # which accompanies this distribution. The full text of the license may be found at | |
8 | # http://opensource.org/licenses/bsd-license.php | |
9 | # | |
10 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, | |
11 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. | |
12 | ||
13 | ||
14 | """ This program converts EDK II MSA files into EDK II Extended INF format files """ | |
15 | ||
16 | import os, re, sys, fnmatch, xml.dom.minidom | |
17 | from optparse import OptionParser | |
18 | from AutoGenExterns import * | |
19 | from Common.XmlRoutines import * # XmlParseFile, XmlElement, XmlAttribute, XmlList, XmlElementData, XmlNode | |
20 | from Common.EdkIIWorkspace import * | |
b36d134f | 21 | from Common.BuildVersion import gBUILD_VERSION |
30fdf114 | 22 | |
b36d134f | 23 | versionNumber = ("0.9" + " " + gBUILD_VERSION) |
30fdf114 | 24 | __version__ = "%prog Version " + versionNumber |
52302d4d | 25 | __copyright__ = "Copyright (c) 2007 - 2010, Intel Corporation All rights reserved." |
30fdf114 LG |
26 | |
27 | commonHeaderFilename = "CommonHeader.h" | |
28 | entryPointFilename = "EntryPoint.c" | |
29 | ||
30 | AutoGenLibraryMapping = { | |
31 | "HiiLib":"HiiLibFramework", | |
32 | "EdkIfrSupportLib":"IfrSupportLibFramework", | |
33 | "EdkScsiLib":"ScsiLib", | |
34 | "EdkUsbLib":"UsbLib", | |
35 | "EdkFvbServiceLib":"FvbServiceLib", | |
36 | "EdkGraphicsLib":"GraphicsLib" | |
37 | } | |
38 | ||
39 | def myOptionParser(): | |
40 | """ Argument Parser """ | |
41 | usage = "%prog [options] -f input_filename" | |
42 | parser = OptionParser(usage=usage,description=__copyright__,version="%prog " + str(versionNumber)) | |
43 | parser.add_option("-f", "--file", dest="filename", help="Name of MSA file to convert") | |
44 | parser.add_option("-o", "--output", dest="outfile", help="Specific Name of the INF file to create, otherwise it is the MSA filename with the extension repalced.") | |
45 | parser.add_option("-a", "--auto", action="store_true", dest="autowrite", default=False, help="Automatically create output files and write the INF file") | |
46 | parser.add_option("-i", "--interactive", action="store_true", dest="interactive", default=False, help="Set Interactive mode, user must approve each change.") | |
47 | parser.add_option("-q", "--quiet", action="store_const", const=0, dest="verbose", help="Do not print any messages, just return either 0 for succes or 1 for failure") | |
48 | parser.add_option("-v", "--verbose", action="count", dest="verbose", help="Do not print any messages, just return either 0 for succes or 1 for failure") | |
49 | parser.add_option("-d", "--debug", action="store_true", dest="debug", default=False, help="Enable printing of debug messages.") | |
50 | parser.add_option("-c", "--convert", action="store_true", dest="convert", default=False, help="Convert package: OldMdePkg->MdePkg EdkModulePkg->MdeModulePkg.") | |
51 | parser.add_option("-e", "--event", action="store_true", dest="event", default=False, help="Enable handling of Exit Boot Services & Virtual Address Changed Event") | |
52 | parser.add_option("-m", "--manual", action="store_true", dest="manual", default=False, help="Generate CommonHeader.txt, user picks up & copy it to a module common header") | |
53 | parser.add_option("-w", "--workspace", dest="workspace", default=str(os.environ.get('WORKSPACE')), help="Specify workspace directory.") | |
54 | (options, args) = parser.parse_args(sys.argv[1:]) | |
55 | ||
56 | return options,args | |
57 | ||
58 | ||
59 | def openDatabase(f): | |
60 | """ Parse XML in the FrameworkDatabase.db file pointed to by f """ | |
61 | if (options.debug and options.verbose > 1): | |
62 | print "Opening the database file:", f | |
63 | if os.path.exists(f): | |
64 | fdb = XmlParseFile(f) | |
65 | else: | |
66 | return "None" | |
67 | return fdb | |
68 | ||
69 | def openSpd(s): | |
70 | """ Parse XML in the SPD file pointed to by s """ | |
71 | if (options.debug and options.verbose > 1): | |
72 | print "Opening the SPD file:", s | |
73 | if os.path.exists(s): | |
74 | spd = XmlParseFile(s) | |
75 | else: | |
76 | return "None" | |
77 | return spd | |
78 | ||
79 | def openMsa(m): | |
80 | """ Parse XML in the MSA file pointed to by m """ | |
81 | if (options.debug and options.verbose > 1): | |
82 | print "Opening the MSA file:", m | |
83 | if os.path.exists(m): | |
84 | msa = XmlParseFile(m) | |
85 | else: | |
86 | return "None" | |
87 | return msa | |
88 | ||
89 | def AddGuid(ArchList, CName, Usage): | |
90 | """ Add a GUID to the Architecture array that the GUID is valid for. """ | |
91 | if "IA32" in ArchList: | |
92 | GuidCNameIa32.insert(0, str(" %-45s # %s" % (CName, Usage))) | |
93 | if "X64" in ArchList: | |
94 | GuidCNameX64.insert(0, str(" %-45s # %s" % (CName, Usage))) | |
95 | if "IPF" in ArchList: | |
96 | GuidCNameIPF.insert(0, str(" %-45s # %s" % (CName, Usage))) | |
97 | if "EBC" in ArchList: | |
98 | GuidCNameEBC.insert(0, str(" %-45s # %s" % (CName, Usage))) | |
99 | if "ALL" in ArchList: | |
100 | GuidCName.insert(0, str(" %-45s # %s" % (CName, Usage))) | |
101 | ||
102 | ||
103 | def removeDups(CN, ListName): | |
104 | """ Remove Duplicate Entries from the Guid List passed in """ | |
105 | for Entry in ListName[:]: | |
106 | if " " + CN + " " in Entry: | |
107 | if (options.verbose > 1): | |
108 | print "Removing C Name %s Entry from Guids List." % (CN) | |
109 | ListName.remove(Entry) | |
110 | ||
111 | def chkArch(Archs): | |
112 | """ Process the supported architectures passed in to combine if possible """ | |
113 | Archs = Archs.upper() | |
114 | if (("IA32" in Archs) & ("X64" in Archs) & ("IPF" in Archs) & ("EBC" in Archs)): | |
115 | Archs = "ALL" | |
116 | if (len(Archs) == 0): | |
117 | Archs = "ALL" | |
118 | return Archs | |
119 | ||
120 | def saveSourceFile(moduleDir, sourceFilename, sourceFileContents): | |
121 | newFilename = os.path.join(moduleDir, sourceFilename) | |
122 | ||
123 | try: | |
124 | f = open(newFilename, "w+") | |
125 | f.write(sourceFileContents) | |
126 | f.close() | |
127 | except: | |
128 | print "IO error in saving %s" % sourceFilename | |
129 | ||
130 | return sourceFilename | |
131 | ||
132 | def openSourceFile(moduleDir, sourceFilename): | |
133 | newFilename = os.path.join(moduleDir, sourceFilename) | |
134 | sourceFileContents = "" | |
135 | try: | |
136 | f = open(newFilename, "r") | |
137 | sourceFileContents = f.read() | |
138 | f.close() | |
139 | except: | |
140 | print "IO error in opening %s" % sourceFilename | |
141 | ||
142 | return sourceFileContents | |
143 | ||
144 | def MatchOption(eline, ToolChainFamily, Targets, Archs, ToolCode, Value): | |
145 | IDs = eline.split("_") | |
146 | ||
147 | if len(IDs) < 5: | |
148 | return [] | |
149 | ||
150 | MatchedTargets = [] | |
151 | if (Targets[0] == "*") or IDs[0] in Targets: | |
152 | MatchedTargets.append(IDs[0]) | |
153 | elif IDs[0] == "*": | |
154 | MatchedTargets = Targets | |
155 | ||
156 | MatchedArchs = [] | |
157 | if Archs[0] == "*" or IDs[2] in Archs: | |
158 | MatchedArchs.append(IDs[2]) | |
159 | elif IDs[2] == "*": | |
160 | MatchedArchs = Archs | |
161 | ||
162 | if IDs[3] != ToolCode and IDs[3] != "*": | |
163 | return [] | |
164 | ||
165 | result = [] | |
166 | for arch in MatchedArchs: | |
167 | for target in MatchedTargets: | |
168 | line = "%s:%s_%s_%s_%s_FLAGS = %s" % (ToolChainFamily, target, IDs[1], arch, ToolCode, Value) | |
169 | result.append(line) | |
170 | ||
171 | return result | |
172 | ||
173 | def main(): | |
174 | ||
175 | AutoGenSource = "" | |
176 | AutoGenHeader = "" | |
177 | AutoGenDeclaration = "" | |
178 | AutoGenModuleFolder = None | |
179 | ||
180 | workspace = "" | |
181 | ||
182 | if (options.workspace == None): | |
183 | print "ERROR: E0000: WORKSPACE not defined.\n Please set the WORKSPACE environment variable to the location of the EDK II install directory." | |
184 | sys.exit(1) | |
185 | else: | |
186 | workspace = options.workspace | |
187 | if (options.debug): | |
188 | print "Using Workspace:", workspace | |
189 | ||
190 | try: | |
191 | options.verbose +=1 | |
192 | except: | |
193 | options.verbose = 1 | |
194 | pass | |
195 | ||
196 | ||
197 | FdbPath = os.path.join(workspace, "Conf") | |
198 | FdbPath = os.path.join(FdbPath, "FrameworkDatabase.db") | |
199 | if os.path.exists(FdbPath): | |
200 | FdbFile = FdbPath | |
201 | else: | |
202 | print "ERROR: E0001: WORKSPACE does not contain the FrameworkDatabase File.\n Please run EdkSetup from the EDK II install directory.\n" | |
203 | sys.exit(1) | |
204 | ||
205 | Fdb = openDatabase(FdbFile) | |
206 | if (Fdb == 'None'): | |
207 | print "ERROR: E0002 Could not open the Framework Database file:", FdbFile | |
208 | sys.exit(1) | |
209 | ||
210 | if (options.debug): | |
211 | print "FrameworkDataBase.db file:", FdbFile | |
212 | ||
213 | # | |
214 | InitializeAutoGen(workspace, Fdb) | |
215 | ||
216 | if (options.filename): | |
217 | filename = options.filename | |
218 | if ((options.verbose > 1) | (options.autowrite)): | |
219 | print "Filename:", filename | |
220 | else: | |
221 | print "ERROR: E0001 - You must specify an input filename" | |
222 | sys.exit(1) | |
223 | ||
224 | if (options.outfile): | |
225 | outputFile = options.outfile | |
226 | else: | |
227 | outputFile = filename.replace('.msa', '.inf') | |
228 | ||
229 | if ((options.verbose > 2) or (options.debug)): | |
230 | print "Output Filename:", outputFile | |
231 | ||
232 | Msa = openMsa(filename) | |
233 | if (Msa == 'None'): | |
234 | ## Maybe developer think WORKSPACE macro is the root directory of file name | |
235 | ## So we will try to add WORKSPACE path into filename | |
236 | MsaFileName = "" | |
237 | MsaFileName = os.path.join(workspace, filename) | |
238 | Msa = openMsa(MsaFileName) | |
239 | if (Msa == 'None'): | |
240 | print "ERROR: E0002: Could not open the file:", filename | |
241 | sys.exit(1) | |
242 | ||
243 | AutoGenModuleFolder = os.path.dirname(filename) | |
244 | ||
245 | MsaHeader = "/ModuleSurfaceArea/MsaHeader/" | |
246 | MsaDefs = "/ModuleSurfaceArea/ModuleDefinitions/" | |
247 | BaseName = str(XmlElement(Msa, MsaDefs + "OutputFileBasename")).strip() | |
248 | ||
249 | if (len(BaseName) < 1): | |
250 | BaseName = str(XmlElement(Msa, MsaHeader + "BaseName")).strip() | |
251 | BaseName = re.sub(' ', '_', BaseName) | |
252 | ||
253 | GuidValue = str(XmlElement(Msa, MsaHeader + "GuidValue")).strip() | |
254 | VerString = str(XmlElement(Msa, MsaHeader + "Version")).strip() | |
255 | ModType = str(XmlElement(Msa, MsaHeader + "ModuleType")).strip() | |
256 | CopyRight = str(XmlElement(Msa, MsaHeader + "Copyright")).strip() | |
257 | Abstract = str(XmlElement(Msa, MsaHeader + "Abstract")).strip() | |
258 | Description = str(XmlElement(Msa, MsaHeader + "Description")).strip().replace(" ", " ").replace(" ", " ").replace(" ", " ") | |
259 | if not CopyRight.find("2007"): | |
260 | CopyRight = CopyRight.replace("2006", "2007") | |
261 | License = str(XmlElement(Msa, MsaHeader + "License")).strip().replace(" ", " ") | |
262 | MsaDefs = "/ModuleSurfaceArea/ModuleDefinitions/" | |
263 | BinModule = "" | |
264 | try: | |
265 | BinModule = str(XmlElement(Msa, MsaDefs + "BinaryModule")).strip() | |
266 | except: | |
267 | pass | |
268 | ||
269 | SupportedArchitectures = "" | |
270 | try: | |
271 | SupportedArchitectures = str(XmlElement(Msa, MsaDefs + "SupportedArchitectures")).strip() | |
272 | except: | |
273 | pass | |
274 | ||
275 | DefinesComments = [] | |
276 | if (len(SupportedArchitectures) > 0): | |
277 | DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n") | |
278 | DefinesComments.append("# VALID_ARCHITECTURES = " + SupportedArchitectures + "\n") | |
279 | DefinesComments.append("#\n") | |
280 | ||
281 | MsaExtern = "/ModuleSurfaceArea/Externs/" | |
282 | PcdIsDriver = "" | |
283 | try: | |
284 | PcdIsDriver = str(XmlElement(Msa, MsaExtern + "PcdIsDriver")).strip() | |
285 | except: | |
286 | pass | |
287 | ||
288 | SpecList = [] | |
289 | List = [] | |
290 | try: | |
291 | List = XmlList(Msa, MsaExtern + "Specification") | |
292 | except: | |
293 | pass | |
294 | ||
295 | if (len(List) > 0): | |
296 | for spec in List[:]: | |
297 | SpecList.insert(0, str(XmlElementData(spec)).strip()) | |
298 | ||
299 | DriverModules = [] | |
300 | LibraryModules = [] | |
301 | Externlist = [] | |
302 | Flag = (DefinesComments == []) | |
303 | ||
304 | # Data structure to insert autogen code | |
305 | AutoGenDriverModel = [] | |
306 | AutoGenExitBootServices = [] | |
307 | AutoGenVirtualAddressChanged = [] | |
308 | AutoGenEntryPoint = "" | |
309 | AutoGenUnload = "" | |
310 | AutoGenGuid = [] | |
311 | AutoGenLibClass = [] | |
312 | AutoGenPackage = [] | |
313 | AutoGenSourceFiles = [] | |
314 | OldEntryPoint = "" | |
315 | OldUnload = "" | |
316 | ||
317 | try: | |
318 | Externlist = XmlList(Msa, MsaExtern + "Extern") | |
319 | except: | |
320 | pass | |
321 | ||
322 | if (len(Externlist) > 0): | |
323 | if (options.debug and options.verbose > 2): | |
324 | print "In Extern Parsing Routine" | |
325 | for extern in Externlist: | |
326 | EntryPoint = "" | |
327 | Unload = "" | |
328 | DBinding = "" | |
329 | CompName = "" | |
330 | Diag = "" | |
331 | Config = "" | |
332 | Constr = "" | |
333 | Destr = "" | |
334 | CallBack = "" | |
335 | lFlag = False | |
336 | AutoGenDriverModelItem = [] | |
337 | try: | |
338 | EntryPoint = str(XmlElementData(extern.getElementsByTagName("ModuleEntryPoint")[0])).strip() | |
339 | AutoGenEntryPoint = EntryPoint | |
340 | #DriverModules.append(" %-30s = %s\n" % ("ENTRY_POINT" , EntryPoint)) | |
341 | except: | |
342 | pass | |
343 | ||
344 | try: | |
345 | Unload = str(XmlElementData(extern.getElementsByTagName("ModuleUnloadImage")[0])).strip() | |
346 | AutoGenUnload = Unload | |
347 | DriverModules.append(" %-30s = %s\n" % ("UNLOAD_IMAGE", Unload)) | |
348 | except: | |
349 | pass | |
350 | ||
351 | try: | |
352 | DBinding = str(XmlElementData(extern.getElementsByTagName("DriverBinding")[0])).strip() | |
353 | AutoGenDriverModelItem.append("&" + DBinding) | |
354 | DefinesComments.append("# %-29s = %-45s\n" % ("DRIVER_BINDING", DBinding)) | |
355 | lFlag = True | |
356 | except: | |
357 | pass | |
358 | ||
359 | try: | |
360 | CompName = str(XmlElementData(extern.getElementsByTagName("ComponentName")[0])).strip() | |
361 | AutoGenDriverModelItem.append("&" + CompName) | |
362 | DefinesComments.append("# %-29s = %-45s\n" % ("COMPONENT_NAME", CompName)) | |
363 | lFlag = True | |
364 | except: | |
365 | if lFlag: | |
366 | AutoGenDriverModelItem.append("NULL") | |
367 | pass | |
368 | ||
369 | try: | |
370 | Config = str(XmlElementData(extern.getElementsByTagName("DriverConfig")[0])).strip() | |
371 | AutoGenDriverModelItem.append("&" + Config) | |
372 | DefinesComments.append("# %-29s = %-45s\n" % ("DRIVER_CONFIG", Config)) | |
373 | lFlag = True | |
374 | except: | |
375 | if lFlag: | |
376 | AutoGenDriverModelItem.append("NULL") | |
377 | pass | |
378 | ||
379 | try: | |
380 | Diag = str(XmlElementData(extern.getElementsByTagName("DriverDiag")[0])).strip() | |
381 | AutoGenDriverModelItem.append("&" + Diag) | |
382 | DefinesComments.append("# %-29s = %-45s\n" % ("DRIVER_DIAG", Diag)) | |
383 | lFlag = True | |
384 | except: | |
385 | if lFlag: | |
386 | AutoGenDriverModelItem.append("NULL") | |
387 | pass | |
388 | ||
389 | if len(AutoGenDriverModelItem) > 0: | |
390 | AutoGenDriverModel.append(AutoGenDriverModelItem) | |
391 | ||
392 | try: | |
393 | Constr = str(XmlElementData(extern.getElementsByTagName("Constructor")[0])).strip() | |
394 | LibraryModules.append(" %-30s = %s\n" % ("CONSTRUCTOR", Constr)) | |
395 | except: | |
396 | pass | |
397 | ||
398 | try: | |
399 | Destr = str(XmlElementData(extern.getElementsByTagName("Destructor")[0])).strip() | |
400 | LibraryModules.append(" %-30s = %s\n" % ("DESTRUCTOR", Destr)) | |
401 | except: | |
402 | pass | |
403 | ||
404 | try: | |
405 | CallBack = str(XmlElement(extern, "Extern/SetVirtualAddressMapCallBack")).strip() | |
406 | if CallBack != "": | |
407 | AutoGenVirtualAddressChanged.append(CallBack) | |
408 | DefinesComments.append("# %-29s = %-45s\n" % ("VIRTUAL_ADDRESS_MAP_CALLBACK", CallBack)) | |
409 | lFlag = True | |
410 | except: | |
411 | ||
412 | pass | |
413 | ||
414 | try: | |
415 | CallBack = str(XmlElement(extern, "Extern/ExitBootServicesCallBack")).strip() | |
416 | if CallBack != "": | |
417 | AutoGenExitBootServices.append(CallBack) | |
418 | DefinesComments.append("# %-29s = %-45s\n" % ("EXIT_BOOT_SERVICES_CALLBACK", CallBack)) | |
419 | lFlag = True | |
420 | except: | |
421 | pass | |
422 | ||
423 | ||
424 | Flag = False | |
425 | ||
426 | """ Get the Module's custom build options """ | |
427 | MBOlines = [] | |
428 | MBO = "/ModuleSurfaceArea/ModuleBuildOptions/Options/Option" | |
429 | mboList = [] | |
430 | try: | |
431 | mboList = XmlList(Msa, MBO) | |
432 | except: | |
433 | pass | |
434 | ||
435 | if (len(mboList) > 0): | |
436 | for Option in mboList: | |
437 | Targets = [] | |
438 | Archs = [] | |
439 | ||
440 | bt = "" | |
441 | try: | |
442 | bt = str(Option.getAttribute("BuildTargets")) | |
443 | except: | |
444 | pass | |
445 | ||
446 | if (len(bt) > 0): | |
447 | if (re.findall(" ", bt) > 0): | |
448 | Targets = bt.split() | |
449 | else: | |
450 | Targets.insert(0, bt) | |
451 | else: | |
452 | Targets.insert(0, "*") | |
453 | ||
454 | if (options.debug and options.verbose > 2): | |
455 | print "Targets", len(Targets), Targets | |
456 | ||
457 | pro = "" | |
458 | try: | |
459 | pro = Option.getAttribute("SupArchList") | |
460 | if (re.findall(" ", pro) > 0): | |
461 | Archs = pro.split() | |
462 | elif (re.findall(",", pro) > 0): | |
463 | Archs = pro.split(",") | |
464 | except: | |
465 | pass | |
466 | ||
467 | if (len(pro) == 0): | |
468 | Archs.insert(0, "*") | |
469 | ||
470 | if (options.debug and options.verbose > 2): | |
471 | print "Archs", len(Archs), Archs | |
472 | ||
473 | ToolCode = "" | |
474 | try: | |
475 | ToolCode = str(Option.getAttribute("ToolCode")) | |
476 | except: | |
477 | pass | |
478 | ||
479 | if (len(ToolCode) == 0): | |
480 | ToolCode="*" | |
481 | ||
482 | value = "" | |
483 | try: | |
484 | value = str(XmlElementData(Option)) | |
485 | except: | |
486 | pass | |
487 | Tags = [] | |
488 | TagName = "" | |
489 | try: | |
490 | TagName = str(Option.getAttribute("TagName")) | |
491 | except: | |
492 | pass | |
493 | ||
494 | if (len(TagName) > 0) : | |
495 | if (options.debug and options.verbose > 2): | |
496 | print "TagName was defined:", TagName | |
497 | Tags.insert(0, TagName) | |
498 | else: | |
499 | if (options.debug and options.verbose > 2): | |
500 | print "TagName was NOT defined!" | |
501 | TagName = "*" | |
502 | Tags.insert(0, "*") | |
503 | ||
504 | Family = "" | |
505 | try: | |
506 | Family = str(Option.getAttribute("ToolChainFamily")).strip() | |
507 | except: | |
508 | pass | |
509 | ||
510 | if (len(Family) > 0): | |
511 | if (options.debug): | |
512 | print "Searching tools_def.txt for Tool Tags that belong to:", Family, "family" | |
513 | TCF = [] | |
514 | tdFile = "" | |
515 | tdPath = os.path.join(workspace, "Tools") | |
516 | tdPath = os.path.join(tdPath, "Conf") | |
517 | tdPath = os.path.join(tdPath, "tools_def.txt") | |
518 | tdPath = tdPath.replace("\\", "/") | |
519 | if os.path.exists(tdPath): | |
520 | tdFile = tdPath | |
521 | else: | |
522 | tdPath = os.path.join(workspace, "Conf") | |
523 | tdPath = os.path.join(tdPath, "tools_def.txt") | |
524 | if os.path.exists(tdPath): | |
525 | tdFile = tdPath | |
526 | else: | |
527 | print "ERROR: E0001: WORKSPACE does not contain the tools_def.txt File.\n Please run EdkSetup from the EDK II install directory.\n" | |
528 | sys.exit(1) | |
529 | ||
530 | if (options.debug and options.verbose > 2): | |
531 | print "Opening:", tdFile | |
532 | ||
533 | TagNameList = [] | |
534 | tools_def = open(tdFile, "r") | |
535 | for tdline in tools_def: | |
536 | if "# " in tdline: | |
537 | continue | |
538 | if "FAMILY" in tdline: | |
539 | if (options.debug and options.verbose > 2): | |
540 | print "Testing for FAMILY:", Family, "in the line:", tdline.strip() | |
541 | if Family in tdline: | |
542 | enter = tdline.split("=")[0] | |
543 | if (options.debug and options.verbose > 2): | |
544 | print "Adding TNL:", tdline | |
545 | TagNameList.insert(0, enter) | |
546 | tools_def.close() | |
547 | ||
548 | if (options.debug and options.verbose > 2): | |
549 | print "TagNameList:", TagNameList | |
550 | ||
551 | olinesSet = {} | |
552 | for eline in TagNameList: | |
553 | if "# " in eline: | |
554 | continue | |
555 | if (options.debug and options.verbose > 2): | |
556 | print "ToolsDef entry:", eline | |
557 | ||
558 | olines = MatchOption(eline, Family, Targets, Archs, ToolCode, value) | |
559 | for oline in olines: | |
560 | olinesSet[oline] = 1 | |
561 | ||
562 | for oline in olinesSet: | |
563 | if (options.debug and options.verbose > 2): | |
564 | print "Adding:", str(oline) | |
565 | MBOlines.insert(0, oline) | |
566 | else: | |
567 | for targ in Targets: | |
568 | for arch in Archs: | |
569 | oline = " %s_%s_%s_%s_FLAGS = %s" % (targ, Tags[0], arch, str(ToolCode), str(Value)) | |
570 | if (options.debug and options.verbose > 2): | |
571 | print "Adding:", str(oline) | |
572 | MBOlines.insert(0, oline) | |
573 | ||
574 | ||
575 | ||
576 | ||
577 | for tag in Tags: | |
578 | for targ in Targets: | |
579 | for arch in Archs: | |
580 | oline = " " + str(targ) + "_" + str(tag) + "_" + str(arch) + "_" + str(ToolCode) + "_FLAGS = " + str(value) | |
581 | if (options.debug and options.verbose > 2): | |
582 | print "Adding:", str(oline) | |
583 | #MBOlines.insert(0, oline) | |
584 | ||
585 | ||
586 | """ Get the Library Class information """ | |
587 | MsaLcDefs = "/ModuleSurfaceArea/LibraryClassDefinitions/LibraryClass" | |
588 | LcDefList = [] | |
589 | try: | |
590 | LcDefList = XmlList(Msa, MsaLcDefs) | |
591 | except: | |
592 | pass | |
593 | ||
594 | IamLibrary = [] | |
595 | LibClassList = [] | |
596 | LibClassListIa32 = [] | |
597 | LibClassListX64 = [] | |
598 | LibClassListIpf = [] | |
599 | LibClassListEbc = [] | |
600 | ||
601 | ||
602 | if (len(LcDefList) > 0): | |
603 | for Lc in LcDefList: | |
604 | lcKeyword = "" | |
605 | try: | |
606 | lcKeyword = str(XmlElementData(Lc.getElementsByTagName("Keyword")[0])) | |
607 | except: | |
608 | raise SyntaxError, "The MSA is not correctly formed, a Library Class Keyword Element is required" | |
609 | ||
610 | lcUsage = "" | |
611 | try: | |
612 | lcUsage = str(XmlAttribute(Lc, "Usage")) | |
613 | except: | |
614 | raise SyntaxError, "The MSA is not correctly formed, a Usage Attribute is required for all Library Class Elements" | |
615 | ||
616 | Archs = "" | |
617 | try: | |
618 | Archs = str(XmlAttribute(Lc, "SupArchList")) | |
619 | except: | |
620 | pass | |
621 | ||
622 | Archs = chkArch(Archs) | |
623 | ||
624 | if (options.debug and options.verbose > 2): | |
625 | print "Attr: ", lcUsage, lcKeyword, Archs | |
626 | ||
627 | if (options.convert): | |
628 | lcKeyword = AutoGenLibraryMapping.get(lcKeyword, lcKeyword) | |
629 | ||
630 | if re.findall("PRODUCED", lcUsage, re.IGNORECASE): | |
631 | try: | |
632 | lcSupModList = "" | |
633 | ||
634 | try: | |
635 | lcSupModList = str(XmlAttribute(Lc, "SupModuleList")) | |
636 | except: | |
637 | lcSupModList = "" | |
638 | pass | |
639 | ||
640 | lcLine = lcKeyword | |
641 | AutoGenLibClass.append(lcKeyword) | |
642 | if len(lcSupModList) > 0: | |
643 | lcLine = lcLine + "|" + lcSupModList | |
644 | IamLibrary.insert(0, lcLine) | |
645 | except: | |
646 | pass | |
647 | elif lcKeyword != "UefiDriverModelLib": | |
648 | AutoGenLibClass.append(lcKeyword) | |
649 | # This section handles the library classes that are CONSUMED | |
650 | if "IA32" in Archs: | |
651 | LibClassListIa32.insert(0, lcKeyword) | |
652 | if "X64" in Archs: | |
653 | LibClassListX64.insert(0, lcKeyword) | |
654 | if "IPF" in Archs: | |
655 | LibClassListIpf.insert(0, lcKeyword) | |
656 | if "EBC" in Archs: | |
657 | LibClassListEbc.insert(0, lcKeyword) | |
658 | if "ALL" in Archs: | |
659 | LibClassList.insert(0, lcKeyword) | |
660 | if len(AutoGenDriverModel) > 0 and "UefiLib" not in LibClassList: | |
661 | AutoGenLibClass.append("UefiLib") | |
662 | LibClassList.insert(0, "UefiLib") | |
663 | ||
664 | AutoGenDxsFiles = [] | |
665 | """ Get the Source File list """ | |
666 | SrcFilenames = [] | |
667 | SrcFilenamesIa32 = [] | |
668 | SrcFilenamesX64 = [] | |
669 | SrcFilenamesIpf = [] | |
670 | SrcFilenamesEbc = [] | |
671 | SrcFiles = "/ModuleSurfaceArea/SourceFiles/Filename" | |
672 | SrcList = [] | |
673 | try: | |
674 | SrcList = XmlList(Msa, SrcFiles) | |
675 | except: | |
676 | pass | |
677 | ||
678 | if (len(SrcList) > 0): | |
679 | for fn in SrcList: | |
680 | file = "" | |
681 | Archs = "" | |
682 | ||
683 | try: | |
684 | Archs = fn.getAttribute("SupArchList") | |
685 | except: | |
686 | pass | |
687 | ||
688 | Archs = chkArch(Archs) | |
689 | ||
690 | try: | |
691 | file = str(XmlElementData(fn)) | |
692 | except: | |
693 | pass | |
694 | ||
695 | if file.endswith(".dxs"): | |
696 | AutoGenDxsFiles.append((file, Archs)) | |
697 | else: | |
698 | AutoGenSourceFiles.append(file) | |
699 | if "IA32" in Archs: | |
700 | SrcFilenamesIa32.insert(0, file) | |
701 | if "X64" in Archs: | |
702 | SrcFilenamesX64.insert(0, file) | |
703 | if "IPF" in Archs: | |
704 | SrcFilenamesIpf.insert(0, file) | |
705 | if "EBC" in Archs: | |
706 | SrcFilenamesEbc.insert(0, file) | |
707 | if "ALL" in Archs: | |
708 | SrcFilenames.insert(0, file) | |
709 | ||
710 | """ Package Dependency section """ | |
711 | DbPkgList = "/FrameworkDatabase/PackageList/Filename" | |
712 | WorkspacePkgs = [] | |
713 | try: | |
714 | WorkspacePkgs = XmlList(Fdb, DbPkgList) | |
715 | except: | |
716 | print "Could not tet the package data from the database" | |
717 | sys.exit(1) | |
718 | ||
719 | PkgDb = [] | |
720 | HeaderLocations = [] | |
721 | ||
722 | if (options.debug and options.verbose > 1): | |
723 | print "Found %s packages in the WORKSPACE" % (len(WorkspacePkgs)) | |
724 | ||
725 | Dirs = [] | |
726 | GuidDecls = [] | |
727 | if (len(WorkspacePkgs) > 0): | |
728 | SpdHeader = "/PackageSurfaceArea/SpdHeader/" | |
729 | for Pkg in WorkspacePkgs[:]: | |
730 | PackageGuid = "" | |
731 | PackageVersion = "" | |
732 | file = "" | |
733 | try: | |
734 | file = str(XmlElementData(Pkg)) | |
735 | except: | |
736 | pass | |
737 | ||
738 | if (options.debug and options.verbose > 2): | |
739 | print "PKG:", file | |
740 | ||
741 | if fnmatch.fnmatch(file, "*.dec"): | |
742 | print "parsing " + os.path.join(workspace, file) | |
743 | PackageGuid = "" | |
744 | PackageVersion = "" | |
745 | try: | |
746 | Lines = open(os.path.join(workspace, file)).readlines() | |
747 | except: | |
748 | print "Could not parse the Package file:", file | |
749 | sys.exit(1) | |
750 | ||
751 | for Line in Lines: | |
752 | Line = Line.split("#")[0] | |
753 | Items = Line.split("=") | |
754 | if len(Items) != 2: | |
755 | continue | |
756 | ||
757 | Key = Items[0].strip().upper() | |
758 | if Key == "PACKAGE_GUID": | |
759 | PackageGuid = Items[1].strip() | |
760 | if Key == "PACKAGE_VERSION": | |
761 | PackageVersion = Items[1].strip() | |
762 | ||
763 | else: | |
764 | Spd = openSpd(os.path.join(workspace, file)) | |
765 | if (Spd == 'None'): | |
766 | print "Could not parse the Package file:", file | |
767 | sys.exit(1) | |
768 | ||
769 | path = os.path.split(file)[0] | |
770 | file = file.replace(".nspd", ".dec") | |
771 | file = file.replace(".spd", ".dec") | |
772 | ||
773 | try: | |
774 | PackageGuid = str(XmlElement(Spd, SpdHeader + "GuidValue")) | |
775 | except: | |
776 | pass | |
777 | ||
778 | try: | |
779 | PackageVersion = str(XmlElement(Spd, SpdHeader + "Version")) | |
780 | except: | |
781 | pass | |
782 | ||
783 | file = file + "|" + PackageGuid + "|" + PackageVersion | |
784 | PkgDb.insert(0, file) | |
785 | ||
786 | GuidEntries = [] | |
787 | try: | |
788 | GuidEntries = XmlList(Spd, "/PackageSurfaceArea/GuidDeclarations/Entry") | |
789 | except: | |
790 | pass | |
791 | ||
792 | if (len(GuidEntries) > 0): | |
793 | for Entry in GuidEntries[:]: | |
794 | try: | |
795 | GuidDecls.append(str(XmlElementData(Entry.getElementsByTagName("C_Name")[0])).strip()) | |
796 | except: | |
797 | pass | |
798 | ||
799 | ||
800 | pHdrs = [] | |
801 | try: | |
802 | pHdrs = XmlList(Spd, "/PackageSurfaceArea/PackageHeaders/IncludePkgHeader") | |
803 | except: | |
804 | pass | |
805 | ||
806 | if (len(pHdrs) > 0): | |
807 | for Hdr in pHdrs[:]: | |
808 | try: | |
809 | ModTypeList = str(Hdr.getAttribute("ModuleType")) | |
810 | if (ModType in ModTypeList): | |
811 | HeaderName= str(XmlElementData(Hdr))[0] | |
812 | Dirs.insert(0, os.path.join(packagepath,str(os.path.split(HeaderName)))) | |
813 | except: | |
814 | pass | |
815 | ||
816 | # Get the Guid:Header from the Packages | |
817 | SpdLcDec = "/PackageSurfaceArea/LibraryClassDeclarations/LibraryClass" | |
818 | lcList = [] | |
819 | try: | |
820 | lcList = XmlList(Spd, SpdLcDec) | |
821 | except: | |
822 | pass | |
823 | ||
824 | if (len(lcList) > 0): | |
825 | for Lc in lcList[:]: | |
826 | Name = "" | |
827 | try: | |
828 | Name = Lc.getAttribute("Name") | |
829 | except: | |
830 | pass | |
831 | ||
832 | Header = "" | |
833 | try: | |
834 | Header = XmlElementData(Lc.getElementsByTagName("IncludeHeader")[0]) | |
835 | except: | |
836 | pass | |
837 | ||
838 | if ((len(Name) > 0) and (len(Header) > 0)): | |
839 | line = Name + "|" + os.path.join(path, Header) | |
840 | if (options.debug and options.verbose > 2): | |
841 | print "Adding:", line | |
842 | HeaderLocations.insert(0, line) | |
843 | ||
844 | ishList = [] | |
845 | try: | |
846 | IndStdHeaders = "/PackageSurfaceArea/IndustryStdIncludes/IndustryStdHeader" | |
847 | ishList = XmlList(Spd, IndStdHeaders) | |
848 | except: | |
849 | pass | |
850 | ||
851 | if (len(ishList) > 0): | |
852 | for Lc in ishList[:]: | |
853 | Name = "" | |
854 | try: | |
855 | Name = str(Lc.getAttribute("Name")).strip() | |
856 | except: | |
857 | pass | |
858 | ||
859 | Header = "" | |
860 | try: | |
861 | Header = str(XmlElementData(Lc.getElementsByTagName("IncludeHeader")[0])).strip() | |
862 | except: | |
863 | pass | |
864 | ||
865 | if ((len(Name) > 0) and (len(Header) > 0)): | |
866 | line = Name + "|" + os.path.join(path, Header) | |
867 | HeaderLocations.insert(0, str(line)) | |
868 | ||
869 | PkgList = [] | |
870 | PkgListIa32 = [] | |
871 | PkgListX64 = [] | |
872 | PkgListIpf = [] | |
873 | PkgListEbc = [] | |
874 | Pkgs = "/ModuleSurfaceArea/PackageDependencies/Package" | |
875 | pkgL = [] | |
876 | try: | |
877 | pkgL = XmlList(Msa, Pkgs) | |
878 | except: | |
879 | pass | |
880 | ||
881 | ||
882 | gUnknownPkgGuid = {} | |
883 | if (len(pkgL) > 0): | |
884 | if (options.debug and options.verbose > 1): | |
885 | print "Found %s packages in the module" % (len(pkgL)) | |
886 | for pkg in pkgL[:]: | |
887 | Archs = "" | |
888 | pkgGuid = "" | |
889 | pkgVer = "" | |
890 | ||
891 | FindPkgGuid = False | |
892 | try: | |
893 | Archs = pkg.getAttribute("SupArchList") | |
894 | except: | |
895 | pass | |
896 | ||
897 | Archs = chkArch(Archs) | |
898 | ||
899 | try: | |
900 | pkgGuid = pkg.getAttribute("PackageGuid") | |
901 | except: | |
902 | pass | |
903 | ||
904 | if options.convert: | |
905 | if pkgGuid.lower() == "5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec": | |
906 | pkgGuid = "1E73767F-8F52-4603-AEB4-F29B510B6766" | |
907 | if pkgGuid.lower() == "68169ab0-d41b-4009-9060-292c253ac43d": | |
908 | pkgGuid = "BA0D78D6-2CAF-414b-BD4D-B6762A894288" | |
909 | AutoGenPackage.append(pkgGuid) | |
910 | try: | |
911 | pkgVer = pkg.getAttribute("PackageVersion") | |
912 | except: | |
913 | pass | |
914 | ||
915 | for PkgEntry in PkgDb[:]: | |
916 | if pkgGuid in PkgEntry: | |
917 | if len(pkgVer) > 0: | |
918 | if pkgVer in PkgEntry: | |
919 | FindPkgGuid = True | |
920 | if "IA32" in Archs: | |
921 | PkgListIa32.insert(0, PkgEntry.split("|")[0]) | |
922 | if "X64" in Archs: | |
923 | PkgListX64.insert(0, PkgEntry.split("|")[0]) | |
924 | if "IPF" in Archs: | |
925 | PkgListIpf.insert(0, PkgEntry.split("|")[0]) | |
926 | if "EBC" in Archs: | |
927 | PkgListEbc.insert(0, PkgEntry.split("|")[0]) | |
928 | if "ALL" in Archs: | |
929 | PkgList.insert(0, PkgEntry.split("|")[0]) | |
930 | else: | |
931 | FindPkgGuid = True | |
932 | if "IA32" in Archs: | |
933 | PkgListIa32.insert(0, PkgEntry.split("|")[0]) | |
934 | if "X64" in Archs: | |
935 | PkgListX64.insert(0, PkgEntry.split("|")[0]) | |
936 | if "IPF" in Archs: | |
937 | PkgListIpf.insert(0, PkgEntry.split("|")[0]) | |
938 | if "EBC" in Archs: | |
939 | PkgListEbc.insert(0, PkgEntry.split("|")[0]) | |
940 | if "ALL" in Archs: | |
941 | PkgList.insert(0, PkgEntry.split("|")[0]) | |
942 | ||
943 | if not FindPkgGuid: | |
944 | gUnknownPkgGuid[str(pkgGuid)] = 1 | |
945 | ||
946 | for UnknownPkgGuid in gUnknownPkgGuid: | |
947 | print "Cannot resolve package dependency Guid:", UnknownPkgGuid | |
948 | ||
949 | PkgList.reverse() | |
950 | PkgListIa32.reverse() | |
951 | PkgListX64.reverse() | |
952 | PkgListIpf.reverse() | |
953 | PkgListEbc.reverse() | |
954 | if (options.debug): | |
955 | print "Package List:", PkgList | |
956 | ||
957 | ||
958 | ||
959 | """ Setup the Global GuidCName arrays that will hold data from various MSA locations """ | |
960 | global GuidCName | |
961 | global GuidCNameIa32 | |
962 | global GuidCNameX64 | |
963 | global GuidCNameIPF | |
964 | global GuidCNameEBC | |
965 | GuidCName = [] | |
966 | GuidCNameIa32 = [] | |
967 | GuidCNameX64 = [] | |
968 | GuidCNameIPF = [] | |
969 | GuidCNameEBC = [] | |
970 | ||
971 | """ Check for the GUIDs Element """ | |
972 | Guids = "/ModuleSurfaceArea/Guids/GuidCNames" | |
973 | GuidList = [] | |
974 | try: | |
975 | GuidList = XmlList(Msa, Guids) | |
976 | except: | |
977 | pass | |
978 | ||
979 | if (len(GuidList) > 0): | |
980 | for Guid in GuidList: | |
981 | Archs = "" | |
982 | Usage = "" | |
983 | CName = "" | |
984 | ||
985 | try: | |
986 | Archs = Guid.getAttribute("SupArchList") | |
987 | except: | |
988 | pass | |
989 | ||
990 | Archs = chkArch(Archs) | |
991 | ||
992 | try: | |
993 | Usage = Guid.getAttribute("Usage") | |
994 | except: | |
995 | pass | |
996 | ||
997 | try: | |
998 | CName = str(XmlElementData(Guid.getElementsByTagName("GuidCName")[0])) | |
999 | if CName in GuidDecls: | |
1000 | if (options.debug and options.verbose > 1): | |
1001 | print "Guids Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs) | |
1002 | AddGuid(Archs, CName, Usage) | |
1003 | AutoGenGuid.append(CName) | |
1004 | else: | |
1005 | raise AssertionError, "Guid %s defined in %s is not declared in any package (.dec) file!" % (CName, filename) | |
1006 | except: | |
1007 | pass | |
1008 | ||
1009 | if (options.debug and options.verbose > 2): | |
1010 | print "Guid C Name List:", GuidCName | |
1011 | ||
1012 | """ Check for Events """ | |
1013 | Guids = "/ModuleSurfaceArea/Events/CreateEvents/EventTypes" | |
1014 | GuidList = [] | |
1015 | try: | |
1016 | GuidList = XmlList(Msa, Guids) | |
1017 | except: | |
1018 | pass | |
1019 | ||
1020 | if (len(GuidList) > 0): | |
1021 | for Guid in GuidList: | |
1022 | Archs = "" | |
1023 | Usage = "" | |
1024 | CName = "" | |
1025 | ||
1026 | try: | |
1027 | Archs = Guid.getAttribute("SupArchList") | |
1028 | except: | |
1029 | pass | |
1030 | ||
1031 | Archs = chkArch(Archs) | |
1032 | ||
1033 | try: | |
1034 | Usage = Guid.getAttribute("Usage") | |
1035 | Type = str(XmlElementData(Guid.getElementsByTagName("EventType")[0])) | |
1036 | Usage += " Create Event: " + Type | |
1037 | except: | |
1038 | pass | |
1039 | ||
1040 | try: | |
1041 | CName = str(Guid.getAttribute("EventGuidCName")) | |
1042 | if CName in GuidDecls: | |
1043 | if (options.debug and options.verbose > 1): | |
1044 | print "CreateEvent Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs) | |
1045 | AddGuid(Archs, CName, Usage) | |
1046 | AutoGenGuid.append(CName) | |
1047 | else: | |
1048 | if (len(DefinesComments) == 0): | |
1049 | DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n") | |
1050 | DefinesComments.append("# Create Event Guid C Name: " + CName + " Event Type: " + Type + "\n") | |
1051 | Flag = True | |
1052 | except: | |
1053 | pass | |
1054 | ||
1055 | if (Flag): | |
1056 | DefinesComments.append("#\n") | |
1057 | Flag = False | |
1058 | ||
1059 | Guids = "/ModuleSurfaceArea/Events/SignalEvents/EventTypes" | |
1060 | GuidList = [] | |
1061 | try: | |
1062 | GuidList = XmlList(Msa, Guids) | |
1063 | except: | |
1064 | pass | |
1065 | ||
1066 | if (len(GuidList) > 0): | |
1067 | for Guid in GuidList: | |
1068 | Archs = "" | |
1069 | Usage = "" | |
1070 | CName = "" | |
1071 | ||
1072 | try: | |
1073 | Archs = Guid.getAttribute("SupArchList") | |
1074 | except: | |
1075 | pass | |
1076 | ||
1077 | Archs = chkArch(Archs) | |
1078 | ||
1079 | try: | |
1080 | Usage = Guid.getAttribute("Usage") | |
1081 | Type = str(XmlElementData(Guid.getElementsByTagName("EventType")[0])) | |
1082 | Usage += " Signal Event: " + Type | |
1083 | except: | |
1084 | pass | |
1085 | ||
1086 | try: | |
1087 | CName = str(Guid.getAttribute("EventGuidCName")) | |
1088 | if CName in GuidDecls: | |
1089 | if (options.debug and options.verbose > 1): | |
1090 | print "SignalEvent Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs) | |
1091 | AddGuid(Archs, CName, Usage) | |
1092 | AutoGenGuid.append(CName) | |
1093 | else: | |
1094 | if (len(DefinesComments) == 0): | |
1095 | DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n") | |
1096 | DefinesComments.append("# Signal Event Guid C Name: " + CName + " Event Type: " + Type + "\n") | |
1097 | Flag = True | |
1098 | except: | |
1099 | pass | |
1100 | ||
1101 | if (Flag): | |
1102 | DefinesComments.append("#\n") | |
1103 | Flag = False | |
1104 | ||
1105 | """ Check the HOB guids """ | |
1106 | Guids = "/ModuleSurfaceArea/Hobs/HobTypes" | |
1107 | GuidList = [] | |
1108 | try: | |
1109 | GuidList = XmlList(Msa, Guids) | |
1110 | except: | |
1111 | pass | |
1112 | ||
1113 | if (len(GuidList) > 0): | |
1114 | for Guid in GuidList: | |
1115 | Archs = "" | |
1116 | Usage = "" | |
1117 | CName = "" | |
1118 | ||
1119 | try: | |
1120 | Archs = Guid.getAttribute("SupArchList") | |
1121 | except: | |
1122 | pass | |
1123 | ||
1124 | Archs = chkArch(Archs) | |
1125 | ||
1126 | try: | |
1127 | Usage = Guid.getAttribute("Usage") | |
1128 | Type = str(XmlElementData(Guid.getElementsByTagName("HobType")[0])) | |
1129 | Usage += " Hob: " + Type | |
1130 | except: | |
1131 | pass | |
1132 | ||
1133 | try: | |
1134 | CName = str(Guid.getAttribute("HobGuidCName")) | |
1135 | if CName in GuidDecls: | |
1136 | if (options.debug and options.verbose > 1): | |
1137 | print "Hob Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs) | |
1138 | AddGuid(Archs, CName, Usage) | |
1139 | AutoGenGuid.append(CName) | |
1140 | else: | |
1141 | if (len(DefinesComments) == 0): | |
1142 | DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n") | |
1143 | DefinesComments.append("# HOB Guid C Name: " + CName + " Hob Type: " + Type + "\n") | |
1144 | Flag = True | |
1145 | except: | |
1146 | if (len(DefinesComments) == 0): | |
1147 | DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n") | |
1148 | DefinesComments.append("# HOB: " + Type + "\n") | |
1149 | Flag = True | |
1150 | pass | |
1151 | ||
1152 | if (Flag): | |
1153 | DefinesComments.append("#\n") | |
1154 | Flag = False | |
1155 | ||
1156 | """ Check for the SystemTables Element """ | |
1157 | Guids = "/ModuleSurfaceArea/SystemTables/SystemTableCNames" | |
1158 | GuidList = [] | |
1159 | try: | |
1160 | GuidList = XmlList(Msa, Guids) | |
1161 | except: | |
1162 | pass | |
1163 | ||
1164 | if (len(GuidList) > 0): | |
1165 | for Guid in GuidList: | |
1166 | Archs = "" | |
1167 | Usage = "" | |
1168 | CName = "" | |
1169 | ||
1170 | try: | |
1171 | Archs = Guid.getAttribute("SupArchList") | |
1172 | except: | |
1173 | pass | |
1174 | ||
1175 | Archs = chkArch(Archs) | |
1176 | ||
1177 | try: | |
1178 | Usage = Guid.getAttribute("Usage") | |
1179 | Usage += " System Table" | |
1180 | except: | |
1181 | pass | |
1182 | ||
1183 | try: | |
1184 | CName = str(XmlElementData(Guid.getElementsByTagName("SystemTableCName")[0])) | |
1185 | if (options.debug and options.verbose > 1): | |
1186 | print "System Table Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs) | |
1187 | AddGuid(Archs, CName, Usage) | |
1188 | AutoGenGuid.append(CName) | |
1189 | except: | |
1190 | pass | |
1191 | ||
1192 | """ Check for the DataHubs Element """ | |
1193 | Guids = "/ModuleSurfaceArea/DataHubs/DataHubRecord" | |
1194 | GuidList = [] | |
1195 | try: | |
1196 | GuidList = XmlList(Msa, Guids) | |
1197 | except: | |
1198 | pass | |
1199 | ||
1200 | if (len(GuidList) > 0): | |
1201 | for Guid in GuidList: | |
1202 | Archs = "" | |
1203 | Usage = "" | |
1204 | CName = "" | |
1205 | ||
1206 | try: | |
1207 | Archs = Guid.getAttribute("SupArchList") | |
1208 | except: | |
1209 | pass | |
1210 | ||
1211 | Archs = chkArch(Archs) | |
1212 | ||
1213 | try: | |
1214 | Usage = Guid.getAttribute("Usage") | |
1215 | Usage += " Data Hub" | |
1216 | except: | |
1217 | pass | |
1218 | ||
1219 | try: | |
1220 | CName = str(XmlElementData(Guid.getElementsByTagName("DataHubCName")[0])) | |
1221 | if (options.debug and options.verbose > 1): | |
1222 | print "Data Hub Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs) | |
1223 | AddGuid(Archs, CName, Usage) | |
1224 | AutoGenGuid.append(CName) | |
1225 | except: | |
1226 | pass | |
1227 | ||
1228 | """ Check for the HiiPackages Element """ | |
1229 | Guids = "/ModuleSurfaceArea/HiiPackages/HiiPackage" | |
1230 | GuidList = [] | |
1231 | try: | |
1232 | GuidList = XmlList(Msa, Guids) | |
1233 | except: | |
1234 | pass | |
1235 | ||
1236 | if (len(GuidList) > 0): | |
1237 | for Guid in GuidList: | |
1238 | Archs = "" | |
1239 | Usage = "" | |
1240 | CName = "" | |
1241 | ||
1242 | try: | |
1243 | Archs = Guid.getAttribute("SupArchList") | |
1244 | except: | |
1245 | pass | |
1246 | ||
1247 | Archs = chkArch(Archs) | |
1248 | ||
1249 | try: | |
1250 | Usage = Guid.getAttribute("Usage") | |
1251 | Usage += " HII Formset" | |
1252 | except: | |
1253 | pass | |
1254 | ||
1255 | try: | |
1256 | CName = str(XmlElementData(Guid.getElementsByTagName("HiiCName")[0])) | |
1257 | if (options.debug and options.verbose > 1): | |
1258 | print "Hii Formset Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs) | |
1259 | AddGuid(Archs, CName, Usage) | |
1260 | AutoGenGuid.append(CName) | |
1261 | except: | |
1262 | pass | |
1263 | ||
1264 | """ Check for the Variables Element """ | |
1265 | Guids = "/ModuleSurfaceArea/Variables/Variable" | |
1266 | GuidList = [] | |
1267 | try: | |
1268 | GuidList = XmlList(Msa, Guids) | |
1269 | except: | |
1270 | pass | |
1271 | ||
1272 | if (len(GuidList) > 0): | |
1273 | for Guid in GuidList: | |
1274 | Archs = "" | |
1275 | Usage = "" | |
1276 | CName = "" | |
1277 | VariableName = "" | |
1278 | ||
1279 | try: | |
1280 | Archs = Guid.getAttribute("SupArchList") | |
1281 | except: | |
1282 | pass | |
1283 | ||
1284 | Archs = chkArch(Archs) | |
1285 | ||
1286 | try: | |
1287 | Usage = Guid.getAttribute("Usage") | |
1288 | except: | |
1289 | pass | |
1290 | ||
1291 | try: | |
1292 | VariableName = str(XmlElementData(Guid.getElementsByTagName("VariableName")[0])) | |
1293 | CName = str(XmlElementData(Guid.getElementsByTagName("GuidC_Name")[0])) | |
1294 | ||
1295 | HexData = VariableName.strip().split() | |
1296 | UniString = " L\"" | |
1297 | for dig in HexData[:]: | |
1298 | UniString += str(unichr(eval(dig))) | |
1299 | UniString += "\"" | |
1300 | ||
1301 | Usage += UniString | |
1302 | ||
1303 | if CName in set(GuidDecls): | |
1304 | removeDups(CName, GuidCName) | |
1305 | removeDups(CName, GuidCNameIa32) | |
1306 | removeDups(CName, GuidCNameX64) | |
1307 | removeDups(CName, GuidCNameIPF) | |
1308 | removeDups(CName, GuidCNameEBC) | |
1309 | ||
1310 | if (options.debug): | |
1311 | print "Variable Adding Guid CName: %-45s # %s Archs: %s" % (CName, Usage, Archs) | |
1312 | AddGuid(Archs, CName, Usage) | |
1313 | AutoGenGuid.append(CName) | |
1314 | else: | |
1315 | if (len(DefinesComments) == 0): | |
1316 | DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n") | |
1317 | DefinesComments.append("# Variable Guid C Name: " + CName + " Variable Name:" + UniString + "\n") | |
1318 | Flag = True | |
1319 | except: | |
1320 | pass | |
1321 | ||
1322 | if (Flag): | |
1323 | DefinesComments.append("#\n") | |
1324 | Flag = False | |
1325 | ||
1326 | """ Check for the Protocol Element """ | |
1327 | Protocols = "/ModuleSurfaceArea/Protocols/Protocol" | |
1328 | ProtocolList = [] | |
1329 | ProtocolCName = [] | |
1330 | ProtocolCNameIa32 = [] | |
1331 | ProtocolCNameX64 = [] | |
1332 | ProtocolCNameIPF = [] | |
1333 | ProtocolCNameEBC = [] | |
1334 | ||
1335 | try: | |
1336 | ProtocolList = XmlList(Msa, Protocols) | |
1337 | except: | |
1338 | pass | |
1339 | ||
1340 | if (len(ProtocolList) > 0): | |
1341 | for Protocol in ProtocolList: | |
1342 | Archs = "" | |
1343 | Usage = "" | |
1344 | CName = "" | |
1345 | ||
1346 | try: | |
1347 | Archs = Protocol.getAttribute("SupArchList") | |
1348 | except: | |
1349 | pass | |
1350 | ||
1351 | Archs = chkArch(Archs) | |
1352 | ||
1353 | try: | |
1354 | Usage = Protocol.getAttribute("Usage") | |
1355 | except: | |
1356 | pass | |
1357 | ||
1358 | try: | |
1359 | CName = str(XmlElementData(Protocol.getElementsByTagName("ProtocolCName")[0])) | |
1360 | AutoGenGuid.append(CName) | |
1361 | removeDups(CName, GuidCName) | |
1362 | removeDups(CName, GuidCNameIa32) | |
1363 | removeDups(CName, GuidCNameX64) | |
1364 | removeDups(CName, GuidCNameIPF) | |
1365 | removeDups(CName, GuidCNameEBC) | |
1366 | ||
1367 | if (options.debug and options.verbose > 1): | |
1368 | print "Found %s - %s - %s " % (CName, Usage, str(len(Archs))) | |
1369 | ||
1370 | if "IA32" in Archs: | |
1371 | ProtocolCNameIa32.insert(0, str(" %-45s # PROTOCOL %s" % (CName, Usage))) | |
1372 | if "X64" in Archs: | |
1373 | ProtocolCNameX64.insert(0, str(" %-45s # PROTOCOL %s" % (CName, Usage))) | |
1374 | if "IPF" in Archs: | |
1375 | ProtocolCNameIPF.insert(0, str(" %-45s # PROTOCOL %s" % (CName, Usage))) | |
1376 | if "EBC" in Archs: | |
1377 | ProtocolCNameEBC.insert(0, str(" %-45s # PROTOCOL %s" % (CName, Usage))) | |
1378 | if "ALL" in Archs: | |
1379 | ProtocolCName.insert(0, str(" %-45s # PROTOCOL %s" % (CName, Usage))) | |
1380 | except: | |
1381 | pass | |
1382 | ||
1383 | ||
1384 | Protocols = "/ModuleSurfaceArea/Protocols/ProtocolNotify" | |
1385 | try: | |
1386 | ProtocolList = XmlList(Msa, Protocols) | |
1387 | except: | |
1388 | pass | |
1389 | ||
1390 | if (len(ProtocolList) > 0): | |
1391 | for Protocol in ProtocolList: | |
1392 | Archs = "" | |
1393 | Usage = "" | |
1394 | CName = "" | |
1395 | ||
1396 | try: | |
1397 | Archs = Protocol.getAttribute("SupArchList") | |
1398 | except: | |
1399 | pass | |
1400 | ||
1401 | Archs = chkArch(Archs) | |
1402 | ||
1403 | try: | |
1404 | Usage = Protocol.getAttribute("Usage") | |
1405 | except: | |
1406 | pass | |
1407 | ||
1408 | try: | |
1409 | CName = str(XmlElementData(Protocol.getElementsByTagName("ProtocolNotifyCName")[0])) | |
1410 | AutoGenGuid.append(CName) | |
1411 | removeDups(CName, GuidCName) | |
1412 | removeDups(CName, GuidCNameIa32) | |
1413 | removeDups(CName, GuidCNameX64) | |
1414 | removeDups(CName, GuidCNameIPF) | |
1415 | removeDups(CName, GuidCNameEBC) | |
1416 | ||
1417 | if "IA32" in Archs: | |
1418 | ProtocolCNameIa32.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName, Usage)) | |
1419 | if "X64" in Archs: | |
1420 | ProtocolCNameX64.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName, Usage)) | |
1421 | if "IPF" in Archs: | |
1422 | ProtocolCNameIPF.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName, Usage)) | |
1423 | if "EBC" in Archs: | |
1424 | ProtocolCNameEBC.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName, Usage)) | |
1425 | if "ALL" in Archs: | |
1426 | ProtocolCName.insert(0, " %-45s # PROTOCOL_NOTIFY %s" % (CName, Usage)) | |
1427 | except: | |
1428 | pass | |
1429 | ||
1430 | """ Check for the PPIs Element """ | |
1431 | PPIs = "/ModuleSurfaceArea/PPIs/Ppi" | |
1432 | PPIsList = [] | |
1433 | PpiCName = [] | |
1434 | PpiCNameIa32 = [] | |
1435 | PpiCNameX64 = [] | |
1436 | PpiCNameIPF = [] | |
1437 | PpiCNameEBC = [] | |
1438 | ||
1439 | try: | |
1440 | PPIsList = XmlList(Msa, PPIs) | |
1441 | except: | |
1442 | pass | |
1443 | ||
1444 | if (len(PPIsList) > 0): | |
1445 | for Ppi in PPIsList: | |
1446 | Archs = "" | |
1447 | Usage = "" | |
1448 | CName = "" | |
1449 | ||
1450 | try: | |
1451 | Archs = str(Ppi.getAttribute("SupArchList")) | |
1452 | except: | |
1453 | pass | |
1454 | ||
1455 | Archs = chkArch(Archs) | |
1456 | ||
1457 | try: | |
1458 | Usage = str(Ppi.getAttribute("Usage")) | |
1459 | except: | |
1460 | pass | |
1461 | ||
1462 | try: | |
1463 | CName = str(XmlElementData(Ppi.getElementsByTagName("PpiCName")[0])).strip() | |
1464 | AutoGenGuid.append(CName) | |
1465 | removeDups(CName, GuidCName) | |
1466 | removeDups(CName, GuidCNameIa32) | |
1467 | removeDups(CName, GuidCNameX64) | |
1468 | removeDups(CName, GuidCNameIPF) | |
1469 | removeDups(CName, GuidCNameEBC) | |
1470 | ||
1471 | if "IA32" in Archs: | |
1472 | PpiCNameIa32.insert(0, " %-45s # PPI %s" % (CName, Usage)) | |
1473 | if "X64" in Archs: | |
1474 | PpiCNameX64.insert(0, " %-45s # PPI %s" % (CName, Usage)) | |
1475 | if "IPF" in Archs: | |
1476 | PpiCNameIPF.insert(0, " %-45s # PPI %s" % (CName, Usage)) | |
1477 | if "EBC" in Archs: | |
1478 | PpiCNameEBC.insert(0, " %-45s # PPI %s" % (CName, Usage)) | |
1479 | if "ALL" in Archs: | |
1480 | PpiCName.insert(0, " %-45s # PPI %s" % (CName, Usage)) | |
1481 | except: | |
1482 | pass | |
1483 | ||
1484 | ||
1485 | PPIs = "/ModuleSurfaceArea/PPIs/PpiNotify" | |
1486 | try: | |
1487 | PPIsList = XmlList(Msa, PPIs) | |
1488 | except: | |
1489 | pass | |
1490 | ||
1491 | if (len(PPIsList) > 0): | |
1492 | for Ppi in PPIsList: | |
1493 | Archs = "" | |
1494 | Usage = "" | |
1495 | CName = "" | |
1496 | ||
1497 | try: | |
1498 | Archs = Ppi.getAttribute("SupArchList") | |
1499 | except: | |
1500 | pass | |
1501 | ||
1502 | Archs = chkArch(Archs) | |
1503 | ||
1504 | try: | |
1505 | Usage = Ppi.getAttribute("Usage") | |
1506 | except: | |
1507 | pass | |
1508 | ||
1509 | try: | |
1510 | CName = str(XmlElementData(Ppi.getElementsByTagName("PpiNotifyCName")[0])) | |
1511 | AutoGenGuid.append(CName) | |
1512 | removeDups(CName, GuidCName) | |
1513 | removeDups(CName, GuidCNameIa32) | |
1514 | removeDups(CName, GuidCNameX64) | |
1515 | removeDups(CName, GuidCNameIPF) | |
1516 | removeDups(CName, GuidCNameEBC) | |
1517 | ||
1518 | if "IA32" in Archs: | |
1519 | PpiCNameIa32.insert(0, " %-45s # PPI_NOTIFY %s" % (CName, Usage)) | |
1520 | if "X64" in Archs: | |
1521 | PpiCNameX64.insert(0, " %-45s # PPI_NOTIFY %s" % (CName, Usage)) | |
1522 | if "IPF" in Archs: | |
1523 | PpiCNameIPF.insert(0, " %-45s # PPI_NOTIFY %s" % (CName, Usage)) | |
1524 | if "EBC" in Archs: | |
1525 | PpiCNameEBC.insert(0, " %-45s # PPI_NOTIFY %s" % (CName, Usage)) | |
1526 | if "ALL" in Archs: | |
1527 | PpiCName.insert(0, " %-45s # PPI_NOTIFY %s" % (CName, Usage)) | |
1528 | except: | |
1529 | pass | |
1530 | ||
1531 | ||
1532 | """ Get the PCD entries now """ | |
1533 | PcdCoded = "/ModuleSurfaceArea/PcdCoded/PcdEntry" | |
1534 | PcdList = [] | |
1535 | try: | |
1536 | PcdList = XmlList(Msa, PcdCoded) | |
1537 | except: | |
1538 | pass | |
1539 | ||
1540 | (PcdFF, PcdFFIa32, PcdFFX64, PcdFFIpf, PcdFFEbc) = ([],[],[],[],[]) | |
1541 | (PcdFAB, PcdFABIa32, PcdFABX64, PcdFABIpf, PcdFABEbc) = ([],[],[],[],[]) | |
1542 | (PcdPIM, PcdPIMIa32, PcdPIMX64, PcdPIMIpf, PcdPIMEbc) = ([],[],[],[],[]) | |
1543 | (PcdDY, PcdDYIa32, PcdDYX64, PcdDYIpf, PcdDYEbc) = ([],[],[],[],[]) | |
1544 | (PcdDYE, PcdDYEIa32, PcdDYEX64, PcdDYEIpf, PcdDYEEbc) = ([],[],[],[],[]) | |
1545 | ||
1546 | if (len(PcdList) > 0): | |
1547 | for Pcd in PcdList: | |
1548 | Archs = "" | |
1549 | Usage = "" | |
1550 | CName = "" | |
1551 | DefVal = "" | |
1552 | ||
1553 | try: | |
1554 | Archs = Pcd.getAttribute("SupArchList") | |
1555 | except: | |
1556 | pass | |
1557 | ||
1558 | Archs = chkArch(Archs) | |
1559 | ||
1560 | try: | |
1561 | ItemType = Pcd.getAttribute("PcdItemType") | |
1562 | except: | |
1563 | pass | |
1564 | ||
1565 | try: | |
1566 | CName = str(XmlElementData(Pcd.getElementsByTagName("C_Name")[0])) | |
1567 | except: | |
1568 | raise SyntaxError, "ERROR: MSA has a PCD with no Pcd C_Name defined" | |
1569 | ||
1570 | try: | |
1571 | TSGC = str(XmlElementData(Pcd.getElementsByTagName("TokenSpaceGuidCName")[0])) | |
1572 | except: | |
1573 | pass | |
1574 | ||
1575 | try: | |
1576 | DefVal = str(XmlElementData(Pcd.getElementsByTagName("DefaultValue"))) | |
1577 | except: | |
1578 | pass | |
1579 | ||
1580 | if (len(DefVal) > 0): | |
1581 | line = TSGC + "." + CName + "|" + DefVal | |
1582 | else: | |
1583 | line = TSGC + "." + CName | |
1584 | ||
1585 | if (ItemType == "FEATURE_FLAG"): | |
1586 | if ("IA32" in Archs): | |
1587 | PcdFFIa32.insert(0, line) | |
1588 | if ("IPF" in Archs): | |
1589 | PcdFFIpf.insert(0, line) | |
1590 | if ("X64" in Archs): | |
1591 | PcdFFX64.insert(0, line) | |
1592 | if ("EBC" in Archs): | |
1593 | PcdFFEbc.insert(0, line) | |
1594 | if ("ALL" in Archs): | |
1595 | PcdFF.insert(0, line) | |
1596 | elif (ItemType == "FIXED_AT_BUILD"): | |
1597 | if ("IA32" in Archs): | |
1598 | PcdFABIa32.insert(0, line) | |
1599 | if ("IPF" in Archs): | |
1600 | PcdFABIpf.insert(0, line) | |
1601 | if ("X64" in Archs): | |
1602 | PcdFABX64.insert(0, line) | |
1603 | if ("EBC" in Archs): | |
1604 | PcdFABEbc.insert(0, line) | |
1605 | if ("ALL" in Archs): | |
1606 | PcdFAB.insert(0, line) | |
1607 | elif (ItemType == "PATCHABLE_IN_MODULE"): | |
1608 | if ("IA32" in Archs): | |
1609 | PcdPIMIa32.insert(0, line) | |
1610 | if ("IPF" in Archs): | |
1611 | PcdPIMIpf.insert(0, line) | |
1612 | if ("X64" in Archs): | |
1613 | PcdPIMX64.insert(0, line) | |
1614 | if ("EBC" in Archs): | |
1615 | PcdPIMEbc.insert(0, line) | |
1616 | if ("ALL" in Archs): | |
1617 | PcdFAB.insert(0, line) | |
1618 | elif (ItemType == "DYNAMIC_EX"): | |
1619 | if ("IA32" in Archs): | |
1620 | PcdDYEIa32.insert(0, line) | |
1621 | if ("IPF" in Archs): | |
1622 | PcdDYEIpf.insert(0, line) | |
1623 | if ("X64" in Archs): | |
1624 | PcdDYEX64.insert(0, line) | |
1625 | if ("EBC" in Archs): | |
1626 | PcdDYEEbc.insert(0, line) | |
1627 | if ("ALL" in Archs): | |
1628 | PcdDYE.insert(0, line) | |
1629 | else: | |
1630 | if ("IA32" in Archs): | |
1631 | PcdDYIa32.insert(0, line) | |
1632 | if ("IPF" in Archs): | |
1633 | PcdDYIpf.insert(0, line) | |
1634 | if ("X64" in Archs): | |
1635 | PcdDYX64.insert(0, line) | |
1636 | if ("EBC" in Archs): | |
1637 | PcdDYEbc.insert(0, line) | |
1638 | if ("ALL" in Archs): | |
1639 | PcdDY.insert(0, line) | |
1640 | ||
1641 | """ User Extensions Section """ | |
1642 | UEList = [] | |
1643 | UESectionList = [] | |
1644 | try: | |
1645 | UESectionList = XmlList(Msa, "/ModuleSurfaceArea/UserExtensions") | |
1646 | except: | |
1647 | pass | |
1648 | ||
1649 | if (len(UESectionList) > 0): | |
1650 | for UE in UESectionList[:]: | |
1651 | UserId = "" | |
1652 | Identifier = "" | |
1653 | Value = "" | |
1654 | ||
1655 | try: | |
1656 | UserId = str(UE.getAttribute("UserID")) | |
1657 | except: | |
1658 | raise SyntaxError, "ERROR: Malformed MSA, No UserID Specified in UserExtensions element" | |
1659 | ||
1660 | try: | |
1661 | Identifier = str(UE.getAttribute("Identifier")) | |
1662 | except: | |
1663 | raise SyntaxError, "ERROR: Malformed MSA, No Identifier Specified in UserExtensions element" | |
1664 | ||
1665 | if (options.debug): | |
1666 | print "FOUND A UE Element", UserId, Identifier | |
1667 | ||
1668 | try: | |
1669 | Value = str(XmlElementData(UE)) | |
1670 | except: | |
1671 | pass | |
1672 | ||
1673 | Entry = [UserId, Identifier, Value] | |
1674 | UEList.insert(0, Entry) | |
1675 | ||
1676 | ||
1677 | ||
1678 | if (len(Externlist) > 0): | |
1679 | AutoGenSource = "" | |
1680 | AutoGenDefinitionSource = "" | |
1681 | AutoGenEntryPointSource = "" | |
1682 | AutoGenUnloadSource = "" | |
1683 | if (len(AutoGenDriverModel) > 0): | |
1684 | AutoGenCode = AddDriverBindingProtocolStatement(AutoGenDriverModel) | |
1685 | AutoGenEntryPointSource += AutoGenCode[0] | |
1686 | AutoGenUnloadSource += AutoGenCode[1] | |
1687 | AutoGenDeclaration += AutoGenCode[3] | |
1688 | ||
1689 | ||
1690 | if (len(AutoGenExitBootServices) > 0): | |
1691 | print "[Warning] Please manually add Create Event statement for Exit Boot Service Event!" | |
1692 | if options.event: | |
1693 | AutoGenCode = AddBootServiceEventStatement(AutoGenExitBootServices) | |
1694 | AutoGenEntryPointSource += AutoGenCode[0] | |
1695 | AutoGenUnloadSource += AutoGenCode[1] | |
1696 | AutoGenDefinitionSource += AutoGenCode[2] | |
1697 | AutoGenDeclaration += AutoGenCode[3] | |
1698 | ||
1699 | if (len(AutoGenVirtualAddressChanged) > 0): | |
1700 | print "[Warning] Please manually add Create Event statement for Virtual Address Change Event!" | |
1701 | if options.event: | |
1702 | AutoGenCode = AddVirtualAddressEventStatement(AutoGenVirtualAddressChanged) | |
1703 | AutoGenEntryPointSource += AutoGenCode[0] | |
1704 | AutoGenUnloadSource += AutoGenCode[1] | |
1705 | AutoGenDefinitionSource += AutoGenCode[2] | |
1706 | AutoGenDeclaration += AutoGenCode[3] | |
1707 | ||
1708 | if AutoGenEntryPointSource != "": | |
1709 | OldEntryPoint = AutoGenEntryPoint | |
1710 | AutoGenCode = AddNewEntryPointContentsStatement(BaseName, AutoGenEntryPoint, AutoGenEntryPointSource) | |
1711 | AutoGenEntryPoint = AutoGenCode[0] | |
1712 | AutoGenEntryPointSource = AutoGenCode[1] | |
1713 | AutoGenDeclaration += AutoGenCode[2] | |
1714 | ||
1715 | ||
1716 | if AutoGenEntryPoint != "": | |
1717 | DriverModules.insert(0, " %-30s = %s\n" % ("ENTRY_POINT" , AutoGenEntryPoint)) | |
1718 | ||
1719 | AutoGenSource = AutoGenDefinitionSource + AutoGenEntryPointSource + AutoGenUnloadSource | |
1720 | ||
1721 | if (lFlag): | |
1722 | DefinesComments.append("#\n") | |
1723 | ||
1724 | if (Flag and len(DefinesComments) > 0): | |
1725 | DefinesComments.insert(0, "\n#\n# The following information is for reference only and not required by the build tools.\n#\n") | |
1726 | ||
1727 | if (options.debug and options.verbose > 2): | |
1728 | if (len(DriverModules) > 0): | |
1729 | print DriverModules | |
1730 | if (len(LibraryModules) > 0): | |
1731 | print LibraryModules | |
1732 | if (len(DefinesComments) > 0): | |
1733 | print DefinesComments | |
1734 | ||
1735 | Depex = [] | |
1736 | DepexIa32 = [] | |
1737 | DepexX64 = [] | |
1738 | DepexIpf = [] | |
1739 | DepexEbc = [] | |
1740 | ||
1741 | for DxsFile, Archs in AutoGenDxsFiles: | |
1742 | fileContents = openSourceFile(AutoGenModuleFolder, DxsFile) | |
1743 | Contents, Unresolved = TranslateDpxSection(fileContents) | |
1744 | if Contents == "": | |
1745 | print "[warning] Cannot read dxs expression" | |
1746 | else: | |
1747 | if (len(Unresolved) > 0): | |
1748 | print "[warning] Guid Macro(s): %s cannot find corresponding cNames. Please resolve it in [depex] section in extened inf" % ",".join(Unresolved) | |
1749 | ||
1750 | if ("IA32" in Archs): | |
1751 | DepexIa32.insert(0, Contents) | |
1752 | if ("IPF" in Archs): | |
1753 | DepexIpf.insert(0, Contents) | |
1754 | if ("X64" in Archs): | |
1755 | DepexX64.insert(0, Contents) | |
1756 | if ("EBC" in Archs): | |
1757 | DepexEbc.insert(0, Contents) | |
1758 | if ("ALL" in Archs): | |
1759 | Depex.insert(0, Contents) | |
1760 | ||
1761 | AutoGenSourceHeaderFormat = "/**@file\n %s\n\n %s\n %s\n %s\n**/\n\n%s" | |
1762 | includeCommonHeaderFileStatement = "#include \"%s\"" % commonHeaderFilename | |
1763 | ||
1764 | AutoGenHeader += AddSystemIncludeStatement(ModType, AutoGenPackage) | |
1765 | AutoGenHeader += AddGuidStatement(AutoGenGuid) | |
1766 | AutoGenHeader += AddLibraryClassStatement(AutoGenLibClass) | |
1767 | ||
1768 | if options.manual: | |
1769 | saveSourceFile(AutoGenModuleFolder, "CommonHeader.txt", AutoGenHeader) | |
1770 | else: | |
1771 | ||
1772 | commonHeaderFilename2 = re.sub("(?=[^a-z])", "_", commonHeaderFilename) | |
1773 | commonHeaderFilename2 = "_" + commonHeaderFilename2.replace(".", "").upper() + "_" | |
1774 | briefDiscription = "Common header file shared by all source files." | |
1775 | detailedDiscription = "This file includes package header files, library classes and protocol, PPI & GUID definitions.\n" | |
1776 | AutoGenHeader += AutoGenDeclaration | |
1777 | AutoGenHeader = "#ifndef %s\n#define %s\n\n\n%s\n#endif\n" % (commonHeaderFilename2, commonHeaderFilename2, AutoGenHeader) | |
1778 | AutoGenHeader = AutoGenSourceHeaderFormat % (briefDiscription, detailedDiscription, CopyRight, License, AutoGenHeader) | |
1779 | saveSourceFile(AutoGenModuleFolder, commonHeaderFilename, AutoGenHeader) | |
1780 | SrcFilenames.append(commonHeaderFilename) | |
1781 | ||
1782 | for source in AutoGenSourceFiles: | |
1783 | extension = os.path.splitext(source)[1] | |
1784 | if extension == ".c": | |
1785 | sourceContents = openSourceFile(AutoGenModuleFolder, source) | |
1786 | sourceContents = AddCommonInclusionStatement(sourceContents, includeCommonHeaderFileStatement) | |
1787 | saveSourceFile(AutoGenModuleFolder, source, sourceContents) | |
1788 | ||
1789 | ||
1790 | if AutoGenSource != "": | |
1791 | briefDiscription = "Entry Point Source file." | |
1792 | detailedDiscription = "This file contains the user entry point \n" | |
1793 | AutoGenSource = AutoGenSourceHeaderFormat % (briefDiscription, detailedDiscription, CopyRight, License, AutoGenSource) | |
1794 | AutoGenSource = AddCommonInclusionStatement(AutoGenSource, includeCommonHeaderFileStatement) | |
1795 | ||
1796 | saveSourceFile(AutoGenModuleFolder, entryPointFilename, AutoGenSource) | |
1797 | SrcFilenames.append(entryPointFilename) | |
1798 | ||
1799 | ||
1800 | ||
1801 | ||
1802 | # DONE Getting data, now output it in INF format. | |
1803 | Msa.unlink() | |
1804 | Fdb.unlink() | |
1805 | Output = [] | |
1806 | ||
1807 | """ Print the converted data format """ | |
1808 | head = "#/** @file\n" | |
1809 | head += "# " + str(Abstract) + "\n#\n" | |
1810 | head += "# " + str(Description).strip().replace("\n", "\n# ") + "\n" | |
1811 | head += "# " + str(CopyRight) + "\n#\n" | |
1812 | head += "# " + str(License).replace("\n", "\n# ").replace(" ", " ").strip() + "\n#\n" | |
1813 | head += "#\n#**/\n" | |
1814 | ||
1815 | Output.append(head) | |
1816 | if (options.debug): | |
1817 | print head | |
1818 | ||
1819 | ## Defines = "\n" + "#"*80+ "\n#\n" | |
1820 | ## if (BinModule != "false"): | |
1821 | ## Defines += "# Defines Section - statements that will be processed to generate a binary image.\n" | |
1822 | ## else: | |
1823 | ## Defines += "# Defines Section - statements that will be processed to create a Makefile.\n" | |
1824 | ## Defines += "#\n" + "#"*80 + "\n" | |
1825 | ||
1826 | Defines = "\n" | |
1827 | Defines += "[Defines]\n" | |
1828 | Defines += " %-30s = %s\n" % ("INF_VERSION", "0x00010005") | |
1829 | Defines += " %-30s = %s\n" % ("BASE_NAME", BaseName) | |
1830 | Defines += " %-30s = %s\n" % ("FILE_GUID", GuidValue) | |
1831 | Defines += " %-30s = %s\n" % ("MODULE_TYPE", ModType) | |
1832 | Defines += " %-30s = %s\n" % ("VERSION_STRING", VerString) | |
1833 | ||
1834 | if (len(PcdIsDriver) > 0): | |
1835 | Defines += " %-30s = %s\n" % ("PCD_DRIVER", PcdIsDriver) | |
1836 | ||
1837 | if (len(IamLibrary) > 0): | |
1838 | lcstr = "" | |
1839 | for lc in IamLibrary[:]: | |
1840 | lcstr += lc + " " | |
1841 | Defines += " %-30s = %s" % ("LIBRARY_CLASS", lcstr) | |
1842 | Defines += "\n" | |
1843 | ||
1844 | if (len(SpecList) > 0): | |
1845 | for spec in SpecList[:]: | |
1846 | (specname, specval) = spec.split() | |
1847 | Defines += " %-30s = %s\n" % (specname, specval) | |
1848 | Defines += "\n" | |
1849 | ||
1850 | if (len(DriverModules) > 0): | |
1851 | for line in DriverModules[:]: | |
1852 | Defines += line | |
1853 | ||
1854 | if (len(LibraryModules) > 0): | |
1855 | for line in LibraryModules[:]: | |
1856 | Defines += line | |
1857 | ||
1858 | if (len(DefinesComments) > 0): | |
1859 | for line in DefinesComments[:]: | |
1860 | Defines += line | |
1861 | ||
1862 | Output.append(Defines) | |
1863 | ||
1864 | if (options.debug): | |
1865 | print Defines | |
1866 | ||
1867 | if (BinModule != "false"): | |
1868 | """ Binary Module, so sources are really binaries. """ | |
1869 | ## Sources = "\n" + "#"*80 + "\n#\n" | |
1870 | ## Sources += "# Binaries Section - list of binary files that are required for the build\n# to succeed.\n" | |
1871 | ## Sources += "#\n" + "#"*80 + "\n\n" | |
1872 | Sources = "\n" | |
1873 | if ModType == "UEFI_APPLICATION": | |
1874 | FileType = "UEFI_APP" | |
1875 | if options.verbose > 0: | |
1876 | print "WARNING: Binary Module: %s is assuming UEFI_APPLICATION file type." % (options.filename) | |
1877 | else: | |
1878 | FileType = "FV" | |
1879 | if options.verbose > 0: | |
1880 | print "WARNING: Binary Module: %s is assuming FV file type." % (options.filename) | |
1881 | ||
1882 | if (len(SrcFilenames) > 0): | |
1883 | Sources += "[Binaries.common]\n" | |
1884 | for file in SrcFilenames[:]: | |
1885 | file = file.replace("\\", "/") | |
1886 | Sources += " " + FileType + "|" + file + "\n" | |
1887 | Sources += "\n" | |
1888 | ||
1889 | if (len(SrcFilenamesIa32) > 0): | |
1890 | Sources += "[Binaries.Ia32]\n" | |
1891 | for file in SrcFilenamesIa32[:]: | |
1892 | file = file.replace("\\", "/") | |
1893 | Sources += " " + FileType + "|" + file + "\n" | |
1894 | Sources += "\n" | |
1895 | ||
1896 | if (len(SrcFilenamesX64) > 0): | |
1897 | Sources += "[Binaries.X64]\n" | |
1898 | for file in SrcFilenamesX64[:]: | |
1899 | file = file.replace("\\", "/") | |
1900 | Sources += " " + FileType + "|" + file + "\n" | |
1901 | Sources += "\n" | |
1902 | ||
1903 | if (len(SrcFilenamesIpf) > 0): | |
1904 | Sources += "[Binaries.IPF]\n" | |
1905 | for file in SrcFilenamesIpf[:]: | |
1906 | file = file.replace("\\", "/") | |
1907 | Sources += " " + FileType + "|" + file + "\n" | |
1908 | Sources += "\n" | |
1909 | ||
1910 | if (len(SrcFilenamesEbc) > 0): | |
1911 | Sources += "[Binaries.EBC]\n" | |
1912 | for file in SrcFilenamesEbc[:]: | |
1913 | file = file.replace("\\", "/") | |
1914 | Sources += " " + FileType + "|" + file + "\n" | |
1915 | Sources += "\n" | |
1916 | ||
1917 | Output.append(Sources) | |
1918 | if (options.debug): | |
1919 | print Sources | |
1920 | else: | |
1921 | ## Sources = "\n" + "#"*80 + "\n#\n" | |
1922 | ## Sources += "# Sources Section - list of files that are required for the build to succeed.\n" | |
1923 | ## Sources += "#\n" + "#"*80 + "\n\n" | |
1924 | Sources = "\n" | |
1925 | if (len(SrcFilenames) > 0): | |
1926 | Sources += "[Sources.common]\n" | |
1927 | for file in SrcFilenames[:]: | |
1928 | Sources += " " + file + "\n" | |
1929 | Sources += "\n" | |
1930 | ||
1931 | if (len(SrcFilenamesIa32) > 0): | |
1932 | Sources += "[Sources.Ia32]\n" | |
1933 | for file in SrcFilenamesIa32[:]: | |
1934 | Sources += " " + file + "\n" | |
1935 | Sources += "\n" | |
1936 | ||
1937 | if (len(SrcFilenamesX64) > 0): | |
1938 | Sources += "[Sources.X64]\n" | |
1939 | for file in SrcFilenamesX64[:]: | |
1940 | Sources += " " + file + "\n" | |
1941 | Sources += "\n" | |
1942 | ||
1943 | if (len(SrcFilenamesIpf) > 0): | |
1944 | Sources += "[Sources.IPF]\n" | |
1945 | for file in SrcFilenamesIpf[:]: | |
1946 | Sources += " " + file + "\n" | |
1947 | Sources += "\n" | |
1948 | ||
1949 | if (len(SrcFilenamesEbc) > 0): | |
1950 | Sources += "[Sources.EBC]\n" | |
1951 | for file in SrcFilenamesEbc[:]: | |
1952 | Sources += " " + file + "\n" | |
1953 | Sources += "\n" | |
1954 | ||
1955 | Output.append(Sources) | |
1956 | if (options.debug): | |
1957 | print Sources | |
1958 | ||
1959 | ||
1960 | includeLine = "" | |
1961 | if ((len(HeaderLocations) > 0) or (len(Dirs) > 0)): | |
1962 | allLcs = set(LibClassList + LibClassListIa32 + LibClassListX64 + LibClassListIpf + LibClassListEbc + Dirs) | |
1963 | Lines = [] | |
1964 | for line in HeaderLocations[:]: | |
1965 | for Lc in allLcs: | |
1966 | (keyword, header) = line.split("|") | |
1967 | if Lc in keyword: | |
1968 | if (options.debug): | |
1969 | print "FOUND", Lc, "in", keyword, "header", header | |
1970 | path = "$(WORKSPACE)/" + os.path.split(header)[0] | |
1971 | Lines.insert(0, path.strip()) | |
1972 | Includes = "" | |
1973 | ## Includes = "\n" + "#"*80 + "\n#\n" | |
1974 | ## Includes += "# Includes Section - list of Include locations that are required for\n" | |
1975 | ## Includes += "# this module.\n" | |
1976 | ## Includes += "#\n" + "#"*80 + "\n\n" | |
1977 | ## Includes += "[Includes]\n" | |
1978 | ## includeLines = [] | |
1979 | ## includeLines = set(Lines) | |
1980 | ## if (options.debug): | |
1981 | ## print "There are", len(includeLines), "entries" | |
1982 | ## for Line in includeLines: | |
1983 | ## Includes += " " + str(Line).strip().replace("\\", "/") + "\n" | |
1984 | ||
1985 | Output.append(Includes) | |
1986 | if (options.debug): | |
1987 | print Includes | |
1988 | ||
1989 | ||
1990 | ||
1991 | if ((len(PkgList) + len(PkgListIa32) + len(PkgListX64) + len(PkgListIpf) + len(PkgListEbc)) > 0): | |
1992 | """ We do this if and only if we have Package Dependencies """ | |
1993 | ## PackageDepends = "\n" + "#"*80 + "\n#\n" | |
1994 | ## PackageDepends += "# Package Dependency Section - list of Package files that are required for\n" | |
1995 | ## PackageDepends += "# this module.\n" | |
1996 | ## PackageDepends += "#\n" + "#"*80 + "\n\n" | |
1997 | PackageDepends = "\n" | |
1998 | if (len(PkgList) > 0): | |
1999 | PackageDepends += "[Packages]\n" | |
2000 | for lc in PkgList[:]: | |
2001 | lc = lc.replace("\\", "/") | |
2002 | PackageDepends += " " + lc + "\n" | |
2003 | PackageDepends += "\n" | |
2004 | ||
2005 | if (len(PkgListIa32) > 0): | |
2006 | PackageDepends += "[Packages.IA32]\n" | |
2007 | for lc in PkgListIa32[:]: | |
2008 | lc = lc.replace("\\", "/") | |
2009 | PackageDepends += " " + lc + "\n" | |
2010 | PackageDepends += "\n" | |
2011 | ||
2012 | if (len(PkgListX64) > 0): | |
2013 | PackageDepends += "[Packages.X64]\n" | |
2014 | for lc in PkgListX64[:]: | |
2015 | lc = lc.replace("\\", "/") | |
2016 | PackageDepends += " " + lc + "\n" | |
2017 | PackageDepends += "\n" | |
2018 | ||
2019 | if (len(PkgListIpf) > 0): | |
2020 | PackageDepends += "[Packages.IPF]\n" | |
2021 | for lc in PkgListIpf[:]: | |
2022 | lc = lc.replace("\\", "/") | |
2023 | PackageDepends += " " + lc + "\n" | |
2024 | PackageDepends += "\n" | |
2025 | ||
2026 | if (len(PkgListEbc) > 0): | |
2027 | PackageDepends += "[Packages.EBC]\n" | |
2028 | for lc in PkgListEbc[:]: | |
2029 | lc = lc.replace("\\", "/") | |
2030 | PackageDepends += " " + lc + "\n" | |
2031 | PackageDepends += "\n" | |
2032 | ||
2033 | Output.append(PackageDepends) | |
2034 | if (options.debug): | |
2035 | print PackageDepends | |
2036 | ||
2037 | if ((len(LibClassList) + len(LibClassListIa32) + len(LibClassListX64) + len(LibClassListIpf) + len(LibClassListEbc)) > 0): | |
2038 | ## LibraryClasses = "\n" + "#"*80 + "\n#\n" | |
2039 | ## LibraryClasses += "# Library Class Section - list of Library Classes that are required for\n" | |
2040 | ## LibraryClasses += "# this module.\n" | |
2041 | ## LibraryClasses += "#\n" + "#"*80 + "\n\n" | |
2042 | ||
2043 | LibraryClasses = "\n" | |
2044 | if (len(LibClassList) > 0): | |
2045 | LibraryClasses += "[LibraryClasses]\n" | |
2046 | for lc in LibClassList[:]: | |
2047 | LibraryClasses += " " + lc + "\n" | |
2048 | LibraryClasses += "\n" | |
2049 | ||
2050 | if (len(LibClassListIa32) > 0): | |
2051 | LibraryClasses += "[LibraryClasses.IA32]\n" | |
2052 | for lc in LibClassListIa32[:]: | |
2053 | LibraryClasses += " " + lc + "\n" | |
2054 | LibraryClasses += "\n" | |
2055 | ||
2056 | if (len(LibClassListX64) > 0): | |
2057 | LibraryClasses += "[LibraryClasses.X64]\n" | |
2058 | for lc in LibClassListX64[:]: | |
2059 | LibraryClasses += " " + lc + "\n" | |
2060 | LibraryClasses += "\n" | |
2061 | ||
2062 | if (len(LibClassListIpf) > 0): | |
2063 | LibraryClasses += "[LibraryClasses.IPF]\n" | |
2064 | for lc in LibClassListIpf[:]: | |
2065 | LibraryClasses += " " + lc + "\n" | |
2066 | LibraryClasses += "\n" | |
2067 | ||
2068 | if (len(LibClassListEbc) > 0): | |
2069 | LibraryClasses += "[LibraryClasses.EBC]\n" | |
2070 | for lc in LibClassListEbc[:]: | |
2071 | LibraryClasses += " " + lc + "\n" | |
2072 | LibraryClasses += "\n" | |
2073 | ||
2074 | Output.append(LibraryClasses) | |
2075 | if (options.debug): | |
2076 | print LibraryClasses | |
2077 | ||
2078 | # Print the Guids sections | |
2079 | if (len(GuidCName) + len(GuidCNameIa32) + len(GuidCNameIPF) + len(GuidCNameX64) + len(GuidCNameEBC)) > 0: | |
2080 | ## GuidSection = "\n" + "#"*80 + "\n#\n" | |
2081 | ## GuidSection += "# Guid C Name Section - list of Guids that this module uses or produces.\n" | |
2082 | ## GuidSection += "#\n" + "#"*80 + "\n\n" | |
2083 | GuidSection = "\n" | |
2084 | if (len(GuidCName) > 0): | |
2085 | GuidSection += "[Guids]\n" | |
2086 | for Guid in GuidCName[:]: | |
2087 | GuidSection += Guid + "\n" | |
2088 | GuidSection += "\n" | |
2089 | ||
2090 | if (len(GuidCNameIa32) > 0): | |
2091 | GuidSection += "[Guids.IA32]\n" | |
2092 | for Guid in GuidCNameIa32[:]: | |
2093 | GuidSection += Guid + "\n" | |
2094 | GuidSection += "\n" | |
2095 | ||
2096 | if (len(GuidCNameX64) > 0): | |
2097 | GuidSection += "[Guids.X64]\n" | |
2098 | for Guid in GuidCNameX64[:]: | |
2099 | GuidSection += Guid + "\n" | |
2100 | GuidSection += "\n" | |
2101 | ||
2102 | if (len(GuidCNameIPF) > 0): | |
2103 | GuidSection += "[Guids.IPF]\n" | |
2104 | for Guid in GuidCNameIPF[:]: | |
2105 | GuidSection += Guid + "\n" | |
2106 | GuidSection += "\n" | |
2107 | ||
2108 | if (len(GuidCNameEBC) > 0): | |
2109 | GuidSection += "[Guids.EBC]\n" | |
2110 | for Guid in GuidCNameEBC[:]: | |
2111 | GuidSection += Guid + "\n" | |
2112 | GuidSection += "\n" | |
2113 | ||
2114 | Output.append(GuidSection) | |
2115 | if (options.debug and options.verbose > 1): | |
2116 | print GuidSection | |
2117 | ||
2118 | # Print the Protocol sections | |
2119 | if (len(ProtocolCName) + len(ProtocolCNameIa32) + len(ProtocolCNameIPF) + len(ProtocolCNameX64) + len(ProtocolCNameEBC)) > 0: | |
2120 | ## ProtocolsSection = "\n" + "#"*80 + "\n#\n" | |
2121 | ## ProtocolsSection += "# Protocol C Name Section - list of Protocol and Protocol Notify C Names\n" | |
2122 | ## ProtocolsSection += "# that this module uses or produces.\n" | |
2123 | ## ProtocolsSection += "#\n" + "#"*80 + "\n\n" | |
2124 | ||
2125 | ProtocolsSection = "\n" | |
2126 | if (len(ProtocolCName) > 0): | |
2127 | ProtocolsSection += "[Protocols]\n" | |
2128 | for Guid in ProtocolCName[:]: | |
2129 | ProtocolsSection += Guid + "\n" | |
2130 | ProtocolsSection += "\n" | |
2131 | ||
2132 | if (len(ProtocolCNameIa32) > 0): | |
2133 | ProtocolsSection += "[Protocols.IA32]\n" | |
2134 | for Guid in ProtocolCNameIa32[:]: | |
2135 | ProtocolsSection += Guid + "\n" | |
2136 | ProtocolsSection += "\n" | |
2137 | ||
2138 | if (len(ProtocolCNameX64) > 0): | |
2139 | ProtocolsSection += "[Protocols.X64]\n" | |
2140 | for Guid in ProtocolCNameX64[:]: | |
2141 | ProtocolsSection += Guid + "\n" | |
2142 | ProtocolsSection += "\n" | |
2143 | ||
2144 | if (len(ProtocolCNameIPF) > 0): | |
2145 | ProtocolsSection += "[Protocols.IPF]\n" | |
2146 | for Guid in ProtocolCNameIPF[:]: | |
2147 | ProtocolsSection += Guid + "\n" | |
2148 | ProtocolsSection += "\n" | |
2149 | ||
2150 | if (len(ProtocolCNameEBC) > 0): | |
2151 | ProtocolsSection += "[Protocols.EBC]\n" | |
2152 | for Guid in ProtocolCNameEBC[:]: | |
2153 | ProtocolsSection += Guid + "\n" | |
2154 | ProtocolsSection += "\n" | |
2155 | ||
2156 | Output.append(ProtocolsSection) | |
2157 | if (options.debug): | |
2158 | print ProtocolsSection | |
2159 | ||
2160 | # Print the PPI sections | |
2161 | if (len(PpiCName) + len(PpiCNameIa32) + len(PpiCNameIPF) + len(PpiCNameX64) + len(PpiCNameEBC)) > 0: | |
2162 | ## PpiSection = "\n" + "#"*80 + "\n#\n" | |
2163 | ## PpiSection += "# PPI C Name Section - list of PPI and PPI Notify C Names that this module\n" | |
2164 | ## PpiSection += "# uses or produces.\n" | |
2165 | ## PpiSection += "#\n" + "#"*80 + "\n\n" | |
2166 | ||
2167 | PpiSection = "\n" | |
2168 | if (len(PpiCName) > 0): | |
2169 | PpiSection += "[Ppis]\n" | |
2170 | for Guid in PpiCName[:]: | |
2171 | PpiSection += Guid + "\n" | |
2172 | PpiSection += "\n" | |
2173 | ||
2174 | if (len(PpiCNameIa32) > 0): | |
2175 | PpiSection += "[Ppis.IA32]\n" | |
2176 | for Guid in PpiCNameIa32[:]: | |
2177 | PpiSection += Guid + "\n" | |
2178 | PpiSection += "\n" | |
2179 | ||
2180 | if (len(PpiCNameX64) > 0): | |
2181 | PpiSection += "[Ppis.X64]\n" | |
2182 | for Guid in PpiCNameX64[:]: | |
2183 | PpiSection += Guid + "\n" | |
2184 | PpiSection += "\n" | |
2185 | ||
2186 | if (len(PpiCNameIPF) > 0): | |
2187 | PpiSection += "[Ppis.IPF]\n" | |
2188 | for Guid in PpiCNameIPF[:]: | |
2189 | PpiSection += Guid + "\n" | |
2190 | PpiSection += "\n" | |
2191 | ||
2192 | if (len(PpiCNameEBC) > 0): | |
2193 | PpiSection += "[Ppis.EBC]\n" | |
2194 | for Guid in PpiCNameEBC[:]: | |
2195 | PpiSection += Guid + "\n" | |
2196 | PpiSection += "\n" | |
2197 | ||
2198 | Output.append(PpiSection) | |
2199 | if (options.debug): | |
2200 | print PpiSection | |
2201 | ||
2202 | # Print the PCD sections | |
2203 | if ((len(PcdFF)+len(PcdFFIa32)+len(PcdFFX64)+len(PcdFFIpf)+len(PcdFFEbc)) > 0): | |
2204 | ## FeatureFlagSection = "\n" + "#"*80 + "\n#\n" | |
2205 | ## FeatureFlagSection += "# Pcd FEATURE_FLAG - list of PCDs that this module is coded for.\n" | |
2206 | ## FeatureFlagSection += "#\n" + "#"*80 + "\n\n" | |
2207 | ||
2208 | FeatureFlagSection = "\n" | |
2209 | if (len(PcdFF) > 0): | |
2210 | FeatureFlagSection += "[FeaturePcd.common]\n" | |
2211 | for Entry in PcdFF[:]: | |
2212 | FeatureFlagSection += " " + Entry + "\n" | |
2213 | FeatureFlagSection += "\n" | |
2214 | if (len(PcdFFIa32) > 0): | |
2215 | FeatureFlagSection += "[FeaturePcd.IA32]\n" | |
2216 | for Entry in PcdFFIa32[:]: | |
2217 | FeatureFlagSection += " " + Entry + "\n" | |
2218 | FeatureFlagSection += "\n" | |
2219 | if (len(PcdFFX64) > 0): | |
2220 | FeatureFlagSection += "[FeaturePcd.X64]\n" | |
2221 | for Entry in PcdFFX64[:]: | |
2222 | FeatureFlagSection += " " + Entry + "\n" | |
2223 | FeatureFlagSection += "\n" | |
2224 | if (len(PcdFFIpf) > 0): | |
2225 | FeatureFlagSection += "[PcdsFeatureFlag.IPF]\n" | |
2226 | for Entry in PcdFFIpf[:]: | |
2227 | FeatureFlagSection += " " + Entry + "\n" | |
2228 | FeatureFlagSection += "\n" | |
2229 | if (len(PcdFFEbc) > 0): | |
2230 | FeatureFlagSection += "[FeaturePcd.EBC]\n" | |
2231 | for Entry in PcdFFEbc[:]: | |
2232 | FeatureFlagSection += " " + Entry + "\n" | |
2233 | FeatureFlagSection += "\n" | |
2234 | ||
2235 | Output.append(FeatureFlagSection) | |
2236 | if (options.debug): | |
2237 | print FeatureFlagSection | |
2238 | ||
2239 | if ((len(PcdFAB)+len(PcdFABIa32)+len(PcdFABX64)+len(PcdFABIpf)+len(PcdFABEbc)) > 0): | |
2240 | ## FixedAtBuildSection = "\n" + "#"*80 + "\n#\n" | |
2241 | ## FixedAtBuildSection += "# Pcd FIXED_AT_BUILD - list of PCDs that this module is coded for.\n" | |
2242 | ## FixedAtBuildSection += "#\n" + "#"*80 + "\n\n" | |
2243 | ||
2244 | FixedAtBuildSection = "\n" | |
2245 | if (len(PcdFAB) > 0): | |
2246 | FixedAtBuildSection += "[FixedPcd.common]\n" | |
2247 | for Entry in PcdFAB[:]: | |
2248 | FixedAtBuildSection += " " + Entry + "\n" | |
2249 | FixedAtBuildSection += "\n" | |
2250 | if (len(PcdFABIa32) > 0): | |
2251 | FixedAtBuildSection += "[FixedPcd.IA32]\n" | |
2252 | for Entry in PcdFABIa32[:]: | |
2253 | FixedAtBuildSection += " " + Entry + "\n" | |
2254 | FixedAtBuildSection += "\n" | |
2255 | if (len(PcdFABX64) > 0): | |
2256 | FixedAtBuildSection += "[FixedPcd.X64]\n" | |
2257 | for Entry in PcdFABX64[:]: | |
2258 | FixedAtBuildSection += " " + Entry + "\n" | |
2259 | FixedAtBuildSection += "\n" | |
2260 | if (len(PcdFABIpf) > 0): | |
2261 | FixedAtBuildSection += "[FixedPcd.IPF]\n" | |
2262 | for Entry in PcdFABIpf[:]: | |
2263 | FixedAtBuildSection += " " + Entry + "\n" | |
2264 | FixedAtBuildSection += "\n" | |
2265 | if (len(PcdFABEbc) > 0): | |
2266 | FixedAtBuildSection += "[FixedPcd.EBC]\n" | |
2267 | for Entry in PcdFABEbc[:]: | |
2268 | FixedAtBuildSection += " " + Entry + "\n" | |
2269 | FixedAtBuildSection += "\n" | |
2270 | ||
2271 | Output.append(FixedAtBuildSection) | |
2272 | if (options.debug): | |
2273 | print FixedAtBuildSection | |
2274 | ||
2275 | if ((len(PcdPIM)+len(PcdPIMIa32)+len(PcdPIMX64)+len(PcdPIMIpf)+len(PcdPIMEbc)) > 0): | |
2276 | ## PatchableInModuleSection = "\n" + "#"*80 + "\n#\n" | |
2277 | ## PatchableInModuleSection += "# Pcd PATCHABLE_IN_MODULE - list of PCDs that this module is coded for.\n" | |
2278 | ## PatchableInModuleSection += "#\n" + "#"*80 + "\n\n" | |
2279 | ||
2280 | PatchableInModuleSection = "\n" | |
2281 | if (len(PcdPIM) > 0): | |
2282 | PatchableInModuleSection += "[PatchPcd.common]\n" | |
2283 | for Entry in PcdPIM[:]: | |
2284 | PatchableInModuleSection += " " + Entry + "\n" | |
2285 | PatchableInModuleSection += "\n" | |
2286 | if (len(PcdPIMIa32) > 0): | |
2287 | PatchableInModuleSection += "[PatchPcd.IA32]\n" | |
2288 | for Entry in PcdPIMIa32[:]: | |
2289 | PatchableInModuleSection += " " + Entry + "\n" | |
2290 | PatchableInModuleSection += "\n" | |
2291 | if (len(PcdPIMX64) > 0): | |
2292 | PatchableInModuleSection += "[PatchPcd.X64]\n" | |
2293 | for Entry in PcdPIMX64[:]: | |
2294 | PatchableInModuleSection += " " + Entry + "\n" | |
2295 | PatchableInModuleSection += "\n" | |
2296 | if (len(PcdPIMIpf) > 0): | |
2297 | PatchableInModuleSection += "[PatchPcd.IPF]\n" | |
2298 | for Entry in PcdPIMIpf[:]: | |
2299 | PatchableInModuleSection += " " + Entry + "\n" | |
2300 | PatchableInModuleSection += "\n" | |
2301 | if (len(PcdPIMEbc) > 0): | |
2302 | PatchableInModuleSection += "[PatchPcd.EBC]\n" | |
2303 | for Entry in PcdPIMEbc[:]: | |
2304 | PatchableInModuleSection += " " + Entry + "\n" | |
2305 | PatchableInModuleSection += "\n" | |
2306 | ||
2307 | Output.append(PatchableInModuleSection) | |
2308 | if (options.debug): | |
2309 | print PatchableInModuleSection | |
2310 | ||
2311 | if ((len(PcdDYE)+len(PcdDYEIa32)+len(PcdDYEX64)+len(PcdDYEIpf)+len(PcdDYEEbc)) > 0): | |
2312 | ## DynamicExSection = "\n" + "#"*80 + "\n#\n" | |
2313 | ## DynamicExSection += "# Pcd DYNAMIC_EX - list of PCDs that this module is coded for.\n" | |
2314 | ## DynamicExSection += "#\n" + "#"*80 + "\n\n" | |
2315 | ||
2316 | DynamicExSection = "\n" | |
2317 | if (len(PcdDYE) > 0): | |
2318 | DynamicExSection += "[PcdEx.common]\n" | |
2319 | for Entry in PcdDYE[:]: | |
2320 | DynamicExSection += " " + Entry + "\n" | |
2321 | DynamicExSection += "\n" | |
2322 | if (len(PcdDYEIa32) > 0): | |
2323 | DynamicExSection += "[PcdEx.IA32]\n" | |
2324 | for Entry in PcdDYEIa32[:]: | |
2325 | DynamicExSection += " " + Entry + "\n" | |
2326 | DynamicExSection += "\n" | |
2327 | if (len(PcdDYEX64) > 0): | |
2328 | DynamicExSection += "[PcdEx.X64]\n" | |
2329 | for Entry in PcdDYEX64[:]: | |
2330 | DynamicExSection += " " + Entry + "\n" | |
2331 | DynamicExSection += "\n" | |
2332 | if (len(PcdDYEIpf) > 0): | |
2333 | DynamicExSection += "[PcdEx.IPF]\n" | |
2334 | for Entry in PcdDYEIpf[:]: | |
2335 | DynamicExSection += " " + Entry + "\n" | |
2336 | DynamicExSection += "\n" | |
2337 | if (len(PcdDYEEbc) > 0): | |
2338 | DynamicExSection += "[PcdEx.EBC]\n" | |
2339 | for Entry in PcdDYEEbc[:]: | |
2340 | DynamicExSection += " " + Entry + "\n" | |
2341 | DynamicExSection += "\n" | |
2342 | ||
2343 | Output.append(DynamicExSection) | |
2344 | if (options.debug): | |
2345 | print DynamicExSection | |
2346 | ||
2347 | if ((len(PcdDY)+len(PcdDYIa32)+len(PcdDYX64)+len(PcdDYIpf)+len(PcdDYEbc)) > 0): | |
2348 | ## DynamicSection = "\n" + "#"*80 + "\n#\n" | |
2349 | ## DynamicSection += "# Pcd DYNAMIC - list of PCDs that this module is coded for.\n" | |
2350 | ## DynamicSection += "#\n" + "#"*80 + "\n\n" | |
2351 | ||
2352 | DynamicSection = "\n" | |
2353 | if (len(PcdDY) > 0): | |
2354 | DynamicSection += "[Pcd.common]\n" | |
2355 | for Entry in PcdDY[:]: | |
2356 | DynamicSection += " " + Entry + "\n" | |
2357 | DynamicSection += "\n" | |
2358 | if (len(PcdDYIa32) > 0): | |
2359 | DynamicSection += "[Pcd.IA32]\n" | |
2360 | for Entry in PcdDYIa32[:]: | |
2361 | DynamicSection += " " + Entry + "\n" | |
2362 | DynamicSection += "\n" | |
2363 | if (len(PcdDYX64) > 0): | |
2364 | DynamicSection += "[Pcd.X64]\n" | |
2365 | for Entry in PcdDYX64[:]: | |
2366 | DynamicSection += " " + Entry + "\n" | |
2367 | DynamicSection += "\n" | |
2368 | if (len(PcdDYIpf) > 0): | |
2369 | DynamicSection += "[Pcd.IPF]\n" | |
2370 | for Entry in PcdDYIpf[:]: | |
2371 | DynamicSection += " " + Entry + "\n" | |
2372 | DynamicSection += "\n" | |
2373 | if (len(PcdDYEbc) > 0): | |
2374 | DynamicSection += "[Pcd.EBC]\n" | |
2375 | for Entry in PcdDYEbc[:]: | |
2376 | DynamicSection += " " + Entry + "\n" | |
2377 | DynamicSection += "\n" | |
2378 | ||
2379 | Output.append(DynamicSection) | |
2380 | if (options.debug): | |
2381 | print DynamicSection | |
2382 | ||
2383 | if ((len(Depex) + len(DepexIa32) + len(DepexX64) + len(DepexIpf) + len(DepexEbc)) > 0): | |
2384 | """ We do this if and only if we have Package Dependencies """ | |
2385 | ## Dpx = "\n" + "#"*80 + "\n#\n" | |
2386 | ## Dpx += "# Dependency Expression Section - list of Dependency expressions that are required for\n" | |
2387 | ## Dpx += "# this module.\n" | |
2388 | ## Dpx += "#\n" + "#"*80 + "\n\n" | |
2389 | Dpx = "\n" | |
2390 | if (len(Depex) > 0): | |
2391 | Dpx += "[Depex]\n" | |
2392 | for lc in Depex[:]: | |
2393 | Dpx += " " + lc + "\n" | |
2394 | Dpx += "\n" | |
2395 | ||
2396 | if (len(DepexIa32) > 0): | |
2397 | Dpx += "[Depex.IA32]\n" | |
2398 | for lc in DepexIa32[:]: | |
2399 | Dpx += " " + lc + "\n" | |
2400 | Dpx += "\n" | |
2401 | ||
2402 | if (len(DepexX64) > 0): | |
2403 | Dpx += "[Depex.X64]\n" | |
2404 | for lc in DepexX64[:]: | |
2405 | Dpx += " " + lc + "\n" | |
2406 | Dpx += "\n" | |
2407 | ||
2408 | if (len(DepexIpf) > 0): | |
2409 | Dpx += "[Depex.IPF]\n" | |
2410 | for lc in DepexIpf[:]: | |
2411 | Dpx += " " + lc + "\n" | |
2412 | Dpx += "\n" | |
2413 | ||
2414 | if (len(DepexEbc) > 0): | |
2415 | Dpx += "[Depex.EBC]\n" | |
2416 | for lc in DepexEbc[:]: | |
2417 | Dpx += " " + lc + "\n" | |
2418 | Dpx += "\n" | |
2419 | ||
2420 | Output.append(Dpx) | |
2421 | if (options.debug): | |
2422 | print Dpx | |
2423 | ||
2424 | if (len(MBOlines) > 0): | |
2425 | BuildSection = "" | |
2426 | ## BuildSection = "\n" + "#"*80 + "\n#\n" | |
2427 | ## BuildSection += "# Build Options - list of custom build options for this module.\n" | |
2428 | ## BuildSection += "#\n" + "#"*80 + "\n\n" | |
2429 | BuildSection += "\n[BuildOptions]\n" | |
2430 | for mbo in MBOlines: | |
2431 | tool, targs = mbo.split("=",2) | |
2432 | BuildSection += " %-40s = %s\n" % (tool.strip(), targs.strip()) | |
2433 | ||
2434 | Output.append(BuildSection) | |
2435 | if (options.debug): | |
2436 | print BuildSection | |
2437 | ||
2438 | ||
2439 | if (len(UEList) > 0): | |
2440 | UserExtensionSection = "" | |
2441 | for UE in UEList[:]: | |
2442 | UserExtensionSection += "[UserExtensions." + UE[0] + '."' + UE[1] + '"]\n' | |
2443 | if (len(UE[2]) > 0): | |
2444 | UserExtensionSection += '"' + UE[2] + '"\n' | |
2445 | else: | |
2446 | UserExtensionSection += "\n" | |
2447 | ||
2448 | Output.append(UserExtensionSection) | |
2449 | if (options.debug): | |
2450 | print UserExtensionSection | |
2451 | ||
2452 | print "write file", outputFile | |
2453 | if (options.autowrite): | |
2454 | fo = open(outputFile, "w") | |
2455 | for Section in Output[:]: | |
2456 | fo.writelines(Section) | |
2457 | if (options.verbose > 1): | |
2458 | print Section | |
2459 | fo.close() | |
2460 | elif (options.outfile): | |
2461 | fo = open(outputFile, "w") | |
2462 | for Section in Output[:]: | |
2463 | fo.writelines(Section) | |
2464 | fo.close() | |
2465 | else: | |
2466 | for Section in Output[:]: | |
2467 | print Section | |
2468 | ||
2469 | ||
2470 | if __name__ == '__main__': | |
2471 | ||
2472 | global options | |
2473 | global args | |
2474 | options,args = myOptionParser() | |
2475 | ||
2476 | main() | |
2477 | sys.exit(0) | |
2478 |