+++ /dev/null
-## @file\r
-# Convert an XML-based FPD file to a text-based DSC file.\r
-#\r
-# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-\r
-##\r
-# Import Modules\r
-#\r
-import os, re, sys, xml.dom.minidom #XmlRoutines, EdkIIWorkspace\r
-from LoadFpd import LoadFpd\r
-from StoreDsc import StoreDsc\r
-from optparse import OptionParser\r
-from Common.BuildVersion import gBUILD_VERSION\r
-\r
-# Version and Copyright\r
-__version_number__ = ("1.0" + " " + gBUILD_VERSION)\r
-__version__ = "%prog Version " + __version_number__\r
-__copyright__ = "Copyright (c) 2007 - 2010, Intel Corporation All rights reserved."\r
-\r
-## Parse command line options\r
-#\r
-# Using standard Python module optparse to parse command line option of this tool.\r
-#\r
-# @retval Options A optparse.Values object containing the parsed options\r
-# @retval Args All the arguments got from the command line\r
-#\r
-def MyOptionParser():\r
- """ Argument Parser """\r
- usage = "%prog [options] input_filename"\r
- parser = OptionParser(usage=usage,description=__copyright__,version="%prog " + str(__version_number__))\r
- parser.add_option("-o", "--output", dest="outfile", help="Specific Name of the DSC file to create, otherwise it is the FPD filename with the extension repalced.")\r
- parser.add_option("-a", "--auto", action="store_true", dest="autowrite", default=False, help="Automatically create output files and write the DSC file")\r
- parser.add_option("-q", "--quiet", action="store_const", const=0, dest="verbose", help="Do not print any messages, just return either 0 for succes or 1 for failure")\r
- parser.add_option("-v", "--verbose", action="count", dest="verbose", help="Do not print any messages, just return either 0 for succes or 1 for failure")\r
- parser.add_option("-d", "--debug", action="store_true", dest="debug", default=False, help="Enable printing of debug messages.")\r
- parser.add_option("-w", "--workspace", dest="workspace", default=str(os.environ.get('WORKSPACE')), help="Specify workspace directory.")\r
- (options, args) = parser.parse_args(sys.argv[1:])\r
-\r
- return options,args\r
-\r
-## Entrance method\r
-#\r
-# This method mainly dispatch specific methods per the command line options.\r
-# If no error found, return zero value so the caller of this tool can know\r
-# if it's executed successfully or not.\r
-#\r
-# @retval 0 Tool was successful\r
-# @retval 1 Tool failed\r
-#\r
-def Main():\r
- global Options\r
- global Args\r
- global WorkSpace\r
- Options,Args = MyOptionParser()\r
-\r
- WorkSpace = ""\r
- #print Options.workspace\r
- if (Options.workspace == None):\r
- print "ERROR: E0000: WORKSPACE not defined.\n Please set the WORKSPACE environment variable to the location of the EDK II install directory."\r
- sys.exit(1)\r
- else:\r
- WorkSpace = Options.workspace\r
- if (Options.debug):\r
- print "Using Workspace:", WorkSpace\r
- try:\r
- Options.verbose +=1\r
- except:\r
- Options.verbose = 1\r
- pass\r
-\r
- InputFile = ""\r
- if Args == []:\r
- print "usage:" "%prog [options] input_filename"\r
- else:\r
- InputFile = Args[0]\r
- #print InputFile\r
- if InputFile != "":\r
- FileName = InputFile\r
- if ((Options.verbose > 1) | (Options.autowrite)):\r
- print "FileName:",InputFile\r
- else:\r
- print "ERROR: E0001 - You must specify an input filename"\r
- sys.exit(1)\r
-\r
- if (Options.outfile):\r
- OutputFile = Options.outfile\r
- else:\r
- OutputFile = FileName.replace('.fpd', '.dsc')\r
-\r
- if ((Options.verbose > 2) or (Options.debug)):\r
- print "Output Filename:", OutputFile\r
- \r
- try:\r
- Platform = LoadFpd(FileName)\r
- StoreDsc(OutputFile, Platform)\r
- return 0\r
- except Exception, e:\r
- print e\r
- return 1\r
-\r
-if __name__ == '__main__':\r
- sys.exit(Main())\r
- #pass\r
- #global Options\r
- #global Args\r
- #Options,Args = MyOptionParser()\r
- \r
- #Main()\r
- #sys.exit(0)
\ No newline at end of file