]>
git.proxmox.com Git - mirror_edk2.git/blob - Tools/Python/MkFar.py
3 import os
, sys
, re
, getopt
, string
, glob
, xml
.dom
.minidom
, pprint
, zipfile
, tempfile
4 from XmlRoutines
import *
5 from WorkspaceRoutines
import *
7 def parseMsa(msaFile
, spdDir
):
11 msaDir
= os
.path
.dirname(msaFile
)
13 msa
= xml
.dom
.minidom
.parse(inWorkspace(msaFile
))
16 "/ModuleSurfaceArea/SourceFiles/Filename" ]
18 for xmlPath
in xmlPaths
:
19 for f
in XmlList(msa
, xmlPath
):
20 filelist
.append(str(os
.path
.join(msaDir
, XmlElementData(f
))))
24 def parseSpd(spdFile
):
29 spdDir
= os
.path
.dirname(spdFile
)
31 spd
= xml
.dom
.minidom
.parse(inWorkspace(spdFile
))
34 "/PackageSurfaceArea/LibraryClassDeclarations/LibraryClass/IncludeHeader",
35 "/PackageSurfaceArea/IndustryStdIncludes/IndustryStdHeader/IncludeHeader",
36 "/PackageSurfaceArea/<PackageHeaders/IncludePkgHeader" ]
38 for xmlPath
in xmlPaths
:
39 for f
in XmlList(spd
, xmlPath
):
40 filelist
.append(str(os
.path
.join(spdDir
, XmlElementData(f
))))
42 for xmlPath
in ["/PackageSurfaceArea/MsaFiles/Filename"]:
43 for f
in XmlList(spd
, xmlPath
):
44 msaFile
= str(os
.path
.join(spdDir
, XmlElementData(f
)))
45 filelist
.append(msaFile
)
47 filelist
+= parseMsa(msaFile
, spdDir
)
51 def makeFar(filelist
, farname
):
54 """<?xml version="1.0" encoding="UTF-8"?>
55 <FrameworkArchiveManifest>
56 </FrameworkArchiveManifest>
58 zip = zipfile
.ZipFile(farname
, "w")
60 if not os
.path
.exists(inWorkspace(file)):
61 print "Skipping non-existent file '%s'." % file
62 (_
, extension
) = os
.path
.splitext(file)
63 if extension
== ".spd":
64 filelist
= parseSpd(file)
65 elif extension
== ".fpd":
69 for f
in set(filelist
):
70 zip.write(inWorkspace(f
), f
)
71 zip.writestr("FrameworkArchiveManifest.xml", man
)
75 # This acts like the main() function for the script, unless it is 'import'ed into another
77 if __name__
== '__main__':
79 # Create a pretty printer for dumping data structures in a readable form.
80 # pp = pprint.PrettyPrinter(indent=2)
82 # Process the command line args.
83 optlist
, args
= getopt
.getopt(sys
.argv
[1:], 'h', [ 'example-long-arg=', 'testing'])
85 makeFar(args
, "test.far")