mirror of https://github.com/acidanthera/audk.git
Add multi-architecture support to the GNU makefile generator.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2212 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
c6359f6825
commit
07253e8e47
|
@ -1,23 +1,35 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
"""Create Makefiles for the MdePkg."""
|
"""Create GNU Makefiles for the Libraries of the MdePkg."""
|
||||||
|
|
||||||
import os, sys, getopt, string, xml.dom.minidom, shutil
|
import os, sys, getopt, string, xml.dom.minidom, shutil
|
||||||
from XmlRoutines import *
|
from XmlRoutines import *
|
||||||
from WorkspaceRoutines import *
|
from WorkspaceRoutines import *
|
||||||
|
|
||||||
ARCH = "X64"
|
copyingSources = 1
|
||||||
|
|
||||||
Makefile = """MAKEROOT ?= ..
|
Makefile = string.Template("""ARCH = $ARCH
|
||||||
|
|
||||||
LIBNAME = %s
|
MAKEROOT ?= ../..
|
||||||
|
|
||||||
OBJECTS = %s
|
VPATH = ..
|
||||||
|
|
||||||
include $(MAKEROOT)/lib.makefile
|
LIBNAME = $LIBNAME
|
||||||
"""
|
|
||||||
|
|
||||||
def openMdeSpd():
|
OBJECTS = $OBJECTS
|
||||||
|
|
||||||
|
include $$(MAKEROOT)/lib.makefile
|
||||||
|
""")
|
||||||
|
|
||||||
|
def mkdir(path):
|
||||||
|
"""Make a directory if it is not there already."""
|
||||||
|
|
||||||
|
try:
|
||||||
|
os.makedirs(path)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def openMdeSpd(arch):
|
||||||
|
|
||||||
"""Open the MdePkg.spd and process the msa files."""
|
"""Open the MdePkg.spd and process the msa files."""
|
||||||
|
|
||||||
|
@ -25,7 +37,7 @@ def openMdeSpd():
|
||||||
|
|
||||||
for msaFile in XmlList(db, "/PackageSurfaceArea/MsaFiles/Filename"):
|
for msaFile in XmlList(db, "/PackageSurfaceArea/MsaFiles/Filename"):
|
||||||
msaFileName = XmlElementData(msaFile)
|
msaFileName = XmlElementData(msaFile)
|
||||||
DoLib(msaFileName)
|
doLib(msaFileName, arch)
|
||||||
|
|
||||||
return db
|
return db
|
||||||
|
|
||||||
|
@ -33,7 +45,7 @@ def inMde(f):
|
||||||
"""Make a path relative to the Mde Pkg root dir."""
|
"""Make a path relative to the Mde Pkg root dir."""
|
||||||
return inWorkspace(os.path.join("MdePkg", f))
|
return inWorkspace(os.path.join("MdePkg", f))
|
||||||
|
|
||||||
def DoLib(msafile):
|
def doLib(msafile, arch):
|
||||||
|
|
||||||
"""Create a directory with the sources, AutoGen.h and a makefile."""
|
"""Create a directory with the sources, AutoGen.h and a makefile."""
|
||||||
|
|
||||||
|
@ -45,45 +57,43 @@ def DoLib(msafile):
|
||||||
msabase = os.path.basename(base)
|
msabase = os.path.basename(base)
|
||||||
|
|
||||||
suppArch = str(XmlElement(msa, "/ModuleSurfaceArea/ModuleDefinitions/SupportedArchitectures"))
|
suppArch = str(XmlElement(msa, "/ModuleSurfaceArea/ModuleDefinitions/SupportedArchitectures"))
|
||||||
if not ARCH in string.split(suppArch, " "):
|
if not arch in string.split(suppArch, " "):
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
mkdir(libName);
|
||||||
os.path.isdir(libName) or os.mkdir(libName);
|
|
||||||
except:
|
|
||||||
print "Error: file %s exists" % libName
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
|
|
||||||
for msaFile in XmlList(msa, "/ModuleSurfaceArea/SourceFiles/Filename"):
|
buildDir = os.path.join(libName, "build-%s" % arch )
|
||||||
|
mkdir(buildDir)
|
||||||
|
|
||||||
msaFileName = str(XmlElementData(msaFile))
|
for sourceFile in XmlList(msa, "/ModuleSurfaceArea/SourceFiles/Filename"):
|
||||||
arch = msaFile.getAttribute("SupArchList")
|
|
||||||
toolchain = msaFile.getAttribute("ToolChainFamily")
|
|
||||||
base, ext = os.path.splitext(msaFileName)
|
|
||||||
|
|
||||||
if arch in ["", ARCH] and (ext in [".c", ".h"] or toolchain in ["GCC"]):
|
sourceFileName = str(XmlElementData(sourceFile))
|
||||||
|
suppArchs = sourceFile.getAttribute("SupArchList").split(" ")
|
||||||
|
toolchain = sourceFile.getAttribute("ToolChainFamily")
|
||||||
|
base, ext = os.path.splitext(sourceFileName)
|
||||||
|
|
||||||
|
if ( suppArchs == [""] or arch in suppArchs) and (ext in [".c", ".h", ".S"] or toolchain in ["GCC"]):
|
||||||
if ext in [".c", ".S"]:
|
if ext in [".c", ".S"]:
|
||||||
sources.append(str(base+".o"))
|
sources.append(str(base+".o"))
|
||||||
targetDir = os.path.join(libName, os.path.dirname(msaFileName))
|
sourceDir = os.path.join(libName, os.path.dirname(sourceFileName))
|
||||||
try:
|
mkdir(sourceDir)
|
||||||
os.makedirs(targetDir)
|
mkdir(os.path.join(buildDir, os.path.dirname(sourceFileName)))
|
||||||
except:
|
if copyingSources :
|
||||||
pass
|
shutil.copy(inMde(os.path.join(os.path.dirname(msafile), sourceFileName)),
|
||||||
shutil.copy(inMde(os.path.join(os.path.dirname(msafile), msaFileName)),
|
sourceDir)
|
||||||
targetDir)
|
|
||||||
|
|
||||||
# Write a Makefile for this module
|
# Write a Makefile for this module
|
||||||
f = open(os.path.join(libName, "Makefile"), "w")
|
f = open(os.path.join(buildDir, "Makefile"), "w")
|
||||||
f.write(Makefile % (libName, string.join(sources, " ")))
|
f.write(Makefile.substitute(ARCH=arch, LIBNAME=libName, OBJECTS=string.join(sources, " ")))
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
# Right now we are getting the AutoGen.h file from a previous build. We
|
# Right now we are getting the AutoGen.h file from a previous build. We
|
||||||
# could create it from scratch also.
|
# could create it from scratch also.
|
||||||
shutil.copy(inWorkspace("Build/Mde/DEBUG_UNIXGCC/%s/MdePkg/Library/%s/%s/DEBUG/AutoGen.h") % (ARCH, libName, msabase), libName)
|
shutil.copy(inWorkspace("Build/Mde/DEBUG_UNIXGCC/%s/MdePkg/Library/%s/%s/DEBUG/AutoGen.h") % (arch, libName, msabase), buildDir)
|
||||||
|
|
||||||
# This acts like the main() function for the script, unless it is 'import'ed
|
# This acts like the main() function for the script, unless it is 'import'ed
|
||||||
# into another script.
|
# into another script.
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
openMdeSpd();
|
for arch in ["IA32", "X64"]:
|
||||||
|
openMdeSpd(arch);
|
||||||
|
|
Loading…
Reference in New Issue