sbsv2/raptor/python/raptor_cli.py
branchwip
changeset 498 564986768b79
parent 413 5eb26ea9cb49
equal deleted inserted replaced
461:0c5ca7f6d8ae 498:564986768b79
    16 # This module represents a Command Line Interpreter (CLI) for Raptor.
    16 # This module represents a Command Line Interpreter (CLI) for Raptor.
    17 # The interface with Raptor is the GetArgs() function, which is called
    17 # The interface with Raptor is the GetArgs() function, which is called
    18 # by a raptor.Raptor object.
    18 # by a raptor.Raptor object.
    19 #
    19 #
    20 
    20 
    21 import re
       
    22 import types
    21 import types
    23 import raptor
    22 import raptor
    24 import os
       
    25 import sys
       
    26 import tempfile
       
    27 from raptor_utilities import getOSPlatform
       
    28 
    23 
    29 from optparse import OptionParser # for parsing command line parameters
    24 from optparse import OptionParser # for parsing command line parameters
    30 
    25 
    31 fullCommandOption = "--command"
    26 fullCommandOption = "--command"
    32 miniCommandOption = "--co"  # update this if another "co" option is added
    27 miniCommandOption = "--co"  # update this if another "co" option is added
   130                 help="Build a specific project (mmp or extension) in the given bld.inf file. Multiple -p options can be given.")
   125                 help="Build a specific project (mmp or extension) in the given bld.inf file. Multiple -p options can be given.")
   131 
   126 
   132 parser.add_option("-q","--quiet",action="store_true",dest="quiet",
   127 parser.add_option("-q","--quiet",action="store_true",dest="quiet",
   133 				help="Run quietly, not generating output messages.")
   128 				help="Run quietly, not generating output messages.")
   134 
   129 
       
   130 parser.add_option("--query",action="append",dest="query",
       
   131 				help="""Access various build settings and options using a basic API. The current options are:
       
   132 				
       
   133 				* aliases - return all the values that can be sensibly used with the sbs -c option.
       
   134 				
       
   135 				* products - return all the values that can be "." appended to an alias to specialise it for a product build.
       
   136 				
       
   137 				* config[x] - return a set of values that represent the build configuration "x". Typically "x" will be an alias name or an alias followed by "." followed by a product.
       
   138 				
       
   139 				Multiple --query options can be given.
       
   140 				""")
       
   141 
   135 parser.add_option("-s","--sysdef",action="store",dest="sys_def_file",
   142 parser.add_option("-s","--sysdef",action="store",dest="sys_def_file",
   136 				help="System Definition XML filename.")
   143 				help="System Definition XML filename.")
   137 
   144 
   138 parser.add_option("--source-target",action="append",dest="source_target",
   145 parser.add_option("--source-target",action="append",dest="source_target",
   139 				help="Build the listed source or resource file in isolation - do not perform any dependent processing. Multiple --source-target options can be given.")
   146 				help="Build the listed source or resource file in isolation - do not perform any dependent processing. Multiple --source-target options can be given.")
   243 		return False
   250 		return False
   244 
   251 
   245 	# parse the full set of arguments
   252 	# parse the full set of arguments
   246 	(options, leftover_args) = parser.parse_args(expanded_args)
   253 	(options, leftover_args) = parser.parse_args(expanded_args)
   247 
   254 
   248 	# the leftover_args are either variable assignments of the form a=b
   255 	# the leftover_args are target names.
   249 	# or target names.
       
   250 	for leftover in leftover_args:
   256 	for leftover in leftover_args:
   251 		Raptor.AddTarget(leftover)
   257 		Raptor.AddTarget(leftover)
   252 
   258 
   253 	# Define the dictionary of functions to be used.
   259 	# Define the dictionary of functions to be used.
   254 	# Attributes and function names can be added easily.
   260 	# Attributes and function names can be added easily.
   273 				 'make_option': Raptor.AddMakeOption,
   279 				 'make_option': Raptor.AddMakeOption,
   274 				 'noDependInclude': Raptor.SetNoDependInclude,
   280 				 'noDependInclude': Raptor.SetNoDependInclude,
   275 				 'noDependGenerate': Raptor.SetNoDependGenerate,
   281 				 'noDependGenerate': Raptor.SetNoDependGenerate,
   276 				 'number_of_jobs': Raptor.SetJobs,
   282 				 'number_of_jobs': Raptor.SetJobs,
   277 				 'project_name' :  Raptor.AddProject,
   283 				 'project_name' :  Raptor.AddProject,
       
   284 				 'query' : Raptor.AddQuery,
   278 				 'filter_list' : Raptor.FilterList,
   285 				 'filter_list' : Raptor.FilterList,
   279 				 'ignore_os_detection': Raptor.IgnoreOsDetection,
   286 				 'ignore_os_detection': Raptor.IgnoreOsDetection,
   280 				 'check' :  Raptor.SetCheck,
   287 				 'check' :  Raptor.SetCheck,
   281 				 'what' :  Raptor.SetWhat,
   288 				 'what' :  Raptor.SetWhat,
   282 				 'tries' : Raptor.SetTries,
   289 				 'tries' : Raptor.SetTries,