]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Added a template mechanism to act as the user interface in far creation.
authorbbahnsen <bbahnsen@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 21 Dec 2006 01:32:37 +0000 (01:32 +0000)
committerbbahnsen <bbahnsen@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 21 Dec 2006 01:32:37 +0000 (01:32 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2124 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Python/MkFar.py
Tools/Python/far-template [new file with mode: 0644]

index ffe27a870aa7483bf8de06c4c0605e59cbc2c8a2..7531527f582bfc522110fee95b5dd77f88f73abe 100755 (executable)
@@ -4,6 +4,22 @@ import os, sys, getopt, string, xml.dom.minidom, zipfile, md5
 from XmlRoutines import *
 from WorkspaceRoutines import *
 
+class Far:
+  """This class is used to collect arbitrarty data from the template file."""
+  def __init__(far):
+    """Assign the default values for the far fields."""
+    far.FileName = "output.far"
+    far.FarName=""
+    far.Version=""
+    far.License=""
+    far.Description=""
+    far.Copyright=""
+    far.SpdFiles=""
+    far.FpdFile=""
+    far.ExtraFile=""
+
+far = Far()
+
 def parseMsa(msaFile, spdDir):
 
   filelist = [msaFile]
@@ -16,7 +32,6 @@ def parseMsa(msaFile, spdDir):
     "/ModuleSurfaceArea/SourceFiles/Filename",
     "/ModuleSurfaceArea/NonProcessedFiles/Filename" ]
     
-
   for xmlPath in xmlPaths:
     for f in XmlList(msa, xmlPath):
       filelist.append(str(os.path.join(msaDir, XmlElementData(f))))
@@ -60,25 +75,25 @@ def makeFarHeader(doc):
 
   header = doc.createElement("FarHeader")
   name = doc.createElement("FarName")
-  name.appendChild(doc.createTextNode("My New Far"))
+  name.appendChild(doc.createTextNode(far.FarName))
   header.appendChild(name)
   guidVal = doc.createElement("GuidValue")
   guidVal.appendChild(doc.createTextNode(genguid()))
   header.appendChild(guidVal)
   ver = doc.createElement("Version")
-  ver.appendChild(doc.createTextNode("1.0"))
+  ver.appendChild(doc.createTextNode(far.Version))
   header.appendChild(ver)
   abstract = doc.createElement("Abstract")
-  abstract.appendChild(doc.createTextNode("This is a cool new far."))
+  abstract.appendChild(doc.createTextNode(far.Abstract))
   header.appendChild(abstract)
   desc = doc.createElement("Description")
-  desc.appendChild(doc.createTextNode("This is a cool new far. It can do great things."))
+  desc.appendChild(doc.createTextNode(far.Description))
   header.appendChild(desc)
   copy = doc.createElement("Copyright")
-  copy.appendChild(doc.createTextNode("Copyright (c) Intel Corporation 2006."))
+  copy.appendChild(doc.createTextNode(far.Copyright))
   header.appendChild(copy)
   lic = doc.createElement("License")
-  lic.appendChild(doc.createTextNode("BSD Compatible."))
+  lic.appendChild(doc.createTextNode(far.License))
   header.appendChild(lic)
   spec = doc.createElement("Specification")
   spec.appendChild(doc.createTextNode("FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052"))
@@ -193,11 +208,8 @@ if __name__ == '__main__':
   # Create a pretty printer for dumping data structures in a readable form.
   # pp = pprint.PrettyPrinter(indent=2)
 
-  # Default name for far file.
-  farName = "output.far"
-
   # Process the command line args.
-  optlist, args = getopt.getopt(sys.argv[1:], 'hf:', [ 'far=', 'help'])
+  optlist, args = getopt.getopt(sys.argv[1:], 'hf:t:', [ 'template=', 'far=', 'help'])
 
   for o, a in optlist:
     if o in ["-h", "--help"]:
@@ -207,12 +219,20 @@ 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 relative to the WORKSPACE envirnonment
-which must be set to a valid workspace root directory.
+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.
 """ % os.path.basename(sys.argv[0])
 
       sys.exit()
+    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 ["-f", "--far"]:
-      farName = a
+      far.FileName = a
+      if os.path.exists(far.FileName):
+        print "Error: File %s exists. Not overwriting." % far.FileName
+        sys.exit()
 
-  makeFar(args, farName)
+  makeFar(args, far.FileName)
diff --git a/Tools/Python/far-template b/Tools/Python/far-template
new file mode 100644 (file)
index 0000000..c0c40f5
--- /dev/null
@@ -0,0 +1,23 @@
+# 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