]>
git.proxmox.com Git - mirror_edk2.git/blob - Python/GenMake.py
3 """Create Makefiles for the MdePkg."""
5 import os
, sys
, getopt
, string
, xml
.dom
.minidom
, shutil
6 from XmlRoutines
import *
7 from WorkspaceRoutines
import *
11 Makefile
= """MAKEROOT ?= ..
17 include $(MAKEROOT)/lib.makefile
22 """Open the MdePkg.spd and process the msa files."""
24 db
= xml
.dom
.minidom
.parse(inWorkspace("MdePkg/MdePkg.spd"))
26 for msaFile
in XmlList(db
, "/PackageSurfaceArea/MsaFiles/Filename"):
27 msaFileName
= XmlElementData(msaFile
)
33 """Make a path relative to the Mde Pkg root dir."""
34 return inWorkspace(os
.path
.join("MdePkg", f
))
38 """Create a directory with the sources, AutoGen.h and a makefile."""
42 msa
= xml
.dom
.minidom
.parse(inMde(msafile
))
43 libName
= str(XmlElement(msa
, "/ModuleSurfaceArea/MsaHeader/ModuleName"))
44 base
, _
= os
.path
.splitext(msafile
)
45 msabase
= os
.path
.basename(base
)
47 suppArch
= str(XmlElement(msa
, "/ModuleSurfaceArea/ModuleDefinitions/SupportedArchitectures"))
48 if not ARCH
in string
.split(suppArch
, " "):
52 os
.path
.isdir(libName
) or os
.mkdir(libName
);
54 print "Error: file %s exists" % libName
58 for msaFile
in XmlList(msa
, "/ModuleSurfaceArea/SourceFiles/Filename"):
60 msaFileName
= str(XmlElementData(msaFile
))
61 arch
= msaFile
.getAttribute("SupArchList")
62 toolchain
= msaFile
.getAttribute("ToolChainFamily")
63 base
, ext
= os
.path
.splitext(msaFileName
)
65 if arch
in ["", ARCH
] and (ext
in [".c", ".h"] or toolchain
in ["GCC"]):
66 if ext
in [".c", ".S"]:
67 sources
.append(str(base
+".o"))
68 targetDir
= os
.path
.join(libName
, os
.path
.dirname(msaFileName
))
70 os
.makedirs(targetDir
)
73 shutil
.copy(inMde(os
.path
.join(os
.path
.dirname(msafile
), msaFileName
)),
76 # Write a Makefile for this module
77 f
= open(os
.path
.join(libName
, "Makefile"), "w")
78 f
.write(Makefile
% (libName
, string
.join(sources
, " ")))
81 # Right now we are getting the AutoGen.h file from a previous build. We
82 # could create it from scratch also.
83 shutil
.copy(inWorkspace("Build/Mde/DEBUG_UNIXGCC/%s/MdePkg/Library/%s/%s/DEBUG/AutoGen.h") % (ARCH
, libName
, msabase
), libName
)
85 # This acts like the main() function for the script, unless it is 'import'ed
86 # into another script.
87 if __name__
== '__main__':