]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/fpd2dsc/fpd2dsc.py
2 # Convert an XML-based FPD file to a text-based DSC file.
4 # Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
5 # This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 import os
, re
, sys
, xml
. dom
. minidom
#XmlRoutines, EdkIIWorkspace
18 from LoadFpd
import LoadFpd
19 from StoreDsc
import StoreDsc
20 from optparse
import OptionParser
22 # Version and Copyright
23 __version_number__
= "1.0"
24 __version__
= "%prog Version " + __version_number__
25 __copyright__
= "Copyright (c) 2007 - 2010, Intel Corporation All rights reserved."
27 ## Parse command line options
29 # Using standard Python module optparse to parse command line option of this tool.
31 # @retval Options A optparse.Values object containing the parsed options
32 # @retval Args All the arguments got from the command line
35 """ Argument Parser """
36 usage
= "%prog [options] input_filename"
37 parser
= OptionParser ( usage
= usage
, description
= __copyright__
, version
= "%prog " + str ( __version_number__
))
38 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." )
39 parser
. add_option ( "-a" , "--auto" , action
= "store_true" , dest
= "autowrite" , default
= False , help = "Automatically create output files and write the DSC file" )
40 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" )
41 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" )
42 parser
. add_option ( "-d" , "--debug" , action
= "store_true" , dest
= "debug" , default
= False , help = "Enable printing of debug messages." )
43 parser
. add_option ( "-w" , "--workspace" , dest
= "workspace" , default
= str ( os
. environ
. get ( 'WORKSPACE' )), help = "Specify workspace directory." )
44 ( options
, args
) = parser
. parse_args ( sys
. argv
[ 1 :])
50 # This method mainly dispatch specific methods per the command line options.
51 # If no error found, return zero value so the caller of this tool can know
52 # if it's executed successfully or not.
54 # @retval 0 Tool was successful
55 # @retval 1 Tool failed
61 Options
, Args
= MyOptionParser ()
64 #print Options.workspace
65 if ( Options
. workspace
== None ):
66 print "ERROR: E0000: WORKSPACE not defined. \n Please set the WORKSPACE environment variable to the location of the EDK II install directory."
69 WorkSpace
= Options
. workspace
71 print "Using Workspace:" , WorkSpace
80 print "usage:" "%prog [options] input_filename"
86 if (( Options
. verbose
> 1 ) |
( Options
. autowrite
)):
87 print "FileName:" , InputFile
89 print "ERROR: E0001 - You must specify an input filename"
93 OutputFile
= Options
. outfile
95 OutputFile
= FileName
. replace ( '.fpd' , '.dsc' )
97 if (( Options
. verbose
> 2 ) or ( Options
. debug
)):
98 print "Output Filename:" , OutputFile
101 Platform
= LoadFpd ( FileName
)
102 StoreDsc ( OutputFile
, Platform
)
108 if __name__
== '__main__' :
113 #Options,Args = MyOptionParser()