cscm.CompilerModel¶
- class
cscm.CompilerModel¶ -
Bases:
objectRepresents a compiler.
Subclass this (or one of the provided subclasses) to define a custom compiler model.
This class should not have any mutable member variables or state. In most cases, if you think you need to add mutable member variables to this class, you probably need to add locals to
__call__().Immediate subclasses are:
Methods
__call__()Implement this function to generate and return a CompilerModelResultbased on a list of arguments passed from the command line and aParseConfiguration.__init__()Default initializer. get_append_flags()Implement this function to return a list of flags to be appended to the raw args. get_prepend_flags()Implement this function to return a list of flags to be prepended to the raw args. name()All compiler models must implement this to return a unique name for the model. translate_raw_args()Takes in a list of arguments, augments it with relevant prepends/appends, and invokes __call__()on the result.verbose_name()All compiler models must implement this to return a verbose version of the model name. -
__call__(args, config)¶ -
Implement this function to generate and return a
CompilerModelResultbased on a list of arguments passed from the command line and aParseConfiguration.Parameters: - args (iterable of str) –
- config (
ParseConfiguration) –
Returns: A
CompilerModelResultobject containing a list ofFrontEndCommandobjects: one for every source file on the native command line.Return type: This function should take all the arguments that the modeled compiler recognizes and turn them into front end arguments. For example, it could take something like
--define BUNCAKE=0x12and turn it into-DBUNCAKE=0x12In many cases, reading the arguments in args is not enough. The model may have to invoke the compiler to obtain things like version information or predefined macros. It may need to read additional arguments from a file. Or maybe examine various environment variables.
Usually you do not need to care about the information in
config. You could, for instance, print out extra information ifconfig.get_verbose()returns non-zero.
-
__init__()¶ -
Default initializer.
Note that you will need to create an instance of your compiler model class to pass to
register_compiler_model().
-
get_append_flags(config)¶ -
Implement this function to return a list of flags to be appended to the raw args.
Parameters: config ( ParseConfiguration) –Returns: A list of flags to be prepended to the raw args. Typically this will be the value returned by one of the following. Return type: [ str ]
-
get_prepend_flags(config)¶ -
Implement this function to return a list of flags to be prepended to the raw args.
Parameters: config ( ParseConfiguration) –Returns: A list of flags to be prepended to the raw args. Typically this will be the value returned by one of the following. Return type: [ str ]
-
name()¶ -
All compiler models must implement this to return a unique name for the model.
If you want to register a single model under multiple names, construct multiple instances of your class, each of which has a different name() return value, then register each instance with cscm.register_compiler_model().Returns: The base name of this compiler model. Return type: str This will generally entail defining a nondefault initializer, then basing the name() return value on the argument or arguments provided to that initializer.
-
translate_raw_args(args, config)¶ -
Takes in a list of arguments, augments it with relevant prepends/appends, and invokes
__call__()on the result.Parameters: - args (iterable of str) –
- config (
ParseConfiguration) –
Return type: You will not usually need to modify this function.
-
verbose_name()¶ -
All compiler models must implement this to return a verbose version of the model name.
Returns: The verbose name of this compiler model. In general this will consist of the full name for the compiler, including the name of the vendor. Return type: str
-