summaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
authorbbahnsen <bbahnsen@6f19259b-4bc3-4df7-8a09-765794883524>2006-12-22 00:25:11 +0000
committerbbahnsen <bbahnsen@6f19259b-4bc3-4df7-8a09-765794883524>2006-12-22 00:25:11 +0000
commitaf2efcafd4974000a9dfe0f09aa78dcda70aba78 (patch)
treee63bfb61a65476ef90a31119d297b585ca2464d9 /Tools
parentd56b1906f1f157735559397578474f8cc7d8fcdb (diff)
downloadedk2-platforms-af2efcafd4974000a9dfe0f09aa78dcda70aba78.tar.xz
Added some new field to the far template.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2126 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/Python/Calc-Deps.py17
-rwxr-xr-xTools/Python/ListWorkspace.py47
-rwxr-xr-xTools/Python/MkFar.py42
-rwxr-xr-xTools/Python/WorkspaceRoutines.py5
-rwxr-xr-xTools/Python/XmlRoutines.py2
-rw-r--r--Tools/Python/far-template71
6 files changed, 140 insertions, 44 deletions
diff --git a/Tools/Python/Calc-Deps.py b/Tools/Python/Calc-Deps.py
index a0afa3f432..204379a3cb 100755
--- a/Tools/Python/Calc-Deps.py
+++ b/Tools/Python/Calc-Deps.py
@@ -120,6 +120,8 @@ def getCNames(spdFile):
# Get the name of the package
packageName = XmlElement(spd, "PackageSurfaceArea/SpdHeader/PackageName")
+ packageVersion = XmlElement(spd, "PackageSurfaceArea/SpdHeader/Version")
+ packageGuid = XmlElement(spd, "PackageSurfaceArea/SpdHeader/GuidValue")
# Find the C_Name
for cname in XmlList(spd, "/PackageSurfaceArea/GuidDeclarations/Entry/C_Name") + \
@@ -132,7 +134,8 @@ def getCNames(spdFile):
# Map the <C_Name> to the <PackageName>. We will use this to lookup every
# identifier in the Input Code.
- cname_table[cname_text] = packageName
+ cname_table[cname_text] = {"name": packageName, "version": packageVersion, "guid": packageGuid}
+
return
@@ -195,7 +198,11 @@ large file."""
getSpds()
# Debug stuff.
- print pp.pprint(function_table)
- print pp.pprint(cname_table)
- print "Classes = ", pp.pprint(list(search_classes(ids)))
- print "C_Names = ", pp.pprint(list(search_cnames(ids)))
+ print "Function Table = "
+ pp.pprint(function_table)
+ print "CName Table = "
+ pp.pprint(cname_table)
+ print "Classes = "
+ pp.pprint(list(search_classes(ids)))
+ print "C_Names = "
+ pp.pprint(list(search_cnames(ids)))
diff --git a/Tools/Python/ListWorkspace.py b/Tools/Python/ListWorkspace.py
new file mode 100755
index 0000000000..1a1c9deaef
--- /dev/null
+++ b/Tools/Python/ListWorkspace.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+
+"""List the contents of the Framework Database to the screen in a readble
+form."""
+
+import os, sys, getopt, string, xml.dom.minidom, zipfile, md5
+from XmlRoutines import *
+from WorkspaceRoutines import *
+
+def openDatabase(f):
+
+ print "Dumping the contents of %s workspace database file." % f
+
+ db = xml.dom.minidom.parse(inWorkspace(f))
+
+ return db
+
+def showSpds(db):
+
+ print "--------\nPackages\n--------"
+
+ for spdFile in XmlList(db, "/FrameworkDatabase/PackageList/Filename"):
+ spdFileName = XmlElementData(spdFile)
+ spd = xml.dom.minidom.parse(inWorkspace(spdFileName))
+ spdName = XmlElement(spd, "/PackageSurfaceArea/SpdHeader/PackageName")
+
+ print " %-24s %-10s" % (spdName, spdFileName)
+
+def showFpds(db):
+
+ print "--------\nPlatforms\n--------"
+
+ for fpdFile in XmlList(db, "/FrameworkDatabase/PlatformList/Filename"):
+ fpdFileName = XmlElementData(fpdFile)
+ fpd = xml.dom.minidom.parse(inWorkspace(fpdFileName))
+ fpdName = XmlElement(fpd, "/PlatformSurfaceArea/PlatformHeader/PlatformName")
+
+ print " %-24s %-10s" % (fpdName, fpdFileName)
+
+# This acts like the main() function for the script, unless it is 'import'ed
+# into another script.
+if __name__ == '__main__':
+
+ db = openDatabase("Tools/Conf/FrameworkDatabase.db")
+
+ showSpds(db)
+ showFpds(db)
diff --git a/Tools/Python/MkFar.py b/Tools/Python/MkFar.py
index 7531527f58..327c81a94a 100755
--- a/Tools/Python/MkFar.py
+++ b/Tools/Python/MkFar.py
@@ -12,11 +12,12 @@ class Far:
far.FarName=""
far.Version=""
far.License=""
+ far.Abstract=""
far.Description=""
far.Copyright=""
- far.SpdFiles=""
- far.FpdFile=""
- far.ExtraFile=""
+ far.SpdFiles=[]
+ far.FpdFiles=[]
+ far.ExtraFiles=[]
far = Far()
@@ -62,7 +63,8 @@ def parseSpd(spdFile):
cwd = os.getcwd()
os.chdir(inWorkspace(spdDir))
for root, dirs, entries in os.walk("Include"):
- for r in ["CVS", ".svn"]:
+ # Some files need to be skipped.
+ for r in ["CVS", ".svn"]:
if r in dirs:
dirs.remove(r)
for entry in entries:
@@ -108,7 +110,7 @@ def getSpdGuidVersion(spdFile):
return (XmlElement(spd, "/PackageSurfaceArea/SpdHeader/GuidValue"),
XmlElement(spd, "/PackageSurfaceArea/SpdHeader/Version"))
-def makeFar(filelist, farname):
+def makeFar(files, farname):
domImpl = xml.dom.minidom.getDOMImplementation()
man = domImpl.createDocument(None, "FrameworkArchiveManifest", None)
@@ -129,7 +131,7 @@ def makeFar(filelist, farname):
top_element.appendChild(exts)
zip = zipfile.ZipFile(farname, "w")
- for infile in filelist:
+ for infile in set(files):
if not os.path.exists(inWorkspace(infile)):
print "Skipping non-existent file '%s'." % infile
(_, extension) = os.path.splitext(infile)
@@ -144,7 +146,7 @@ def makeFar(filelist, farname):
spdfilename = farFileNode(man, inWorkspace(infile))
zip.write(inWorkspace(infile), infile)
- spdfilename.appendChild(man.createTextNode(infile))
+ spdfilename.appendChild(man.createTextNode(lean(infile)))
package.appendChild(spdfilename)
guidValue = man.createElement("GuidValue")
@@ -171,7 +173,7 @@ def makeFar(filelist, farname):
for spdfile in filelist:
content = farFileNode(man, inWorkspace(os.path.join(spdDir, spdfile)))
zip.write(inWorkspace(os.path.join(spdDir, spdfile)), spdfile)
- content.appendChild(man.createTextNode(spdfile))
+ content.appendChild(man.createTextNode(lean(spdfile)))
packContents.appendChild(content)
elif extension == ".fpd":
@@ -182,12 +184,12 @@ def makeFar(filelist, farname):
fpdfilename = farFileNode(man, inWorkspace(infile))
zip.write(inWorkspace(infile), infile)
platform.appendChild(fpdfilename)
- fpdfilename.appendChild( man.createTextNode(infile) )
+ fpdfilename.appendChild(man.createTextNode(lean(infile)))
else:
content = farFileNode(man, inWorkspace(infile))
zip.write(inWorkspace(infile), infile)
- content.appendChild(man.createTextNode(infile))
+ content.appendChild(man.createTextNode(lean(infile)))
contents.appendChild(content)
zip.writestr("FrameworkArchiveManifest.xml", man.toprettyxml(2*" "))
@@ -211,6 +213,7 @@ if __name__ == '__main__':
# Process the command line args.
optlist, args = getopt.getopt(sys.argv[1:], 'hf:t:', [ 'template=', 'far=', 'help'])
+ # First pass through the options list.
for o, a in optlist:
if o in ["-h", "--help"]:
print """
@@ -220,19 +223,28 @@ You may give the name of the far with a -f or --far option. For example:
%s --far library.far MdePkg/MdePkg.spd
The file paths of .spd and .fpd are treated as relative to the WORKSPACE
-envirnonment variable which must be set to a valid workspace root directory.
+environment variable which must be set to a valid workspace root directory.
""" % os.path.basename(sys.argv[0])
sys.exit()
+ optlist.remove((o,a))
if o in ["-t", "--template"]:
# The template file is processed first, so that command line options can
# override it.
templateName = a
execfile(templateName)
+ optlist.remove((o,a))
+
+ # Second pass through the options list. These can override the first pass.
+ for o, a in optlist:
+ print o, a
if o in ["-f", "--far"]:
far.FileName = a
- if os.path.exists(far.FileName):
- print "Error: File %s exists. Not overwriting." % far.FileName
- sys.exit()
- makeFar(args, far.FileName)
+ # Let's err on the side of caution and not let people blow away data
+ # accidentally.
+ if os.path.exists(far.FileName):
+ print "Error: File %s exists. Not overwriting." % far.FileName
+ sys.exit()
+
+ makeFar(far.SpdFiles + far.FpdFiles + far.ExtraFiles + args, far.FileName)
diff --git a/Tools/Python/WorkspaceRoutines.py b/Tools/Python/WorkspaceRoutines.py
index c919065fc3..a34eff2d71 100755
--- a/Tools/Python/WorkspaceRoutines.py
+++ b/Tools/Python/WorkspaceRoutines.py
@@ -19,3 +19,8 @@ def genguid():
str(time.time()) +
socket.gethostbyname(socket.gethostname())).hexdigest()
return "%s-%s-%s-%s-%s" % (g[0:8], g[8:12], g[12:16], g[16:20], g[20:])
+
+def lean(path):
+ """Lean the slashes forward"""
+
+ return os.path.normpath(path).replace("\\", "/")
diff --git a/Tools/Python/XmlRoutines.py b/Tools/Python/XmlRoutines.py
index 6968f14aef..9d1ff4a0e3 100755
--- a/Tools/Python/XmlRoutines.py
+++ b/Tools/Python/XmlRoutines.py
@@ -44,7 +44,7 @@ def XmlAttribute (Dom, String):
def XmlTopTag(Dom):
"""Return the name of the Root or top tag in the XML tree."""
- return Dom.firstChild.nodeName
+ return Dom.documentElement.nodeName
# This acts like the main() function for the script, unless it is 'import'ed into another
diff --git a/Tools/Python/far-template b/Tools/Python/far-template
index c0c40f5d27..62a54d5a87 100644
--- a/Tools/Python/far-template
+++ b/Tools/Python/far-template
@@ -1,23 +1,48 @@
-# This file is a template to be used in creating a Framework Archive Manifest.
-# Each entry can be assigned to a string, which is quoted, or to a string that
-# spans mutliple lines, which is triple quoted.
-# This file should be passed as a command line argument to the MkFar.py script.
-# It is used to help the user control how the far is created.
-
-far.FileName = "my.far"
-far.FarName = "My Far"
-far.Version = "0.3"
-far.License="""This program and the accompanying materials are licensed and made
-available under the terms and conditions of the BSD License which accompanies
-this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER
-THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF
-ANY KIND, EITHER EXPRESS OR IMPLIED."""
-far.Description="""This Package provides headers and libraries that conform to
-my wishes."""
-far.Copyright="Copyright (c) 2006, My Corporation."
-far.SpdFiles=""
-far.FpdFile=""
-far.ExtraFile=""
-
-# vim:syntax=python
+# This file is a template to be used in creating a Framework Archive Manifest.
+# Each entry can be assigned to a string, which is quoted, or to a string that
+# spans mutliple lines, which is triple quoted. Lists of strings are placed
+# inside of square brackets.
+# This file should be passed as a command line argument to the MkFar.py script.
+# It is used to help the user control how the far is created.
+
+# The filename to give the new far.
+far.FileName = "my.far"
+
+# The user readable name to give the far.
+far.FarName = "My Far"
+
+# The version of the far.
+far.Version = "0.3"
+
+# The license terms of the far.
+far.License="""This program and the accompanying materials are licensed and made
+available under the terms and conditions of the BSD License which accompanies
+this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER
+THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF
+ANY KIND, EITHER EXPRESS OR IMPLIED."""
+
+# Short description.
+far.Abstract = "Its a good far."
+
+# Long description.
+far.Description="""This Package provides headers and libraries that conform to
+my wishes."""
+
+# Copyright string to be placed inside the far.
+far.Copyright="Copyright (c) 2006, My Corporation."
+
+# A list of workspace-relative paths to the .spd files that should be
+# placed inside this far.
+far.SpdFiles=[]
+
+# A list of workspace-relative paths to the .fpd files that should be
+# placed inside this far.
+far.FpdFiles=[]
+
+# A list of workspace-relative paths to the extra files that should be
+# placed inside this far. Extra files are ones that are not part of
+# an spd or msa or fpd.
+far.ExtraFiles=["tools_def_for_this_package.template", "setup.sh"]
+
+# vim:syntax=python