]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Added some new field to the far template.
authorbbahnsen <bbahnsen@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 22 Dec 2006 00:25:11 +0000 (00:25 +0000)
committerbbahnsen <bbahnsen@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 22 Dec 2006 00:25:11 +0000 (00:25 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2126 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Python/Calc-Deps.py
Tools/Python/ListWorkspace.py [new file with mode: 0755]
Tools/Python/MkFar.py
Tools/Python/WorkspaceRoutines.py
Tools/Python/XmlRoutines.py
Tools/Python/far-template

index a0afa3f432c15853ba01d167e2bd12e80fb1f03b..204379a3cb682a19f66be69c676f5454b155be28 100755 (executable)
@@ -120,6 +120,8 @@ def getCNames(spdFile):
 
   # Get the name of the package
   packageName = XmlElement(spd, "PackageSurfaceArea/SpdHeader/PackageName")
 
   # 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") + \
 
   # 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.
 
     # 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
 
 
   return
 
@@ -195,7 +198,11 @@ large file."""
   getSpds()
 
   # Debug stuff.
   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 (executable)
index 0000000..1a1c9de
--- /dev/null
@@ -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)
index 7531527f582bfc522110fee95b5dd77f88f73abe..327c81a94a28e3033128fbb91ab7f5ed5ce64f43 100755 (executable)
@@ -12,11 +12,12 @@ class Far:
     far.FarName=""
     far.Version=""
     far.License=""
     far.FarName=""
     far.Version=""
     far.License=""
+    far.Abstract=""
     far.Description=""
     far.Copyright=""
     far.Description=""
     far.Copyright=""
-    far.SpdFiles=""
-    far.FpdFile=""
-    far.ExtraFile=""
+    far.SpdFiles=[]
+    far.FpdFiles=[]
+    far.ExtraFiles=[]
 
 far = Far()
 
 
 far = Far()
 
@@ -62,7 +63,8 @@ def parseSpd(spdFile):
   cwd = os.getcwd()
   os.chdir(inWorkspace(spdDir))
   for root, dirs, entries in os.walk("Include"):
   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:
       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"))
 
   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)
 
   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")
   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)
     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 = 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")
       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)
       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":
         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 = 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)
 
     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*" "))
       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'])
 
   # 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 """
   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
   %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()
 """ % 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)
     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 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)
index c919065fc3d3bfa52b7d0c0ac7e6b82f1c306c36..a34eff2d7177a597b605edff7e0d7bbc85be0031 100755 (executable)
@@ -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:])
         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("\\", "/")
index 6968f14aefa03f93ce847193726aa3d1fcdb6b59..9d1ff4a0e32cb43f2fc04d3d6b95b1f04cfe6025 100755 (executable)
@@ -44,7 +44,7 @@ def XmlAttribute (Dom, String):
 
 def XmlTopTag(Dom):
   """Return the name of the Root or top tag in the XML tree."""
 
 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
   
 
 # This acts like the main() function for the script, unless it is 'import'ed into another
index c0c40f5d277a07d18cbb155fd60fca19e289dc46..62a54d5a8740792897bd1ec4ff1a6201f096888c 100644 (file)
@@ -1,23 +1,48 @@
-# This file is a template to be used in creating a Framework Archive Manifest.\r
-# Each entry can be assigned to a string, which is quoted, or to a string that\r
-# spans mutliple lines, which is triple quoted.\r
-# This file should be passed as a command line argument to the MkFar.py script. \r
-# It is used to help the user control how the far is created.\r
-\r
-far.FileName = "my.far"\r
-far.FarName = "My Far"\r
-far.Version = "0.3"\r
-far.License="""This program and the accompanying materials are licensed and made\r
-available under the terms and conditions of the BSD License which accompanies\r
-this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php THE PROGRAM IS DISTRIBUTED UNDER\r
-THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS OF\r
-ANY KIND, EITHER EXPRESS OR IMPLIED."""\r
-far.Description="""This Package provides headers and libraries that conform to\r
-my wishes."""\r
-far.Copyright="Copyright (c) 2006, My Corporation."\r
-far.SpdFiles=""\r
-far.FpdFile=""\r
-far.ExtraFile=""\r
-\r
-# vim:syntax=python\r
+# 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